1
linux/kernel/cgroup
Xiu Jianfeng 3cc4e13bb1 cgroup: Fix potential overflow issue when checking max_depth
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>
2024-10-14 13:39:25 -10:00
..
cgroup-internal.h mm, memcg: cg2 memory{.swap,}.peak write handlers 2024-09-01 20:25:53 -07:00
cgroup-v1.c cgroup: Do not report unavailable v1 controllers in /proc/cgroups 2024-09-10 10:04:28 -10:00
cgroup.c cgroup: Fix potential overflow issue when checking max_depth 2024-10-14 13:39:25 -10:00
cpuset-internal.h cgroup/cpuset: Move cpu.h include to cpuset-internal.h 2024-09-04 10:46:49 -10:00
cpuset-v1.c cgroup/cpuset: rename functions shared between v1 and v2 2024-08-30 10:00:16 -10:00
cpuset.c cgroup/cpuset: Move cpu.h include to cpuset-internal.h 2024-09-04 10:46:49 -10:00
debug.c kernel: cgroup: fix misuse of %x 2019-05-06 08:47:48 -07:00
freezer.c cgroup: cleanup comments 2022-03-13 19:19:27 -10:00
legacy_freezer.c cgroup, legacy_freezer: update comment for freezer_css_offline() 2024-04-18 06:01:50 -10:00
Makefile cgroup/cpuset: guard cpuset-v1 code under CONFIG_CPUSETS_V1 2024-08-30 10:00:16 -10:00
misc.c cgroup/misc: Introduce misc.events.local 2024-07-12 06:45:23 -10:00
namespace.c cgroup:namespace: Remove unused cgroup_namespaces_init() 2023-08-14 14:29:47 -10:00
pids.c cgroup/pids: Remove unreachable paths of pids_{can,cancel}_fork 2024-08-05 10:32:16 -10:00
rdma.c rdmacg: fix kernel-doc warnings in rdmacg 2023-06-05 09:45:14 -10:00
rstat.c cgroup/rstat: add force idle show helper 2024-07-05 08:32:08 -10:00