* [PATCH v2] usb: image: microtek: limit REQUEST SENSE transfer to the sense buffer
@ 2026-11-26 12:22 Alexandre Becholey
2026-11-26 12:29 ` sashiko-bot
2026-11-26 12:39 ` Oliver Neukum
0 siblings, 2 replies; 3+ messages in thread
From: Alexandre Becholey @ 2026-11-26 12:22 UTC (permalink / raw)
To: Oliver Neukum, Greg Kroah-Hartman
Cc: linux-usb, Oliver Neukum, Alexandre Becholey, stable
mts_command_done() receives the data phase of a REQUEST SENSE into
srb->sense_buffer (SCSI_SENSE_BUFFERSIZE, 96 bytes), but with the
length of the command's own data buffer. A REQUEST SENSE sent through
SG_IO, allowed on a read-only /dev/sgN without any capability, can have
a much larger buffer (252 bytes with sg_requests), and a device that
returns that much writes past the end of the sense buffer.
Limit the transfer to SCSI_SENSE_BUFFERSIZE.
The bug was found, and the reproducer and this fix were written, by AI
agents (Claude Mythos and Claude Opus models). The analysis and the
patch were reviewed by a human.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Becholey <alex@becholey.ch>
---
v2: keep receiving the REQUEST SENSE data into sense_buffer and limit
the transfer to SCSI_SENSE_BUFFERSIZE instead of removing the special
case (Oliver Neukum)
v1: https://lore.kernel.org/all/20261119084526.535901-1-alex@becholey.ch/
An emulated ScanMaker X6 answering a 252-byte SG_IO REQUEST SENSE with
252 bytes triggers KASAN in dummy_timer on v7.3.1 and master
4405c18c95d2; no reports with the patch. An honest device gives the same
results with and without it, including the error handler's REQUEST
SENSE. Not tested on real hardware. Reproducer available on request.
drivers/usb/image/microtek.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 1f0b3c44d388..09817ac6e3d8 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -449,7 +449,8 @@ static void mts_command_done( struct urb *transfer )
mts_int_submit_urb(transfer,
context->data_pipe,
context->srb->sense_buffer,
- context->data_length,
+ min_t(unsigned int, context->data_length,
+ SCSI_SENSE_BUFFERSIZE),
mts_data_done);
} else { if ( context->data ) {
mts_int_submit_urb(transfer,
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] usb: image: microtek: limit REQUEST SENSE transfer to the sense buffer
2026-11-26 12:22 [PATCH v2] usb: image: microtek: limit REQUEST SENSE transfer to the sense buffer Alexandre Becholey
@ 2026-11-26 12:29 ` sashiko-bot
2026-11-26 12:39 ` Oliver Neukum
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-26 12:29 UTC (permalink / raw)
To: Alexandre Becholey; +Cc: linux-usb
> mts_command_done() receives the data phase of a REQUEST SENSE into
> srb->sense_buffer (SCSI_SENSE_BUFFERSIZE, 96 bytes), but with the
> length of the command's own data buffer. A REQUEST SENSE sent through
> SG_IO, allowed on a read-only /dev/sgN without any capability, can have
> a much larger buffer (252 bytes with sg_requests), and a device that
> returns that much writes past the end of the sense buffer.
>
> Limit the transfer to SCSI_SENSE_BUFFERSIZE.
>
> The bug was found, and the reproducer and this fix were written, by AI
> agents (Claude Mythos and Claude Opus models). The analysis and the
> patch were reviewed by a human.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexandre Becholey <alex@becholey.ch>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126122151.414230-1-alex@becholey.ch?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] usb: image: microtek: limit REQUEST SENSE transfer to the sense buffer
2026-11-26 12:22 [PATCH v2] usb: image: microtek: limit REQUEST SENSE transfer to the sense buffer Alexandre Becholey
2026-11-26 12:29 ` sashiko-bot
@ 2026-11-26 12:39 ` Oliver Neukum
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Neukum @ 2026-11-26 12:39 UTC (permalink / raw)
To: Alexandre Becholey, Oliver Neukum, Greg Kroah-Hartman
Cc: linux-usb, Oliver Neukum, stable
On 26.11.26 13:22, Alexandre Becholey wrote:
> mts_command_done() receives the data phase of a REQUEST SENSE into
> srb->sense_buffer (SCSI_SENSE_BUFFERSIZE, 96 bytes), but with the
> length of the command's own data buffer. A REQUEST SENSE sent through
> SG_IO, allowed on a read-only /dev/sgN without any capability, can have
> a much larger buffer (252 bytes with sg_requests), and a device that
> returns that much writes past the end of the sense buffer.
>
> Limit the transfer to SCSI_SENSE_BUFFERSIZE.
>
> The bug was found, and the reproducer and this fix were written, by AI
> agents (Claude Mythos and Claude Opus models). The analysis and the
> patch were reviewed by a human.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexandre Becholey <alex@becholey.ch>
Acked-by: Oliver Neukum <oneukum@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 12:22 [PATCH v2] usb: image: microtek: limit REQUEST SENSE transfer to the sense buffer Alexandre Becholey
2026-11-26 12:29 ` sashiko-bot
2026-11-26 12:39 ` Oliver Neukum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox