]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: add required remount flags
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 8 Feb 2018 10:36:41 +0000 (11:36 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 12 Feb 2018 16:04:14 +0000 (17:04 +0100)
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9566d6742852c527bf5af38af5cbb878dad75705

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/conf.c

index ead2348cd1edb3952cc159474e8cc1064f483538..b29b0f9e4e611b69e2bf3805cea56c6221120642 100644 (file)
@@ -1902,7 +1902,7 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
                                           char *controllerpath, char *cgpath,
                                           const char *container_cgroup)
 {
-       int ret;
+       int ret, remount_flags;
        char *sourcepath;
        int flags = MS_BIND;
 
@@ -1914,6 +1914,9 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
                        return -1;
                }
 
+               remount_flags = add_required_remount_flags(controllerpath,
+                                                          controllerpath,
+                                                          flags | MS_REMOUNT);
                ret = mount(controllerpath, controllerpath, "cgroup",
                            MS_REMOUNT | MS_BIND | MS_RDONLY, NULL);
                if (ret < 0) {
@@ -1938,13 +1941,15 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
        INFO("Mounted \"%s\" onto \"%s\"", h->controllers[0], cgpath);
 
        if (flags & MS_RDONLY) {
-               ret = mount(sourcepath, cgpath, "cgroup",
-                           MS_REMOUNT | flags | MS_RDONLY, NULL);
+               remount_flags = add_required_remount_flags(sourcepath, cgpath,
+                                                          flags | MS_REMOUNT);
+               ret = mount(sourcepath, cgpath, "cgroup", remount_flags, NULL);
                if (ret < 0) {
                        SYSERROR("Failed to remount \"%s\" ro", cgpath);
                        free(sourcepath);
                        return -1;
                }
+               INFO("Remounted %s read-only", cgpath);
        }
 
        free(sourcepath);
@@ -1952,7 +1957,8 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
        return 0;
 }
 
-static int mount_cgroup_cgns_supported(int type, struct hierarchy *h, const char *controllerpath)
+static int cg_mount_in_cgroup_namespace(int type, struct hierarchy *h,
+                                       const char *controllerpath)
 {
         int ret;
         char *controllers = NULL;
@@ -2045,7 +2051,7 @@ static bool cgfsng_mount(void *hdata, const char *root, int type)
                         * will not have CAP_SYS_ADMIN after it has started we
                         * need to mount the cgroups manually.
                         */
-                       r = mount_cgroup_cgns_supported(type, h, controllerpath);
+                       r = cg_mount_in_cgroup_namespace(type, h, controllerpath);
                        free(controllerpath);
                        if (r < 0)
                                goto bad;
index dab112b1587b7c82c57e331932cbbd547f5ed057..640e37095b4e43a150a0d62a80984de6af29c72c 100644 (file)
@@ -430,7 +430,7 @@ int pin_rootfs(const char *rootfs)
  * NOEXEC etc are honored.
  */
 unsigned long add_required_remount_flags(const char *s, const char *d,
-               unsigned long flags)
+                                        unsigned long flags)
 {
 #ifdef HAVE_STATVFS
        struct statvfs sb;