Commit 42058dc7 authored by Andrei Vagin's avatar Andrei Vagin Committed by Pavel Emelyanov

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

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.

Reported-by: Mr Travis
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent c220c2f9
#!/bin/sh
set -e
mount --make-rprivate /
mount --make-rslave /
umount -l /proc
mount -t proc proc /proc/
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc/
......
......@@ -84,7 +84,7 @@ static int prepare_mntns(void)
return -1;
}
if (mount("./old", "./old", NULL, MS_PRIVATE | MS_REC , NULL)) {
if (mount("./old", "./old", NULL, MS_SLAVE | MS_REC , NULL)) {
fprintf(stderr, "Can't bind-mount root: %m\n");
return -1;
}
......
......@@ -20,8 +20,8 @@ int main(int argc, char **argv)
return 1;
pid = fork();
if (pid == 0) {
if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
fprintf(stderr, "mount(/, S_REC | MS_PRIVATE)): %m");
if (mount(NULL, "/", NULL, MS_REC | MS_SLAVE, NULL)) {
fprintf(stderr, "mount(/, S_REC | MS_SLAVE)): %m");
return 1;
}
umount2("/proc", MNT_DETACH);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment