Skip to content

Commit a20f1dd

Browse files
Tianchu Chengregkh
authored andcommitted
usb: storage: sddr55: Reject out-of-bound new_pba
commit b59d4fd upstream. 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> Cc: stable <stable@kernel.org> Link: https://patch.msgid.link/B2DC73A3EE1E3A1D+202511161322001664687@tencent.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fada9c8 commit a20f1dd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/usb/storage/sddr55.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ static int sddr55_write_data(struct us_data *us,
469469
new_pba = (status[3] + (status[4] << 8) + (status[5] << 16))
470470
>> info->blockshift;
471471

472+
/* check if device-reported new_pba is out of range */
473+
if (new_pba >= (info->capacity >> (info->blockshift + info->pageshift))) {
474+
result = USB_STOR_TRANSPORT_FAILED;
475+
goto leave;
476+
}
477+
472478
/* check status for error */
473479
if (status[0] == 0xff && status[1] == 0x4) {
474480
info->pba_to_lba[new_pba] = BAD_BLOCK;

0 commit comments

Comments
 (0)