From: Ming Lei <ming.lei@redhat.com>
To: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH] ublk: santizize the arguments from userspace when adding a device
Date: Thu, 19 Jun 2025 10:36:00 +0800 [thread overview]
Message-ID: <aFN3kNtyG_0xcyUY@fedora> (raw)
In-Reply-To: <20250619021031.181340-1-ronniesahlberg@gmail.com>
On Thu, Jun 19, 2025 at 12:10:31PM +1000, Ronnie Sahlberg wrote:
> From: Ronnie Sahlberg <rsahlberg@whamcloud.com>
>
> 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>
> ---
> 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 374e4efa8759..febdb5609e95 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -2336,6 +2336,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))
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")
Thanks,
Ming
next prev parent reply other threads:[~2025-06-19 2:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 2:10 [PATCH] ublk: santizize the arguments from userspace when adding a device Ronnie Sahlberg
2025-06-19 2:36 ` Ming Lei [this message]
2025-06-19 13:54 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFN3kNtyG_0xcyUY@fedora \
--to=ming.lei@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=ronniesahlberg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.