]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:37:20 +0000 (18:37 +0200)
[ Upstream commit 969127bf0783a4ac0c8a27e633a9e8ea1738583f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/ublk_drv.c

index 746ef36e58df20cbbf055594cf43556a7a443a9a..3b1a5cdd631161e4ecd027cd8294ba2005ef4235 100644 (file)
@@ -2457,7 +2457,8 @@ 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)
+       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))