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

Submitted by Kirill Tkhai on July 15, 2017, 3:25 p.m.

Details

Message ID 150013233964.12956.13798629266076624141.stgit@localhost.localdomain
State New
Series "binfmt_misc: Switch to dumpee user_ns before mount"
Headers show

Commit Message

Kirill Tkhai July 15, 2017, 3:25 p.m.
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@virtuozzo.com>
---
 criu/mount.c |    6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

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;