Re: [PATCH] ublk: santizize the arguments from userspace when adding a device

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

 



On Thu, Jun 19, 2025 at 12:10:31PM +1000, Ronnie Sahlberg wrote:
> From: Ronnie Sahlberg <rsahlberg@xxxxxxxxxxxxx>
> 
> Sanity check the values for queue depth and number of queues
> we get from userspace when adding a device.
> 
> Signed-off-by: Ronnie Sahlberg <rsahlberg@xxxxxxxxxxxxx>
> ---
>  drivers/block/ublk_drv.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 374e4efa8759..febdb5609e95 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -2336,6 +2336,9 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
>  	if (copy_from_user(&info, argp, sizeof(info)))
>  		return -EFAULT;
>  
> +	if (info.queue_depth > UBLK_MAX_QUEUE_DEPTH || info.nr_hw_queues > UBLK_MAX_NR_QUEUES)
> +		return -EINVAL;
> +
>  	if (capable(CAP_SYS_ADMIN))
>  		info.flags &= ~UBLK_F_UNPRIVILEGED_DEV;
>  	else if (!(info.flags & UBLK_F_UNPRIVILEGED_DEV))

Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>

Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
Fixes: 62fe99cef94a ("ublk: add read()/write() support for ublk char device")


Thanks,
Ming





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux