aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/dev-storage.c
diff options
context:
space:
mode:
authorJohn Millikin <john@john-millikin.com>2022-08-17 14:34:58 +0900
committerPaolo Bonzini <pbonzini@redhat.com>2022-09-01 07:42:37 +0200
commitfe9d8927e265fd723a6dc87cd6d220f4677dbe1f (patch)
tree0e2d306704d29e6a06cc10b7a320afcbb31279a1 /hw/usb/dev-storage.c
parentc6e51f1bb28ed762d2039c063cbb71a8ad29762d (diff)
downloadqemu-fe9d8927e265fd723a6dc87cd6d220f4677dbe1f.zip
qemu-fe9d8927e265fd723a6dc87cd6d220f4677dbe1f.tar.gz
qemu-fe9d8927e265fd723a6dc87cd6d220f4677dbe1f.tar.bz2
scsi: Add buf_len parameter to scsi_req_new()
When a SCSI command is received from the guest, the CDB length implied by the first byte might exceed the number of bytes the guest sent. In this case scsi_req_new() will read uninitialized data, causing unpredictable behavior. Adds the buf_len parameter to scsi_req_new() and plumbs it through the call stack. Signed-off-by: John Millikin <john@john-millikin.com> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1127 Message-Id: <20220817053458.698416-1-john@john-millikin.com> [Fill in correct length for adapters other than ESP. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/usb/dev-storage.c')
-rw-r--r--hw/usb/dev-storage.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index dca62d5..9863969 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -415,7 +415,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
cbw.cmd_len, s->data_len);
assert(le32_to_cpu(s->csw.residue) == 0);
s->scsi_len = 0;
- s->req = scsi_req_new(scsi_dev, tag, cbw.lun, cbw.cmd, NULL);
+ s->req = scsi_req_new(scsi_dev, tag, cbw.lun, cbw.cmd, cbw.cmd_len, NULL);
if (s->commandlog) {
scsi_req_print(s->req);
}