aboutsummaryrefslogtreecommitdiffstats
path: root/queue-6.6/ublk-santizize-the-arguments-from-userspace-when-add.patch
diff options
Diffstat (limited to 'queue-6.6/ublk-santizize-the-arguments-from-userspace-when-add.patch')
-rw-r--r--queue-6.6/ublk-santizize-the-arguments-from-userspace-when-add.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/queue-6.6/ublk-santizize-the-arguments-from-userspace-when-add.patch b/queue-6.6/ublk-santizize-the-arguments-from-userspace-when-add.patch
new file mode 100644
index 0000000000..2d5350204d
--- /dev/null
+++ b/queue-6.6/ublk-santizize-the-arguments-from-userspace-when-add.patch
@@ -0,0 +1,40 @@
+From 9ebd08ef504a0d0b36d798de0fababf5e1b79962 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 19 Jun 2025 12:10:31 +1000
+Subject: ublk: santizize the arguments from userspace when adding a device
+
+From: Ronnie Sahlberg <rsahlberg@whamcloud.com>
+
+[ 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 <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>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/block/ublk_drv.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
+index 95095500f93af..df3e5aab4b5ac 100644
+--- a/drivers/block/ublk_drv.c
++++ b/drivers/block/ublk_drv.c
+@@ -2323,6 +2323,9 @@ static int ublk_ctrl_add_dev(struct io_uring_cmd *cmd)
+ 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))
+--
+2.39.5
+