]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: ensure umounts don't propagate to host
authorFengtu Wang <wangfengtu@huawei.com>
Mon, 2 Apr 2018 21:00:19 +0000 (05:00 +0800)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 2 Apr 2018 13:56:40 +0000 (15:56 +0200)
Signed-off-by: Fengtu Wang <wangfengtu@huawei.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index fe30800d779f5a7748bc85aad18421a80c76c81d..7455843086c543d6219dcbcfcb9093bd73e61da2 100644 (file)
@@ -1112,7 +1112,7 @@ static int setup_rootfs_pivot_root(const char *rootfs)
                goto on_error;
        }
 
-       /* At this point the old-root is mounted on top of our new-root To
+       /* At this point the old-root is mounted on top of our new-root. To
         * unmounted it we must not be chdir'd into it, so escape back to
         * old-root.
         */
@@ -1122,6 +1122,15 @@ static int setup_rootfs_pivot_root(const char *rootfs)
                goto on_error;
        }
 
+       /* Make oldroot rslave to make sure our umounts don't propagate to the
+        * host.
+        */
+       ret = mount("", ".", "", MS_SLAVE | MS_REC, NULL);
+       if (ret < 0) {
+               SYSERROR("Failed to make oldroot rslave");
+               goto on_error;
+       }
+
        ret = umount2(".", MNT_DETACH);
        if (ret < 0) {
                SYSERROR("Failed to detach old root directory");