[Devel,CRIU,6/6] mount: Switch user_ns before mount binfmt_misc

Submitted by Kirill Tkhai on July 15, 2017, 1:50 p.m.

Details

Message ID 150012663225.9540.12545587096027192171.stgit@localhost.localdomain
State New
Series "Switch user_ns before mount binfmt_misc"
Headers show

Commit Message

Kirill Tkhai July 15, 2017, 1:50 p.m.
Recent RHEL7 update introduced commit 1352424aae37:
"ms/fs: Add user namespace member to struct super_bloc",
so now we have to change user_ns before binfmt_misc
mount.

https://jira.sw.ru/browse/PSBM-68377

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 36babe721..66119c331 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1441,6 +1441,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;