From: Leon Romanovsky <leon@kernel.org>
To: Yi Liu <liuy22@mails.tsinghua.edu.cn>
Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org
Subject: Re: [PATCH 1/1] RDMA/uverbs: Validate wqe_size before using it in ib_uverbs_post_send
Date: Mon, 26 Jan 2026 15:07:30 +0200 [thread overview]
Message-ID: <20260126130730.GM13967@unreal> (raw)
In-Reply-To: <20260122142900.2356276-2-liuy22@mails.tsinghua.edu.cn>
On Thu, Jan 22, 2026 at 10:29:00PM +0800, Yi Liu wrote:
> ib_uverbs_post_send() uses cmd.wqe_size from userspace without any
> validation before passing it to kmalloc() and using the allocated
> buffer as struct ib_uverbs_send_wr.
>
> If a user provides a small wqe_size value (e.g., 1), kmalloc() will
> succeed, but subsequent accesses to user_wr->opcode, user_wr->num_sge,
> and other fields will read beyond the allocated buffer, resulting in
> an out-of-bounds read from kernel heap memory. This could potentially
> leak sensitive kernel information to userspace.
>
> Additionally, providing an excessively large wqe_size can trigger a
> WARNING in the memory allocation path, as reported by syzkaller.
>
> This is inconsistent with ib_uverbs_unmarshall_recv() which properly
> validates that wqe_size >= sizeof(struct ib_uverbs_recv_wr) before
> proceeding.
>
> Add the same validation for ib_uverbs_post_send() to ensure wqe_size
> is at least sizeof(struct ib_uverbs_send_wr).
>
> Fixes: 67cdb40ca444 ("[IB] uverbs: Implement more commands")
The commit referenced in the "fixes" tag already includes the cmd.wqe_size
check. The correct commit is c3bea3d2dc53 ("RDMA/uverbs: Use the iterator
for ib_uverbs_unmarshall_recv()").
In addition, I added _GFP_NOWARN to suppress warnings when a large size is
provided.
I took this patch and fixed it.
Thanks
> Signed-off-by: Yi Liu <liuy22@mails.tsinghua.edu.cn>
> ---
> drivers/infiniband/core/uverbs_cmd.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index ce16404cd..a80b95948 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -2049,6 +2049,9 @@ static int ib_uverbs_post_send(struct uverbs_attr_bundle *attrs)
> if (ret)
> return ret;
>
> + if (cmd.wqe_size < sizeof(struct ib_uverbs_send_wr))
> + return -EINVAL;
> +
> user_wr = kmalloc(cmd.wqe_size, GFP_KERNEL);
> if (!user_wr)
> return -ENOMEM;
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2026-01-26 13:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 14:28 [PATCH 0/1] RDMA/uverbs: Fix missing wqe_size validation in ib_uverbs_post_send Yi Liu
2026-01-22 14:29 ` [PATCH 1/1] RDMA/uverbs: Validate wqe_size before using it " Yi Liu
2026-01-22 17:10 ` Greg KH
2026-01-26 13:07 ` Leon Romanovsky [this message]
2026-01-26 13:07 ` Leon Romanovsky
2026-01-22 17:10 ` [PATCH 0/1] RDMA/uverbs: Fix missing wqe_size validation " Greg KH
-- strict thread matches above, loose matches on Subject: below --
2026-01-23 1:42 [PATCH v2 " Yi Liu
2026-01-23 1:42 ` [PATCH 1/1] RDMA/uverbs: Validate wqe_size before using it " Yi Liu
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=20260126130730.GM13967@unreal \
--to=leon@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
--cc=liuy22@mails.tsinghua.edu.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox