[CRIU] [PATCH v4 08/19] mnt: Populate ROOT_FD_OFF
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jan 10 17:01:33 MSK 2018
This patch populates and occupies ROOT_FD_OFF fd,
which guarantees it won't be reused by ordinary fds.
v4: New
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/cr-restore.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index f9889099f..49d367e4c 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -512,6 +512,23 @@ static int setup_child_task_namespaces(struct pstree_item *item, struct ns_id **
return 0;
}
+/* This actually populates and occupies ROOT_FD_OFF sfd */
+static int populate_root_fd_off(void)
+{
+ struct ns_id *mntns = NULL;
+ int ret;
+
+ if (root_ns_mask & CLONE_NEWNS) {
+ mntns = lookup_ns_by_id(root_item->ids->mnt_ns_id, &mnt_ns_desc);
+ BUG_ON(!mntns);
+ }
+
+ ret = mntns_get_root_fd(mntns);
+ if (ret < 0)
+ pr_err("Can't get root fd\n");
+ return ret >= 0 ? 0 : -1;
+}
+
static rt_sigaction_t sigchld_act;
/*
* If parent's sigaction has blocked SIGKILL (which is non-sence),
@@ -1863,6 +1880,9 @@ static int restore_task_with_children(void *_arg)
if (root_prepare_shared())
goto err;
+
+ if (populate_root_fd_off())
+ goto err;
}
if ((ca->clone_flags & CLONE_NEWPID) && setup_current_pid_ns())
More information about the CRIU
mailing list