linux/kernel/cgroup
Xiu Jianfeng a69d18e802 cgroup: Fix potential overflow issue when checking max_depth
[ Upstream commit 3cc4e13bb1 ]

cgroup.max.depth is the maximum allowed descent depth below the current
cgroup. If the actual descent depth is equal or larger, an attempt to
create a new child cgroup will fail. However due to the cgroup->max_depth
is of int type and having the default value INT_MAX, the condition
'level > cgroup->max_depth' will never be satisfied, and it will cause
an overflow of the level after it reaches to INT_MAX.

Fix it by starting the level from 0 and using '>=' instead.

It's worth mentioning that this issue is unlikely to occur in reality,
as it's impossible to have a depth of INT_MAX hierarchy, but should be
be avoided logically.

Fixes: 1a926e0bba ("cgroup: implement hierarchy limits")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-08 16:25:51 +01:00
..
cgroup-internal.h cgroup: Make operations on the cgroup root_list RCU safe 2024-10-17 15:10:40 +02:00
cgroup-v1.c cgroup: Remove duplicates in cgroup v1 tasks file 2023-10-19 23:05:37 +02:00
cgroup.c cgroup: Fix potential overflow issue when checking max_depth 2024-11-08 16:25:51 +01:00
cpuset.c cgroup/cpuset: Prevent UAF in proc_cpuset_show() 2024-09-04 13:23:38 +02:00
debug.c kernel: cgroup: fix misuse of %x 2019-05-06 08:47:48 -07:00
freezer.c cgroup: freezer: don't change task and cgroups status unnecessarily 2019-11-07 07:38:41 -08:00
legacy_freezer.c cgroup: rename freezer.c into legacy_freezer.c 2019-04-19 11:26:48 -07:00
Makefile cgroup: Add misc cgroup controller 2021-04-04 13:34:46 -04:00
misc.c svm/sev: Register SEV and SEV-ES ASIDs to the misc controller 2021-04-04 13:34:46 -04:00
namespace.c cgroup:namespace: Remove unused cgroup_namespaces_init() 2023-09-19 12:22:47 +02:00
pids.c clone3: allow spawning processes into cgroups 2020-02-12 17:57:51 -05:00
rdma.c cgroup: fix spelling mistakes 2021-05-24 12:45:26 -04:00
rstat.c cgroup: Fix rootcg cpu.stat guest double counting 2021-11-18 19:16:45 +01:00