diff options
author | Tadeusz Struk <[email protected]> | 2021-11-03 10:06:58 -0700 |
---|---|---|
committer | Martin K. Petersen <[email protected]> | 2021-11-03 22:02:52 -0400 |
commit | 20aaef52eb08f1d987d46ad26edb8f142f74d83a (patch) | |
tree | 60c2ea05e16173b3cdcff8fec4d2ef109112bd21 | |
parent | 9ec5128a8b5631d652ed06b37e0166f337802f90 (diff) |
scsi: scsi_ioctl: Validate command size
Need to make sure the command size is valid before copying the command from
user space.
Link: https://lore.kernel.org/r/[email protected]
Cc: Bart Van Assche <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: James E.J. Bottomley <[email protected]>
Cc: Martin K. Petersen <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]> # 5.15, 5.14, 5.10
Signed-off-by: Tadeusz Struk <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
-rw-r--r-- | drivers/scsi/scsi_ioctl.c | 2 |
1 files changed, 2 insertions, 0 deletions
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)) |