[CRIU] [PATCH] Don't use open_proc() where it fails

Kir Kolyshkin kir at openvz.org
Wed Mar 29 15:02:16 PDT 2017


This reverts a hunk from commit 4ad343c ("Use *open_proc* where
possible"), and adds a comment explaining why.

The bug was caught by ci [1] and wasn't caught by Travis because
the last one runs on the older kernel.

(00.271276)      1: Error (criu/util.c:204): fd 0 already in use
	(called at criu/files.c:1008)
(00.292162) Error (criu/cr-restore.c:1127): 425 exited, status=1
(00.295802) Error (criu/cr-restore.c:2059): Restoring FAILED.

[1] https://ci.openvz.org/view/CRIU/job/CRIU/job/CRIU-snap/job/criu-dev/2079/consoleFull

Reported-by: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 criu/namespaces.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 02959e7..6637abc 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2190,9 +2190,15 @@ static int create_user_ns_hierarhy_fn(void *in_arg)
 		/* Set self pid to allow parent restore user_ns maps */
 		p_arg->pid = get_self_real_pid();
 		futex_set_and_wake(p_futex, NS__CREATED);
-		fd = open_proc(PROC_SELF, "ns/user");
-		if (fd < 0)
+		/*
+		 * Note we can't use open_proc() here after
+		 * clone() with CLONE_FILES but no CLONE_VM.
+		 */
+		fd = open("/proc/self/ns/user", O_RDONLY);
+		if (fd < 0) {
+			pr_perror("Can't get self user ns");
 			goto out;
+		}
 		me->user.nsfd_id = fdstore_add(fd);
 		close(fd);
 		if (me->user.nsfd_id < 0) {
-- 
2.9.3



More information about the CRIU mailing list