[LTP] [PATCH] lib: switch cgroup bit-fields from signed to unsigned int
Li Wang
liwang@redhat.com
Sat Jan 25 03:43:11 CET 2025
On Fri, Jan 24, 2025 at 7:20 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> > There is a problem in cgroup lib that the declearation int
> > can lead to -1 during the | operation.
> >
> > Becasue if the field contains uninitialized garbage data,
> > a bit-field declared as int could interpret 0b1 as -1 due
> > to signed arithmetic.
>
> Uff, so we have a number that can be either -1 or 0. Where did it break?
>
It doesn't break anything so far, I found that issue while reviewing
Guojie's patch-v2, when that memory_recursiveprot declared as int,
the test result is always wrong.
However, the root->nsdelegate avoids this problem by negating value twice:
static int cgroup_v2_nsdelegate(void)
{
return !!roots[0].nsdelegate;
}
But I think we should fix this from the root.
> I suppose that things are okay as long as we do if (s->bar | s->bar).
>
>
> Anyways:
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
>
--
Regards,
Li Wang
More information about the ltp
mailing list