From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Jason Gunthorpe <jgg@nvidia.com>,
Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
Leon Romanovsky <leon@kernel.org>,
linux-rdma@vger.kernel.org,
Selvin Xavier <selvin.xavier@broadcom.com>,
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Cc: patches@lists.linux.dev
Subject: Re: [PATCH 06/10] RDMA/bnxt_re: Add compatibility checks to the uapi path
Date: Sun, 8 Feb 2026 11:29:12 -0800 [thread overview]
Message-ID: <2768471c-4b50-4b34-a87a-35fbc49019b7@linux.dev> (raw)
In-Reply-To: <6-v1-89ea7d615ba4+636-bnxt_re_uapi_jgg@nvidia.com>
在 2026/2/5 17:45, Jason Gunthorpe 写道:
> Check that the driver data is properly sized and properly zeroed by
> calling ib_copy_validate_udata_in().
>
> Use git history to find the commit introducing each req struct and use
> that to select the end member.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
> ---
> drivers/infiniband/hw/bnxt_re/ib_verbs.c | 29 +++++++++++++-----------
> 1 file changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index f19b55c13d5809..2942ff44f6a547 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -1655,9 +1655,11 @@ int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr,
> qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
>
> uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext, ib_uctx);
> - if (udata)
> - if (ib_copy_from_udata(&ureq, udata, min(udata->inlen, sizeof(ureq))))
> - return -EFAULT;
> + if (udata) {
> + rc = ib_copy_validate_udata_in(udata, ureq, qp_handle);
> + if (rc)
> + return rc;
> + }
>
> rc = bnxt_re_test_qp_limits(rdev, qp_init_attr, dev_attr);
> if (!rc) {
> @@ -1847,9 +1849,11 @@ static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev,
> int bytes = 0;
> struct bnxt_re_ucontext *cntx = rdma_udata_to_drv_context(
> udata, struct bnxt_re_ucontext, ib_uctx);
> + int rc;
>
> - if (ib_copy_from_udata(&ureq, udata, sizeof(ureq)))
> - return -EFAULT;
> + rc = ib_copy_validate_udata_in(udata, ureq, srq_handle);
> + if (rc)
> + return rc;
>
> bytes = (qplib_srq->max_wqe * qplib_srq->wqe_size);
> bytes = PAGE_ALIGN(bytes);
> @@ -3156,10 +3160,10 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
> cq->qplib_cq.sg_info.pgshft = PAGE_SHIFT;
> if (udata) {
> struct bnxt_re_cq_req req;
> - if (ib_copy_from_udata(&req, udata, sizeof(req))) {
> - rc = -EFAULT;
> +
> + rc = ib_copy_validate_udata_in(udata, req, cq_handle);
> + if (rc)
> goto fail;
> - }
>
> cq->umem = ib_umem_get(&rdev->ibdev, req.cq_va,
> entries * sizeof(struct cq_base),
> @@ -3289,10 +3293,9 @@ int bnxt_re_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
> entries = dev_attr->max_cq_wqes + 1;
>
> /* uverbs consumer */
> - if (ib_copy_from_udata(&req, udata, sizeof(req))) {
> - rc = -EFAULT;
> + rc = ib_copy_validate_udata_in(udata, req, cq_va);
> + if (rc)
> goto fail;
> - }
>
> cq->resize_umem = ib_umem_get(&rdev->ibdev, req.cq_va,
> entries * sizeof(struct cq_base),
> @@ -4391,8 +4394,8 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
> if (_is_host_msn_table(rdev->qplib_res.dattr->dev_cap_flags2))
> resp.comp_mask |= BNXT_RE_UCNTX_CMASK_MSN_TABLE_ENABLED;
>
> - if (udata->inlen >= sizeof(ureq)) {
> - rc = ib_copy_from_udata(&ureq, udata, min(udata->inlen, sizeof(ureq)));
> + if (udata->inlen) {
> + rc = ib_copy_validate_udata_in(udata, ureq, comp_mask);
> if (rc)
> goto cfail;
> if (ureq.comp_mask & BNXT_RE_COMP_MASK_REQ_UCNTX_POW2_SUPPORT) {
next prev parent reply other threads:[~2026-02-08 19:29 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 1:45 [PATCH 00/10] Provide udata helpers and use them in bnxt_re Jason Gunthorpe
2026-02-06 1:45 ` [PATCH 01/10] RDMA: Add ib_copy_validate_udata_in() Jason Gunthorpe
2026-02-09 6:11 ` Junxian Huang
2026-02-09 14:06 ` Jason Gunthorpe
2026-02-06 1:45 ` [PATCH 02/10] RDMA: Add ib_copy_validate_udata_in_cm() Jason Gunthorpe
2026-02-06 1:45 ` [PATCH 03/10] RDMA: Add ib_respond_udata() Jason Gunthorpe
2026-02-13 10:10 ` Leon Romanovsky
2026-02-13 12:43 ` Jason Gunthorpe
2026-02-13 15:37 ` Leon Romanovsky
2026-02-13 15:48 ` Jason Gunthorpe
2026-02-16 23:14 ` Jason Gunthorpe
2026-02-17 7:48 ` Leon Romanovsky
2026-02-06 1:45 ` [PATCH 04/10] RDMA: Add ib_is_udata_in_empty() Jason Gunthorpe
2026-02-13 10:22 ` Leon Romanovsky
2026-02-13 12:56 ` Jason Gunthorpe
2026-02-06 1:45 ` [PATCH 05/10] RDMA: Provide documentation about the uABI compatibility rules Jason Gunthorpe
2026-02-13 10:23 ` Leon Romanovsky
2026-02-13 12:56 ` Jason Gunthorpe
2026-02-13 15:57 ` Leon Romanovsky
2026-02-18 0:01 ` Jason Gunthorpe
2026-02-06 1:45 ` [PATCH 06/10] RDMA/bnxt_re: Add compatibility checks to the uapi path Jason Gunthorpe
2026-02-08 19:29 ` Zhu Yanjun [this message]
2026-02-06 1:45 ` [PATCH 07/10] RDMA/bnxt_re: Add compatibility checks to the uapi path for no data Jason Gunthorpe
2026-02-13 10:34 ` Leon Romanovsky
2026-02-06 1:45 ` [PATCH 08/10] RDMA/bnxt_re: Add missing comp_mask validation Jason Gunthorpe
2026-02-06 1:45 ` [PATCH 09/10] RDMA/bnxt_re: Use ib_respond_udata() Jason Gunthorpe
2026-02-13 10:40 ` Leon Romanovsky
2026-02-13 12:42 ` Jason Gunthorpe
2026-02-13 15:39 ` Leon Romanovsky
2026-02-06 1:45 ` [PATCH 10/10] RDMA/bnxt_re: Add BNXT_RE_UCNTX_CMASK_UAPI_COMPAT_SUPPORTED Jason Gunthorpe
2026-02-06 12:20 ` [PATCH 00/10] Provide udata helpers and use them in bnxt_re Sriharsha Basavapatna
2026-02-06 19:11 ` Jason Gunthorpe
2026-02-09 12:28 ` Sriharsha Basavapatna
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=2768471c-4b50-4b34-a87a-35fbc49019b7@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=jgg@nvidia.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=selvin.xavier@broadcom.com \
--cc=sriharsha.basavapatna@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox