cr-restore: Mount proc only for NEWNS or NEWPID

Submitted by Radostin Stoyanov on Dec. 18, 2018, 11:19 p.m.


Message ID
State New
Series "cr-restore: Mount proc only for NEWNS or NEWPID"
Headers show

Commit Message

Radostin Stoyanov Dec. 18, 2018, 11:19 p.m.
In commit a201f59 (rst: Create custom proc every time we restore a
namespace) was introduced an approach to restore a mount namespace
using custom proc mount. This approach is also used to restore the
PID namespace.

However, there could be the case that neither of those namespaces is
being used. While commit 4dd0735 (restore: Save some time mounting
proc) handles the case when there are no namespaces to be restored,
this patch changes the CRIU's behaviour to use custom proc mount only
when it is needed (i.e. to restore mount or pid namespace).

Signed-off-by: Radostin Stoyanov <>
 criu/cr-restore.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)


Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 7bbe79aa..5b80cf40 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1552,7 +1552,7 @@  static int mount_proc(void)
 	int fd, ret;
 	char proc_mountpoint[] = "crtools-proc.XXXXXX";

-	if (root_ns_mask == 0)
+	if (!(root_ns_mask & CLONE_NEWNS || root_ns_mask & CLONE_NEWPID))
 		fd = ret = open("/proc", O_DIRECTORY);
 	else {
 		if (mkdtemp(proc_mountpoint) == NULL) {
@@ -1701,9 +1701,8 @@  static int restore_task_with_children(void *_arg)

-		 * We need non /proc proc mount for restoring pid and mount
-		 * namespaces and do not care for the rest of the cases.
-		 * Thus -- mount proc at custom location for any new namespace
+		 * For restoring pid and mount namespaces we need to
+		 * mount proc at custom location.
 		if (mount_proc())
 			goto err;