All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Parav Pandit <parav@nvidia.com>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	linux-rdma@vger.kernel.org, Mark Bloch <mbloch@nvidia.com>
Subject: Re: [PATCH rdma-next 2/7] RDMA/uverbs: Check CAP_NET_RAW in user namespace for QP create
Date: Tue, 17 Jun 2025 14:52:31 -0300	[thread overview]
Message-ID: <20250617175231.GZ1174925@nvidia.com> (raw)
In-Reply-To: <1845d577e9b09caad3af28474aa2498390587db3.1750148509.git.leon@kernel.org>

On Tue, Jun 17, 2025 at 11:35:46AM +0300, Leon Romanovsky wrote:
> 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 QP.
> 
> 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: 2dee0e545894 ("IB/uverbs: Enable QP creation with a given source QP number")
> Fixes: 6d1e7ba241e9 ("IB/uverbs: Introduce create/destroy QP commands over ioctl")
> Signed-off-by: Parav Pandit <parav@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/core/uverbs_cmd.c          | 11 +++++++----
>  drivers/infiniband/core/uverbs_std_types_qp.c |  2 +-
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 08a738a2a1ff..84f9bbc781d3 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -1312,9 +1312,6 @@ static int create_qp(struct uverbs_attr_bundle *attrs,
>  
>  	switch (cmd->qp_type) {
>  	case IB_QPT_RAW_PACKET:
> -		if (!capable(CAP_NET_RAW))
> -			return -EPERM;
> -		break;

I don't think we should do these code movements, I'm not sure we won't
create a security problem by actually creating the object and then
immediately destroying it.

Add a rdma_uattrs_has_raw_cap() and call ib_uverbs_get_ucontext_file()
to get the ->ib_device

Jason

  reply	other threads:[~2025-06-17 17:52 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 [this message]
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 ` [PATCH rdma-next 5/7] RDMA/mlx5: Check CAP_NET_RAW in user namespace for devx create Leon Romanovsky
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=20250617175231.GZ1174925@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=ebiederm@xmission.com \
    --cc=leon@kernel.org \
    --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.