jail: ensure mounts are not MS_SHARED to avoid pivot_root() failure
[project/procd.git] / jail / jail.c
index b3f27d3..e425254 100644 (file)
@@ -129,6 +129,12 @@ static int build_jail_fs(void)
                return -1;
        }
 
                return -1;
        }
 
+       /* oldroot can't be MS_SHARED else pivot_root() fails */
+       if (mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL)) {
+               ERROR("private mount failed %s\n", strerror(errno));
+               return -1;
+       }
+
        if (mount("tmpfs", jail_root, "tmpfs", MS_NOATIME, "mode=0755")) {
                ERROR("tmpfs mount failed %s\n", strerror(errno));
                return -1;
        if (mount("tmpfs", jail_root, "tmpfs", MS_NOATIME, "mode=0755")) {
                ERROR("tmpfs mount failed %s\n", strerror(errno));
                return -1;