mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
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>
This commit is contained in:
parent
c6e51f1bb2
commit
fe9d8927e2
13 changed files with 45 additions and 33 deletions
|
@ -783,6 +783,7 @@ static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req)
|
|||
union srp_iu *srp = &req_iu(req)->srp;
|
||||
SCSIDevice *sdev;
|
||||
int n, lun;
|
||||
size_t cdb_len = sizeof (srp->cmd.cdb) + (srp->cmd.add_cdb_len & ~3);
|
||||
|
||||
if ((srp->cmd.lun == 0 || be64_to_cpu(srp->cmd.lun) == SRP_REPORT_LUNS_WLUN)
|
||||
&& srp->cmd.cdb[0] == REPORT_LUNS) {
|
||||
|
@ -801,7 +802,7 @@ static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req)
|
|||
} return 1;
|
||||
}
|
||||
|
||||
req->sreq = scsi_req_new(sdev, req->qtag, lun, srp->cmd.cdb, req);
|
||||
req->sreq = scsi_req_new(sdev, req->qtag, lun, srp->cmd.cdb, cdb_len, req);
|
||||
n = scsi_req_enqueue(req->sreq);
|
||||
|
||||
trace_spapr_vscsi_queue_cmd(req->qtag, srp->cmd.cdb[0],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue