Skip to content

Commit 969127b

Browse files
RonnieSahlbergaxboe
authored andcommitted
ublk: sanity check add_dev input for underflow
Add additional checks that queue depth and number of queues are non-zero. Signed-off-by: Ronnie Sahlberg <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 4c8a951 commit 969127b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/block/ublk_drv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2849,7 +2849,8 @@ static int ublk_ctrl_add_dev(const struct ublksrv_ctrl_cmd *header)
28492849
if (copy_from_user(&info, argp, sizeof(info)))
28502850
return -EFAULT;
28512851

2852-
if (info.queue_depth > UBLK_MAX_QUEUE_DEPTH || info.nr_hw_queues > UBLK_MAX_NR_QUEUES)
2852+
if (info.queue_depth > UBLK_MAX_QUEUE_DEPTH || !info.queue_depth ||
2853+
info.nr_hw_queues > UBLK_MAX_NR_QUEUES || !info.nr_hw_queues)
28532854
return -EINVAL;
28542855

28552856
if (capable(CAP_SYS_ADMIN))

0 commit comments

Comments
 (0)