All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] scsi: scsi_ioctl: Validate command size
@ 2021-11-03 17:06 Tadeusz Struk
  2021-11-03 17:06 ` [PATCH v2 2/2] scsi: core: remove command size deduction from scsi_setup_scsi_cmnd Tadeusz Struk
  2021-11-03 17:09 ` [PATCH v2 1/2] scsi: scsi_ioctl: Validate command size Christoph Hellwig
  0 siblings, 2 replies; 7+ messages in thread
From: Tadeusz Struk @ 2021-11-03 17:06 UTC (permalink / raw)
  To: Bart Van Assche, linux-scsi
  Cc: Tadeusz Struk, Christoph Hellwig, James E . J . Bottomley,
	Martin K . Petersen, linux-kernel, stable

Need to make sure the command size is valid before copying
the command from user.

Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: <stable@vger.kernel.org> # 5.15, 5.14, 5.10
Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
---
Changes in v2:
- removed check for upper len limit as it is handled in sg_io()
---
 drivers/scsi/scsi_ioctl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 6ff2207bd45a..a06c61f22742 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -347,6 +347,8 @@ static int scsi_fill_sghdr_rq(struct scsi_device *sdev, struct request *rq,
 {
 	struct scsi_request *req = scsi_req(rq);
 
+	if (hdr->cmd_len < 6)
+		return -EMSGSIZE;
 	if (copy_from_user(req->cmd, hdr->cmdp, hdr->cmd_len))
 		return -EFAULT;
 	if (!scsi_cmd_allowed(req->cmd, mode))
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-03 17:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 17:06 [PATCH v2 1/2] scsi: scsi_ioctl: Validate command size Tadeusz Struk
2021-11-03 17:06 ` [PATCH v2 2/2] scsi: core: remove command size deduction from scsi_setup_scsi_cmnd Tadeusz Struk
2021-11-03 17:17   ` Bart Van Assche
2021-11-03 17:18   ` Christoph Hellwig
2021-11-03 17:09 ` [PATCH v2 1/2] scsi: scsi_ioctl: Validate command size Christoph Hellwig
2021-11-03 17:19   ` Tadeusz Struk
2021-11-03 17:20     ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.