Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: tj@kernel.org, mkoutny@suse.com,
	"Heiko Carstens" <hca@linux.ibm.com>,
	hannes@cmpxchg.org, linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH rdma-next 08/13] RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace
Date: Fri, 10 Jul 2026 09:56:29 +0000	[thread overview]
Message-ID: <20260710095629.BF89E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260709095532.855647-9-jiri@resnulli.us>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Scoping RDMA cgroup device visibility to the reader's network namespace breaks host-level cgroup administration and monitoring.
- [Medium] Concurrent lockless read of `device->net` using `read_pnet()` without `READ_ONCE()` leads to a data race.
--

--- Patch [8]: [PATCH rdma-next 08/13] RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace ---
commit 18e4bddcfb08bd42bef710d6d1b72824d15fa2c9
Author: Jiri Pirko <jiri@resnulli.us>

RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace

Track each rdma cgroup device's net namespace and sharing mode, then filter
name lookups and cgroupfs enumeration to devices visible from the caller's
namespace. Keep the cached sharing mode synchronized across registration,
netns moves, and runtime mode changes.

> diff --git a/kernel/cgroup/rdma.c b/kernel/cgroup/rdma.c
> index 5e82a03b3270a..c8b4e3de76305 100644
> --- a/kernel/cgroup/rdma.c
> +++ b/kernel/cgroup/rdma.c
[ ... ]
> @@ -464,6 +465,13 @@ void rdmacg_unregister_device(struct rdmacg_device *device)
>  }
>  EXPORT_SYMBOL(rdmacg_unregister_device);
>  
> +/* netns_shared is toggled without rdmacg_mutex, hence READ_ONCE(). */
> +static bool rdmacg_device_visible(const struct rdmacg_device *device)
> +{
> +	return READ_ONCE(device->netns_shared) ||
> +	       net_eq(read_pnet(&device->net), current->nsproxy->net_ns);

[Severity: Medium]
Does this lockless read of device->net using read_pnet() cause a data race?

When another thread concurrently moves the RDMA device to a new network
namespace, it updates device->net:

drivers/infiniband/core/cgroup.c:ib_device_rdmacg_change_netns() {
	write_pnet(&device->cg_device.net, net);
}

While write_pnet() uses rcu_assign_pointer() to update the pointer concurrently,
read_pnet() here expands to a plain pointer access without READ_ONCE(). Since
rdmacg_mutex is not held during the write, could this plain read race with the
assignment and cause undefined behavior?

[Severity: High]
Does tying RDMA cgroup device visibility to the reader's network namespace
break host-level cgroup administration and monitoring?

If a device is moved to a non-init network namespace (exclusive mode), host
administrators and orchestration tools (like systemd or Kubernetes running in
init_net) will completely lose visibility and control over its RDMA cgroup
resources. Attempting to write to rdma.max will result in -ENODEV, and reading
rdma.current will show an empty list for these devices.

Since cgroup state must reflect the cgroup's configuration independent of the
reading process's network namespace, does tying the UAPI to
current->nsproxy->net_ns violate VFS semantics where an open file descriptor's
behavior would dynamically change depending on which process calls write()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709095532.855647-1-jiri@resnulli.us?part=8

  parent reply	other threads:[~2026-07-10  9:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  9:55 [PATCH rdma-next 00/13] RDMA: Make device names unique per net namespace Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 01/13] RDMA/core: Pass the net namespace to the device name lookups Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 02/13] RDMA/core: Handle device name conflicts when changing net namespace Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-09  9:55 ` [PATCH rdma-next 03/13] RDMA/core: Support renaming a device when changing its " Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-09  9:55 ` [PATCH rdma-next 04/13] RDMA/nldev: Report net namespace move errors through extack Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 05/13] RDMA/nldev: Allow setting the device name while changing net namespace Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 06/13] net/smc: Look up the pnetid ib device within the " Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-09  9:55 ` [PATCH rdma-next 07/13] RDMA/srp: Make the SRP sysfs class net namespace aware Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 08/13] RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace Jiri Pirko
2026-07-09 13:04   ` Michal Koutný
2026-07-10  9:56   ` sashiko-bot [this message]
2026-07-09  9:55 ` [PATCH rdma-next 09/13] RDMA/cma: Document that CM configfs cannot be net namespace scoped Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 10/13] RDMA/core: Document the SELinux ibendport net namespace limitation Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 11/13] RDMA/core: Make device names unique per net namespace Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 12/13] RDMA/rxe: Implement disassociate_ucontext callback Jiri Pirko
2026-07-10  4:21   ` Zhu Yanjun
2026-07-10  9:56   ` sashiko-bot
2026-07-09  9:55 ` [PATCH rdma-next 13/13] RDMA/selftests: Add rxe_netns_names test Jiri Pirko
2026-07-10  4:24   ` Zhu Yanjun
2026-07-10  9:56   ` sashiko-bot

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=20260710095629.BF89E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hannes@cmpxchg.org \
    --cc=hca@linux.ibm.com \
    --cc=jiri@resnulli.us \
    --cc=linux-s390@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tj@kernel.org \
    /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