]> 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:35:20 +0000 (18:35 +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 df3e5aab4b5ac9f5adf17f613673a5958d9116b7..8c873a8e39cd93feb3ca3b1e6f76cbb629912dd3 100644 (file)
@@ -2323,7 +2323,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))