mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RDMA/uverbs: Set MR iova and length in ioctl reg paths
@ 2026-09-04  2:24 lirongqing
  2026-09-06  9:06 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-09-04  2:24 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky, Li RongQing, Yishai Hadas,
	Edward Srouji, Sean Hefty, Christian Koenig, Michael J . Ruhl,
	linux-rdma, linux-kernel

From: Li RongQing <lirongqing@baidu.com>

UVERBS_METHOD_REG_MR and UVERBS_METHOD_REG_DMABUF_MR do not
initialize ib_mr->iova and ib_mr->length, unlike
ib_uverbs_reg_mr() which assigns both from the command.

Drivers that do not set these fields themselves are therefore left
with zero values. UVERBS_METHOD_QUERY_MR and RDMA netlink then report
zero iova and length. Some drivers also use these fields in their data
path; for example, rxe uses them for range validation in
mr_check_range(), causing accesses to MRs registered through these
ioctl paths to fail.

Drivers such as mlx5 that initialize the fields themselves are
unaffected.

Set iova and length in both ioctl handlers, matching the legacy
registration path.

Fixes: 5b2e45049dc0 ("IB/core: Add UVERBS_METHOD_REG_MR on the MR object")
Fixes: bfe0cc6eb249 ("RDMA/uverbs: Add uverbs command for dma-buf based MR registration")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/infiniband/core/uverbs_std_types_mr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/core/uverbs_std_types_mr.c b/drivers/infiniband/core/uverbs_std_types_mr.c
index 0c72f80..df02488 100644
--- a/drivers/infiniband/core/uverbs_std_types_mr.c
+++ b/drivers/infiniband/core/uverbs_std_types_mr.c
@@ -247,6 +247,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(
 	mr->pd = pd;
 	mr->type = IB_MR_TYPE_USER;
 	mr->uobject = uobj;
+	mr->iova = iova;
+	mr->length = length;
 	atomic_inc(&pd->usecnt);
 
 	rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR);
@@ -374,6 +376,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
 	mr->pd = pd;
 	mr->type = IB_MR_TYPE_USER;
 	mr->uobject = uobj;
+	mr->iova = iova;
+	mr->length = length;
 	atomic_inc(&pd->usecnt);
 	if (dmah) {
 		mr->dmah = dmah;
-- 
2.9.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] RDMA/uverbs: Set MR iova and length in ioctl reg paths
  2026-09-04  2:24 [PATCH] RDMA/uverbs: Set MR iova and length in ioctl reg paths lirongqing
@ 2026-09-06  9:06 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-09-06  9:06 UTC (permalink / raw)
  To: lirongqing
  Cc: Jason Gunthorpe, Yishai Hadas, Edward Srouji, Sean Hefty,
	Christian Koenig, Michael J . Ruhl, linux-rdma, linux-kernel

On Fri, Sep 04, 2026 at 10:24:41AM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> UVERBS_METHOD_REG_MR and UVERBS_METHOD_REG_DMABUF_MR do not
> initialize ib_mr->iova and ib_mr->length, unlike
> ib_uverbs_reg_mr() which assigns both from the command.
> 
> Drivers that do not set these fields themselves are therefore left
> with zero values. UVERBS_METHOD_QUERY_MR and RDMA netlink then report
> zero iova and length. Some drivers also use these fields in their data
> path; for example, rxe uses them for range validation in
> mr_check_range(), causing accesses to MRs registered through these
> ioctl paths to fail.
> 
> Drivers such as mlx5 that initialize the fields themselves are
> unaffected.
> 
> Set iova and length in both ioctl handlers, matching the legacy
> registration path.

They are affected because you overwrite the fields set by an earlier
driver callback.

Thanks

> 
> Fixes: 5b2e45049dc0 ("IB/core: Add UVERBS_METHOD_REG_MR on the MR object")
> Fixes: bfe0cc6eb249 ("RDMA/uverbs: Add uverbs command for dma-buf based MR registration")
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
>  drivers/infiniband/core/uverbs_std_types_mr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/infiniband/core/uverbs_std_types_mr.c b/drivers/infiniband/core/uverbs_std_types_mr.c
> index 0c72f80..df02488 100644
> --- a/drivers/infiniband/core/uverbs_std_types_mr.c
> +++ b/drivers/infiniband/core/uverbs_std_types_mr.c
> @@ -247,6 +247,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_DMABUF_MR)(
>  	mr->pd = pd;
>  	mr->type = IB_MR_TYPE_USER;
>  	mr->uobject = uobj;
> +	mr->iova = iova;
> +	mr->length = length;
>  	atomic_inc(&pd->usecnt);
>  
>  	rdma_restrack_new(&mr->res, RDMA_RESTRACK_MR);
> @@ -374,6 +376,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
>  	mr->pd = pd;
>  	mr->type = IB_MR_TYPE_USER;
>  	mr->uobject = uobj;
> +	mr->iova = iova;
> +	mr->length = length;
>  	atomic_inc(&pd->usecnt);
>  	if (dmah) {
>  		mr->dmah = dmah;
> -- 
> 2.9.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-06  9:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04  2:24 [PATCH] RDMA/uverbs: Set MR iova and length in ioctl reg paths lirongqing
2026-09-06  9:06 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®