]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ublk: sanity check add_dev input for underflow
authorRonnie Sahlberg <rsahlberg@whamcloud.com>
Thu, 26 Jun 2025 02:20:45 +0000 (12:20 +1000)
committerJens Axboe <axboe@kernel.dk>
Thu, 26 Jun 2025 13:31:24 +0000 (07:31 -0600)
Add additional checks that queue depth and number of queues are
non-zero.

Signed-off-by: Ronnie Sahlberg <rsahlberg@whamcloud.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250626022046.235018-1-ronniesahlberg@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c

index d441d3259edb3fe9314077dae1c07e4d981b5ec4..c3e3c3b65a6d4d3990822897845c5ce438a7c111 100644 (file)
@@ -2849,7 +2849,8 @@ static int ublk_ctrl_add_dev(const struct ublksrv_ctrl_cmd *header)
        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)
+       if (info.queue_depth > UBLK_MAX_QUEUE_DEPTH || !info.queue_depth ||
+           info.nr_hw_queues > UBLK_MAX_NR_QUEUES || !info.nr_hw_queues)
                return -EINVAL;
 
        if (capable(CAP_SYS_ADMIN))