Re: [REGRESSION][BISECTED] erroneous buffer overflow detected in bch2_xattr_validate
From: Alan Huang
Date: Thu May 01 2025 - 13:28:56 EST
Thanks,
Alan
> On May 2, 2025, at 01:22, Jan Hendrik Farr <kernel@xxxxxxxx> wrote:
>
>>
>> I wonder if the __counted_by(x_name_len) in struct bch_xattr is needed, since there is also a value after x_name.
>
> Wait a minute. Are you saying that the value with length x_val_len
> is behind the name (of length x_name_len) at the end of the struct.
> So essentially the flexible array member x_name has a length of
> x_name_len + x_val_len and contains both the name and value?
Yes.
>
> If that's the case:
>
> 1. that's not at all clear from the struct definition
> 2. __counted_by(x_name_len) is not correct in that case
>
Both clang and gcc say:
• p->array has at least p->count number of elements available all the time.
Note the at least here. Though I think the counted_by is misleading here.
>
> Best Regards
> Jan