* [PATCH v2] scsi: storvsc: Set correct data length for sending SCSI command without payload
@ 2025-01-23 3:07 longli
2025-02-04 3:33 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: longli @ 2025-01-23 3:07 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
James E.J. Bottomley, Martin K. Petersen, James Bottomley,
linux-hyperv, linux-scsi, linux-kernel, Roman Kisel,
Michael Kelley
Cc: Long Li, stable
From: Long Li <longli@microsoft.com>
In StorVSC, payload->range.len is used to indicate if this SCSI command
carries payload. This data is allocated as part of the private driver
data by the upper layer and may get passed to lower driver uninitialized.
For example, the SCSI error handling mid layer may send TEST_UNIT_READY
or REQUEST_SENSE while reusing the buffer from a failed command. The
private data section may have stale data from the previous command.
If the SCSI command doesn't carry payload, the driver may use this value as
is for communicating with host, resulting in possible corruption.
Fix this by always initializing this value.
Fixes: be0cf6ca301c ("scsi: storvsc: Set the tablesize based on the information given by the host")
Cc: stable@kernel.org
Tested-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Long Li <longli@microsoft.com>
---
Changes:
v2: add details in comment section explaining why there might be uninitialized data in driver private section
drivers/scsi/storvsc_drv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 7ceb982040a5..ca5e5c0aeabf 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1789,6 +1789,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
length = scsi_bufflen(scmnd);
payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb;
+ payload->range.len = 0;
payload_sz = 0;
if (scsi_sg_count(scmnd)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] scsi: storvsc: Set correct data length for sending SCSI command without payload
2025-01-23 3:07 [PATCH v2] scsi: storvsc: Set correct data length for sending SCSI command without payload longli
@ 2025-02-04 3:33 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2025-02-04 3:33 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
James E.J. Bottomley, James Bottomley, linux-hyperv, linux-scsi,
linux-kernel, Roman Kisel, Michael Kelley, longli
Cc: Martin K . Petersen, Long Li, stable
On Wed, 22 Jan 2025 19:07:22 -0800, longli@linuxonhyperv.com wrote:
> In StorVSC, payload->range.len is used to indicate if this SCSI command
> carries payload. This data is allocated as part of the private driver
> data by the upper layer and may get passed to lower driver uninitialized.
>
> For example, the SCSI error handling mid layer may send TEST_UNIT_READY
> or REQUEST_SENSE while reusing the buffer from a failed command. The
> private data section may have stale data from the previous command.
>
> [...]
Applied to 6.14/scsi-fixes, thanks!
[1/1] scsi: storvsc: Set correct data length for sending SCSI command without payload
https://git.kernel.org/mkp/scsi/c/87c4b5e8a6b6
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-04 3:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23 3:07 [PATCH v2] scsi: storvsc: Set correct data length for sending SCSI command without payload longli
2025-02-04 3:33 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).