Commit 339df13
cgroup: Fix potential overflow issue when checking max_depth
[ Upstream commit 3cc4e13 ]
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: 1a926e0 ("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>1 parent 7c47d87 commit 339df13
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5104 | 5104 | | |
5105 | 5105 | | |
5106 | 5106 | | |
5107 | | - | |
| 5107 | + | |
5108 | 5108 | | |
5109 | 5109 | | |
5110 | 5110 | | |
5111 | 5111 | | |
5112 | 5112 | | |
5113 | 5113 | | |
5114 | 5114 | | |
5115 | | - | |
| 5115 | + | |
5116 | 5116 | | |
5117 | 5117 | | |
5118 | 5118 | | |
| |||
0 commit comments