]> 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>
Mon, 22 Feb 2021 20:40:02 +0000 (21:40 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 2ac1b7bbad41207f8effb6dd2c259a1888e7edc3..3632d788fde2da0b38520a9bddfcacddfcb251d5 100644 (file)
@@ -1305,6 +1305,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);
 
                /*