Skip to content

Commit

Permalink
scsi: virtio_scsi: Add validation for residual bytes from response
Browse files Browse the repository at this point in the history
This ensures that the residual bytes in response (might come from an
untrusted device) will not exceed the data buffer length.

Link: https://lore.kernel.org/r/[email protected]
Acked-by: Jason Wang <[email protected]>
Signed-off-by: Xie Yongji <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
YongjiXie authored and martinkpetersen committed Jun 29, 2021
1 parent 7df47cd commit 5f638e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/virtio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static inline struct Scsi_Host *virtio_scsi_host(struct virtio_device *vdev)
static void virtscsi_compute_resid(struct scsi_cmnd *sc, u32 resid)
{
if (resid)
scsi_set_resid(sc, resid);
scsi_set_resid(sc, min(resid, scsi_bufflen(sc)));
}

/*
Expand Down

0 comments on commit 5f638e5

Please sign in to comment.