Skip to content

Commit 8c84728

Browse files
RonnieSahlbergaxboe
authored andcommitted
ublk: santizize the arguments from userspace when adding a device
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]>
1 parent cffc873 commit 8c84728

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
@@ -2825,6 +2825,9 @@ static int ublk_ctrl_add_dev(const struct ublksrv_ctrl_cmd *header)
28252825
if (copy_from_user(&info, argp, sizeof(info)))
28262826
return -EFAULT;
28272827

2828+
if (info.queue_depth > UBLK_MAX_QUEUE_DEPTH || info.nr_hw_queues > UBLK_MAX_NR_QUEUES)
2829+
return -EINVAL;
2830+
28282831
if (capable(CAP_SYS_ADMIN))
28292832
info.flags &= ~UBLK_F_UNPRIVILEGED_DEV;
28302833
else if (!(info.flags & UBLK_F_UNPRIVILEGED_DEV))

0 commit comments

Comments
 (0)