lkml.org 
[lkml]   [2022]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] ext4: fix bug in extents parsing when eh_entries == 0 and eh_depth > 0
From
Hi Luís,


On 8/12/2022 9:19 PM, Luís Henriques wrote:
> Hi Baokun!
>
> On Fri, Aug 12, 2022 at 08:50:34PM +0800, Baokun Li wrote:
>> Hi Luís,
> ...
>>> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
>>> index 53cfe2c681c4..a5457ac1999c 100644
>>> --- a/fs/ext4/extents.c
>>> +++ b/fs/ext4/extents.c
>>> @@ -460,6 +460,11 @@ static int __ext4_ext_check(const char *function, unsigned int line,
>>> error_msg = "invalid eh_entries";
>>> goto corrupted;
>>> }
>>> + if (unlikely((le16_to_cpu(eh->eh_entries) == 0) &&
>>> + (le16_to_cpu(eh->eh_depth > 0)))) {

le16_to_cpu(eh->eh_depth > 0) It's the wrong position of the parentheses here.

>> The parentheses are misplaced,
> I'm not sure I understand what you mean. I want to have
>
> if (unlikely((CONDITION A) && (CONDITION B))) {
> /* ... */
> }
>
> so they look correct. Or is that a matter of style/alignment? (Which
> checkpatch.pl doesn't complains about, by the way.)
>
>> and le16_to_cpu is not needed here.
> OK, I guess that, since both conditions do a comparison against '0', the
> le16_to_cpu() can be dropped. And, if the parentheses problem you
> mentioned above is a style problem, dropping it will also solve it because
> that statement will become
>
> if (unlikely((eh->eh_entries == 0) && (eh->eh_depth > 0))) {
> /* ... */
> }

Yeah, but it could be more streamlined here.

The earlier judgment has guaranteed "depth == eh->eh_depth"

> And once again, thanks for your review!
>
> Cheers,

--
With Best Regards,
Baokun Li

\
 
 \ /
  Last update: 2022-08-12 15:35    [W:0.045 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site