Commit 71ccb4a0 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

sfds: Protect service fds

Mark area, where service fds modifications are prohibited.

v4: New
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 79bebdda
......@@ -1181,6 +1181,7 @@ static int restore_one_task(int pid, CoreEntry *core)
ret = restore_one_zombie(core);
else if (current->pid->state == TASK_HELPER) {
ret = restore_one_helper();
sfds_protected = false;
close_image_dir();
close_proc();
for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++)
......@@ -1709,6 +1710,8 @@ static int restore_task_with_children(void *_arg)
if (populate_pid_proc())
goto err;
sfds_protected = true;
if (unmap_guard_pages(current))
goto err;
......@@ -3436,6 +3439,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
if (restore_fs(current))
goto err;
sfds_protected = false;
close_image_dir();
close_proc();
close_service_fd(TRANSPORT_FD_OFF);
......
......@@ -1247,7 +1247,9 @@ int prepare_fds(struct pstree_item *me)
* correct /tasks file if it is in a different cgroup
* set than its parent
*/
sfds_protected = false;
close_service_fd(CGROUP_YARD);
sfds_protected = true;
set_proc_self_fd(-1); /* flush any proc cached fds we may have */
if (rsti(me)->fdt) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment