Skip to content

Commit 5f638e5

Browse files
YongjiXiemartinkpetersen
authored andcommitted
scsi: virtio_scsi: Add validation for residual bytes from response
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]>
1 parent 7df47cd commit 5f638e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/virtio_scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static inline struct Scsi_Host *virtio_scsi_host(struct virtio_device *vdev)
9797
static void virtscsi_compute_resid(struct scsi_cmnd *sc, u32 resid)
9898
{
9999
if (resid)
100-
scsi_set_resid(sc, resid);
100+
scsi_set_resid(sc, min(resid, scsi_bufflen(sc)));
101101
}
102102

103103
/*

0 commit comments

Comments
 (0)