Skip to content

Commit 3b8c72d

Browse files
andrea-parrimartinkpetersen
authored andcommitted
scsi: storvsc: Validate length of incoming packet in storvsc_on_channel_callback()
Check that the packet is of the expected size at least, don't copy data past the packet. Link: https://lore.kernel.org/r/20201118145348.109879-1-parri.andrea@gmail.com Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: linux-scsi@vger.kernel.org Reported-by: Saruhan Karademir <skarade@microsoft.com> Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6112ff4 commit 3b8c72d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/scsi/storvsc_drv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,11 @@ static void storvsc_on_channel_callback(void *context)
12461246
request = (struct storvsc_cmd_request *)
12471247
((unsigned long)desc->trans_id);
12481248

1249+
if (hv_pkt_datalen(desc) < sizeof(struct vstor_packet) - vmscsi_size_delta) {
1250+
dev_err(&device->device, "Invalid packet len\n");
1251+
continue;
1252+
}
1253+
12491254
if (request == &stor_device->init_request ||
12501255
request == &stor_device->reset_request) {
12511256
memcpy(&request->vstor_packet, packet,

0 commit comments

Comments
 (0)