Commit 3cc4e13
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: 1a926e0 ("cgroup: implement hierarchy limits")
Signed-off-by: Xiu Jianfeng <[email protected]>
Reviewed-by: Michal Koutný <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>1 parent 117932e commit 3cc4e13
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5789 | 5789 | | |
5790 | 5790 | | |
5791 | 5791 | | |
5792 | | - | |
| 5792 | + | |
5793 | 5793 | | |
5794 | 5794 | | |
5795 | 5795 | | |
5796 | 5796 | | |
5797 | 5797 | | |
5798 | 5798 | | |
5799 | 5799 | | |
5800 | | - | |
| 5800 | + | |
5801 | 5801 | | |
5802 | 5802 | | |
5803 | 5803 | | |
| |||
0 commit comments