Skip to content

Commit

Permalink
conf: ensure umounts don't propagate to host
Browse files Browse the repository at this point in the history
Signed-off-by: Fengtu Wang <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
FengtuWang authored and Christian Brauner committed Apr 2, 2018
1 parent 0474e8a commit e599717
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lxc/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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");
Expand Down

0 comments on commit e599717

Please sign in to comment.