From: gregkh <gregkh@linuxfoundation.org>
To: "flynnnchen(陈天楚)" <flynnnchen@tencent.com>
Cc: linux-usb <linux-usb@vger.kernel.org>
Subject: Re: [PATCH] usb: storage: sddr55: Reject out-of-bound new_pba
Date: Sun, 16 Nov 2025 07:07:57 -0500 [thread overview]
Message-ID: <2025111605-stardust-unvocal-222f@gregkh> (raw)
In-Reply-To: <B2DC73A3EE1E3A1D+202511161322001664687@tencent.com>
On Sun, Nov 16, 2025 at 01:22:01PM +0800, flynnnchen(陈天楚) wrote:
> From c63dc814b5e51713222462e6bf27d7956a933834 Mon Sep 17 00:00:00 2001
> From: Tianchu Chen <flynnnchen@tencent.com>
> Date: Sun, 16 Nov 2025 12:46:18 +0800
> Subject: [PATCH] usb: storage: sddr55: Reject out-of-bound new_pba
You can use git send-email to not have this show up in the body of the
email in the future :)
> Discovered by Atuin - Automated Vulnerability Discovery Engine.
>
> new_pba comes from the status packet returned after each write.
> A bogus device could report values beyond the block count derived
> from info->capacity, letting the driver walk off the end of
> pba_to_lba[] and corrupt heap memory.
>
> Reject PBAs that exceed the computed block count and fail the
> transfer so we avoid touching out-of-range mapping entries.
>
> Signed-off-by: Tianchu Chen <flynnnchen@tencent.com>
> ---
> drivers/usb/storage/sddr55.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
> index b323f0a36..9d813727e 100644
> --- a/drivers/usb/storage/sddr55.c
> +++ b/drivers/usb/storage/sddr55.c
> @@ -469,6 +469,12 @@ static int sddr55_write_data(struct us_data *us,
> new_pba = (status[3] + (status[4] << 8) + (status[5] << 16))
> >> info->blockshift;
>
> + /* check if device-reported new_pba is out of range */
> + if (new_pba >= (info->capacity >> (info->blockshift + info->pageshift))) {
> + result = USB_STOR_TRANSPORT_FAILED;
> + goto leave;
> + }
Any chance you tested this with real hardware?
thanks,
greg k-h
next prev parent reply other threads:[~2025-11-16 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-16 5:22 [PATCH] usb: storage: sddr55: Reject out-of-bound new_pba =?gb18030?B?Zmx5bm5uY2hlbiizwszss/4p?=
2025-11-16 12:07 ` gregkh [this message]
2025-11-16 13:15 ` =?gb18030?B?Zmx5bm5uY2hlbiizwszss/4p?=
2025-11-16 13:28 ` gregkh
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=2025111605-stardust-unvocal-222f@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=flynnnchen@tencent.com \
--cc=linux-usb@vger.kernel.org \
/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