Skip to content

Commit 3162d82

Browse files
RonnieSahlberggregkh
authored andcommitted
ublk: santizize the arguments from userspace when adding a device
[ Upstream commit 8c84728 ] Sanity check the values for queue depth and number of queues we get from userspace when adding a device. Signed-off-by: Ronnie Sahlberg <rsahlberg@whamcloud.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Fixes: 71f28f3 ("ublk_drv: add io_uring based userspace block driver") Fixes: 62fe99c ("ublk: add read()/write() support for ublk char device") Link: https://lore.kernel.org/r/20250619021031.181340-1-ronniesahlberg@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 66bba1f commit 3162d82

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/block/ublk_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,9 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
23232323
if (copy_from_user(&info, argp, sizeof(info)))
23242324
return -EFAULT;
23252325

2326+
if (info.queue_depth > UBLK_MAX_QUEUE_DEPTH || info.nr_hw_queues > UBLK_MAX_NR_QUEUES)
2327+
return -EINVAL;
2328+
23262329
if (capable(CAP_SYS_ADMIN))
23272330
info.flags &= ~UBLK_F_UNPRIVILEGED_DEV;
23282331
else if (!(info.flags & UBLK_F_UNPRIVILEGED_DEV))

0 commit comments

Comments
 (0)