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/20210615105218.214-1-xieyongji@bytedance.com Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 7df47cd commit 5f638e5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)