Commit 969127bf authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Jens Axboe
Browse files

ublk: sanity check add_dev input for underflow



Add additional checks that queue depth and number of queues are
non-zero.

Signed-off-by: default avatarRonnie Sahlberg <rsahlberg@whamcloud.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250626022046.235018-1-ronniesahlberg@gmail.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4c8a9517
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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))