Re: [PATCH v2 1/2] scsi: scsi_ioctl: Validate command size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 03, 2021 at 10:06:58AM -0700, Tadeusz Struk wrote:
> Need to make sure the command size is valid before copying
> the command from user.
> 
> Cc: Bart Van Assche <bvanassche@xxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> Cc: James E.J. Bottomley <jejb@xxxxxxxxxxxxx>
> Cc: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
> Cc: <linux-scsi@xxxxxxxxxxxxxxx>
> Cc: <linux-kernel@xxxxxxxxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx> # 5.15, 5.14, 5.10
> Signed-off-by: Tadeusz Struk <tadeusz.struk@xxxxxxxxxx>
> ---
> 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;

The checks looks good, but I'd be tempted to place it next to the
other check on hdr->cmd_len in the caller.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux