From: Jiri Pirko <jiri@resnulli.us>
To: sashiko-reviews@lists.linux.dev
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: Tue, 14 Jul 2026 13:39:15 +0200 [thread overview]
Message-ID: <alYfV5DlIDBw5J3_@FV6GYCPJ69> (raw)
In-Reply-To: <20260710095629.BF89E1F00A3A@smtp.kernel.org>
Fri, Jul 10, 2026 at 11:56:29AM +0200, sashiko-bot@kernel.org wrote:
>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()?
This report made me think a bit more about the current approach.
A cgroup may contain processes using devices from multiple network
namespaces, so caller-relative filtering can hide part of its state
from host administrators and make the same open file behave differently
depending on the calling task. That does not look and feel correct.
Instead, to handle device names that are duplicated across network
namespaces, v2 will use the system-wide RDMA device index for
disambiguation. The existing name-only format will remain unchanged
for unique names. For duplicate names, reads will include an `index=N`
selector and writes will require it; ambiguous name-only writes will
fail with `-ENOTUNIQ`.
next prev parent reply other threads:[~2026-07-14 11:39 UTC|newest]
Thread overview: 34+ 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-13 12:32 ` Jiri Pirko
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-13 12:17 ` Jiri Pirko
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-13 9:34 ` Jiri Pirko
2026-07-14 2:28 ` Tao Cui
2026-07-14 7:39 ` Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-14 11:39 ` Jiri Pirko [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-13 13:24 ` Jiri Pirko
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-13 8:58 ` Jiri Pirko
2026-07-10 9:56 ` sashiko-bot
2026-07-13 13:35 ` Jiri Pirko
2026-07-10 23:51 ` yanjun.zhu
2026-07-13 9:02 ` Jiri Pirko
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=alYfV5DlIDBw5J3_@FV6GYCPJ69 \
--to=jiri@resnulli.us \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hca@linux.ibm.com \
--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 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.