Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: storage: sddr55: Reject out-of-bound new_pba
@ 2025-11-16  5:22 =?gb18030?B?Zmx5bm5uY2hlbiizwszss/4p?=
  2025-11-16 12:07 ` gregkh
  0 siblings, 1 reply; 4+ messages in thread
From: =?gb18030?B?Zmx5bm5uY2hlbiizwszss/4p?= @ 2025-11-16  5:22 UTC (permalink / raw)
  To: linux-usb; +Cc: gregkh

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

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;
+		}
+
 		/* check status for error */
 		if (status[0] == 0xff && status[1] == 0x4) {
 			info->pba_to_lba[new_pba] = BAD_BLOCK;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-16 13:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-11-16 13:15   ` =?gb18030?B?Zmx5bm5uY2hlbiizwszss/4p?=
2025-11-16 13:28     ` gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox