sfds: Protect service fds

Mark area, where service fds modifications are prohibited.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
This commit is contained in:
Kirill Tkhai 2018-01-10 17:02:00 +03:00 committed by Andrei Vagin
parent cdcfe1d5ae
commit 8d1eb0b89a
2 changed files with 6 additions and 0 deletions

View file

@ -1335,6 +1335,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++)
@ -1924,6 +1925,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;
@ -3762,6 +3765,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(CR_PROC_FD_OFF);

View file

@ -1296,7 +1296,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) {