]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Merge pull request #4085 from brauner/2022-02-20.cgroup.fixes
authorStéphane Graber <stgraber@ubuntu.com>
Sun, 20 Feb 2022 19:53:07 +0000 (14:53 -0500)
committerGitHub <noreply@github.com>
Sun, 20 Feb 2022 19:53:07 +0000 (14:53 -0500)
cgroups: fixes

src/lxc/cgroups/cgfsng.c

index e82b5690291873e2dd54402fdf7c7e3320d675cc..247b8bcd463df0e27bf7ec5d8be91af26b387362 100644 (file)
@@ -727,6 +727,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
                 * it will be automatically zapped if we return early.
                 */
                dfd_cur = dfd_final;
+               TRACE("Opened%s cgroup %s as %d", !ret ? " newly created" : "", cur, dfd_cur);
        }
 
        /* The final cgroup must be succesfully creatd by us. */
@@ -3174,6 +3175,12 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
                                SYSTRACE("Unified cgroup not mounted");
                                continue;
                        }
+
+                       if (!fhas_fs_type(dfd_mnt, CGROUP2_SUPER_MAGIC)) {
+                               SYSTRACE("Opened file descriptor %d is not a cgroup2 mountpoint", dfd_mnt);
+                               continue;
+                       }
+
                        dfd = dfd_mnt;
 
                        if (!is_empty_string(current_cgroup)) {
@@ -3239,6 +3246,12 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
                                SYSTRACE("%s not mounted", controllers);
                                continue;
                        }
+
+                       if (!fhas_fs_type(dfd_mnt, CGROUP_SUPER_MAGIC)) {
+                               SYSTRACE("Opened file descriptor %d is not a cgroup mountpoint", dfd_mnt);
+                               continue;
+                       }
+
                        dfd = dfd_mnt;
 
                        if (!abspath(__current_cgroup))