All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	linux-rdma@vger.kernel.org, Mark Bloch <mbloch@nvidia.com>
Subject: [PATCH rdma-next 5/7] RDMA/mlx5: Check CAP_NET_RAW in user namespace for devx create
Date: Tue, 17 Jun 2025 11:35:49 +0300	[thread overview]
Message-ID: <4ca59ae31ac6300a9f36009d57d0d7547584508d.1750148509.git.leon@kernel.org> (raw)
In-Reply-To: <cover.1750148509.git.leon@kernel.org>

From: Parav Pandit <parav@nvidia.com>

Currently, the capability check is done in the default
init_user_ns user namespace. When a process runs in a
non default user namespace, such check fails. Due to this
when a process is running using podman, it fails to create
the devx object.

Since the RDMA device is a resource within a network namespace,
use the network namespace associated with the RDMA device to
determine its owning user namespace.

Fixes: a8b92ca1b0e5 ("IB/mlx5: Introduce DEVX")
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/devx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index b690b58ec91d..3d2e194dcf8c 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -159,7 +159,7 @@ int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user, u64 req_ucaps)
 	uctx = MLX5_ADDR_OF(create_uctx_in, in, uctx);
 	if (is_user &&
 	    (MLX5_CAP_GEN(dev->mdev, uctx_cap) & MLX5_UCTX_CAP_RAW_TX) &&
-	    capable(CAP_NET_RAW))
+	    rdma_dev_has_raw_cap(&dev->ib_dev))
 		cap |= MLX5_UCTX_CAP_RAW_TX;
 	if (is_user &&
 	    (MLX5_CAP_GEN(dev->mdev, uctx_cap) &
-- 
2.49.0


  parent reply	other threads:[~2025-06-17  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17  8:35 [PATCH rdma-next 0/7] Check CAP_NET_RAW in right namespace Leon Romanovsky
2025-06-17  8:35 ` [PATCH rdma-next 1/7] RDMA/uverbs: Check CAP_NET_RAW in user namespace for flow create Leon Romanovsky
2025-06-17  8:35 ` [PATCH rdma-next 2/7] RDMA/uverbs: Check CAP_NET_RAW in user namespace for QP create Leon Romanovsky
2025-06-17 17:52   ` Jason Gunthorpe
2025-06-18  5:33     ` Parav Pandit
2025-06-17  8:35 ` [PATCH rdma-next 3/7] RDMA/mlx5: Check CAP_NET_RAW in user namespace for flow create Leon Romanovsky
2025-06-17  8:35 ` [PATCH rdma-next 4/7] RDMA/mlx5: Check CAP_NET_RAW in user namespace for anchor create Leon Romanovsky
2025-06-17  8:35 ` Leon Romanovsky [this message]
2025-06-17  8:35 ` [PATCH rdma-next 6/7] RDMA/counter: Check CAP_NET_RAW check in user namespace for RDMA counters Leon Romanovsky
2025-06-17  8:35 ` [PATCH rdma-next 7/7] RDMA/nldev: Check CAP_NET_RAW in user namespace for QP modify 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=4ca59ae31ac6300a9f36009d57d0d7547584508d.1750148509.git.leon@kernel.org \
    --to=leon@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=parav@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.