[CRIU] [PATCH 5/5] mount: Switch user_ns before mount binfmt_misc

Kirill Tkhai ktkhai at virtuozzo.com
Sat Jul 15 18:25:39 MSK 2017


After commit 6e4eab577a0c "fs: Add user namespace member to struct super_block"
mainstream kernel keeps mounter's user_ns in superblock.
Change user_ns before mounting of binfmt_misc to fit it.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/mount.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/criu/mount.c b/criu/mount.c
index 9c5c75bc7..8ab60b705 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1271,6 +1271,12 @@ static __maybe_unused int mount_cr_time_mount(struct ns_id *ns, unsigned int *s_
 		goto out;
 	}
 
+	ret = switch_ns(ns->ns_pid, &user_ns_desc, NULL);
+	if (ret < 0) {
+		pr_err("Can't switch user_ns\n");
+		goto out;
+	}
+
 	ret = mount(source, target, type, 0, NULL);
 	if (ret < 0) {
 		exit_code = -errno;



More information about the CRIU mailing list