The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Guangshuo Li <lgs201920130244@gmail.com>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	Johannes Thumshirn <jth@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] zonefs: check multiplication overflow in zonefs_fname_to_fno()
Date: Thu, 9 Jul 2026 08:02:47 +0900	[thread overview]
Message-ID: <801587f1-de61-45eb-958e-d998e5dfac04@kernel.org> (raw)
In-Reply-To: <20260708104617.745781-1-lgs201920130244@gmail.com>

On 7/8/26 19:46, Guangshuo Li wrote:
> The change referenced by the Fixes tag added overflow checking for the
> addition used while converting a zone file name to a zone number.
> 
> However, the digit value and decimal shift are still computed with
> unchecked signed long multiplications. For sufficiently long numeric
> names, shift or digit can overflow before check_add_overflow() sees the
> value, leaving the parser with an already corrupted intermediate result.
> 
> Check the digit and shift multiplications as well. Only advance the shift
> when another digit remains, so valid boundary values are not rejected due
> to an unused final shift update.
> 
> Fixes: 3a8389d42bdf ("zonefs: handle integer overflow in zonefs_fname_to_fno")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Please check your email setup. This one was in my Junk folder.

The patch looks OK to me.

> ---
>  fs/zonefs/super.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index ff43d6d1ea30..106cf304348b 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -615,10 +615,12 @@ static long zonefs_fname_to_fno(const struct qstr *fname)
>  		c = *rname;
>  		if (!isdigit(c))
>  			return -ENOENT;
> -		digit = (c - '0') * shift;
> +		if (check_mul_overflow((long)(c - '0'), shift, &digit))
> +			return -ENOENT;
>  		if (check_add_overflow(fno, digit, &fno))
>  			return -ENOENT;
> -		shift *= 10;
> +		if (i + 1 < len && check_mul_overflow(shift, 10L, &shift))
> +			return -ENOENT;
>  	}
>  
>  	return fno;


-- 
Damien Le Moal
Western Digital Research

      reply	other threads:[~2026-07-08 23:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 10:46 [PATCH] zonefs: check multiplication overflow in zonefs_fname_to_fno() Guangshuo Li
2026-07-08 23:02 ` Damien Le Moal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=801587f1-de61-45eb-958e-d998e5dfac04@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=jth@kernel.org \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox