[CRIU] [PATCH] mount: umount a temporary mount with MTN_DETACH

Andrey Vagin avagin at openvz.org
Tue Dec 8 05:07:00 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

If a temporary mount is a shared one, a new mount can be
propagated into it.

Fixes: 0e9736ab68e0 ("mount: fix restoring a bind-mount when its root is overmounted)")

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 mount.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/mount.c b/mount.c
index 01c7d91..462f288 100644
--- a/mount.c
+++ b/mount.c
@@ -2383,7 +2383,15 @@ out:
 	exit_code = 0;
 err:
 	if (umount_mnt_path) {
-		if (umount(mnt_path)) {
+		/*
+		 * If mnt_path was shared, a new mount may be propagated
+		 * into it.
+		 */
+		if (mount(NULL, mnt_path, NULL, MS_PRIVATE, NULL)) {
+			pr_perror("Unable to make %s private", mnt_path);
+			return -1;
+		}
+		if (umount2(mnt_path, MNT_DETACH)) {
 			pr_perror("Unable to umount %s", mnt_path);
 			return -1;
 		}
-- 
2.4.3



More information about the CRIU mailing list