Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jacob Moroni <jmoroni@google.com>
Cc: tatyana.e.nikolova@intel.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next v3 5/7] RDMA/irdma: Use robust udata helper for QP creation
Date: Sun, 12 Jul 2026 11:29:41 +0300	[thread overview]
Message-ID: <20260712082941.GA33197@unreal> (raw)
In-Reply-To: <20260702170652.4159201-6-jmoroni@google.com>

On Thu, Jul 02, 2026 at 05:06:50PM +0000, Jacob Moroni wrote:
> Replace the manual udata input copy and validation during
> QP creation with the robust helper.
> 
> The irdma driver is backwards compatible with the legacy
> i40iw userspace provider. The current create_qp ABI contains
> two 8 byte fields. The legacy i40iw ABI was the same but
> also contained two additional fields which were never actually
> used. Furthermore, the i40iw userspace provider never explicitly
> zero-initialized those extra fields, so there is a chance that
> existing binaries are passing non-zero garbage values down
> to the kernel.
> 
> Previously, the irdma driver only copied out the first 16
> bytes and did not have any check for the rest of the buffer
> being zero, so that additional garbage didn't matter.
> 
> By switching to ib_copy_validate_udata_in(), we will now be
> checking to ensure that data beyond the kernel's definition
> of the request is all zero.
> 
> In order to avoid breaking legacy binaries, we therefore need
> to increase the request structure size to cover those garbage
> fields.
> 
> - Legacy binaries will continue to pass down a 32 byte request,
>   with the driver copying the entire 32 bytes out but ignoring
>   the second 16 bytes, just as before.
> 
> - Newer binaries will pass down the normal 16 byte request. The
>   ib_copy_validate_udata_in() call will allow this to succeed
>   because we use user_compl_ctx as our minimum length (16 bytes).
> 
> - If the request is ever extended, the new fields would be
>   added after the "don't use" fields and would work as per
>   the normal uAPI mechanism.
> 
> Signed-off-by: Jacob Moroni <jmoroni@google.com>
> ---
>  drivers/infiniband/hw/irdma/verbs.c | 41 ++++++++++++++++-------------
>  include/uapi/rdma/irdma-abi.h       |  1 +
>  2 files changed, 23 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
> index 519ac780e9f1..00a648922c7b 100644
> --- a/drivers/infiniband/hw/irdma/verbs.c
> +++ b/drivers/infiniband/hw/irdma/verbs.c
> @@ -632,37 +632,29 @@ static void irdma_setup_virt_qp(struct irdma_device *iwdev,
>  
>  /**
>   * irdma_setup_umode_qp - setup sq and rq size in user mode qp
> - * @udata: udata
> + * @ucontext: user context
> + * @req: user request pointer
>   * @iwdev: iwarp device
>   * @iwqp: qp ptr (user or kernel)
>   * @info: initialize info to return
>   * @init_attr: Initial QP create attributes
>   */
> -static int irdma_setup_umode_qp(struct ib_udata *udata,
> +static int irdma_setup_umode_qp(struct irdma_ucontext *ucontext,
> +				struct irdma_create_qp_req *req,
>  				struct irdma_device *iwdev,
>  				struct irdma_qp *iwqp,
>  				struct irdma_qp_init_info *info,
>  				struct ib_qp_init_attr *init_attr)
>  {
> -	struct irdma_ucontext *ucontext = rdma_udata_to_drv_context(udata,
> -				struct irdma_ucontext, ibucontext);
>  	struct irdma_qp_uk_init_info *ukinfo = &info->qp_uk_init_info;
> -	struct irdma_create_qp_req req;
>  	unsigned long flags;
>  	int ret;
>  
> -	ret = ib_copy_from_udata(&req, udata,
> -				 min(sizeof(req), udata->inlen));
> -	if (ret) {
> -		ibdev_dbg(&iwdev->ibdev, "VERBS: ib_copy_from_data fail\n");
> -		return ret;
> -	}
> -
> -	iwqp->ctx_info.qp_compl_ctx = req.user_compl_ctx;
> +	iwqp->ctx_info.qp_compl_ctx = req->user_compl_ctx;
>  	iwqp->user_mode = 1;
>  
>  	spin_lock_irqsave(&ucontext->qp_reg_mem_list_lock, flags);
> -	iwqp->iwpbl = irdma_get_pbl((unsigned long)req.user_wqe_bufs,
> +	iwqp->iwpbl = irdma_get_pbl((unsigned long)req->user_wqe_bufs,
>  				    &ucontext->qp_reg_mem_list);
>  	spin_unlock_irqrestore(&ucontext->qp_reg_mem_list_lock, flags);

Which codebase did you use for this series?

That function differs from the current implementation, which has
remained unchanged since 2023:
https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/tree/drivers/infiniband/hw/irdma/verbs.c#n639

Thanks

  reply	other threads:[~2026-07-12  8:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 17:06 [PATCH rdma-next v3 0/7] RDMA/irdma: Adopt robust udata Jacob Moroni
2026-07-02 17:06 ` [PATCH rdma-next v3 1/7] RDMA/core: Add ib_no_udata_io() helper Jacob Moroni
2026-07-02 17:06 ` [PATCH rdma-next v3 2/7] RDMA/irdma: Add checks for no udata Jacob Moroni
2026-07-02 17:06 ` [PATCH rdma-next v3 3/7] RDMA/irdma: Clear udata response buffers where necessary Jacob Moroni
2026-07-02 17:06 ` [PATCH rdma-next v3 4/7] RDMA/irdma: Use robust input copy helpers Jacob Moroni
2026-07-02 17:06 ` [PATCH rdma-next v3 5/7] RDMA/irdma: Use robust udata helper for QP creation Jacob Moroni
2026-07-12  8:29   ` Leon Romanovsky [this message]
2026-07-02 17:06 ` [PATCH rdma-next v3 6/7] RDMA/irdma: Fix legacy i40iw compat check in create_qp Jacob Moroni
2026-07-02 17:06 ` [PATCH rdma-next v3 7/7] RDMA/irdma: Enable uverbs_robust_udata compliance flag Jacob Moroni
2026-07-12  8:31 ` (subset) [PATCH rdma-next v3 0/7] RDMA/irdma: Adopt robust udata Leon Romanovsky
2026-07-12  8:32 ` Leon Romanovsky

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=20260712082941.GA33197@unreal \
    --to=leon@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jmoroni@google.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=tatyana.e.nikolova@intel.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