diff options
author | Ronnie Sahlberg <rsahlberg@whamcloud.com> | 2025-06-19 05:10:31 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2025-06-19 16:53:24 +0300 |
commit | 8c8472855884355caf3d8e0c50adf825f83454b2 (patch) | |
tree | 7e5a5c4774bdccef75551639d8006416b54b07a3 | |
parent | cffc873d68ab09a0432b8212008c5613f8a70a2c (diff) | |
download | linux-8c8472855884355caf3d8e0c50adf825f83454b2.tar.xz |
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 <rsahlberg@whamcloud.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
Fixes: 62fe99cef94a ("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>
-rw-r--r-- | drivers/block/ublk_drv.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index c637ea010d34..d36f44f5ee80 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -2825,6 +2825,9 @@ 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) + return -EINVAL; + if (capable(CAP_SYS_ADMIN)) info.flags &= ~UBLK_F_UNPRIVILEGED_DEV; else if (!(info.flags & UBLK_F_UNPRIVILEGED_DEV)) |