2022-05-23 10:07:09

by Lukas Czerner

[permalink] [raw]
Subject: Re: [PATCH 2/2] ext4: correct the judgment of BUG in ext4_mb_normalize_request

On Sat, May 21, 2022 at 09:42:17PM +0800, Baokun Li wrote:
> When either of the "start + size <= ac->ac_o_ex.fe_logical" or
> "start > ac->ac_o_ex.fe_logical" conditions is met, it indicates
> that the fe_logical is not in the allocated range.
> In this case, it should be bug_ON.

This seems wrong, I think that this condition is testing overflow and
it's correct as it is. Or am I missing something?

-Lukas

>
> Fixes: dfe076c106f6 ("ext4: get rid of code duplication")
> Signed-off-by: Baokun Li <[email protected]>
> ---
> fs/ext4/mballoc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 32410b79b664..d0fb57970648 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4190,7 +4190,7 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
> }
> rcu_read_unlock();
>
> - if (start + size <= ac->ac_o_ex.fe_logical &&
> + if (start + size <= ac->ac_o_ex.fe_logical ||
> start > ac->ac_o_ex.fe_logical) {
> ext4_msg(ac->ac_sb, KERN_ERR,
> "start %lu, size %lu, fe_logical %lu",
> --
> 2.31.1
>