From 414fbacca9f06620cfa65b3a9a0543fd040b7b7f Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Mon, 28 Jun 2021 09:44:20 +0200 Subject: [PATCH] cgroups: verify that hierarchies are non-empty Fixes: #3881 Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgroup.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h index cb2a9751a..d057957b4 100644 --- a/src/lxc/cgroups/cgroup.h +++ b/src/lxc/cgroups/cgroup.h @@ -326,6 +326,9 @@ static inline int prepare_cgroup_ctx(struct cgroup_ops *ops, { __u32 idx; + if (!ops || !ops->hierarchies) + return ret_errno(ENOENT); + for (idx = 0; ops->hierarchies[idx]; idx++) { if (idx >= CGROUP_CTX_MAX_FD) return ret_errno(E2BIG); -- 2.47.2