From 8d1eb0b89af94ee4f3549082e8efba2764587c0d Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Wed, 10 Jan 2018 17:02:00 +0300 Subject: [PATCH] sfds: Protect service fds Mark area, where service fds modifications are prohibited. v4: New Signed-off-by: Kirill Tkhai --- criu/cr-restore.c | 4 ++++ criu/files.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 2534575a4..86c923cf2 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -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); diff --git a/criu/files.c b/criu/files.c index d1a961d58..16f9a9169 100644 --- a/criu/files.c +++ b/criu/files.c @@ -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) {