Skip to content

Commit 20aaef5

Browse files
tstrukmartinkpetersen
authored andcommitted
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]>
1 parent 9ec5128 commit 20aaef5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/scsi/scsi_ioctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ static int scsi_fill_sghdr_rq(struct scsi_device *sdev, struct request *rq,
347347
{
348348
struct scsi_request *req = scsi_req(rq);
349349

350+
if (hdr->cmd_len < 6)
351+
return -EMSGSIZE;
350352
if (copy_from_user(req->cmd, hdr->cmdp, hdr->cmd_len))
351353
return -EFAULT;
352354
if (!scsi_cmd_allowed(req->cmd, mode))

0 commit comments

Comments
 (0)