Skip to content

Commit d1b8de2

Browse files
longlimsftgregkh
authored andcommitted
scsi: storvsc: Set correct data length for sending SCSI command without payload
commit 87c4b5e upstream. 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: be0cf6c ("scsi: storvsc: Set the tablesize based on the information given by the host") Cc: [email protected] Tested-by: Roman Kisel <[email protected]> Reviewed-by: Roman Kisel <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Signed-off-by: Long Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2b9b9ce commit d1b8de2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: drivers/scsi/storvsc_drv.c

+1
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
18001800

18011801
length = scsi_bufflen(scmnd);
18021802
payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb;
1803+
payload->range.len = 0;
18031804
payload_sz = 0;
18041805

18051806
if (scsi_sg_count(scmnd)) {

0 commit comments

Comments
 (0)