]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: skip and warn about invalid file descriptors
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 21 Feb 2021 18:57:31 +0000 (19:57 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Feb 2021 20:28:27 +0000 (21:28 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 574e8569a41d7e75045e67e6a9c3c1ff1171887a..f9fb38ad7967d077e0310d9aaceb8e8bf7eb74cc 100644 (file)
@@ -1303,6 +1303,9 @@ static int chown_cgroup_wrapper(void *data)
        for (int i = 0; arg->hierarchies[i]; i++) {
                int dirfd = arg->hierarchies[i]->dfd_con;
 
+               if (dirfd < 0)
+                       return syserrno_set(-EBADF, "Invalid cgroup file descriptor");
+
                (void)fchowmodat(dirfd, "", destuid, nsgid, 0775);
 
                /*