linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/mlx5: fix linking with CONFIG_INFINIBAND_USER_ACCESS=n
@ 2025-07-10  8:09 Arnd Bergmann
  2025-07-10 20:12 ` yanjun.zhu
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2025-07-10  8:09 UTC (permalink / raw)
  To: Leon Romanovsky, Jason Gunthorpe, Parav Pandit
  Cc: Arnd Bergmann, Mark Bloch, Patrisious Haddad, Moshe Shemesh,
	linux-rdma, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The check for rdma_uattrs_has_raw_cap() is not possible if user
access is disabled:

ERROR: modpost: "rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!

Limit the check to configurations that have the option enabled
and instead assume the capability is not there otherwise.

From what I can tell, the UVERBS code in fs.c is not actually called
when INFINIBAND_USER_ACCESS is turned off, so this haz no effect
other than fixing the link error. A better change might be to not
build the code at all in that configuration, but I did not see
an obvious way to do that.

Fixes: 95a89ec304c3 ("RDMA/mlx5: Check CAP_NET_RAW in user namespace for flow create")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
If there is a better way of addressing the link failure, please just
treat this as a bug report
---
 drivers/infiniband/hw/mlx5/fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/fs.c b/drivers/infiniband/hw/mlx5/fs.c
index bab2f58240c9..c1ec9aa1dfd3 100644
--- a/drivers/infiniband/hw/mlx5/fs.c
+++ b/drivers/infiniband/hw/mlx5/fs.c
@@ -2459,7 +2459,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
 	struct mlx5_ib_dev *dev;
 	u32 flags;
 
-	if (!rdma_uattrs_has_raw_cap(attrs))
+	if (!IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) ||
+	    !rdma_uattrs_has_raw_cap(attrs))
 		return -EPERM;
 
 	fs_matcher = uverbs_attr_get_obj(attrs,
-- 
2.39.5


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

* Re: [PATCH] RDMA/mlx5: fix linking with CONFIG_INFINIBAND_USER_ACCESS=n
  2025-07-10  8:09 [PATCH] RDMA/mlx5: fix linking with CONFIG_INFINIBAND_USER_ACCESS=n Arnd Bergmann
@ 2025-07-10 20:12 ` yanjun.zhu
  2025-07-11  5:39   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: yanjun.zhu @ 2025-07-10 20:12 UTC (permalink / raw)
  To: Arnd Bergmann, Leon Romanovsky, Jason Gunthorpe, Parav Pandit
  Cc: Arnd Bergmann, Mark Bloch, Patrisious Haddad, Moshe Shemesh,
	linux-rdma, linux-kernel

On 7/10/25 1:09 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The check for rdma_uattrs_has_raw_cap() is not possible if user
> access is disabled:
> 
> ERROR: modpost: "rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!

https://patchwork.kernel.org/project/linux-rdma/patch/72dee6b379bd709255a5d8e8010b576d50e47170.1751967071.git.leon@kernel.org/

The issue you described seems to be the same as the one discussed in the 
link above. Could you try applying the commit from that link and see if 
the problem still persists?

Yanjun.Zhu

> 
> Limit the check to configurations that have the option enabled
> and instead assume the capability is not there otherwise.
> 
>  From what I can tell, the UVERBS code in fs.c is not actually called
> when INFINIBAND_USER_ACCESS is turned off, so this haz no effect
> other than fixing the link error. A better change might be to not
> build the code at all in that configuration, but I did not see
> an obvious way to do that.
> 
> Fixes: 95a89ec304c3 ("RDMA/mlx5: Check CAP_NET_RAW in user namespace for flow create")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> If there is a better way of addressing the link failure, please just
> treat this as a bug report
> ---
>   drivers/infiniband/hw/mlx5/fs.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx5/fs.c b/drivers/infiniband/hw/mlx5/fs.c
> index bab2f58240c9..c1ec9aa1dfd3 100644
> --- a/drivers/infiniband/hw/mlx5/fs.c
> +++ b/drivers/infiniband/hw/mlx5/fs.c
> @@ -2459,7 +2459,8 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
>   	struct mlx5_ib_dev *dev;
>   	u32 flags;
>   
> -	if (!rdma_uattrs_has_raw_cap(attrs))
> +	if (!IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) ||
> +	    !rdma_uattrs_has_raw_cap(attrs))
>   		return -EPERM;
>   
>   	fs_matcher = uverbs_attr_get_obj(attrs,


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

* Re: [PATCH] RDMA/mlx5: fix linking with CONFIG_INFINIBAND_USER_ACCESS=n
  2025-07-10 20:12 ` yanjun.zhu
@ 2025-07-11  5:39   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-07-11  5:39 UTC (permalink / raw)
  To: Zhu Yanjun, Arnd Bergmann, Leon Romanovsky, Jason Gunthorpe,
	Parav Pandit
  Cc: Mark Bloch, Patrisious Haddad, Moshe Shemesh, linux-rdma,
	linux-kernel

On Thu, Jul 10, 2025, at 22:12, yanjun.zhu wrote:
> On 7/10/25 1:09 AM, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> The check for rdma_uattrs_has_raw_cap() is not possible if user
>> access is disabled:
>> 
>> ERROR: modpost: "rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!
>
> https://patchwork.kernel.org/project/linux-rdma/patch/72dee6b379bd709255a5d8e8010b576d50e47170.1751967071.git.leon@kernel.org/
>
> The issue you described seems to be the same as the one discussed in the 
> link above. Could you try applying the commit from that link and see if 
> the problem still persists?

That one looks fine, I'm sure it's sufficient without my patch.

    Arnd

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

end of thread, other threads:[~2025-07-11  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10  8:09 [PATCH] RDMA/mlx5: fix linking with CONFIG_INFINIBAND_USER_ACCESS=n Arnd Bergmann
2025-07-10 20:12 ` yanjun.zhu
2025-07-11  5:39   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).