Re: [PATCH] cgroup: Fix potential overflow issue when checking max_depth

From: Xiu Jianfeng
Date: Mon Oct 14 2024 - 10:17:44 EST


Hi Michal,

On 2024/10/14 21:37, Michal Koutný wrote:
> Hello.
>
> On Sat, Oct 12, 2024 at 07:22:46AM GMT, Xiu Jianfeng <xiujianfeng@xxxxxxxxxxxxxxx> wrote:
>> 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.
>
> Strictly speaking the overflow would be undefined behavior (Out of curiousity --
> have you figured this out with a checker tool or code reading?)

Thanks for your review, I figured it out with code reading.


> Logically (neglecting UB), max_depth=INT_MAX would behave like intended
> (no limit).

Agreed, this is the real 'no limit'.

>
>> Fixes: 1a926e0bbab8 ("cgroup: implement hierarchy limits")
>> Signed-off-by: Xiu Jianfeng <xiujianfeng@xxxxxxxxxx>
>> ---
>> kernel/cgroup/cgroup.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Reviewed-by: Michal Koutný <mkoutny@xxxxxxxx>