scsi: storvsc: Set correct data length for sending SCSI command without payload
Subsystems (3)
PATCH v2 1/1 scsi: storvsc: Set correct data length for sending SCSI command without payload
From: Long Li <[email protected]>
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.
---
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(+)
drivers/scsi/storvsc_drv.c +1 -0
@@ -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)) {
Signature · 1 line
2.43.0
Martin K. Petersen
AppliedQuoted 9 lines · On Wed, 22 Jan 2025 19:07:22 -0800, [email protected] wrote:
In StorVSC,
payload->range.lenis 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_READYorREQUEST_SENSEwhile 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
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering