[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210615105218.214-1-xieyongji@bytedance.com>
Date: Tue, 15 Jun 2021 18:52:18 +0800
From: Xie Yongji <xieyongji@...edance.com>
To: mst@...hat.com, jasowang@...hat.com, stefanha@...hat.com,
jejb@...ux.ibm.com, martin.petersen@...cle.com
Cc: virtualization@...ts.linux-foundation.org,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2] 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.
Signed-off-by: Xie Yongji <xieyongji@...edance.com>
Acked-by: Jason Wang <jasowang@...hat.com>
---
drivers/scsi/virtio_scsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index b9c86a7e3b97..2badc3c80d73 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -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)));
}
/*
--
2.11.0
Powered by blists - more mailing lists