Skip to content

Commit cad6317

Browse files
RonnieSahlbergopsiff
authored andcommitted
ublk: santizize the arguments from userspace when adding a device
[ Upstream commit 8c8472855884355caf3d8e0c50adf825f83454b2 ] Sanity check the values for queue depth and number of queues we get from userspace when adding a device. Signed-off-by: Ronnie Sahlberg <[email protected]> Reviewed-by: Ming Lei <[email protected]> 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/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 3162d8235c8c4d585525cee8a59d1c180940a968)
1 parent fe2fbc9 commit cad6317

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)