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>
This commit is contained in:
Xie Yongji 2021-06-15 18:52:18 +08:00 committed by Martin K. Petersen
parent 7df47cdf19
commit 5f638e5ac6
1 changed files with 1 additions and 1 deletions

View File

@ -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)));
}
/*