mount: don't do MS_REC|MS_PRIVATE for host mounts

Submitted by Andrei Vagin on June 22, 2016, 6:59 a.m.

Details

Message ID 1466578756-22449-1-git-send-email-avagin@openvz.org
State Accepted
Series "mount: don't do MS_REC|MS_PRIVATE for host mounts"
Commit 113bed107cd1d8a876c40219461702eaf914ba1c
Headers show

Commit Message

Andrei Vagin June 22, 2016, 6:59 a.m.
From: Andrew Vagin <avagin@virtuozzo.com>

Here is a race when someone umounted something and this operation
isn't propagated into our namespace.

CRIU					| Another process
-----------------------------------------------------------------
pivot_root(".", put_root)		|
mount(put_root, MS_REC|MS_PRIVATE)	|
					| umount /xxx/yyy
					| umount /xxx -> EBUSY
umount(put_root)

We do this to not affect mounts in put_root, but we can mask
these mounts as slave and this will work for us and for external
users.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
---
 criu/mount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index e891c92..e3b837f 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2733,7 +2733,7 @@  static int cr_pivot_root(char *root)
 		goto err_tmpfs;
 	}
 
-	if (mount("none", put_root, "none", MS_REC|MS_PRIVATE, NULL)) {
+	if (mount("none", put_root, "none", MS_REC|MS_SLAVE, NULL)) {
 		pr_perror("Can't remount root with MS_PRIVATE");
 		return -1;
 	}

Comments

Vasily Averin June 22, 2016, 12:19 p.m.
On 22.06.2016 09:59, Andrey Vagin wrote:
> From: Andrew Vagin <avagin@virtuozzo.com>

> diff --git a/criu/mount.c b/criu/mount.c
> index e891c92..e3b837f 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -2733,7 +2733,7 @@ static int cr_pivot_root(char *root)
>  		goto err_tmpfs;
>  	}
>  
> -	if (mount("none", put_root, "none", MS_REC|MS_PRIVATE, NULL)) {
> +	if (mount("none", put_root, "none", MS_REC|MS_SLAVE, NULL)) {
>  		pr_perror("Can't remount root with MS_PRIVATE");

Seems you forget update error message here.
Pavel Emelianov June 24, 2016, 12:30 p.m.
Applied