| 0/0 |
2026/09/11 00:01 |
flow |
assessment-security |
25m
Results: map[DenialOfService:true Explanation:**Analysis of the Bug and its Security Impact**
**1. Root Cause and Mechanism**
The bug is a slab-use-after-free (UAF) in `kobject_uevent_net_broadcast()`. It
occurs due to a race condition during the teardown of a network namespace
(`netns`) that contains an RDMA device (e.g., software RoCE `rxe` or soft-iWARP
`siw`).
When a network namespace is destroyed, `cleanup_net()` executes per-net exit
callbacks. One of these callbacks is `uevent_net_exit()`, which frees
`net->uevent_sock`. Concurrently, the destruction of the network namespace
triggers a `NETDEV_UNREGISTER` event. The RDMA driver catches this event and
queues an asynchronous work item (`ib_unregister_work`) to unregister the RDMA
device.
When `ib_unregister_work` executes, it removes the device and triggers a
`kobject_uevent`. The uevent broadcasting mechanism attempts to resolve the
network namespace of the device, which still points to the dying `netns`. It
then accesses `net->uevent_sock->sk` to broadcast the event. Since
`net->uevent_sock` was already freed by `uevent_net_exit()`, this results in a
use-after-free read.
**2. Exploitability**
**Exploitable: Yes.**
The bug involves reading a pointer (`ue_sk->sk`) from a freed 32-byte slab
object (`kmalloc-32`) and subsequently passing this pointer to
`uevent_net_broadcast_tagged()`, which dereferences it as a socket object. An
attacker who can trigger this race condition could potentially use heap spraying
techniques to reallocate the freed `kmalloc-32` object with controlled data. By
controlling the `sk` pointer, the attacker could achieve arbitrary memory
read/write or hijack the kernel control flow when the socket object is
manipulated, leading to privilege escalation.
**3. Denial of Service (DoS)**
**Denial of Service: Yes.**
If the freed memory is not intentionally reallocated and controlled by an
attacker, the stale pointer dereference will cause a kernel panic (e.g., page
fault on unmapped memory or KASAN panic), leading to a system crash and denial
of service.
**4. Accessibility**
**Accessible from Unprivileged Processes: No.**
**Accessible from User Namespaces: No.**
Triggering this bug requires the ability to create or move an RDMA device into a
network namespace. The configuration of RDMA devices (like `rxe` or `siw`) is
done via the RDMA Netlink interface. The handlers for these operations (e.g.,
`RDMA_NLDEV_CMD_NEWLINK`, `RDMA_NLDEV_CMD_SET`) are flagged with
`RDMA_NL_ADMIN_PERM`. The capability check for this flag uses
`netlink_capable(skb, CAP_NET_ADMIN)`, which specifically checks for
`CAP_NET_ADMIN` in the **initial user namespace** (`&init_user_ns`). Therefore,
an unprivileged user, even if they create a new user namespace and acquire
`CAP_NET_ADMIN` within that namespace, will fail the capability check and cannot
configure RDMA devices to trigger the bug.
**5. Other Triggers**
* **VM Guest / Host Trigger:** No. This is a local kernel vulnerability in the
RDMA subsystem and network namespace teardown. It does not involve guest-to-host
escape mechanisms (like virtio or VM exits) or host-to-guest confidential
computing attack vectors.
* **Network / Remote Trigger:** No. The bug is triggered by local network
namespace and device management operations, not by parsing untrusted ingress
network traffic.
* **Peripheral / Filesystem Trigger:** No. The bug is unrelated to the plugging
of physical peripherals or the parsing of malicious filesystems. Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/11 00:01 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/09/11 00:01 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/e4df1e35f73e8871a0bb5986e0a3f7f88903d380]
|
| 3/1 |
2026/09/11 00:02 |
action |
kernel-builder |
11m
Results: map[KernelObj:/app/workdir/cache/build/4052259e3ac679a0ea4a40bb36f332ce6ba3596e]
|
| 4/1 |
2026/09/11 00:13 |
action |
codesearch-prepare |
8m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/11 00:22 |
agent |
expert |
5m
Model:
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
==================================================================
BUG: KASAN: slab-use-after-free in kobject_uevent_net_broadcast+0x110/0x53c lib/kobject_uevent.c:415
Read of size 8 at addr ffff0000d5355b10 by task kworker/u8:16/7257
CPU: 1 UID: 0 PID: 7257 Comm: kworker/u8:16 Tainted: G L syzkaller #0 PREEMPT
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/14/2026
Workqueue: ib-unreg-wq ib_unregister_work
Call trace:
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:499 (C)
__dump_stack+0x30/0x40 lib/dump_stack.c:94
dump_stack_lvl+0xd8/0x12c lib/dump_stack.c:120
print_address_description+0xb0/0x238 mm/kasan/report.c:378
print_report+0x68/0x84 mm/kasan/report.c:482
kasan_report+0x8c/0xc4 mm/kasan/report.c:595
__asan_report_load8_noabort+0x20/0x2c mm/kasan/report_generic.c:381
kobject_uevent_net_broadcast+0x110/0x53c lib/kobject_uevent.c:415
kobject_uevent_env+0x518/0x944 lib/kobject_uevent.c:611
kobject_uevent+0x2c/0x3c lib/kobject_uevent.c:659
device_del+0x5f8/0x71c drivers/base/core.c:3983
remove_one_compat_dev+0x5c/0x7c drivers/infiniband/core/device.c:1036
remove_compat_devs drivers/infiniband/core/device.c:1047 [inline]
disable_device+0x184/0x240 drivers/infiniband/core/device.c:1339
__ib_unregister_device+0x214/0x33c drivers/infiniband/core/device.c:1571
ib_unregister_work+0x20/0x38 drivers/infiniband/core/device.c:1683
process_one_work kernel/workqueue.c:3387 [inline]
process_scheduled_works+0x91c/0x1250 kernel/workqueue.c:3470
worker_thread+0x798/0xbd0 kernel/workqueue.c:3551
kthread+0x304/0x3d4 kernel/kthread.c:436
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:838
Allocated by task 7986:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x40/0x78 mm/kasan/common.c:78
kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:570
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x9c/0xb4 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x2f4/0x5fc mm/slub.c:5563
_kmalloc_noprof include/linux/slab.h:991 [inline]
_kzalloc_noprof include/linux/slab.h:1312 [inline]
uevent_net_init+0xcc/0x2a0 lib/kobject_uevent.c:782
ops_init+0x2cc/0x528 net/core/net_namespace.c:137
setup_net+0x118/0x2fc net/core/net_namespace.c:443
copy_net_ns+0x454/0x698 net/core/net_namespace.c:582
create_new_namespaces+0x304/0x50c kernel/nsproxy.c:132
unshare_nsproxy_namespaces+0x120/0x170 kernel/nsproxy.c:234
ksys_unshare+0x438/0x6cc kernel/fork.c:3292
__do_sys_unshare kernel/fork.c:3356 [inline]
__se_sys_unshare kernel/fork.c:3354 [inline]
__arm64_sys_unshare+0x40/0x54 kernel/fork.c:3354
__invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49
el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121
do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140
el0_svc+0x64/0x260 arch/arm64/kernel/entry-common.c:758
el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:777
el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:590
Freed by task 1355:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x40/0x78 mm/kasan/common.c:78
kasan_save_free_info+0x54/0x6c mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x74/0xa4 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2748 [inline]
slab_free mm/slub.c:6499 [inline]
kfree+0x188/0x698 mm/slub.c:6792
uevent_net_exit+0x1b0/0x1cc lib/kobject_uevent.c:816
ops_exit_list net/core/net_namespace.c:200 [inline]
ops_undo_list+0x3cc/0x81c net/core/net_namespace.c:253
cleanup_net+0x474/0x6c4 net/core/net_namespace.c:706
process_one_work kernel/workqueue.c:3387 [inline]
process_scheduled_works+0x91c/0x1250 kernel/workqueue.c:3470
worker_thread+0x798/0xbd0 kernel/workqueue.c:3551
kthread+0x304/0x3d4 kernel/kthread.c:436
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:838
The buggy address belongs to the object at ffff0000d5355b00
which belongs to the cache kmalloc-32 of size 32
The buggy address is located 16 bytes inside of
freed 32-byte region [ffff0000d5355b00, ffff0000d5355b20)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff0000d5355a80 pfn:0x115355
flags: 0x5ffc00000000200(workingset|node=0|zone=2|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 05ffc00000000200 ffff0000c0001780 fffffdffc35262d0 fffffdffc3c8ea90
raw: ffff0000d5355a80 000000000040003c 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff0000d5355a00: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc
ffff0000d5355a80: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
>ffff0000d5355b00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
^
ffff0000d5355b80: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc
ffff0000d5355c00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
==================================================================
Reply: **Analysis of the Bug and its Security Impact**
**1. Root Cause and Mechanism**
The bug is a slab-use-after-free (UAF) in `kobject_uevent_net_broadcast()`. It occurs due to a race condition during the teardown of a network namespace (`netns`) that contains an RDMA device (e.g., software RoCE `rxe` or soft-iWARP `siw`).
When a network namespace is destroyed, `cleanup_net()` executes per-net exit callbacks. One of these callbacks is `uevent_net_exit()`, which frees `net->uevent_sock`. Concurrently, the destruction of the network namespace triggers a `NETDEV_UNREGISTER` event. The RDMA driver catches this event and queues an asynchronous work item (`ib_unregister_work`) to unregister the RDMA device.
When `ib_unregister_work` executes, it removes the device and triggers a `kobject_uevent`. The uevent broadcasting mechanism attempts to resolve the network namespace of the device, which still points to the dying `netns`. It then accesses `net->uevent_sock->sk` to broadcast the event. Since `net->uevent_sock` was already freed by `uevent_net_exit()`, this results in a use-after-free read.
**2. Exploitability**
**Exploitable: Yes.**
The bug involves reading a pointer (`ue_sk->sk`) from a freed 32-byte slab object (`kmalloc-32`) and subsequently passing this pointer to `uevent_net_broadcast_tagged()`, which dereferences it as a socket object. An attacker who can trigger this race condition could potentially use heap spraying techniques to reallocate the freed `kmalloc-32` object with controlled data. By controlling the `sk` pointer, the attacker could achieve arbitrary memory read/write or hijack the kernel control flow when the socket object is manipulated, leading to privilege escalation.
**3. Denial of Service (DoS)**
**Denial of Service: Yes.**
If the freed memory is not intentionally reallocated and controlled by an attacker, the stale pointer dereference will cause a kernel panic (e.g., page fault on unmapped memory or KASAN panic), leading to a system crash and denial of service.
**4. Accessibility**
**Accessible from Unprivileged Processes: No.**
**Accessible from User Namespaces: No.**
Triggering this bug requires the ability to create or move an RDMA device into a network namespace. The configuration of RDMA devices (like `rxe` or `siw`) is done via the RDMA Netlink interface. The handlers for these operations (e.g., `RDMA_NLDEV_CMD_NEWLINK`, `RDMA_NLDEV_CMD_SET`) are flagged with `RDMA_NL_ADMIN_PERM`. The capability check for this flag uses `netlink_capable(skb, CAP_NET_ADMIN)`, which specifically checks for `CAP_NET_ADMIN` in the **initial user namespace** (`&init_user_ns`). Therefore, an unprivileged user, even if they create a new user namespace and acquire `CAP_NET_ADMIN` within that namespace, will fail the capability check and cannot configure RDMA devices to trigger the bug.
**5. Other Triggers**
* **VM Guest / Host Trigger:** No. This is a local kernel vulnerability in the RDMA subsystem and network namespace teardown. It does not involve guest-to-host escape mechanisms (like virtio or VM exits) or host-to-guest confidential computing attack vectors.
* **Network / Remote Trigger:** No. The bug is triggered by local network namespace and device management operations, not by parsing untrusted ingress network traffic.
* **Peripheral / Filesystem Trigger:** No. The bug is unrelated to the plugging of physical peripherals or the parsing of malicious filesystems.
|
| 6/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 8526
output: 24
thoughts: 91
Thoughts: **KASAN Slab-Use-After-Free Investigation**
Alright, let's break this down. KASAN's flagged a use-after-free situation, specifically within the `kobject_uevent_net_broadcast` function. The key here is that it's a read operation, and the memory access size is 8 bytes at the address `ffff0000d5355b10`. Now, I need to understand the lifecycle of the object involved. It seems this object was brought to life during the `uevent_net_init` phase and later extinguished in `uevent_net_exit`. My initial thought is that we've got a classic dangling pointer scenario. The object is freed, but the code isn't properly accounting for its deletion. Time to dive into `lib/kobject_uevent.c` and figure out precisely how that memory is being handled and where the error is occurring.
|
| 7/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[Name:uevent_net_init]
Results: map[SourceCode: 773: static int uevent_net_init(struct net *net)
774: {
775: struct uevent_sock *ue_sk;
776: struct netlink_kernel_cfg cfg = {
777: .groups = 1,
778: .input = uevent_net_rcv,
779: .flags = NL_CFG_F_NONROOT_RECV
780: };
781:
782: ue_sk = kzalloc_obj(*ue_sk);
783: if (!ue_sk)
784: return -ENOMEM;
785:
786: ue_sk->sk = netlink_kernel_create(net, NETLINK_KOBJECT_UEVENT, &cfg);
787: if (!ue_sk->sk) {
788: pr_err("kobject_uevent: unable to create netlink socket!\n");
789: kfree(ue_sk);
790: return -ENODEV;
791: }
792:
793: net->uevent_sock = ue_sk;
794:
795: /* Restrict uevents to initial user namespace. */
796: if (sock_net(ue_sk->sk)->user_ns == &init_user_ns) {
797: mutex_lock(&uevent_sock_mutex);
798: list_add_tail(&ue_sk->list, &uevent_sock_list);
799: mutex_unlock(&uevent_sock_mutex);
800: }
801:
802: return 0;
803: }
SourceFile:lib/kobject_uevent.c]
|
| 8/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 9349
output: 24
thoughts: 23
Thoughts: Here's my summary, as though I'm thinking through this process:
**Diving into uevent_sock and uevent_net_exit**
Okay, so we're looking at `struct uevent_sock`. Right, this is the structure involved in handling uevent sockets, I remember it well. Now, what's the cleanup procedure? Let's trace it back to `uevent_net_exit`. This is likely where the resources associated with these sockets are freed or cleaned up when the network namespace is destroyed or unloaded. I need to understand what happens during exit. Are there locks being held? What resources are being freed here? Any potential leaks or race conditions? This is where things get interesting. I'll need to confirm my understanding of the uevent socket lifecycle, and how they interact with network namespace management. Specifically, are we correctly closing all the socket file descriptors and releasing associated memory to prevent any issues. Let's see how they handle that.
|
| 9/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[Name:uevent_net_exit]
Results: map[SourceCode: 805: static void uevent_net_exit(struct net *net)
806: {
807: struct uevent_sock *ue_sk = net->uevent_sock;
808:
809: if (sock_net(ue_sk->sk)->user_ns == &init_user_ns) {
810: mutex_lock(&uevent_sock_mutex);
811: list_del(&ue_sk->list);
812: mutex_unlock(&uevent_sock_mutex);
813: }
814:
815: netlink_kernel_release(ue_sk->sk);
816: kfree(ue_sk);
817: }
SourceFile:lib/kobject_uevent.c]
|
| 10/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 9834
output: 27
thoughts: 38
Thoughts: Here's my attempt at summarizing the thought process, as if I were experiencing it:
**Digging into a Kernel Panic**
Okay, hold on a second. I'm looking at this crash, and it seems like `uevent_net_exit` is responsible for freeing `ue_sk`. That's a critical point to remember. Now, the crash is pinpointed in `kobject_uevent_net_broadcast`. Right, I need to investigate that function and the surrounding context. Let's start there and see what's going on with this `ue_sk` object. It's probably a use-after-free situation, but I need to confirm the sequence of events.
|
| 11/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kobject_uevent_net_broadcast]
Results: map[SourceCode: 382: static int kobject_uevent_net_broadcast(struct kobject *kobj,
383: struct kobj_uevent_env *env,
384: const char *action_string,
385: const char *devpath)
386: {
387: int ret = 0;
388:
389: #ifdef CONFIG_NET
390: const struct kobj_ns_type_operations *ops;
391: const struct ns_common *ns = NULL;
392:
393: ops = kobj_ns_ops(kobj);
394: if (!ops && kobj->kset) {
395: struct kobject *ksobj = &kobj->kset->kobj;
396:
397: if (ksobj->parent != NULL)
398: ops = kobj_ns_ops(ksobj->parent);
399: }
400:
401: /* kobjects currently only carry network namespace tags and they
402: * are the only tag relevant here since we want to decide which
403: * network namespaces to broadcast the uevent into.
404: */
405: if (ops && ops->netlink_ns && kobj->ktype->namespace)
406: if (ops->type == KOBJ_NS_TYPE_NET)
407: ns = kobj->ktype->namespace(kobj);
408:
409: if (!ns)
410: ret = uevent_net_broadcast_untagged(env, action_string,
411: devpath);
412: else {
413: const struct net *net = container_of(ns, struct net, ns);
414:
415: ret = uevent_net_broadcast_tagged(net->uevent_sock->sk, env,
416: action_string, devpath);
417: }
418: #endif
419:
420: return ret;
421: }
SourceFile:lib/kobject_uevent.c]
|
| 12/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 10670
output: 24
thoughts: 456
Thoughts: **Debugging a Race Condition in Network Namespace Destruction**
Okay, so I've got a crash at line 415, accessing `net->uevent_sock->sk`. That's a classic null pointer dereference, and it's happening when we're trying to send a uevent. The tricky part is figuring out *why* that pointer is null. I'm seeing that `net->uevent_sock` is being read here. The assumption is that if `net` is being destroyed, `uevent_net_exit` should free the `net->uevent_sock`. But here, `kobject_uevent_net_broadcast` is trying to use it.
The question is, why is `kobject_uevent_net_broadcast` being called for a network namespace that's in the process of being destroyed? The call trace provides a good starting point: it's showing the crash originating from `kobject_uevent_net_broadcast`, which is called through `kobject_uevent_env` and `kobject_uevent`. Then we're seeing `device_del` from the base core, and that's calling into the infiniband driver: `remove_one_compat_dev`, `remove_compat_devs`, `disable_device`, and finally `__ib_unregister_device` and `ib_unregister_work`. So an infiniband device is being unregistered, and obviously, this device is linked to a network namespace.
My focus now is on what's happening within those infiniband driver functions, specifically `remove_one_compat_dev` and `remove_compat_devs`. I need to understand the timing of the infiniband device removal and how it interacts with the network namespace destruction process. There's clearly a race condition where the uevent is being triggered after the socket is freed. I need to examine those functions in detail to see if there's a missing synchronization primitive or an improper ordering of operations. I'll need to pinpoint where the uevent is being generated relative to the network namespace teardown.
|
| 13/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[Name:remove_compat_devs]
Results: map[SourceCode:1041: static void remove_compat_devs(struct ib_device *device)
1042: {
1043: struct ib_core_device *cdev;
1044: unsigned long index;
1045:
1046: xa_for_each (&device->compat_devs, index, cdev)
1047: remove_one_compat_dev(device, index);
1048: }
SourceFile:drivers/infiniband/core/device.c]
|
| 14/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 11752
output: 25
thoughts: 13
Thoughts: Okay, let's dive into this. Here's my take on that function, presented as though it's my own thought process:
**Diving into `remove_one_compat_dev`**
Alright, `remove_one_compat_dev`. That sounds like a utility function, probably nestled deep within the driver or device management code. My initial thought is it's likely responsible for removing a single "compatible device" entry from a device tree or a similar data structure. The "compat" part suggests it deals with devices that declare themselves as compatible with a specific driver, maybe in a legacy or generic way.
I'm immediately trying to visualize the data structures involved. Are we talking about a linked list? A hash table? Or something fancier, like a Red-Black Tree for efficient lookups and removals, especially if there's a large number of compatible devices? The implementation details will depend heavily on the underlying framework.
I'm guessing this function likely takes the device structure as input, or perhaps a unique identifier for the device, and then searches for the corresponding entry in whatever data structure is used to track compatible devices. Once found, it'll need to carefully unhook the device from that list, which could involve updating pointers, deallocating memory (if the entry is dynamically allocated), and ensuring that the overall data structure remains consistent. Race conditions and locking mechanisms are immediately top of mind; this sounds like a potentially multi-threaded environment. Gotta be careful about concurrent access.
The name "remove_one" implies there's probably a counterpart somewhere - maybe a `add_one_compat_dev` or `remove_all_compat_devs`. And probably something that iterates over these devices too. I'm also wondering about error handling. What happens if the device isn't found? Does it return an error code? Log a warning? Maybe even panic?
I'm betting this is a critical piece of code, maybe within a power management routine, a hotplug event handler, or even during device detach/unplug. Any mistakes here could lead to memory leaks, system instability, or even incorrect device functionality. Now I want to see the rest of the code!
|
| 15/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[Name:remove_one_compat_dev]
Results: map[SourceCode:1027: static void remove_one_compat_dev(struct ib_device *device, u32 id)
1028: {
1029: struct ib_core_device *cdev;
1030:
1031: mutex_lock(&device->compat_devs_mutex);
1032: cdev = xa_erase(&device->compat_devs, id);
1033: mutex_unlock(&device->compat_devs_mutex);
1034: if (cdev) {
1035: ib_free_port_attrs(cdev);
1036: device_del(&cdev->dev);
1037: put_device(&cdev->dev);
1038: }
1039: }
SourceFile:drivers/infiniband/core/device.c]
|
| 16/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 12487
output: 21
thoughts: 59
Thoughts: **My Understanding of the Device Removal Process**
Okay, so I'm tracking the removal of a device here, and it's quite straightforward. When a `device_del` function is called, it triggers a chain of events that eventually lead to the device's removal being broadcast. The key player in this broadcasting is the `kobject_uevent` function. It seems this function is responsible for signaling the device namespace. Now, the critical piece here is figuring out *where* that broadcast goes, right? The namespace itself is determined by `kobj->ktype->namespace(kobj)`. Hmm, and in the specific case of a "device" object, that namespace function resolves to `device_namespace`. So, to recap, `device_del` sets off `kobject_uevent`, and that, in turn, uses `device_namespace` to determine the scope of its broadcast to the system. That makes perfect sense; the removal needs to be signaled correctly for anything depending on that device.
|
| 17/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[Name:device_namespace]
Results: map[SourceCode:2647: static const struct ns_common *device_namespace(const struct kobject *kobj)
2648: {
2649: const struct device *dev = kobj_to_dev(kobj);
2650:
2651: if (dev->class && dev->class->namespace)
2652: return dev->class->namespace(dev);
2653:
2654: return NULL;
2655: }
SourceFile:drivers/base/core.c]
|
| 18/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 12933
output: 21
thoughts: 12
Thoughts: Okay, here's my summary, tailored as if I'm the one thinking it:
**Digging into Infiniband Namespace**
Right, so I'm focusing on Infiniband devices. My immediate question is: what's the class namespace for them? I know I've worked with various network devices and their associated namespaces in the past, but I can't quite recall the standard namespace off the top of my head for Infiniband. It's crucial for any sort of programming or configuration access. I need to nail that down if I'm going to start developing or troubleshooting anything that interacts with these devices. Let's see if I can find my old notes.
|
| 19/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 545: static struct class ib_class = {
546: .name = "infiniband",
547: .dev_release = ib_device_release,
548: .dev_uevent = ib_device_uevent,
549: .ns_type = &net_ns_type_operations,
550: .namespace = net_namespace,
551: };
SourceFile:drivers/infiniband/core/device.c]
|
| 20/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 13259
output: 21
thoughts: 13
Thoughts: Here's my understanding of the situation, tailored for an expert like yourself:
**Network Namespace Retrieval**
Alright, so the task at hand is straightforward: I need to ascertain the network namespace associated with a specific device. The function or mechanism, which I'm inferring is likely a system call or library routine, is denoted as `net_namespace`. My initial thought is that this function will likely return some sort of identifier, perhaps an integer or a string representing the namespace. Knowing this ID will be the key to querying further information about the network context a particular interface or device is operating within. I'll need to remember that different tools and APIs might refer to namespaces with varying representations.
|
| 21/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:2234: static const struct ns_common *net_namespace(const struct device *d)
2235: {
2236: const struct net_device *dev = to_net_dev(d);
2237:
2238: return to_ns_common(dev_net(dev));
2239: }
SourceFile:net/core/net-sysfs.c]
|
| 22/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 13560
output: 39
thoughts: 59
Thoughts: **Examining the Infiniband Core Device Code**
Hmm, wait a minute... I was under the impression that `ib_class` was directly tied to both `ib_device_uevent` and `net_namespace`. But that doesn't feel right. Let me just double-check where `ib_class` actually resides. Ah, yes, of course, it's in `drivers/infiniband/core/device.c`. Okay, so now I need to verify how `net_namespace` is used within *that* specific file. I need to understand the relationship between the `ib_class` device class and the networking namespace within the Infiniband core device context. I'll get to the bottom of this.
|
| 23/2 |
2026/09/11 00:22 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/infiniband/core/device.c Name:net_namespace]
Results: map[SourceCode: 536: static const struct ns_common *net_namespace(const struct device *d)
537: {
538: const struct ib_core_device *coredev =
539: container_of(d, struct ib_core_device, dev);
540: struct net *net = read_pnet(&coredev->rdma_net);
541:
542: return net ? to_ns_common(net) : NULL;
543: }
SourceFile:drivers/infiniband/core/device.c]
|
| 24/2 |
2026/09/11 00:22 |
llm |
expert |
0m
Model:
Tokens:
input: 13984
output: 23
thoughts: 102
Thoughts: **Analyzing the RDMA Device Unregistration Process**
Okay, so I'm diving into this code related to RDMA device unregistration, and I'm a bit puzzled. The function `net_namespace` is pointing me towards `coredev->rdma_net`, which makes sense. My concern starts when I see that if `coredev->rdma_net` is in the process of being destroyed, `uevent_net_exit` is called. That's all good, it is expected.
However, the part that's throwing a flag is the fact that `device_del` is called *asynchronously* from `ib_unregister_work`. Asynchronously usually suggests some kind of deferral, and I need to understand the timing here. I can't immediately see the bigger picture with that. So, I have to figure out *why* `ib_unregister_work` is even being called in the first place.
Following the trail, it looks like `__ib_unregister_device` is the function responsible. Now, my next step is clear. I need to pinpoint every single call to `__ib_unregister_device` in the code. I need to understand *who* is initiating this unregistration process, and, maybe even more importantly, *why*. I can't make a judgement of the design or any potential bugs until I understand the context.
|
| 25/2 |
2026/09/11 00:23 |
tool |
codesearch-find-references |
0m
Args: map[Name:ib_unregister_work]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:_ib_alloc_device SourceFile:drivers/infiniband/core/device.c SourceLine:634]] TruncatedOutput:false]
|
| 26/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 14480
output: 23
thoughts: 14
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Unpacking `ib_unregister_work`**
Okay, wait a minute. Deep breath. I'm just looking at `ib_unregister_work` and suddenly, it clicks. This is actually a *work function*, isn't it? My intuition was nudging me and it seems to be right! This isn't just a generic unregistration routine. I need to re-evaluate how I'm thinking about its role and placement within the overall context of the IB stack. This changes things. Now I need to consider the asynchronous implications of it being scheduled via the workqueue. What's the scheduling context? What locks are in play around the data this function touches? Are there any potential race conditions I need to immediately look into given the workqueue context? And what are the implications on error handling, since it's deferred? Alright, time to dig deeper into the surrounding code and documentation, armed with this new, more accurate mental model.
|
| 27/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args: map[Name:ib_unregister_work]
Results: map[SourceCode:1678: static void ib_unregister_work(struct work_struct *work)
1679: {
1680: struct ib_device *ib_dev =
1681: container_of(work, struct ib_device, unregistration_work);
1682:
1683: __ib_unregister_device(ib_dev);
1684: put_device(&ib_dev->dev);
1685: }
SourceFile:drivers/infiniband/core/device.c]
|
| 28/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 14888
output: 22
thoughts: 10
Thoughts: Here's a summary of my thought process, as if I were analyzing that question:
**Locating the `unregistration_work` Scheduling**
Okay, so the immediate question is, where does this `unregistration_work` get scheduled? That's the crux of the issue. I need to figure out the context. Is this a system-level process? Is it related to a specific application or service? Understanding the scope is critical to pinpointing the scheduling mechanism.
I need to start thinking about the architectural landscape. What frameworks or libraries are being used? Are there any obvious candidates like a cron job, a task queue (like Celery or RabbitMQ), a built-in scheduler within a framework like Django or Spring, or even just a simple `setTimeout` or `setInterval` in JavaScript if it's front-end related? I'm going to have to consider all the likely scheduling mechanisms.
I will need to look for any clues. I will look for configuration files, initialization routines, deployment scripts, or any code that references `unregistration_work`. Keywords like "schedule," "task," "cron," "queue," or anything related to background processing are what I'm looking for. I need to trace the execution path and identify how this piece of code is invoked. I can also look at any related error logs, as they will likely have context clues.
|
| 29/2 |
2026/09/11 00:23 |
tool |
codesearch-find-references |
0m
Error:
Args: map[Name:unregistration_work]
Results: map[References:<nil> TruncatedOutput:false]
|
| 30/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 15228
output: 18
thoughts: 11
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the Codebase for Unregistration Work**
Okay, so I need to find where the system handles unregistration processes. My initial thought is to use `grep` – that's often the quickest way to zero in on relevant code segments. The most obvious starting point is to search for `unregistration_work`. It's a reasonably specific term, and I'm hoping it's used consistently within the codebase. This should give me a good jumping-off point, a starting point to locate relevant portions of the code. Once I find where `unregistration_work` shows up, I can hopefully trace the execution paths from there. I might need to refine the `grep` query, perhaps using `-i` for case-insensitive searching if I'm not certain of the capitalization, or adding flags to search specific files. I'll need to remember to check for related terms as well, in case the actual functions use a different, but semantically similar, keyword. After `grep`, I'll start manually examining the code to understand the workflows. I'm hoping it's a relatively self-contained module, though experience tells me this is rarely the case, so I need to be prepared for cross-cutting concerns and dependencies.
|
| 31/2 |
2026/09/11 00:23 |
tool |
grepper |
0m
Args: map[Expression:unregistration_work]
Results: map[Output:drivers/infiniband/core/device.c=594=struct ib_device *_ib_alloc_device(size_t size, struct net *net)
--
drivers/infiniband/core/device.c-633- init_completion(&device->unreg_completion);
drivers/infiniband/core/device.c:634: INIT_WORK(&device->unregistration_work, ib_unregister_work);
drivers/infiniband/core/device.c-635-
--
drivers/infiniband/core/device.c=1678=static void ib_unregister_work(struct work_struct *work)
--
drivers/infiniband/core/device.c-1680- struct ib_device *ib_dev =
drivers/infiniband/core/device.c:1681: container_of(work, struct ib_device, unregistration_work);
drivers/infiniband/core/device.c-1682-
--
drivers/infiniband/core/device.c=1698=void ib_unregister_device_queued(struct ib_device *ib_dev)
--
drivers/infiniband/core/device.c-1702- get_device(&ib_dev->dev);
drivers/infiniband/core/device.c:1703: if (!queue_work(ib_unreg_wq, &ib_dev->unregistration_work))
drivers/infiniband/core/device.c-1704- put_device(&ib_dev->dev);
--
include/rdma/ib_verbs.h=2959=struct ib_device {
--
include/rdma/ib_verbs.h-3034- struct completion unreg_completion;
include/rdma/ib_verbs.h:3035: struct work_struct unregistration_work;
include/rdma/ib_verbs.h-3036-
]
|
| 32/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 16031
output: 25
thoughts: 25
Thoughts: Here's my thought process, as requested:
**Deconstructing `ib_unregister_device_queued`**
Okay, so `ib_unregister_device_queued` is the function that's being talked about. The text immediately points out that it queues something. My immediate question, since I'm already working with this infrastructure, is: *who* is queuing this? Understanding the call site is going to be critical for the bigger picture. Knowing the calling function(s) is key to figuring out the context and the *why* behind this unregistration process.
|
| 33/2 |
2026/09/11 00:23 |
tool |
codesearch-find-references |
0m
Args: map[Name:ib_unregister_device_queued]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:rxe_notify SourceFile:drivers/infiniband/sw/rxe/rxe_net.c SourceLine:725] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:siw_netdev_event SourceFile:drivers/infiniband/sw/siw/siw_main.c SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__UNIQUE_ID_addressable_ib_unregister_device_queued_1040 SourceFile:drivers/infiniband/core/device.c SourceLine:1706] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__gendwarfksyms_ptr_ib_unregister_device_queued SourceFile:drivers/infiniband/core/device.c SourceLine:1706] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__gendwarfksyms_ptr_ib_unregister_device_queued SourceFile:drivers/infiniband/core/device.c SourceLine:1706]] TruncatedOutput:false]
|
| 34/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 16562
output: 22
thoughts: 30
Thoughts: Here's my take on those thoughts, from an expert's perspective:
**Debugging Network Interface Notifications**
Okay, so I'm seeing `rxe_notify` and `siw_netdev_event` being called. That's interesting, usually means something is going on with the RDMA over Converged Ethernet (RoCE) side, or possibly something related to the Soft-iWarp network device handling. Time to dive deeper into `rxe_notify`. I need to figure out what's triggering these notifications and what's being signaled. This could be anything from a change in link state (up/down) to some kind of event within the RoCE network stack. Gotta check the arguments being passed to it, understand the context of the call, and ideally, trace the execution path from the point of origin to `rxe_notify`. This is likely where the relevant information is.
|
| 35/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 713: static int rxe_notify(struct notifier_block *not_blk,
714: unsigned long event,
715: void *arg)
716: {
717: struct net_device *ndev = netdev_notifier_info_to_dev(arg);
718: struct rxe_dev *rxe = rxe_get_dev_from_net(ndev);
719:
720: if (!rxe)
721: return NOTIFY_OK;
722:
723: switch (event) {
724: case NETDEV_UNREGISTER:
725: ib_unregister_device_queued(&rxe->ib_dev);
726: rxe_net_del(&rxe->ib_dev);
727: break;
728: case NETDEV_CHANGEMTU:
729: rxe_dbg_dev(rxe, "%s changed mtu to %d\n", ndev->name, ndev->mtu);
730: rxe_set_mtu(rxe, ndev->mtu);
731: break;
732: case NETDEV_DOWN:
733: case NETDEV_CHANGE:
734: if (ib_get_curr_port_state(ndev) == IB_PORT_DOWN)
735: rxe_counter_inc(rxe, RXE_CNT_LINK_DOWNED);
736: break;
737: case NETDEV_REBOOT:
738: case NETDEV_GOING_DOWN:
739: case NETDEV_CHANGEADDR:
740: case NETDEV_CHANGENAME:
741: case NETDEV_FEAT_CHANGE:
742: default:
743: rxe_dbg_dev(rxe, "ignoring netdev event = %ld for %s\n",
744: event, ndev->name);
745: break;
746: }
747:
748: ib_device_put(&rxe->ib_dev);
749: return NOTIFY_OK;
750: }
SourceFile:drivers/infiniband/sw/rxe/rxe_net.c]
|
| 36/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 17446
output: 28
thoughts: 404
Thoughts: **The Unregistering Conundrum**
Okay, so I'm tracing the unregistration process of a network device, and it seems like there's a potential race condition here, and it's a nasty one. When a `netdev` gets unregistered, `rxe_notify` kicks off `ib_unregister_device_queued`. This is all part of the normal cleanup when a network namespace is being torn down – all the `netdevs` within it get unregistered, triggering that `NETDEV_UNREGISTER` event. That's when things get interesting.
`ib_unregister_device_queued` then schedules `ib_unregister_work`. At the *same* time, `cleanup_net` is busy nuking the network namespace. `cleanup_net` calls `ops_exit_list`, which calls `uevent_net_exit`. And `uevent_net_exit`? That frees `net->uevent_sock`.
My concern is synchronization. *Is* there any between `cleanup_net` and `ib_unregister_work`? They both run in workqueues, but different ones – `cleanup_net`'s workqueue and `ib_unreg_wq` for `ib_unregister_work`. So, these processes are running concurrently.
Here's the problem: when `ib_unregister_work` runs, it eventually calls `__ib_unregister_device`, which calls `disable_device`, then `remove_compat_devs`, and finally, `device_del`. Within `device_del`, `kobject_uevent` gets called, leading to `kobject_uevent_net_broadcast`. This function gets the network namespace for the device, and I think I see a problem.
`device_del` calls `net_namespace`, which reads `coredev->rdma_net`. If that `coredev->rdma_net` *is* the network namespace we're currently destroying in `cleanup_net`, then `uevent_net_exit` might have *already* freed `net->uevent_sock`! This sets the stage for a classic use-after-free scenario.
I need to confirm if `coredev->rdma_net` is holding a reference to the net namespace, because if it isn't, this looks like a critical bug.
|
| 37/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args: map[Name:ib_device_set_netns_put]
Results: map[SourceCode:1881: int ib_device_set_netns_put(struct sk_buff *skb,
1882: struct ib_device *dev, u32 ns_fd, const char *name,
1883: struct netlink_ext_ack *extack)
1884: {
1885: struct net *net;
1886: int ret;
1887:
1888: net = get_net_ns_by_fd(ns_fd);
1889: if (IS_ERR(net)) {
1890: NL_SET_ERR_MSG(extack, "Invalid target net namespace fd");
1891: ret = PTR_ERR(net);
1892: goto net_err;
1893: }
1894:
1895: if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
1896: NL_SET_ERR_MSG(extack,
1897: "Missing CAP_NET_ADMIN in the target net namespace");
1898: ret = -EPERM;
1899: goto ns_err;
1900: }
1901:
1902: /*
1903: * Moving a device to the namespace it already lives in is a no-op; a
1904: * supplied name still renames it in place.
1905: */
1906: if (net_eq(net, read_pnet(&dev->coredev.rdma_net))) {
1907: ret = name ? ib_device_rename(dev, name) : 0;
1908:
1909: if (ret == -EEXIST)
1910: NL_SET_ERR_MSG(extack,
1911: "Device name already exists in the target net namespace");
1912: else if (ret == -EINVAL && name)
1913: NL_SET_ERR_MSG(extack,
1914: "Unable to use requested device name in the target net namespace");
1915: goto ns_err;
1916: }
1917:
1918: /*
1919: * All the ib_clients, including uverbs, are reset when the namespace is
1920: * changed and this cannot be blocked waiting for userspace to do
1921: * something, so disassociation is mandatory.
1922: */
1923: if (ib_devices_shared_netns) {
1924: NL_SET_ERR_MSG(extack,
1925: "Cannot change net namespace of RDMA device in shared netns mode");
1926: ret = -EOPNOTSUPP;
1927: goto ns_err;
1928: }
1929:
1930: if (!dev->ops.disassociate_ucontext) {
1931: NL_SET_ERR_MSG(extack,
1932: "Device does not support namespace changes (no disassociate support)");
1933: ret = -EOPNOTSUPP;
1934: goto ns_err;
1935: }
1936:
1937: get_device(&dev->dev);
1938: ib_device_put(dev);
1939: ret = rdma_dev_change_netns(dev, current->nsproxy->net_ns, net, name,
1940: NULL);
1941: put_device(&dev->dev);
1942: if (ret == -EEXIST)
1943: NL_SET_ERR_MSG(extack,
1944: "Device name already exists in the target net namespace");
1945: else if (ret == -EINVAL && name)
1946: NL_SET_ERR_MSG(extack,
1947: "Unable to use requested device name in the target net namespace");
1948:
1949: put_net(net);
1950: return ret;
1951:
1952: ns_err:
1953: put_net(net);
1954: net_err:
1955: ib_device_put(dev);
1956: return ret;
1957: }
SourceFile:drivers/infiniband/core/device.c]
|
| 38/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 19585
output: 27
thoughts: 42
Thoughts: Okay, let's see. My mind is starting to work through this...
**RDMA Network Namespace Inquiry**
Hmm, now that I'm looking at this code, `rdma_dev_change_netns` is setting `coredev->rdma_net`. The key question here is, does this assignment establish a crucial reference? Specifically, does `coredev->rdma_net` now hold a pointer to the `net` structure? That’s what I need to understand to ensure proper resource management and prevent potential dangling pointers or memory leaks in the context of network namespace changes within RDMA. I need to dig deeper into the data structures and how this reference is used. This is critical for maintaining data integrity when dealing with namespaces. I'll need to trace the usage of `coredev->rdma_net` to see if it's an owned pointer, a borrowed reference, or something else entirely.
|
| 39/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rdma_dev_change_netns]
Results: map[SourceCode:1772: /*
1773: * The caller must pass in a device that has the kref held and the refcount
1774: * released. If the device is in cur_net and still registered then it is moved
1775: * into net.
1776: *
1777: * Naming rules are handled by rdma_dev_pick_netns_name().
1778: */
1779: static int rdma_dev_change_netns(struct ib_device *device, struct net *cur_net,
1780: struct net *net, const char *requested_name,
1781: const char *fallback_pattern)
1782: {
1783: char buf[IB_DEVICE_NAME_MAX];
1784: const char *new_name;
1785: int ret2 = -EINVAL;
1786: int ret;
1787:
1788: mutex_lock(&device->unregistration_lock);
1789:
1790: /*
1791: * If a device not under ib_device_get() or if the unregistration_lock
1792: * is not held, the namespace can be changed, or it can be unregistered.
1793: * Check again under the lock.
1794: */
1795: if (refcount_read(&device->refcount) == 0 ||
1796: !net_eq(cur_net, read_pnet(&device->coredev.rdma_net))) {
1797: ret = -ENODEV;
1798: goto out;
1799: }
1800:
1801: if (!fallback_pattern) {
1802: /*
1803: * Reject a predictable name conflict before tearing anything
1804: * down, so a doomed user move does not disable a live device.
1805: */
1806: down_write(&devices_rwsem);
1807: ret = rdma_dev_pick_netns_name(device, net, requested_name,
1808: fallback_pattern, buf,
1809: sizeof(buf), &new_name);
1810: up_write(&devices_rwsem);
1811: if (ret)
1812: goto out;
1813: }
1814:
1815: kobject_uevent(&device->dev.kobj, KOBJ_REMOVE);
1816: disable_device(device);
1817:
1818: /*
1819: * Recompute the destination name under the write side of devices_rwsem
1820: * now that the device is disabled, closing races with a concurrent
1821: * registration or rename, then publish the new namespace at the sysfs
1822: * level.
1823: */
1824: down_write(&devices_rwsem);
1825: ret = rdma_dev_pick_netns_name(device, net, requested_name,
1826: fallback_pattern, buf, sizeof(buf),
1827: &new_name);
1828: if (ret) {
1829: if (fallback_pattern) {
1830: WARN(1,
1831: "%s: failed to pick device name during namespace teardown: %d\n",
1832: __func__, ret);
1833: write_pnet(&device->coredev.rdma_net, net);
1834: ret = 0;
1835: }
1836: goto rename_done;
1837: }
1838:
1839: write_pnet(&device->coredev.rdma_net, net);
1840: ret = device_rename(&device->dev, new_name);
1841: if (ret) {
1842: if (fallback_pattern) {
1843: WARN(1,
1844: "%s: failed to rename device during namespace teardown: %d\n",
1845: __func__, ret);
1846: ret = 0;
1847: } else {
1848: dev_warn(&device->dev,
1849: "%s: Couldn't rename device after namespace change\n",
1850: __func__);
1851: /* Try and put things back and re-enable the device */
1852: write_pnet(&device->coredev.rdma_net, cur_net);
1853: }
1854: } else {
1855: strscpy(device->name, dev_name(&device->dev),
1856: IB_DEVICE_NAME_MAX);
1857: }
1858: rename_done:
1859: up_write(&devices_rwsem);
1860:
1861: ret2 = enable_device_and_get(device);
1862: if (ret2) {
1863: /*
1864: * This shouldn't really happen, but if it does, let the user
1865: * retry at later point. So don't disable the device.
1866: */
1867: dev_warn(&device->dev,
1868: "%s: Couldn't re-enable device after namespace change\n",
1869: __func__);
1870: }
1871: kobject_uevent(&device->dev.kobj, KOBJ_ADD);
1872:
1873: ib_device_put(device);
1874: out:
1875: mutex_unlock(&device->unregistration_lock);
1876: if (ret)
1877: return ret;
1878: return ret2;
1879: }
SourceFile:drivers/infiniband/core/device.c]
|
| 40/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 21480
output: 23
thoughts: 41
Thoughts: Okay, here's my interpretation of those thoughts, presented as a first-person expert summary:
**Digging into RDMA Device Initialization**
Hmm, hold on a second. I'm looking at this `write_pnet(&device->coredev.rdma_net, net)` call. Something about it doesn't quite sit right. I expected it to take a reference to `net`, but it's not. That's a potential red flag, could be a bug. It means the `write_pnet` might be making a *copy* of something instead of working with the original, which could lead to data inconsistencies down the line or, if we're lucky, be optimized away, or, worst case, it could introduce subtle memory corruption.
Let's quickly check the calling sequence, specifically the function that sets up the device, `ib_register_device`. I need to understand *how* `net` is being handled upstream. Is `net` being properly initialized before being passed down? Is this function called often? What sort of data is it storing that might be impacted? I need to understand if the lack of a reference here is intentional and well-understood, or a potential oversight. Context is key! I need to see if my concern is valid or just a misunderstanding of how this part of the kernel is architected.
|
| 41/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args: map[Name:ib_register_device]
Results: map[SourceCode:1422: /**
1423: * ib_register_device - Register an IB device with IB core
1424: * @device: Device to register
1425: * @name: device name, unique within the device's net namespace. This may
1426: * include a '%' which will cause a unique index to be added to the
1427: * passed device name.
1428: * @dma_device: pointer to a DMA-capable device. If %NULL, then the IB
1429: * device will be used. In this case the caller should fully
1430: * setup the ibdev for DMA. This usually means using dma_virt_ops.
1431: *
1432: * Low-level drivers use ib_register_device() to register their
1433: * devices with the IB core. All registered clients will receive a
1434: * callback for each device that is added. @device must be allocated
1435: * with ib_alloc_device().
1436: *
1437: * If the driver uses ops.dealloc_driver and calls any ib_unregister_device()
1438: * asynchronously then the device pointer may become freed as soon as this
1439: * function returns.
1440: */
1441: int ib_register_device(struct ib_device *device, const char *name,
1442: struct device *dma_device)
1443: {
1444: int ret;
1445:
1446: ret = assign_name(device, name);
1447: if (ret)
1448: return ret;
1449:
1450: /*
1451: * If the caller does not provide a DMA capable device then the IB core
1452: * will set up ib_sge and scatterlist structures that stash the kernel
1453: * virtual address into the address field.
1454: */
1455: WARN_ON(dma_device && !dma_device->dma_parms);
1456: device->dma_device = dma_device;
1457: /*
1458: * In a CoCo guest every device is currently assumed to be untrusted
1459: * (T=0) and therefore subject to DMA bouncing. Once trusted (T=1)
1460: * device detection is wired up, narrow this check to exclude such
1461: * devices.
1462: */
1463: if (dma_device && cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
1464: device->cc_dma_bounce = 1;
1465:
1466: ret = setup_device(device);
1467: if (ret)
1468: return ret;
1469:
1470: ret = ib_cache_setup_one(device);
1471: if (ret) {
1472: dev_warn(&device->dev,
1473: "Couldn't set up InfiniBand P_Key/GID cache\n");
1474: return ret;
1475: }
1476:
1477: device->groups[0] = &ib_dev_attr_group;
1478: device->groups[1] = device->ops.device_group;
1479: ret = ib_setup_device_attrs(device);
1480: if (ret)
1481: goto cache_cleanup;
1482:
1483: ib_device_register_rdmacg(device);
1484:
1485: rdma_counter_init(device);
1486:
1487: /*
1488: * Ensure that ADD uevent is not fired because it
1489: * is too early amd device is not initialized yet.
1490: */
1491: dev_set_uevent_suppress(&device->dev, true);
1492: ret = device_add(&device->dev);
1493: if (ret)
1494: goto cg_cleanup;
1495:
1496: ret = ib_setup_port_attrs(&device->coredev);
1497: if (ret) {
1498: dev_warn(&device->dev,
1499: "Couldn't register device with driver model\n");
1500: goto dev_cleanup;
1501: }
1502:
1503: ret = enable_device_and_get(device);
1504: if (ret) {
1505: void (*dealloc_fn)(struct ib_device *);
1506:
1507: /*
1508: * If we hit this error flow then we don't want to
1509: * automatically dealloc the device since the caller is
1510: * expected to call ib_dealloc_device() after
1511: * ib_register_device() fails. This is tricky due to the
1512: * possibility for a parallel unregistration along with this
1513: * error flow. Since we have a refcount here we know any
1514: * parallel flow is stopped in disable_device and will see the
1515: * special dealloc_driver pointer, causing the responsibility to
1516: * ib_dealloc_device() to revert back to this thread.
1517: */
1518: dealloc_fn = device->ops.dealloc_driver;
1519: device->ops.dealloc_driver = prevent_dealloc_device;
1520: ib_device_put(device);
1521: __ib_unregister_device(device);
1522: device->ops.dealloc_driver = dealloc_fn;
1523: dev_set_uevent_suppress(&device->dev, false);
1524: return ret;
1525: }
1526: dev_set_uevent_suppress(&device->dev, false);
1527:
1528: ib_device_notify_register(device);
1529:
1530: ib_device_put(device);
1531:
1532: return 0;
1533:
1534: dev_cleanup:
1535: device_del(&device->dev);
1536: cg_cleanup:
1537: dev_set_uevent_suppress(&device->dev, false);
1538: ib_device_unregister_rdmacg(device);
1539: cache_cleanup:
1540: ib_cache_cleanup_one(device);
1541: return ret;
1542: }
SourceFile:drivers/infiniband/core/device.c]
|
| 42/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 23704
output: 24
thoughts: 24
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**RDMA Device Allocation - A Quick Review**
Okay, let's see. My mental checklist for RDMA device initialization is ticking along. I'm focusing on the allocation path, specifically the `ib_alloc_device` function. My initial concern was about the networking aspects of the device structure, and I need to solidify that understanding.
And... wait a second. That's it! Looking back at the allocation sequence within `_ib_alloc_device`, I see that the `device->coredev.rdma_net` member is being set within that function. Right there, during the core device setup. That confirms my expectation of when and where the network-related elements are tied into the device structure. This resolves that nagging question and helps solidify my understanding of the device instantiation process as a whole.
|
| 43/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args: map[Name:_ib_alloc_device]
Results: map[SourceCode: 582: /**
583: * _ib_alloc_device - allocate an IB device struct
584: * @size:size of structure to allocate
585: * @net: network namespace device should be located in, namespace
586: * must stay valid until ib_register_device() is completed.
587: *
588: * Low-level drivers should use ib_alloc_device() to allocate &struct
589: * ib_device. @size is the size of the structure to be allocated,
590: * including any private data used by the low-level driver.
591: * ib_dealloc_device() must be used to free structures allocated with
592: * ib_alloc_device().
593: */
594: struct ib_device *_ib_alloc_device(size_t size, struct net *net)
595: {
596: struct ib_device *device;
597: unsigned int i;
598:
599: if (WARN_ON(size < sizeof(struct ib_device)))
600: return NULL;
601:
602: device = kzalloc(size, GFP_KERNEL);
603: if (!device)
604: return NULL;
605:
606: if (rdma_restrack_init(device)) {
607: kfree(device);
608: return NULL;
609: }
610:
611: /* ib_devices_shared_netns can't change while we have active namespaces
612: * in the system which means either init_net is passed or the user has
613: * no idea what they are doing.
614: *
615: * To avoid breaking backward compatibility, when in shared mode,
616: * force to init the device in the init_net.
617: */
618: net = ib_devices_shared_netns ? &init_net : net;
619: rdma_init_coredev(&device->coredev, device, net);
620:
621: INIT_LIST_HEAD(&device->event_handler_list);
622: spin_lock_init(&device->qp_open_list_lock);
623: init_rwsem(&device->event_handler_rwsem);
624: mutex_init(&device->unregistration_lock);
625: /*
626: * client_data needs to be alloc because we don't want our mark to be
627: * destroyed if the user stores NULL in the client data.
628: */
629: xa_init_flags(&device->client_data, XA_FLAGS_ALLOC);
630: init_rwsem(&device->client_data_rwsem);
631: xa_init_flags(&device->compat_devs, XA_FLAGS_ALLOC);
632: mutex_init(&device->compat_devs_mutex);
633: init_completion(&device->unreg_completion);
634: INIT_WORK(&device->unregistration_work, ib_unregister_work);
635:
636: spin_lock_init(&device->cq_pools_lock);
637: for (i = 0; i < ARRAY_SIZE(device->cq_pools); i++)
638: INIT_LIST_HEAD(&device->cq_pools[i]);
639:
640: rwlock_init(&device->cache_lock);
641:
642: device->uverbs_cmd_mask =
643: BIT_ULL(IB_USER_VERBS_CMD_ALLOC_MW) |
644: BIT_ULL(IB_USER_VERBS_CMD_ALLOC_PD) |
645: BIT_ULL(IB_USER_VERBS_CMD_ATTACH_MCAST) |
646: BIT_ULL(IB_USER_VERBS_CMD_CLOSE_XRCD) |
647: BIT_ULL(IB_USER_VERBS_CMD_CREATE_AH) |
648: BIT_ULL(IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
649: BIT_ULL(IB_USER_VERBS_CMD_CREATE_CQ) |
650: BIT_ULL(IB_USER_VERBS_CMD_CREATE_QP) |
651: BIT_ULL(IB_USER_VERBS_CMD_CREATE_SRQ) |
652: BIT_ULL(IB_USER_VERBS_CMD_CREATE_XSRQ) |
653: BIT_ULL(IB_USER_VERBS_CMD_DEALLOC_MW) |
654: BIT_ULL(IB_USER_VERBS_CMD_DEALLOC_PD) |
655: BIT_ULL(IB_USER_VERBS_CMD_DEREG_MR) |
656: BIT_ULL(IB_USER_VERBS_CMD_DESTROY_AH) |
657: BIT_ULL(IB_USER_VERBS_CMD_DESTROY_CQ) |
658: BIT_ULL(IB_USER_VERBS_CMD_DESTROY_QP) |
659: BIT_ULL(IB_USER_VERBS_CMD_DESTROY_SRQ) |
660: BIT_ULL(IB_USER_VERBS_CMD_DETACH_MCAST) |
661: BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT) |
662: BIT_ULL(IB_USER_VERBS_CMD_MODIFY_QP) |
663: BIT_ULL(IB_USER_VERBS_CMD_MODIFY_SRQ) |
664: BIT_ULL(IB_USER_VERBS_CMD_OPEN_QP) |
665: BIT_ULL(IB_USER_VERBS_CMD_OPEN_XRCD) |
666: BIT_ULL(IB_USER_VERBS_CMD_QUERY_DEVICE) |
667: BIT_ULL(IB_USER_VERBS_CMD_QUERY_PORT) |
668: BIT_ULL(IB_USER_VERBS_CMD_QUERY_QP) |
669: BIT_ULL(IB_USER_VERBS_CMD_QUERY_SRQ) |
670: BIT_ULL(IB_USER_VERBS_CMD_REG_MR) |
671: BIT_ULL(IB_USER_VERBS_CMD_REREG_MR) |
672: BIT_ULL(IB_USER_VERBS_CMD_RESIZE_CQ);
673:
674: mutex_init(&device->subdev_lock);
675: INIT_LIST_HEAD(&device->subdev_list_head);
676: INIT_LIST_HEAD(&device->subdev_list);
677:
678: return device;
679: }
SourceFile:drivers/infiniband/core/device.c]
|
| 44/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 25832
output: 25
thoughts: 21
Thoughts: Here's my understanding, as if I were thinking it through:
**Digging into RDMA Initialization**
Okay, so I'm looking at the initialization sequence, and I'm homing in on `rdma_init_coredev`. The name is pretty explicit, but now I'm thinking about the implications. What exactly is this function doing? Oh, right, it's the one that sets `coredev->rdma_net`. That's a key piece of the puzzle! So, we're explicitly tying the RDMA core device to the network namespace right at the start. I guess I didn't fully appreciate that before, now the relationship clicks into place. This `rdma_net` pointer likely becomes the conduit to establish the necessary communication pathways and context to interact with the underlying network infrastructure from the RDMA layer. This has me thinking about how this initialization affects network attachment and virtualisation.
|
| 45/2 |
2026/09/11 00:23 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rdma_init_coredev]
Results: map[SourceCode: 553: static void rdma_init_coredev(struct ib_core_device *coredev,
554: struct ib_device *dev, struct net *net)
555: {
556: bool is_full_dev = &dev->coredev == coredev;
557:
558: /* This BUILD_BUG_ON is intended to catch layout change
559: * of union of ib_core_device and device.
560: * dev must be the first element as ib_core and providers
561: * driver uses it. Adding anything in ib_core_device before
562: * device will break this assumption.
563: */
564: BUILD_BUG_ON(offsetof(struct ib_device, coredev.dev) !=
565: offsetof(struct ib_device, dev));
566:
567: coredev->dev.class = &ib_class;
568: coredev->dev.groups = dev->groups;
569:
570: /*
571: * Don't expose hw counters outside of the init namespace.
572: */
573: if (!is_full_dev && dev->hw_stats_attr_index)
574: coredev->dev.groups[dev->hw_stats_attr_index] = NULL;
575:
576: device_initialize(&coredev->dev);
577: coredev->owner = dev;
578: INIT_LIST_HEAD(&coredev->port_list);
579: write_pnet(&coredev->rdma_net, net);
580: }
SourceFile:drivers/infiniband/core/device.c]
|
| 46/2 |
2026/09/11 00:23 |
llm |
expert |
0m
Model:
Tokens:
input: 26563
output: 30
thoughts: 465
Thoughts: **The Dangling Pointer Conundrum**
Okay, so I've got this `coredev->rdma_net` pointer, and it seems like it's just that – a pointer. No actual reference to the `net` namespace itself, which immediately sets off alarm bells. If the `net` namespace goes away, this thing becomes a dangling pointer.
But hold on, there's a safety net, right? `cleanup_net` should be called when `net` is destroyed. `cleanup_net` takes care of cleaning up the net namespace itself, which is good. Before `cleanup_net` can do its thing, it unregisters all the netdevs in the namespace. That triggers `rxe_notify`, which queues `ib_unregister_device_queued`. This, in turn, queues up `ib_unregister_work`, which unregisters the IB device.
Here's where it gets dicey: `ib_unregister_work` runs asynchronously. *Asynchronously*. This means `cleanup_net` can potentially *start* and finish destroying the net namespace, including freeing `net->uevent_sock`, before `ib_unregister_work` has a chance to complete.
Then `ib_unregister_work` runs, calls `device_del`, and then we get to `kobject_uevent_net_broadcast`. This thing tries to read `coredev->rdma_net` using `net_namespace` and *then* tries to access `net->uevent_sock->sk`. Boom. Use-after-free, because `net->uevent_sock` was already freed by `uevent_net_exit` which is called from `cleanup_net`.
So the real question is: Is there any mechanism, any kind of reference counting, a mutex, *anything*, that prevents `cleanup_net` from finishing before `ib_unregister_work` is done? Nope, `ib_unregister_work` doesn't seem to hold a reference to `net`. Does `ib_device` itself? We have to check if `ib_device` holds a reference to `net` using `ib_register_device` or `_ib_alloc_device`.
Let's check `_ib_alloc_device`. No, that doesn't seem to take a reference to `net` either. Damn, if `ib_device` doesn't hold a reference, `coredev->rdma_net` *definitely* becomes dangling. Even if it did, the fact that `ib_unregister_work` runs asyncronously means that `cleanup_net` can still race and free `net`. This means the whole `ib_device` can be dangling as well.
When `rxe_notify` is called, it calls `ib_unregister_device_queued`. Does the `ib_device` object itself have any kind of `get_net` associated with it?
|
| 47/2 |
2026/09/11 00:24 |
tool |
grepper |
0m
Args: map[Expression:get_net PathPrefix:drivers/infiniband/]
Results: map[Output:drivers/infiniband/core/cache.c=1395=static int config_non_roce_gid_cache(struct ib_device *device,
--
drivers/infiniband/core/cache.c-1421-
drivers/infiniband/core/cache.c:1422: ndev = ib_device_get_netdev(device, port);
drivers/infiniband/core/cache.c-1423- if (!ndev)
--
drivers/infiniband/core/cma.c=1010=__rdma_create_id(struct net *net, rdma_cm_event_handler event_handler,
--
drivers/infiniband/core/cma.c-1039- get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
drivers/infiniband/core/cma.c:1040: id_priv->id.route.addr.dev_addr.net = get_net(net);
drivers/infiniband/core/cma.c-1041- id_priv->seq_num &= 0x00ffffff;
--
drivers/infiniband/core/cma.c=1670=static struct net_device *
drivers/infiniband/core/cma.c:1671:roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event)
drivers/infiniband/core/cma.c-1672-{
--
drivers/infiniband/core/cma.c-1693-
drivers/infiniband/core/cma.c:1694:static struct net_device *cma_get_net_dev(const struct ib_cm_event *ib_event,
drivers/infiniband/core/cma.c-1695- struct cma_req_info *req)
--
drivers/infiniband/core/cma.c-1709- if (rdma_protocol_roce(req->device, req->port))
drivers/infiniband/core/cma.c:1710: net_dev = roce_get_net_dev_by_cm_event(ib_event);
drivers/infiniband/core/cma.c-1711- else
drivers/infiniband/core/cma.c:1712: net_dev = ib_get_net_dev_by_params(req->device, req->port,
drivers/infiniband/core/cma.c-1713- req->pkey,
--
drivers/infiniband/core/cma.c=1844=cma_ib_id_from_event(struct ib_cm_id *cm_id,
--
drivers/infiniband/core/cma.c-1856-
drivers/infiniband/core/cma.c:1857: *net_dev = cma_get_net_dev(ib_event, req);
drivers/infiniband/core/cma.c-1858- if (IS_ERR(*net_dev)) {
--
drivers/infiniband/core/core_priv.h=87=typedef bool (*roce_netdev_filter)(struct ib_device *device, u32 port,
--
drivers/infiniband/core/core_priv.h-89-
drivers/infiniband/core/core_priv.h:90:struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
drivers/infiniband/core/core_priv.h-91- u32 port);
--
drivers/infiniband/core/device.c=1391=static void ib_device_notify_register(struct ib_device *device)
--
drivers/infiniband/core/device.c-1406- rdma_for_each_port(device, port) {
drivers/infiniband/core/device.c:1407: netdev = ib_device_get_netdev(device, port);
drivers/infiniband/core/device.c-1408- if (!netdev)
--
drivers/infiniband/core/device.c=1881=int ib_device_set_netns_put(struct sk_buff *skb,
--
drivers/infiniband/core/device.c-1887-
drivers/infiniband/core/device.c:1888: net = get_net_ns_by_fd(ns_fd);
drivers/infiniband/core/device.c-1889- if (IS_ERR(net)) {
--
drivers/infiniband/core/device.c=2257=static int iw_query_port(struct ib_device *device,
--
drivers/infiniband/core/device.c-2265-
drivers/infiniband/core/device.c:2266: netdev = ib_device_get_netdev(device, port_num);
drivers/infiniband/core/device.c-2267- if (!netdev)
--
drivers/infiniband/core/device.c=2425=static void free_netdevs(struct ib_device *ib_dev)
--
drivers/infiniband/core/device.c-2457-
drivers/infiniband/core/device.c:2458:struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
drivers/infiniband/core/device.c-2459- u32 port)
--
drivers/infiniband/core/device.c-2473- * New drivers should use ib_device_set_netdev() not the legacy
drivers/infiniband/core/device.c:2474: * get_netdev().
drivers/infiniband/core/device.c-2475- */
drivers/infiniband/core/device.c:2476: if (ib_dev->ops.get_netdev)
drivers/infiniband/core/device.c:2477: res = ib_dev->ops.get_netdev(ib_dev, port);
drivers/infiniband/core/device.c-2478- else {
--
drivers/infiniband/core/device.c-2487-}
drivers/infiniband/core/device.c:2488:EXPORT_SYMBOL(ib_device_get_netdev);
drivers/infiniband/core/device.c-2489-
--
drivers/infiniband/core/device.c=2497=int ib_query_netdev_port(struct ib_device *ibdev, struct net_device *ndev,
--
drivers/infiniband/core/device.c-2503- rdma_for_each_port(ibdev, port_num) {
drivers/infiniband/core/device.c:2504: ib_ndev = ib_device_get_netdev(ibdev, port_num);
drivers/infiniband/core/device.c-2505- if (ndev == ib_ndev) {
--
drivers/infiniband/core/device.c=2561=void ib_enum_roce_netdev(struct ib_device *ib_dev,
--
drivers/infiniband/core/device.c-2571- struct net_device *idev =
drivers/infiniband/core/device.c:2572: ib_device_get_netdev(ib_dev, port);
drivers/infiniband/core/device.c-2573-
--
drivers/infiniband/core/device.c=2818=EXPORT_SYMBOL(ib_find_pkey);
--
drivers/infiniband/core/device.c-2820-/**
drivers/infiniband/core/device.c:2821: * ib_get_net_dev_by_params() - Return the appropriate net_dev
drivers/infiniband/core/device.c-2822- * for a received CM request
--
drivers/infiniband/core/device.c-2830- */
drivers/infiniband/core/device.c:2831:struct net_device *ib_get_net_dev_by_params(struct ib_device *dev,
drivers/infiniband/core/device.c-2832- u32 port,
--
drivers/infiniband/core/device.c-2845- * Holding the read side guarantees that the client will not become
drivers/infiniband/core/device.c:2846: * unregistered while we are calling get_net_dev_by_params()
drivers/infiniband/core/device.c-2847- */
--
drivers/infiniband/core/device.c-2852-
drivers/infiniband/core/device.c:2853: if (!client || !client->get_net_dev_by_params)
drivers/infiniband/core/device.c-2854- continue;
drivers/infiniband/core/device.c-2855-
drivers/infiniband/core/device.c:2856: net_dev = client->get_net_dev_by_params(dev, port, pkey, gid,
drivers/infiniband/core/device.c-2857- addr, client_data);
--
drivers/infiniband/core/device.c-2864-}
drivers/infiniband/core/device.c:2865:EXPORT_SYMBOL(ib_get_net_dev_by_params);
drivers/infiniband/core/device.c-2866-
drivers/infiniband/core/device.c=2867=void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
--
drivers/infiniband/core/device.c-2967- SET_DEVICE_OP(dev_ops, get_link_layer);
drivers/infiniband/core/device.c:2968: SET_DEVICE_OP(dev_ops, get_netdev);
drivers/infiniband/core/device.c-2969- SET_DEVICE_OP(dev_ops, get_numa_node);
--
drivers/infiniband/core/nldev.c=359=static int fill_port_info(struct sk_buff *msg,
--
drivers/infiniband/core/nldev.c-400-
drivers/infiniband/core/nldev.c:401: netdev = ib_device_get_netdev(device, port);
drivers/infiniband/core/nldev.c-402- if (netdev && net_eq(dev_net(netdev), net)) {
--
drivers/infiniband/core/nldev.c=3099=static int fill_mon_netdev_rename(struct sk_buff *msg,
--
drivers/infiniband/core/nldev.c-3102-{
drivers/infiniband/core/nldev.c:3103: struct net_device *netdev = ib_device_get_netdev(device, port);
drivers/infiniband/core/nldev.c-3104- int ret = 0;
--
drivers/infiniband/core/nldev.c=3118=static int fill_mon_netdev_association(struct sk_buff *msg,
--
drivers/infiniband/core/nldev.c-3121-{
drivers/infiniband/core/nldev.c:3122: struct net_device *netdev = ib_device_get_netdev(device, port);
drivers/infiniband/core/nldev.c-3123- int ret = 0;
--
drivers/infiniband/core/nldev.c=3156=static void rdma_nl_notify_err_msg(struct ib_device *device, u32 port_num,
--
drivers/infiniband/core/nldev.c-3170- case RDMA_NETDEV_ATTACH_EVENT:
drivers/infiniband/core/nldev.c:3171: netdev = ib_device_get_netdev(device, port_num);
drivers/infiniband/core/nldev.c-3172- dev_warn_ratelimited(&device->dev,
--
drivers/infiniband/core/nldev.c-3187- case RDMA_NETDEV_RENAME_EVENT:
drivers/infiniband/core/nldev.c:3188: netdev = ib_device_get_netdev(device, port_num);
drivers/infiniband/core/nldev.c-3189- dev_warn_ratelimited(&device->dev,
--
drivers/infiniband/core/roce_gid_mgmt.c=525=void rdma_roce_rescan_port(struct ib_device *ib_dev, u32 port)
--
drivers/infiniband/core/roce_gid_mgmt.c-529- if (rdma_protocol_roce(ib_dev, port)) {
drivers/infiniband/core/roce_gid_mgmt.c:530: ndev = ib_device_get_netdev(ib_dev, port);
drivers/infiniband/core/roce_gid_mgmt.c-531- if (!ndev)
--
drivers/infiniband/core/verbs.c=717=EXPORT_SYMBOL(ib_get_rdma_header_version);
drivers/infiniband/core/verbs.c-718-
drivers/infiniband/core/verbs.c:719:static enum rdma_network_type ib_get_net_type_by_grh(struct ib_device *device,
drivers/infiniband/core/verbs.c-720- u32 port_num,
--
drivers/infiniband/core/verbs.c=850=int ib_init_ah_attr_from_wc(struct ib_device *device, u32 port_num,
--
drivers/infiniband/core/verbs.c-870- else
drivers/infiniband/core/verbs.c:871: net_type = ib_get_net_type_by_grh(device, port_num, grh);
drivers/infiniband/core/verbs.c-872- gid_type = ib_network_to_gid_type(net_type);
--
drivers/infiniband/core/verbs.c=2046=int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
--
drivers/infiniband/core/verbs.c-2055-
drivers/infiniband/core/verbs.c:2056: netdev = ib_device_get_netdev(dev, port_num);
drivers/infiniband/core/verbs.c-2057- if (!netdev)
--
drivers/infiniband/hw/erdma/erdma_main.c=19=static int erdma_netdev_event(struct notifier_block *nb, unsigned long event,
--
drivers/infiniband/hw/erdma/erdma_main.c-47-
drivers/infiniband/hw/erdma/erdma_main.c:48:static int erdma_enum_and_get_netdev(struct erdma_dev *dev)
drivers/infiniband/hw/erdma/erdma_main.c-49-{
--
drivers/infiniband/hw/erdma/erdma_main.c=86=static int erdma_device_register(struct erdma_dev *dev)
--
drivers/infiniband/hw/erdma/erdma_main.c-90-
drivers/infiniband/hw/erdma/erdma_main.c:91: ret = erdma_enum_and_get_netdev(dev);
drivers/infiniband/hw/erdma/erdma_main.c-92- if (ret)
--
drivers/infiniband/hw/hns/hns_roce_bond.c=25=static struct net_device *get_upper_dev_from_ndev(struct net_device *net_dev)
--
drivers/infiniband/hw/hns/hns_roce_bond.c-36-
drivers/infiniband/hw/hns/hns_roce_bond.c:37:static int get_netdev_bond_slave_id(struct net_device *net_dev,
drivers/infiniband/hw/hns/hns_roce_bond.c-38- struct hns_roce_bond_group *bond_grp)
--
drivers/infiniband/hw/hns/hns_roce_bond.c=49=struct hns_roce_bond_group *hns_roce_get_bond_grp(struct net_device *net_dev,
--
drivers/infiniband/hw/hns/hns_roce_bond.c-63- continue;
drivers/infiniband/hw/hns/hns_roce_bond.c:64: if (get_netdev_bond_slave_id(net_dev, bond_grp) >= 0)
drivers/infiniband/hw/hns/hns_roce_bond.c-65- return bond_grp;
--
drivers/infiniband/hw/hns/hns_roce_bond.c=79=static int hns_roce_set_bond_netdev(struct hns_roce_bond_group *bond_grp,
--
drivers/infiniband/hw/hns/hns_roce_bond.c-102-
drivers/infiniband/hw/hns/hns_roce_bond.c:103: old_dev = ib_device_get_netdev(&hr_dev->ib_dev, 1);
drivers/infiniband/hw/hns/hns_roce_bond.c-104- if (old_dev == active_dev)
--
drivers/infiniband/hw/hns/hns_roce_bond.c=452=static void hns_roce_bond_info_update_nolock(struct hns_roce_bond_group *bond_grp,
--
drivers/infiniband/hw/hns/hns_roce_bond.c-462- for_each_netdev_in_bond_rcu(upper_dev, net_dev) {
drivers/infiniband/hw/hns/hns_roce_bond.c:463: func_idx = get_netdev_bond_slave_id(net_dev, bond_grp);
drivers/infiniband/hw/hns/hns_roce_bond.c-464- if (func_idx < 0) {
--
drivers/infiniband/hw/hns/hns_roce_bond.c=484=static bool is_dev_bond_supported(struct hns_roce_bond_group *bond_grp,
--
drivers/infiniband/hw/hns/hns_roce_bond.c-491- if (bond_grp &&
drivers/infiniband/hw/hns/hns_roce_bond.c:492: get_netdev_bond_slave_id(net_dev, bond_grp) >= 0)
drivers/infiniband/hw/hns/hns_roce_bond.c-493- return true;
--
drivers/infiniband/hw/hns/hns_roce_bond.c=689=static bool check_unlinking_bond_support(struct hns_roce_bond_group *bond_grp)
--
drivers/infiniband/hw/hns/hns_roce_bond.c-695- for_each_netdev_in_bond_rcu(bond_grp->upper_dev, net_dev) {
drivers/infiniband/hw/hns/hns_roce_bond.c:696: if (get_netdev_bond_slave_id(net_dev, bond_grp) >= 0)
drivers/infiniband/hw/hns/hns_roce_bond.c-697- slave_num++;
--
drivers/infiniband/hw/hns/hns_roce_bond.c=772=static bool hns_roce_bond_upper_event(struct hns_roce_bond_group *bond_grp,
--
drivers/infiniband/hw/hns/hns_roce_bond.c-808- if (net_dev->reg_state >= NETREG_UNREGISTERING) {
drivers/infiniband/hw/hns/hns_roce_bond.c:809: slave_id = get_netdev_bond_slave_id(net_dev, bond_grp);
drivers/infiniband/hw/hns/hns_roce_bond.c-810- if (slave_id >= 0) {
--
drivers/infiniband/hw/hns/hns_roce_main.c=93=static int hns_roce_get_port_state(struct hns_roce_dev *hr_dev, u32 port_num,
--
drivers/infiniband/hw/hns/hns_roce_main.c-99-
drivers/infiniband/hw/hns/hns_roce_main.c:100: net_dev = ib_device_get_netdev(&hr_dev->ib_dev, port_num);
drivers/infiniband/hw/hns/hns_roce_main.c-101- if (!net_dev)
--
drivers/infiniband/hw/hns/hns_roce_main.c=283=static int hns_roce_query_port(struct ib_device *ib_dev, u32 port_num,
--
drivers/infiniband/hw/hns/hns_roce_main.c-307-
drivers/infiniband/hw/hns/hns_roce_main.c:308: net_dev = ib_device_get_netdev(ib_dev, port_num);
drivers/infiniband/hw/hns/hns_roce_main.c-309- if (!net_dev) {
--
drivers/infiniband/hw/ionic/ionic_ibdev.c=22=static int ionic_query_device(struct ib_device *ibdev,
--
drivers/infiniband/hw/ionic/ionic_ibdev.c-33-
drivers/infiniband/hw/ionic/ionic_ibdev.c:34: ndev = ib_device_get_netdev(ibdev, 1);
drivers/infiniband/hw/ionic/ionic_ibdev.c-35- addrconf_ifid_eui48((u8 *)&attr->sys_image_guid, ndev);
--
drivers/infiniband/hw/ionic/ionic_ibdev.c=80=static int ionic_query_port(struct ib_device *ibdev, u32 port,
--
drivers/infiniband/hw/ionic/ionic_ibdev.c-87-
drivers/infiniband/hw/ionic/ionic_ibdev.c:88: ndev = ib_device_get_netdev(ibdev, port);
drivers/infiniband/hw/ionic/ionic_ibdev.c-89- if (!ndev)
--
drivers/infiniband/hw/mana/main.c=9=void mana_ib_uncfg_vport(struct mana_ib_dev *dev, struct mana_ib_pd *pd,
--
drivers/infiniband/hw/mana/main.c-14-
drivers/infiniband/hw/mana/main.c:15: ndev = mana_ib_get_netdev(&dev->ib_dev, port);
drivers/infiniband/hw/mana/main.c-16- mpc = netdev_priv(ndev);
--
drivers/infiniband/hw/mana/main.c=31=int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd,
--
drivers/infiniband/hw/mana/main.c-37-
drivers/infiniband/hw/mana/main.c:38: ndev = mana_ib_get_netdev(&dev->ib_dev, port);
drivers/infiniband/hw/mana/main.c-39- mpc = netdev_priv(ndev);
--
drivers/infiniband/hw/mana/main.c=649=int mana_ib_query_port(struct ib_device *ibdev, u32 port,
--
drivers/infiniband/hw/mana/main.c-652- struct mana_ib_dev *dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
drivers/infiniband/hw/mana/main.c:653: struct net_device *ndev = mana_ib_get_netdev(ibdev, port);
drivers/infiniband/hw/mana/main.c-654-
--
drivers/infiniband/hw/mana/mana_ib.h=678=static inline bool mana_ib_is_rnic(struct mana_ib_dev *mdev)
--
drivers/infiniband/hw/mana/mana_ib.h-682-
drivers/infiniband/hw/mana/mana_ib.h:683:static inline struct net_device *mana_ib_get_netdev(struct ib_device *ibdev, u32 port)
drivers/infiniband/hw/mana/mana_ib.h-684-{
--
drivers/infiniband/hw/mana/qp.c=78=static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,
--
drivers/infiniband/hw/mana/qp.c-139- port = ucmd.port;
drivers/infiniband/hw/mana/qp.c:140: ndev = mana_ib_get_netdev(pd->device, port);
drivers/infiniband/hw/mana/qp.c-141- if (!ndev) {
--
drivers/infiniband/hw/mana/qp.c=279=static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
--
drivers/infiniband/hw/mana/qp.c-324- port = ucmd.port;
drivers/infiniband/hw/mana/qp.c:325: ndev = mana_ib_get_netdev(ibpd->device, port);
drivers/infiniband/hw/mana/qp.c-326- if (!ndev) {
--
drivers/infiniband/hw/mana/qp.c=783=static int mana_ib_gd_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
--
drivers/infiniband/hw/mana/qp.c-821- if (attr_mask & IB_QP_AV) {
drivers/infiniband/hw/mana/qp.c:822: ndev = mana_ib_get_netdev(&mdev->ib_dev, ibqp->port);
drivers/infiniband/hw/mana/qp.c-823- if (!ndev) {
--
drivers/infiniband/hw/mana/qp.c=872=static int mana_ib_destroy_qp_rss(struct mana_ib_qp *qp,
--
drivers/infiniband/hw/mana/qp.c-889-
drivers/infiniband/hw/mana/qp.c:890: ndev = mana_ib_get_netdev(qp->ibqp.device, qp->port);
drivers/infiniband/hw/mana/qp.c-891- mpc = netdev_priv(ndev);
--
drivers/infiniband/hw/mana/qp.c=926=static int mana_ib_destroy_qp_raw(struct mana_ib_qp *qp, struct ib_udata *udata)
--
drivers/infiniband/hw/mana/qp.c-939-
drivers/infiniband/hw/mana/qp.c:940: ndev = mana_ib_get_netdev(qp->ibqp.device, qp->port);
drivers/infiniband/hw/mana/qp.c-941- mpc = netdev_priv(ndev);
--
drivers/infiniband/hw/mana/wr.c=75=static int mana_ib_post_send_ud(struct mana_ib_qp *qp, const struct ib_ud_wr *wr)
--
drivers/infiniband/hw/mana/wr.c-78- struct mana_ib_ah *ah = container_of(wr->ah, struct mana_ib_ah, ibah);
drivers/infiniband/hw/mana/wr.c:79: struct net_device *ndev = mana_ib_get_netdev(&mdev->ib_dev, qp->port);
drivers/infiniband/hw/mana/wr.c-80- struct gdma_queue *queue = qp->ud_qp.queues[MANA_UD_SEND_QUEUE].kmem;
--
drivers/infiniband/hw/mlx4/main.c=116=static int num_ib_ports(struct mlx4_dev *dev)
--
drivers/infiniband/hw/mlx4/main.c-126-
drivers/infiniband/hw/mlx4/main.c:127:static struct net_device *mlx4_ib_get_netdev(struct ib_device *device,
drivers/infiniband/hw/mlx4/main.c-128- u32 port_num)
--
drivers/infiniband/hw/mlx4/main.c=2515=static const struct ib_device_ops mlx4_ib_dev_ops = {
--
drivers/infiniband/hw/mlx4/main.c-2545- .get_link_layer = mlx4_ib_port_link_layer,
drivers/infiniband/hw/mlx4/main.c:2546: .get_netdev = mlx4_ib_get_netdev,
drivers/infiniband/hw/mlx4/main.c-2547- .get_port_immutable = mlx4_port_immutable,
--
drivers/infiniband/hw/mlx5/main.c=133=static struct mlx5_roce *mlx5_get_rep_roce(struct mlx5_ib_dev *dev,
--
drivers/infiniband/hw/mlx5/main.c-153- continue;
drivers/infiniband/hw/mlx5/main.c:154: rep_ndev = ib_device_get_netdev(&dev->ib_dev, i + 1);
drivers/infiniband/hw/mlx5/main.c-155- if (rep_ndev && rep_ndev == ndev) {
--
drivers/infiniband/hw/mlx5/main.c=190=static struct net_device *mlx5_ib_get_rep_uplink_netdev(struct mlx5_ib_dev *ibdev)
--
drivers/infiniband/hw/mlx5/main.c-197- if (port->rep && port->rep->vport == MLX5_VPORT_UPLINK) {
drivers/infiniband/hw/mlx5/main.c:198: return ib_device_get_netdev(&ibdev->ib_dev, i + 1);
drivers/infiniband/hw/mlx5/main.c-199- }
--
drivers/infiniband/hw/mlx5/main.c=205=static int mlx5_netdev_event(struct notifier_block *this,
--
drivers/infiniband/hw/mlx5/main.c-225-
drivers/infiniband/hw/mlx5/main.c:226: ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
drivers/infiniband/hw/mlx5/main.c-227- /* Exit if already registered */
--
drivers/infiniband/hw/mlx5/main.c-238- break;
drivers/infiniband/hw/mlx5/main.c:239: ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
drivers/infiniband/hw/mlx5/main.c-240- if (ib_ndev == ndev)
--
drivers/infiniband/hw/mlx5/main.c-256- if(mlx5_lag_is_roce(mdev))
drivers/infiniband/hw/mlx5/main.c:257: lag_ndev = ib_device_get_netdev(&ibdev->ib_dev, 1);
drivers/infiniband/hw/mlx5/main.c-258- else /* sriov lag */
--
drivers/infiniband/hw/mlx5/main.c-273-
drivers/infiniband/hw/mlx5/main.c:274: ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
drivers/infiniband/hw/mlx5/main.c-275-
--
drivers/infiniband/hw/mlx5/main.c=536=static int mlx5_query_port_roce(struct ib_device *device, u32 port_num,
--
drivers/infiniband/hw/mlx5/main.c-609-
drivers/infiniband/hw/mlx5/main.c:610: ndev = ib_device_get_netdev(device, port_num);
drivers/infiniband/hw/mlx5/main.c-611- if (!ndev)
--
drivers/infiniband/hw/mlx5/main.c=3657=static int lag_event(struct notifier_block *nb, unsigned long event, void *data)
--
drivers/infiniband/hw/mlx5/main.c-3684- }
drivers/infiniband/hw/mlx5/main.c:3685: old_ndev = ib_device_get_netdev(ibdev, portnum + 1);
drivers/infiniband/hw/mlx5/main.c-3686- ret = ib_device_set_netdev(ibdev, ndev, portnum + 1);
--
drivers/infiniband/hw/mlx5/mlx5_ib.h=846=struct mlx5_roce {
drivers/infiniband/hw/mlx5/mlx5_ib.h:847: /* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL
drivers/infiniband/hw/mlx5/mlx5_ib.h-848- * netdev pointer
--
drivers/infiniband/sw/rxe/rxe_mcast.c=31=static int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
--
drivers/infiniband/sw/rxe/rxe_mcast.c-36-
drivers/infiniband/sw/rxe/rxe_mcast.c:37: ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
drivers/infiniband/sw/rxe/rxe_mcast.c-38- if (!ndev)
--
drivers/infiniband/sw/rxe/rxe_mcast.c=56=static int rxe_mcast_del(struct rxe_dev *rxe, union ib_gid *mgid)
--
drivers/infiniband/sw/rxe/rxe_mcast.c-61-
drivers/infiniband/sw/rxe/rxe_mcast.c:62: ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
drivers/infiniband/sw/rxe/rxe_mcast.c-63- if (!ndev)
--
drivers/infiniband/sw/rxe/rxe_net.c=600=const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num)
--
drivers/infiniband/sw/rxe/rxe_net.c-604-
drivers/infiniband/sw/rxe/rxe_net.c:605: ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
drivers/infiniband/sw/rxe/rxe_net.c-606- if (!ndev)
--
drivers/infiniband/sw/rxe/rxe_net.c=647=void rxe_net_del(struct ib_device *dev)
--
drivers/infiniband/sw/rxe/rxe_net.c-652-
drivers/infiniband/sw/rxe/rxe_net.c:653: ndev = ib_device_get_netdev(dev, 1);
drivers/infiniband/sw/rxe/rxe_net.c-654- if (!ndev)
--
drivers/infiniband/sw/rxe/rxe_net.c=697=void rxe_set_port_state(struct rxe_dev *rxe)
--
drivers/infiniband/sw/rxe/rxe_net.c-700-
drivers/infiniband/sw/rxe/rxe_net.c:701: ndev = ib_device_get_netdev(&rxe->ib_dev, 1);
drivers/infiniband/sw/rxe/rxe_net.c-702- if (!ndev)
--
drivers/infiniband/sw/rxe/rxe_verbs.c=34=static int rxe_query_port(struct ib_device *ibdev,
--
drivers/infiniband/sw/rxe/rxe_verbs.c-46-
drivers/infiniband/sw/rxe/rxe_verbs.c:47: ndev = ib_device_get_netdev(ibdev, 1);
drivers/infiniband/sw/rxe/rxe_verbs.c-48- if (!ndev) {
--
drivers/infiniband/sw/rxe/rxe_verbs.c=1442=static int rxe_enable_driver(struct ib_device *ib_dev)
--
drivers/infiniband/sw/rxe/rxe_verbs.c-1446-
drivers/infiniband/sw/rxe/rxe_verbs.c:1447: ndev = ib_device_get_netdev(ib_dev, 1);
drivers/infiniband/sw/rxe/rxe_verbs.c-1448- if (!ndev)
--
drivers/infiniband/sw/siw/siw_cm.c=1809=int siw_create_listen(struct iw_cm_id *id, int backlog)
--
drivers/infiniband/sw/siw/siw_cm.c-1835- if (ipv4_is_zeronet(laddr->sin_addr.s_addr)) {
drivers/infiniband/sw/siw/siw_cm.c:1836: ndev = ib_device_get_netdev(id->device, SIW_PORT);
drivers/infiniband/sw/siw/siw_cm.c-1837- if (ndev) {
--
drivers/infiniband/sw/siw/siw_cm.c-1859- if (ipv6_addr_any(&laddr->sin6_addr)) {
drivers/infiniband/sw/siw/siw_cm.c:1860: ndev = ib_device_get_netdev(id->device, SIW_PORT);
drivers/infiniband/sw/siw/siw_cm.c-1861- if (ndev) {
--
drivers/infiniband/sw/siw/siw_verbs.c=171=int siw_query_port(struct ib_device *base_dev, u32 port,
--
drivers/infiniband/sw/siw/siw_verbs.c-183-
drivers/infiniband/sw/siw/siw_verbs.c:184: ndev = ib_device_get_netdev(base_dev, SIW_PORT);
drivers/infiniband/sw/siw/siw_verbs.c-185- if (!ndev)
--
drivers/infiniband/sw/siw/siw_verbs.c=516=int siw_query_qp(struct ib_qp *base_qp, struct ib_qp_attr *qp_attr,
--
drivers/infiniband/sw/siw/siw_verbs.c-526-
drivers/infiniband/sw/siw/siw_verbs.c:527: ndev = ib_device_get_netdev(base_qp->device, SIW_PORT);
drivers/infiniband/sw/siw/siw_verbs.c-528- if (!ndev)
--
drivers/infiniband/ulp/ipoib/ipoib_main.c=93=static void ipoib_neigh_reclaim(struct rcu_head *rp);
drivers/infiniband/ulp/ipoib/ipoib_main.c:94:static struct net_device *ipoib_get_net_dev_by_params(
drivers/infiniband/ulp/ipoib/ipoib_main.c-95- struct ib_device *dev, u32 port, u16 pkey,
--
drivers/infiniband/ulp/ipoib/ipoib_main.c=102=static struct ib_client ipoib_client = {
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-105- .remove = ipoib_remove_one,
drivers/infiniband/ulp/ipoib/ipoib_main.c:106: .get_net_dev_by_params = ipoib_get_net_dev_by_params,
drivers/infiniband/ulp/ipoib/ipoib_main.c-107-};
--
drivers/infiniband/ulp/ipoib/ipoib_main.c=382=static int ipoib_upper_walk(struct net_device *upper,
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-397-/**
drivers/infiniband/ulp/ipoib/ipoib_main.c:398: * ipoib_get_net_dev_match_addr - Find a net_device matching
drivers/infiniband/ulp/ipoib/ipoib_main.c-399- * the given address, which is an upper device of the given net_device.
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-406- */
drivers/infiniband/ulp/ipoib/ipoib_main.c:407:static struct net_device *ipoib_get_net_dev_match_addr(
drivers/infiniband/ulp/ipoib/ipoib_main.c-408- const struct sockaddr *addr, struct net_device *dev)
--
drivers/infiniband/ulp/ipoib/ipoib_main.c=434=static int ipoib_match_gid_pkey_addr(struct ipoib_dev_priv *priv,
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-451- * IPoIB child devices currently share a GID. */
drivers/infiniband/ulp/ipoib/ipoib_main.c:452: net_dev = ipoib_get_net_dev_match_addr(addr, priv->dev);
drivers/infiniband/ulp/ipoib/ipoib_main.c-453- }
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-483- * reference to the net_device, if the number of matches >= 1 */
drivers/infiniband/ulp/ipoib/ipoib_main.c:484:static int __ipoib_get_net_dev_by_params(struct list_head *dev_list, u32 port,
drivers/infiniband/ulp/ipoib/ipoib_main.c-485- u16 pkey_index,
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-507-
drivers/infiniband/ulp/ipoib/ipoib_main.c:508:static struct net_device *ipoib_get_net_dev_by_params(
drivers/infiniband/ulp/ipoib/ipoib_main.c-509- struct ib_device *dev, u32 port, u16 pkey,
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-526- /* See if we can find a unique device matching the pkey and GID */
drivers/infiniband/ulp/ipoib/ipoib_main.c:527: matches = __ipoib_get_net_dev_by_params(dev_list, port, pkey_index,
drivers/infiniband/ulp/ipoib/ipoib_main.c-528- gid, NULL, &net_dev);
--
drivers/infiniband/ulp/ipoib/ipoib_main.c-540- * address to uniquely match the net device */
drivers/infiniband/ulp/ipoib/ipoib_main.c:541: matches = __ipoib_get_net_dev_by_params(dev_list, port, pkey_index,
drivers/infiniband/ulp/ipoib/ipoib_main.c-542- gid, addr, &net_dev);
]
|
| 48/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 39712
output: 24
thoughts: 848
Thoughts: **Analyzing a Potential Use-After-Free Vulnerability in RDMA Device Unregistration**
Okay, let's break this down. It seems we have a tricky use-after-free issue with RDMA devices and net namespace destruction. The core of the problem lies in the timing of how these devices are unregistered in relation to the destruction of their associated network namespace (`net`).
Initially, I see that the `ib_device` structure itself doesn't directly hold a pointer to the `net` structure, which seems odd. However, the device allocation (`_ib_alloc_device`) *does* take the `net` pointer. This setup is key to the race. When the `net` namespace is destroyed, `cleanup_net` is invoked. The critical question becomes: does `cleanup_net` properly synchronize with `ib_unregister_work`? It doesn't appear to wait.
So, `coredev->rdma_net` becomes a dangling pointer. The code then attempts to broadcast a uevent using `kobject_uevent_net_broadcast`, which accesses `net->uevent_sock->sk`, leading to the crash.
My first thought was that perhaps `net` itself was being freed prematurely. But `uevent_net_exit` only frees `net->uevent_sock`. Looking further, `cleanup_net` *does* free `net` at the very end using `net_drop_ns`, which internally calls `net_free`. However, the crash report indicates that `uevent_sock` is the object that is freed while net is still allocated. `uevent_sock` is relatively small, while `net` is much larger. This suggests that `net` isn't fully gone when the access occurs, or at least `net->uevent_sock` isn't.
`cleanup_net` calls `uevent_net_exit` through a list traversal: `list_for_each_entry_reverse(ops, &pernet_list, list) ops_exit_list(ops, &net_exit_list);` This is where the magic happens. `uevent_net_exit` then proceeds to `ops_free_list`, and then `rcu_barrier()`, then finally calls `net_drop_ns`. This means that `net` *is* still alive when `uevent_net_exit` is called, and remains active for some time after. This is the window of opportunity. If `ib_unregister_work` runs within this window, it will try to access the already freed `net->uevent_sock` which is the key to the vulnerability.
So, how can this be triggered? I'm formulating the sequence of events:
1. A net namespace is created.
2. An RDMA device (RXE or SIW) is created *within* that namespace.
3. The net namespace is destroyed.
4. The namespace destruction unregisters the loopback device and all other associated `netdevs`.
5. This action triggers `NETDEV_UNREGISTER` for the RDMA device's `netdev`.
6. `rxe_notify` or `siw_netdev_event` then queues `ib_unregister_device_queued`.
7. `cleanup_net` runs concurrently and calls `uevent_net_exit`, which *frees* `net->uevent_sock` during namespace destruction.
8. `ib_unregister_work` gets scheduled, and executes. Now the race has begun.
9. `ib_unregister_work` calls `device_del`.
10. `device_del` calls `kobject_uevent_net_broadcast`.
11. `kobject_uevent_net_broadcast` tries to access `coredev->rdma_net` (which points to the dying namespace) and ultimately accesses `net->uevent_sock->sk`, which is a use-after-free.
The critical race condition is between `uevent_net_exit` freeing `net->uevent_sock` and the delayed execution of `ib_unregister_work`.
The final consideration is whether an unprivileged user can trigger this. Creating a net namespace requires `CAP_SYS_ADMIN` in the current user namespace. So an unprivileged user can create a user namespace and then a net namespace. The remaining question is if an unprivileged user can create an RXE or SIW device. RXE devices are created through netlink with `RDMA_NLDEV_CMD_NEWLINK`. If an unprivileged user can create and destroy these devices via this netlink interface within the created namespaces, we have a vulnerability that's potentially accessible. Time to confirm if user namespaces provide enough capability.
|
| 49/2 |
2026/09/11 00:24 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:1818: static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
1819: struct netlink_ext_ack *extack)
1820: {
1821: struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
1822: char ibdev_name[IB_DEVICE_NAME_MAX];
1823: const struct rdma_link_ops *ops;
1824: char ndev_name[IFNAMSIZ];
1825: struct net_device *ndev;
1826: char type[IFNAMSIZ];
1827: int err;
1828:
1829: err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
1830: nldev_policy, extack);
1831: if (err || !tb[RDMA_NLDEV_ATTR_DEV_NAME] ||
1832: !tb[RDMA_NLDEV_ATTR_LINK_TYPE] || !tb[RDMA_NLDEV_ATTR_NDEV_NAME])
1833: return -EINVAL;
1834:
1835: nla_strscpy(ibdev_name, tb[RDMA_NLDEV_ATTR_DEV_NAME],
1836: sizeof(ibdev_name));
1837: if (strchr(ibdev_name, '%') || strlen(ibdev_name) == 0)
1838: return -EINVAL;
1839:
1840: nla_strscpy(type, tb[RDMA_NLDEV_ATTR_LINK_TYPE], sizeof(type));
1841: nla_strscpy(ndev_name, tb[RDMA_NLDEV_ATTR_NDEV_NAME],
1842: sizeof(ndev_name));
1843:
1844: ndev = dev_get_by_name(sock_net(skb->sk), ndev_name);
1845: if (!ndev)
1846: return -ENODEV;
1847:
1848: down_read(&link_ops_rwsem);
1849: ops = link_ops_get(type);
1850: #ifdef CONFIG_MODULES
1851: if (!ops) {
1852: up_read(&link_ops_rwsem);
1853: request_module("rdma-link-%s", type);
1854: down_read(&link_ops_rwsem);
1855: ops = link_ops_get(type);
1856: }
1857: #endif
1858: err = ops ? ops->newlink(ibdev_name, ndev) : -EINVAL;
1859: up_read(&link_ops_rwsem);
1860: dev_put(ndev);
1861:
1862: return err;
1863: }
SourceFile:drivers/infiniband/core/nldev.c]
|
| 50/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 42454
output: 27
thoughts: 52
Thoughts: **Analyzing Potential Security Implications of `nldev_newlink`**
Okay, so I'm looking at this code and immediately my mind jumps to `nldev_newlink`. That's a netlink handler, right? The key question then is, can unprivileged users actually trigger `RDMA_NLDEV_CMD_NEWLINK`? That would be a major vulnerability if it allows them to modify or create network interfaces.
My next step is clear: I need to scrutinize `rdma_nl_rcv_msg`. That's where the incoming netlink messages are processed. I'll need to figure out what kind of access control checks are performed, if any, and if there are any subtle flaws in the logic. I need to understand whether unprivileged users can bypass any checks and achieve some form of privileged operation through this code path. This is all about assessing the potential for a privilege escalation.
|
| 51/2 |
2026/09/11 00:24 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rdma_nl_rcv_msg]
Results: map[SourceCode: 152: static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
153: struct netlink_ext_ack *extack)
154: {
155: int type = nlh->nlmsg_type;
156: unsigned int index = RDMA_NL_GET_CLIENT(type);
157: unsigned int op = RDMA_NL_GET_OP(type);
158: const struct rdma_nl_cbs *cb_table;
159: int err = -EINVAL;
160:
161: if (!is_nl_msg_valid(index, op))
162: return -EINVAL;
163:
164: down_read(&rdma_nl_types[index].sem);
165: cb_table = get_cb_table(skb, index, op);
166: if (!cb_table)
167: goto done;
168:
169: if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
170: !netlink_capable(skb, CAP_NET_ADMIN)) {
171: err = -EPERM;
172: goto done;
173: }
174:
175: /*
176: * LS responses overload the 0x100 (NLM_F_ROOT) flag. Don't
177: * mistakenly call the .dump() function.
178: */
179: if (index == RDMA_NL_LS) {
180: if (cb_table[op].doit)
181: err = cb_table[op].doit(skb, nlh, extack);
182: goto done;
183: }
184: /* FIXME: Convert IWCM to properly handle doit callbacks */
185: if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_IWCM) {
186: struct netlink_dump_control c = {
187: .dump = cb_table[op].dump,
188: };
189: if (c.dump)
190: err = netlink_dump_start(skb->sk, skb, nlh, &c);
191: goto done;
192: }
193:
194: if (cb_table[op].doit)
195: err = cb_table[op].doit(skb, nlh, extack);
196: done:
197: up_read(&rdma_nl_types[index].sem);
198: return err;
199: }
SourceFile:drivers/infiniband/core/netlink.c]
|
| 52/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 43544
output: 22
thoughts: 39
Thoughts: Okay, here's my interpretation of that code snippet, delivered as if it's my own thought process:
**Security Checks in the Kernel**
Alright, so I'm seeing a check for `netlink_capable(skb, CAP_NET_ADMIN)`. My brain immediately jumps to what this *really* means. It's verifying if the user associated with this particular Socket Buffer ( `skb` ) has the `CAP_NET_ADMIN` capability. That's a pretty heavy-duty permission; it's practically a network administrator's license to do just about anything. And then, there's the nuance - this capability check has a dependency on the init user namespace. So I need to keep in mind, I need to check the init user namespace! This implies that even if this capability might appear to be present in other namespaces, it should be denied if it doesn't have it in the init namespace.
|
| 53/2 |
2026/09/11 00:24 |
tool |
codesearch-definition-source |
0m
Args: map[Name:netlink_capable]
Results: map[SourceCode: 874: /**
875: * netlink_capable - Netlink global message capability test
876: * @skb: socket buffer holding a netlink command from userspace
877: * @cap: The capability to use
878: *
879: * Test to see if the opener of the socket we received the message
880: * from had when the netlink socket was created and the sender of the
881: * message has the capability @cap in all user namespaces.
882: */
883: bool netlink_capable(const struct sk_buff *skb, int cap)
884: {
885: return netlink_ns_capable(skb, &init_user_ns, cap);
886: }
SourceFile:net/netlink/af_netlink.c]
|
| 54/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 44046
output: 25
thoughts: 50
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Unpacking the Netlink Capabilities Check and RDMA Registration**
Right, let me see... It looks like the `netlink_capable` function is indeed tied into the initialization of the user namespace (`init_user_ns`). That's a good starting point. I suspected as much, given the context. Now, what's really catching my eye is the registration of `RDMA_NLDEV_CMD_NEWLINK`. That command is defined in the `nldev_cb_table`. My immediate next step is to examine the flags associated with this command. I need to understand what capabilities, permissions, or restrictions are set on it. This will give me a better understanding of how the new RDMA link is being brought up and managed within the netlink framework. It is all about the flags. I have a feeling I'll find something interesting there.
|
| 55/2 |
2026/09/11 00:24 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:2984: static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS] = {
2985: [RDMA_NLDEV_CMD_GET] = {
2986: .doit = nldev_get_doit,
2987: .dump = nldev_get_dumpit,
2988: },
2989: [RDMA_NLDEV_CMD_GET_CHARDEV] = {
2990: .doit = nldev_get_chardev,
2991: },
2992: [RDMA_NLDEV_CMD_SET] = {
2993: .doit = nldev_set_doit,
2994: .flags = RDMA_NL_ADMIN_PERM,
2995: },
2996: [RDMA_NLDEV_CMD_NEWLINK] = {
2997: .doit = nldev_newlink,
2998: .flags = RDMA_NL_ADMIN_PERM,
2999: },
3000: [RDMA_NLDEV_CMD_DELLINK] = {
3001: .doit = nldev_dellink,
3002: .flags = RDMA_NL_ADMIN_PERM,
3003: },
3004: [RDMA_NLDEV_CMD_PORT_GET] = {
3005: .doit = nldev_port_get_doit,
3006: .dump = nldev_port_get_dumpit,
3007: },
3008: [RDMA_NLDEV_CMD_RES_GET] = {
3009: .doit = nldev_res_get_doit,
3010: .dump = nldev_res_get_dumpit,
3011: },
3012: [RDMA_NLDEV_CMD_RES_QP_GET] = {
3013: .doit = nldev_res_get_qp_doit,
3014: .dump = nldev_res_get_qp_dumpit,
3015: },
3016: [RDMA_NLDEV_CMD_RES_CM_ID_GET] = {
3017: .doit = nldev_res_get_cm_id_doit,
3018: .dump = nldev_res_get_cm_id_dumpit,
3019: },
3020: [RDMA_NLDEV_CMD_RES_CQ_GET] = {
3021: .doit = nldev_res_get_cq_doit,
3022: .dump = nldev_res_get_cq_dumpit,
3023: },
3024: [RDMA_NLDEV_CMD_RES_MR_GET] = {
3025: .doit = nldev_res_get_mr_doit,
3026: .dump = nldev_res_get_mr_dumpit,
3027: },
3028: [RDMA_NLDEV_CMD_RES_PD_GET] = {
3029: .doit = nldev_res_get_pd_doit,
3030: .dump = nldev_res_get_pd_dumpit,
3031: },
3032: [RDMA_NLDEV_CMD_RES_CTX_GET] = {
3033: .doit = nldev_res_get_ctx_doit,
3034: .dump = nldev_res_get_ctx_dumpit,
3035: },
3036: [RDMA_NLDEV_CMD_RES_SRQ_GET] = {
3037: .doit = nldev_res_get_srq_doit,
3038: .dump = nldev_res_get_srq_dumpit,
3039: },
3040: [RDMA_NLDEV_CMD_SYS_GET] = {
3041: .doit = nldev_sys_get_doit,
3042: },
3043: [RDMA_NLDEV_CMD_SYS_SET] = {
3044: .doit = nldev_set_sys_set_doit,
3045: .flags = RDMA_NL_ADMIN_PERM,
3046: },
3047: [RDMA_NLDEV_CMD_STAT_SET] = {
3048: .doit = nldev_stat_set_doit,
3049: .flags = RDMA_NL_ADMIN_PERM,
3050: },
3051: [RDMA_NLDEV_CMD_STAT_GET] = {
3052: .doit = nldev_stat_get_doit,
3053: .dump = nldev_stat_get_dumpit,
3054: },
3055: [RDMA_NLDEV_CMD_STAT_DEL] = {
3056: .doit = nldev_stat_del_doit,
3057: .flags = RDMA_NL_ADMIN_PERM,
3058: },
3059: [RDMA_NLDEV_CMD_RES_QP_GET_RAW] = {
3060: .doit = nldev_res_get_qp_raw_doit,
3061: .dump = nldev_res_get_qp_raw_dumpit,
3062: .flags = RDMA_NL_ADMIN_PERM,
3063: },
3064: [RDMA_NLDEV_CMD_RES_CQ_GET_RAW] = {
3065: .doit = nldev_res_get_cq_raw_doit,
3066: .dump = nldev_res_get_cq_raw_dumpit,
3067: .flags = RDMA_NL_ADMIN_PERM,
3068: },
3069: [RDMA_NLDEV_CMD_RES_MR_GET_RAW] = {
3070: .doit = nldev_res_get_mr_raw_doit,
3071: .dump = nldev_res_get_mr_raw_dumpit,
3072: .flags = RDMA_NL_ADMIN_PERM,
3073: },
3074: [RDMA_NLDEV_CMD_RES_SRQ_GET_RAW] = {
3075: .doit = nldev_res_get_srq_raw_doit,
3076: .dump = nldev_res_get_srq_raw_dumpit,
3077: .flags = RDMA_NL_ADMIN_PERM,
3078: },
3079: [RDMA_NLDEV_CMD_STAT_GET_STATUS] = {
3080: .doit = nldev_stat_get_counter_status_doit,
3081: },
3082: [RDMA_NLDEV_CMD_NEWDEV] = {
3083: .doit = nldev_newdev,
3084: .flags = RDMA_NL_ADMIN_PERM,
3085: },
3086: [RDMA_NLDEV_CMD_DELDEV] = {
3087: .doit = nldev_deldev,
3088: .flags = RDMA_NL_ADMIN_PERM,
3089: },
3090: [RDMA_NLDEV_CMD_FRMR_POOLS_GET] = {
3091: .dump = nldev_frmr_pools_get_dumpit,
3092: },
3093: [RDMA_NLDEV_CMD_FRMR_POOLS_SET] = {
3094: .doit = nldev_frmr_pools_set_doit,
3095: .flags = RDMA_NL_ADMIN_PERM,
3096: },
3097: };
SourceFile:drivers/infiniband/core/nldev.c]
|
| 56/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 46532
output: 28
thoughts: 161
Thoughts: **My RDMA Device Discovery**
Okay, so I'm digging into how RDMA devices are created and managed, specifically from a namespace perspective. I'm seeing that the `RDMA_NLDEV_CMD_NEWLINK` Netlink command is guarded by `RDMA_NL_ADMIN_PERM`, which in turn, relies on `rdma_nl_rcv_msg` checking `netlink_capable(skb, CAP_NET_ADMIN)`. That last function ultimately boils down to a check against `init_user_ns`. Basically, an unprivileged user gets shut down at the door. Makes sense, I don't want just anyone spinning up these devices.
But now I'm wondering, is that *the only* way? I'm missing something, there has to be another way. What about hardware devices? They aren't created through Netlink commands, they are probed and created upon hardware initialization. Ah, right! When the hardware is recognized and probed, the IB device comes into existence within `init_net`. Hmm... this gives me pause...
So, if a hardware IB device is born in `init_net`, can an unprivileged user then *move* that device to a different net namespace? That's the crucial question. I need to look into `ib_device_set_netns_put`, and see how this actually works. This might be where the real vulnerability, or opportunity, lies.
|
| 57/2 |
2026/09/11 00:24 |
tool |
codesearch-definition-source |
0m
Args: map[Name:ib_device_set_netns_put]
Results: map[SourceCode:1881: int ib_device_set_netns_put(struct sk_buff *skb,
1882: struct ib_device *dev, u32 ns_fd, const char *name,
1883: struct netlink_ext_ack *extack)
1884: {
1885: struct net *net;
1886: int ret;
1887:
1888: net = get_net_ns_by_fd(ns_fd);
1889: if (IS_ERR(net)) {
1890: NL_SET_ERR_MSG(extack, "Invalid target net namespace fd");
1891: ret = PTR_ERR(net);
1892: goto net_err;
1893: }
1894:
1895: if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
1896: NL_SET_ERR_MSG(extack,
1897: "Missing CAP_NET_ADMIN in the target net namespace");
1898: ret = -EPERM;
1899: goto ns_err;
1900: }
1901:
1902: /*
1903: * Moving a device to the namespace it already lives in is a no-op; a
1904: * supplied name still renames it in place.
1905: */
1906: if (net_eq(net, read_pnet(&dev->coredev.rdma_net))) {
1907: ret = name ? ib_device_rename(dev, name) : 0;
1908:
1909: if (ret == -EEXIST)
1910: NL_SET_ERR_MSG(extack,
1911: "Device name already exists in the target net namespace");
1912: else if (ret == -EINVAL && name)
1913: NL_SET_ERR_MSG(extack,
1914: "Unable to use requested device name in the target net namespace");
1915: goto ns_err;
1916: }
1917:
1918: /*
1919: * All the ib_clients, including uverbs, are reset when the namespace is
1920: * changed and this cannot be blocked waiting for userspace to do
1921: * something, so disassociation is mandatory.
1922: */
1923: if (ib_devices_shared_netns) {
1924: NL_SET_ERR_MSG(extack,
1925: "Cannot change net namespace of RDMA device in shared netns mode");
1926: ret = -EOPNOTSUPP;
1927: goto ns_err;
1928: }
1929:
1930: if (!dev->ops.disassociate_ucontext) {
1931: NL_SET_ERR_MSG(extack,
1932: "Device does not support namespace changes (no disassociate support)");
1933: ret = -EOPNOTSUPP;
1934: goto ns_err;
1935: }
1936:
1937: get_device(&dev->dev);
1938: ib_device_put(dev);
1939: ret = rdma_dev_change_netns(dev, current->nsproxy->net_ns, net, name,
1940: NULL);
1941: put_device(&dev->dev);
1942: if (ret == -EEXIST)
1943: NL_SET_ERR_MSG(extack,
1944: "Device name already exists in the target net namespace");
1945: else if (ret == -EINVAL && name)
1946: NL_SET_ERR_MSG(extack,
1947: "Unable to use requested device name in the target net namespace");
1948:
1949: put_net(net);
1950: return ret;
1951:
1952: ns_err:
1953: put_net(net);
1954: net_err:
1955: ib_device_put(dev);
1956: return ret;
1957: }
SourceFile:drivers/infiniband/core/device.c]
|
| 58/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 48233
output: 22
thoughts: 475
Thoughts: **My Analysis of IB Device Net Namespace Movement**
Okay, so `ib_device_set_netns_put` is called from `nldev_set_doit`, which is part of the `RDMA_NLDEV_CMD_SET` command. That command also needs `RDMA_NL_ADMIN_PERM`, meaning it inherently needs `CAP_NET_ADMIN` within `init_user_ns`. This makes sense, controlling network namespaces requires privileged access.
But, hang on, what about `siw` devices? Are those created using `RDMA_NLDEV_CMD_NEWLINK`? Yes, right, `siw` is an RDMA link type. So, an unprivileged user can't create or move an IB device to another net namespace directly. That's good security.
Alright, is there another way? Could an IB device somehow follow a netdev if the netdev is moved? Let me check how IB devices react. `rxe_notify` seems to be the place. It listens for `NETDEV_UNREGISTER`, `NETDEV_CHANGEMTU`, stuff like that. But, does it listen to `NETDEV_REGISTER` or `NETDEV_CHANGEINFODATA`? Nope. Interesting.
Wait, `rxe_net_add` is actually called when `RDMA_NLDEV_CMD_NEWLINK` is run, right? So, if a netdev is moved to a different net namespace, it gets unregistered in the old namespace and re-registered in the new one. That means `NETDEV_UNREGISTER` will be triggered. And `rxe_notify` then queues `ib_unregister_device_queued`. Ah, so it's not a move at all; the IB device gets destroyed, not moved. Good, consistent behavior.
But wait a minute, how the heck did syzkaller trigger this then? If an unprivileged user *can't* create or move an IB device, how is this even happening? Syzkaller runs as root in a VM, or it's been configured to have `CAP_NET_ADMIN` in `init_user_ns`. Usually, syzkaller will get `CAP_NET_ADMIN` if it's setup to do so, or it just uses a user namespace. If it was using a user namespace, `netlink_capable` would fail.
Okay, let's just go back and check `netlink_capable` one more time, just to be absolutely sure I haven't missed something obvious.
|
| 59/2 |
2026/09/11 00:24 |
tool |
codesearch-definition-source |
0m
Args: map[Name:netlink_capable]
Results: map[SourceCode: 874: /**
875: * netlink_capable - Netlink global message capability test
876: * @skb: socket buffer holding a netlink command from userspace
877: * @cap: The capability to use
878: *
879: * Test to see if the opener of the socket we received the message
880: * from had when the netlink socket was created and the sender of the
881: * message has the capability @cap in all user namespaces.
882: */
883: bool netlink_capable(const struct sk_buff *skb, int cap)
884: {
885: return netlink_ns_capable(skb, &init_user_ns, cap);
886: }
SourceFile:net/netlink/af_netlink.c]
|
| 60/2 |
2026/09/11 00:24 |
llm |
expert |
0m
Model:
Tokens:
input: 49517
output: 25
thoughts: 830
Thoughts: **My Analysis of IB Device Creation and Destruction**
Okay, let me break this down. First, the `netlink_capable` function checks the `init_user_ns`. So, `RDMA_NLDEV_CMD_NEWLINK` is definitely restricted to root within `init_user_ns`. That's the baseline. I need to make sure I haven't missed any other possible ways to create an IB device. `siw` uses the same command. Are there other paths? Maybe another driver calls `ib_register_device`? Like `hns_roce` or `mlx5`? Those are PCI devices, and the kernel probes them, registering an IB device. If a PCI device gets passed through to a VM, a guest root could trigger it, but unprivileged users *can't* probe PCI devices, so that's a dead end for them.
Now, how about device unregistration? Can anything other than the direct creation path trigger `ib_unregister_device_queued`? If a net namespace is destroyed and it *contains* an IB device... How can an unprivileged user even *get* an IB device into a net namespace in the first place, when they can't move or create it? Ah, got it. The administrator, with root privileges, can create or move an IB device to a net namespace. Then, when that net namespace goes away, there's a problem. Wait. What if the IB device is originally in `init_net`? That's never destroyed. So the IB device has to be in a *non-*`init_net` net namespace. And to get there you need `CAP_NET_ADMIN` in `init_user_ns`.
So, it looks like this bug is only reachable if root (or someone with `CAP_NET_ADMIN` in `init_user_ns`) creates or moves an IB device to a net namespace and then destroys that namespace. Syzkaller, it seems, triggered this. But, Syzkaller usually runs as root in the guest, therefore it has `CAP_NET_ADMIN` in `init_user_ns`. In a guest VM context, root can definitely trigger this. Can an unprivileged user? No, because they can't do the initial device creation or movement.
Let's do a sanity check on all other device creation possibilities. What about the `rdma_rxe` module parameter `add`? The `/sys/module/rdma_rxe/parameters/add` sysfs entry? Writing to sysfs needs root. Does `siw` have a sysfs interface? No, it doesn't.
One last check. Is `netlink_capable` the *only* check? Let me look at `rdma_nl_rcv_msg`: there's the `RDMA_NL_ADMIN_PERM` flag, and then the check for `!netlink_capable(skb, CAP_NET_ADMIN)`. Yup, that's the gatekeeper.
Wait a second… Is there any scenario where an IB device is *automatically* created when a netdev is created? For example, `ipoib` creates a netdev when an IB device exists. Does the reverse ever happen? Does `mlx5` automatically make an IB device when a netdev is made? No, that's a PCI driver – both are created during the PCI probe. If a VF is made, that *might* create an IB device, but making a VF needs root.
And what about this: If a net namespace is made, and a netdev is moved there, does the IB device *follow* the netdev? Let's check `mlx5_netdev_event`.
|
| 61/2 |
2026/09/11 00:25 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[Name:mlx5_netdev_event]
Results: map[SourceCode: SourceFile:]
|
| 62/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 51186
output: 21
thoughts: 14
Thoughts: Here's my summary, as though I'm thinking through this process:
**Diving into the `mlx5_netdev_event` Rabbit Hole**
Okay, time to get to the bottom of this. My gut tells me something's amiss with how the Mellanox driver is handling network device events. I need to pinpoint the relevant code quickly. The best first step is to use `grep`. I'll focus on the specific string `mlx5_netdev_event`. This should quickly identify where the driver code is registering, handling, or interacting with those network device events. Hopefully, this keyword will provide a manageable set of results, allowing me to start tracing the code flow and find the relevant sections. From there, I can begin to understand the logic.
|
| 63/2 |
2026/09/11 00:25 |
tool |
grepper |
0m
Args: map[Expression:mlx5_netdev_event]
Results: map[Output:drivers/infiniband/hw/mlx5/main.c=190=static struct net_device *mlx5_ib_get_rep_uplink_netdev(struct mlx5_ib_dev *ibdev)
--
drivers/infiniband/hw/mlx5/main.c-204-
drivers/infiniband/hw/mlx5/main.c:205:static int mlx5_netdev_event(struct notifier_block *this,
drivers/infiniband/hw/mlx5/main.c-206- unsigned long event, void *ptr)
--
drivers/infiniband/hw/mlx5/main.c=3063=static int handle_port_change(struct mlx5_ib_dev *ibdev, struct mlx5_eqe *eqe,
--
drivers/infiniband/hw/mlx5/main.c-3082- /* In RoCE, port up/down events are handled in
drivers/infiniband/hw/mlx5/main.c:3083: * mlx5_netdev_event().
drivers/infiniband/hw/mlx5/main.c-3084- */
--
drivers/infiniband/hw/mlx5/main.c=3765=static void mlx5_netdev_notifier_register(struct mlx5_roce *roce,
--
drivers/infiniband/hw/mlx5/main.c-3772- roce->tracking_netdev = netdev;
drivers/infiniband/hw/mlx5/main.c:3773: roce->nb.notifier_call = mlx5_netdev_event;
drivers/infiniband/hw/mlx5/main.c-3774- err = register_netdevice_notifier_dev_net(netdev, &roce->nb, &roce->nn);
]
|
| 64/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 51868
output: 46
thoughts: 13
Thoughts: Okay, let's dive into this `mlx5_netdev_event` situation. My expertise kicks in here, as I immediately begin to parse what this likely entails. I assume this refers to the Mellanox (or more broadly, NVIDIA networking) driver, specifically related to network device events within the mlx5 framework. It's likely a critical function or handler within the driver, responsible for reacting to changes in the network device's status, configuration, or perhaps even incoming hardware interrupts.
**Dissecting mlx5_netdev_event**
My immediate questions are: What *specific* events are we talking about? Is this generic, covering a broad range of device lifecycle events (link up/down, queue changes, etc.), or is it more granular, perhaps handling particular error conditions, flow control updates, or even offload-specific triggers like a change in the state of an RDMA connection? The naming convention strongly suggests we're dealing with the network device layer, so I start visualizing the data structures involved: the net_device, the mlx5-specific structures, maybe some work queues, potentially even interactions with the hardware's internal event counters.
I start thinking about possible implementations. Is it a polling mechanism, or interrupt-driven? Are they dealing with a threaded model, or even an asynchronous one? Is it a single, monolithic function, or a dispatcher calling a set of event-specific handlers? I need to understand the concurrency model to determine what locking is probably in place to protect the shared structures. The likely interaction with the hardware is key. Is there DMA involved, are we processing incoming packets (or perhaps outgoing ones) at the point of handling these events? I imagine how this would influence how we write the code. I then will try to determine the likely interaction with the hardware. For example, are we polling, or interrupt-driven? What's the threading model here? Is there DMA involved?
|
| 65/2 |
2026/09/11 00:25 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/infiniband/hw/mlx5/main.c Name:mlx5_netdev_event]
Results: map[SourceCode: SourceFile:]
|
| 66/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 52351
output: 44
thoughts: 11
Thoughts: Okay, here's the summary, assuming I'm the expert and the "thoughts" refer to my technical thought process:
**Line Number Check**
Right, okay, I was just looking at the code and got a little lost. Where was I? Ah, yes, the problem area. I need to pinpoint the exact line I was working on. Let me just re-scan that section quickly... Yes! There it is. I've found it, right there at line 205. Now I can get back to it.
|
| 67/2 |
2026/09/11 00:25 |
tool |
read-file |
0m
Args: map[File:drivers/infiniband/hw/mlx5/main.c FirstLine:205 LineCount:100]
Results: map[Contents: 205: static int mlx5_netdev_event(struct notifier_block *this,
206: unsigned long event, void *ptr)
207: {
208: struct mlx5_roce *roce = container_of(this, struct mlx5_roce, nb);
209: struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
210: u32 port_num = roce->native_port_num;
211: struct net_device *ib_ndev = NULL;
212: struct mlx5_core_dev *mdev;
213: struct mlx5_ib_dev *ibdev;
214:
215: ibdev = roce->dev;
216: mdev = mlx5_ib_get_native_port_mdev(ibdev, port_num, NULL);
217: if (!mdev)
218: return NOTIFY_DONE;
219:
220: switch (event) {
221: case NETDEV_REGISTER:
222: /* Should already be registered during the load */
223: if (ibdev->is_rep)
224: break;
225:
226: ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
227: /* Exit if already registered */
228: if (ib_ndev)
229: goto put_ndev;
230:
231: if (ndev->dev.parent == mdev->device)
232: ib_device_set_netdev(&ibdev->ib_dev, ndev, port_num);
233: break;
234:
235: case NETDEV_UNREGISTER:
236: /* In case of reps, ib device goes away before the netdevs */
237: if (ibdev->is_rep)
238: break;
239: ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
240: if (ib_ndev == ndev)
241: ib_device_set_netdev(&ibdev->ib_dev, NULL, port_num);
242: goto put_ndev;
243:
244: case NETDEV_CHANGE:
245: case NETDEV_UP:
246: case NETDEV_DOWN: {
247: struct net_device *upper = NULL;
248:
249: if (!netif_is_lag_master(ndev) && !netif_is_lag_port(ndev) &&
250: !mlx5_core_mp_enabled(mdev))
251: return NOTIFY_DONE;
252:
253: if (mlx5_lag_is_roce(mdev) || mlx5_lag_is_sriov(mdev)) {
254: struct net_device *lag_ndev;
255:
256: if(mlx5_lag_is_roce(mdev))
257: lag_ndev = ib_device_get_netdev(&ibdev->ib_dev, 1);
258: else /* sriov lag */
259: lag_ndev = mlx5_ib_get_rep_uplink_netdev(ibdev);
260:
261: if (lag_ndev) {
262: upper = netdev_master_upper_dev_get(lag_ndev);
263: dev_put(lag_ndev);
264: } else {
265: goto done;
266: }
267: }
268:
269: if (ibdev->is_rep)
270: roce = mlx5_get_rep_roce(ibdev, ndev, upper, &port_num);
271: if (!roce)
272: return NOTIFY_DONE;
273:
274: ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
275:
276: if (mlx5_netdev_send_event(ibdev, ndev, upper, ib_ndev)) {
277: struct ib_event ibev = { };
278: enum ib_port_state port_state;
279:
280: if (get_port_state(&ibdev->ib_dev, port_num,
281: &port_state))
282: goto put_ndev;
283:
284: if (roce->last_port_state == port_state)
285: goto put_ndev;
286:
287: roce->last_port_state = port_state;
288: ibev.device = &ibdev->ib_dev;
289: if (port_state == IB_PORT_DOWN)
290: ibev.event = IB_EVENT_PORT_ERR;
291: else if (port_state == IB_PORT_ACTIVE)
292: ibev.event = IB_EVENT_PORT_ACTIVE;
293: else
294: goto put_ndev;
295:
296: ibev.element.port_num = port_num;
297: ib_dispatch_event(&ibev);
298: }
299: break;
300: }
301:
302: default:
303: break;
304: }
]
|
| 68/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 54131
output: 23
thoughts: 160
Thoughts: **My Analysis of IB Device Creation and Namespaces**
Okay, so I'm looking at this code and it's setting up the `ib_device_set_netdev` function, which is interesting, but I need to understand the implications for moving an InfiniBand device. Aha, it *doesn't* actually move the IB device to a new network namespace on its own. Now, I remember that `ib_device_set_netns_put` is the key function for that, which means namespace changes. But wait a minute, to use that, it needs `CAP_NET_ADMIN` privileges within `init_user_ns`. Right, that's crucial.
So, this strongly implies an unprivileged user can't shift an IB device. That makes sense from a security perspective. Now I'm wondering if an unprivileged user can *create* an IB device in the first place. My initial thought is no, but I need to confirm. I quickly check `RDMA_NLDEV_CMD_NEWLINK` and, yep, that also requires `CAP_NET_ADMIN` in `init_user_ns`. So, that's a dead end.
Okay, let's explore `siw`. Is there a loophole there? Is there any other way, besides the standard approaches, to create a `siw` device? It might have some alternative pathways. I need to dig into `siw_newlink` specifically. I need to see what privileges that function checks for.
|
| 69/2 |
2026/09/11 00:25 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 412: static int siw_newlink(const char *basedev_name, struct net_device *netdev)
413: {
414: struct ib_device *base_dev;
415: struct siw_device *sdev = NULL;
416: int rv = -ENOMEM;
417:
418: if (!siw_dev_qualified(netdev))
419: return -EINVAL;
420:
421: base_dev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_SIW);
422: if (base_dev) {
423: ib_device_put(base_dev);
424: return -EEXIST;
425: }
426: sdev = siw_device_create(netdev);
427: if (sdev) {
428: dev_dbg(&netdev->dev, "siw: new device\n");
429: ib_mark_name_assigned_by_user(&sdev->base_dev);
430: rv = siw_device_register(sdev, basedev_name);
431: if (rv)
432: ib_dealloc_device(&sdev->base_dev);
433: }
434: return rv;
435: }
SourceFile:drivers/infiniband/sw/siw/siw_main.c]
|
| 70/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 55059
output: 26
thoughts: 580
Thoughts: **My Analysis of the Vulnerability**
Okay, let's break this down. The potential vulnerability originates from `ib_unregister_device_queued`, and the entry point is `nldev_newlink`. That immediately tells me it's bound by `CAP_NET_ADMIN` within `init_user_ns`. That's the baseline.
My immediate question is: are there *any* other ways to trigger `ib_unregister_device_queued`? Could it be called indirectly, perhaps through netdev unregistration? The flow then shifts to considering `siw_netdev_event` or `rxe_notify` after a netdev is unregistered. The scenario then involves an unprivileged user creating a net namespace, a dummy netdev, and then unregistering it. The key here is, though, that an unprivileged user *cannot* attach an IB device because that requires `CAP_NET_ADMIN` in the *global* `init_user_ns`. Right.
So, the netdev unregisters, calling `rxe_notify`. It tries to find the associated IB device: `struct rxe_dev *rxe = rxe_get_dev_from_net(ndev);`. Since there's no associated IB device, `rxe` will be `NULL`. It returns `NOTIFY_OK`, and `ib_unregister_device_queued` *isn't* called. That looks like a dead end for an unprivileged user.
Next, I need to confirm: Is there *any* other way for an unprivileged user to create an RXE device? That goes to examining the `unprivileged_bpf_disabled` parameter. We're assuming it's set to 1. That blocks unprivileged BPF access. What about user namespaces? I have to remember the constraint the prompt gives: user namespaces are inaccessible. That means the process cannot get capabilities in a new user namespace. It uses `ns_capable()` to check capabilities. So if this requires a capability checked in `init_user_ns` (like `CAP_NET_ADMIN`), then it's *not* accessible via user namespaces.
Alright, the prompt is clear that anything requiring `CAP_NET_ADMIN` from `init_user_ns` is blocked from user namespaces. We know it uses `netlink_capable`, so let's be sure this checks `init_user_ns`: Yes, `netlink_ns_capable(skb, &init_user_ns, cap)`. So that confirms it does require global `CAP_NET_ADMIN`, effectively preventing the unprivileged user from exploiting this, even within a user namespace. Let me quickly think, there would be no other paths, right? How about the sysfs? Hmm, the `rdma_rxe` sysfs interface might be a way.
|
| 71/2 |
2026/09/11 00:25 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[Name:rxe_param_set_add]
Results: map[SourceCode: SourceFile:]
|
| 72/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 56293
output: 37
thoughts: 23
Thoughts: Here's my thought process, as if I were the one thinking it:
**Digging into the RXE Codebase**
Alright, I need to understand how the `rxe` (Remote Xilinx Ethernet) driver is handling additions, likely of new connections, resources, or perhaps even queue entries, within the Infiniband subsystem. My first instinct, given my experience, is to zero in on where the core logic for these additions is defined. I'm going to quickly search for any instances of the string "add" within the relevant directory. Grep is the perfect tool for this; it's fast and allows for filtering. Using `grep` on that specific directory should give me a quick overview of any functions, variables or configuration parameters that use 'add'. That is the best way to get me started.
|
| 73/2 |
2026/09/11 00:25 |
tool |
grepper |
0m
Error:
Args: map[Expression:module_param.*add PathPrefix:drivers/infiniband/sw/rxe/]
Results:
|
| 74/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 56539
output: 40
thoughts: 11
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Initial Diagnostic Query**
Alright, let's see. If I were to hazard a first guess, based on the context and my existing knowledge of kernel subsystems and potential areas of concern, the most likely culprit, or at least a good place to start my investigation, would be `rxe_sysfs.c`. I immediately jump to that component because it handles sysfs interactions within the RDMA/RoCE subsystem which often leads to user space issues. I have seen issues in the past with the handling of attributes, permissions, or even race conditions during sysfs attribute reads or writes within that module.
|
| 75/2 |
2026/09/11 00:25 |
tool |
grepper |
0m
Error:
Args: map[Expression:add PathPrefix:drivers/infiniband/sw/rxe/rxe_sysfs.c]
Results:
|
| 76/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 56755
output: 35
thoughts: 47
Thoughts: Here's my take on those thoughts:
**Reflecting on the RXE Interface**
Hmm, wasn't there a `sysfs` interface for `rxe` at some point? I seem to recall using that in the past, but it's been a while. My gut tells me it was deprecated, perhaps replaced with `netlink` for some reason... likely more flexibility and control. To confirm my suspicion, I need to check the code. Let me dive into `drivers/infiniband/sw/rxe/rxe.c` and see what the source says about this change. Knowing how `rxe` works is critical to my current work, so I need to make sure I have an accurate understanding of the interface's history.
|
| 77/2 |
2026/09/11 00:25 |
tool |
grepper |
0m
Error:
Args: map[Expression:module_param PathPrefix:drivers/infiniband/sw/rxe/]
Results:
|
| 78/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 57012
output: 23
thoughts: 555
Thoughts: **My Analysis of InfiniBand Device Unregistration**
Okay, so there are no module parameters to exploit, meaning Netlink is the only attack vector to investigate. But hold on, what about hardware InfiniBand (IB) devices? If one exists, can an unprivileged user trigger its removal? A hardware IB device is linked to a PCI device, and unregistering *that* requires root privileges—specifically, writing to `/sys/bus/pci/devices/.../remove`. Forget about hot-unplugging a USB IB device because those don't exist.
The next thing that jumps into my head is, what if the IB device is tied to a network device (netdev) and that netdev is unregistered? For instance, `mlx5` creates a netdev. Could an unprivileged user unregister the `mlx5` netdev? Nope, removing a *physical* netdev requires root.
Then it hits me: could a user move the `mlx5` netdev to a user namespace, and then destroy that namespace? What happens when a network device is moved to a net namespace, and the net namespace is destroyed? I recall that *physical* netdevs are moved back to `init_net` upon net namespace destruction, while *virtual* netdevs like veth or macvlan are unregistered.
But could an unprivileged user create a virtual netdev (like macvlan) on top of a physical RDMA-capable netdev? It does come to mind that inside a user namespace, with `CAP_NET_ADMIN`, I *can* create a macvlan on top of a physical netdev. However, the physical netdev is in `init_net`. An unprivileged user is blocked from seeing it or creating a macvlan on it from a different net namespace.
But what if root moved the physical netdev to a net namespace first, then I could create a macvlan on it. That still demands root intervention.
A bit of a long shot, but what about creating a `veth` pair and hoping that somehow an IB device gets attached to it? No, because attaching an IB device needs `CAP_NET_ADMIN` in `init_user_ns`.
So, it seems this bug is only reachable by the root user, and within `init_user_ns`.
I need to expand my search. Is there *any* other way to trigger `ib_unregister_device`? What other call paths exist to `ib_unregister_device`? I need to check the callers of `ib_unregister_device`.
|
| 79/2 |
2026/09/11 00:25 |
tool |
codesearch-find-references |
0m
Args: map[Name:ib_unregister_device]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__UNIQUE_ID_addressable_ib_unregister_device_1037 SourceFile:drivers/infiniband/core/device.c SourceLine:1615] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__gendwarfksyms_ptr_ib_unregister_device SourceFile:drivers/infiniband/core/device.c SourceLine:1615] map[ReferenceKind:takes-address-of ReferencingEntityKind:global_variable ReferencingEntityName:__gendwarfksyms_ptr_ib_unregister_device SourceFile:drivers/infiniband/core/device.c SourceLine:1615]] TruncatedOutput:false]
|
| 80/2 |
2026/09/11 00:25 |
llm |
expert |
0m
Model:
Tokens:
input: 58369
output: 20
thoughts: 19
Thoughts: Here's my thought process, as requested:
**Unpacking a Kernel Symbol**
Okay, `ib_unregister_device` is showing up as exported, which is interesting. That means it's a symbol available to be used outside of the module that defines it, typically within a kernel module, but potentially other places as well. My first instinct, given I know it's a kernel function, is to understand where it's *used*. What other parts of the kernel are interacting with this function? I'm going to start by grepping the kernel source code for its use. This should give me a good handle on its purpose and the broader context in which it operates. Let's see what that search turns up.
|
| 81/2 |
2026/09/11 00:25 |
tool |
grepper |
0m
Args: map[Expression:ib_unregister_device\(]
Results: map[Output:Documentation/infiniband/core_locking.rst=98=Hot-plug
--
Documentation/infiniband/core_locking.rst-103- must be complete before this call. The device must remain usable
Documentation/infiniband/core_locking.rst:104: until the driver's call to ib_unregister_device() has returned.
Documentation/infiniband/core_locking.rst-105-
Documentation/infiniband/core_locking.rst-106- A low-level driver must call ib_register_device() and
Documentation/infiniband/core_locking.rst:107: ib_unregister_device() from process context. It must not hold any
Documentation/infiniband/core_locking.rst-108- semaphores that could cause deadlock if a consumer calls back into
--
Documentation/translations/zh_CN/infiniband/core_locking.rst=18=infiniband中间层锁
--
Documentation/translations/zh_CN/infiniband/core_locking.rst-104- 准备好供使用者使用,所有的初始化必须在这个调用之前完成。设备必须保
Documentation/translations/zh_CN/infiniband/core_locking.rst:105: 持可用,直到驱动对ib_unregister_device()的调用返回。
Documentation/translations/zh_CN/infiniband/core_locking.rst-106-
Documentation/translations/zh_CN/infiniband/core_locking.rst-107- 低级驱动程序必须从进程上下文调用ib_register_device()和
Documentation/translations/zh_CN/infiniband/core_locking.rst:108: ib_unregister_device()。如果使用者在这些调用中回调到驱动程序,它
Documentation/translations/zh_CN/infiniband/core_locking.rst-109- 不能持有任何可能导致死锁的semaphores。
--
drivers/infiniband/core/device.c=216=static void ib_unregister_work(struct work_struct *work);
drivers/infiniband/core/device.c:217:static void __ib_unregister_device(struct ib_device *device);
drivers/infiniband/core/device.c-218-static int ib_security_change(struct notifier_block *nb, unsigned long event,
--
drivers/infiniband/core/device.c=1391=static void ib_device_notify_register(struct ib_device *device)
--
drivers/infiniband/core/device.c-1436- *
drivers/infiniband/core/device.c:1437: * If the driver uses ops.dealloc_driver and calls any ib_unregister_device()
drivers/infiniband/core/device.c-1438- * asynchronously then the device pointer may become freed as soon as this
--
drivers/infiniband/core/device.c=1441=int ib_register_device(struct ib_device *device, const char *name,
--
drivers/infiniband/core/device.c-1520- ib_device_put(device);
drivers/infiniband/core/device.c:1521: __ib_unregister_device(device);
drivers/infiniband/core/device.c-1522- device->ops.dealloc_driver = dealloc_fn;
--
drivers/infiniband/core/device.c=1543=EXPORT_SYMBOL(ib_register_device);
--
drivers/infiniband/core/device.c-1545-/* Callers must hold a get on the device. */
drivers/infiniband/core/device.c:1546:static void __ib_unregister_device(struct ib_device *ib_dev)
drivers/infiniband/core/device.c-1547-{
--
drivers/infiniband/core/device.c-1608- */
drivers/infiniband/core/device.c:1609:void ib_unregister_device(struct ib_device *ib_dev)
drivers/infiniband/core/device.c-1610-{
drivers/infiniband/core/device.c-1611- get_device(&ib_dev->dev);
drivers/infiniband/core/device.c:1612: __ib_unregister_device(ib_dev);
drivers/infiniband/core/device.c-1613- put_device(&ib_dev->dev);
--
drivers/infiniband/core/device.c=1615=EXPORT_SYMBOL(ib_unregister_device);
--
drivers/infiniband/core/device.c-1620- *
drivers/infiniband/core/device.c:1621: * This is the same as ib_unregister_device(), except it includes an internal
drivers/infiniband/core/device.c-1622- * ib_device_put() that should match a 'get' obtained by the caller.
--
drivers/infiniband/core/device.c=1631=void ib_unregister_device_and_put(struct ib_device *ib_dev)
--
drivers/infiniband/core/device.c-1635- ib_device_put(ib_dev);
drivers/infiniband/core/device.c:1636: __ib_unregister_device(ib_dev);
drivers/infiniband/core/device.c-1637- put_device(&ib_dev->dev);
--
drivers/infiniband/core/device.c=1655=void ib_unregister_driver(enum rdma_driver_id driver_id)
--
drivers/infiniband/core/device.c-1668- WARN_ON(!ib_dev->ops.dealloc_driver);
drivers/infiniband/core/device.c:1669: __ib_unregister_device(ib_dev);
drivers/infiniband/core/device.c-1670-
--
drivers/infiniband/core/device.c=1678=static void ib_unregister_work(struct work_struct *work)
--
drivers/infiniband/core/device.c-1682-
drivers/infiniband/core/device.c:1683: __ib_unregister_device(ib_dev);
drivers/infiniband/core/device.c-1684- put_device(&ib_dev->dev);
--
drivers/infiniband/hw/bnxt_re/main.c=2455=static void bnxt_re_remove_device(struct bnxt_re_dev *rdev, u8 op_type,
--
drivers/infiniband/hw/bnxt_re/main.c-2458- bnxt_re_setup_cc(rdev, false);
drivers/infiniband/hw/bnxt_re/main.c:2459: ib_unregister_device(&rdev->ibdev);
drivers/infiniband/hw/bnxt_re/main.c-2460- bnxt_re_dev_uninit(rdev, op_type);
--
drivers/infiniband/hw/bnxt_re/main.c=2557=static void bnxt_re_shutdown(struct auxiliary_device *adev)
--
drivers/infiniband/hw/bnxt_re/main.c-2562- rdev = en_info->rdev;
drivers/infiniband/hw/bnxt_re/main.c:2563: ib_unregister_device(&rdev->ibdev);
drivers/infiniband/hw/bnxt_re/main.c-2564- bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE);
--
drivers/infiniband/hw/cxgb4/provider.c=568=void c4iw_unregister_device(struct c4iw_dev *dev)
--
drivers/infiniband/hw/cxgb4/provider.c-570- pr_debug("c4iw_dev %p\n", dev);
drivers/infiniband/hw/cxgb4/provider.c:571: ib_unregister_device(&dev->ibdev);
drivers/infiniband/hw/cxgb4/provider.c-572- return;
--
drivers/infiniband/hw/efa/efa_main.c=472=static void efa_ib_device_remove(struct efa_dev *dev)
--
drivers/infiniband/hw/efa/efa_main.c-474- ibdev_info(&dev->ibdev, "Unregister ib device\n");
drivers/infiniband/hw/efa/efa_main.c:475: ib_unregister_device(&dev->ibdev);
drivers/infiniband/hw/efa/efa_main.c-476- efa_destroy_eqs(dev);
--
drivers/infiniband/hw/erdma/erdma_main.c=86=static int erdma_device_register(struct erdma_dev *dev)
--
drivers/infiniband/hw/erdma/erdma_main.c-108- ibdev_err(&dev->ibdev, "failed to register notifier.\n");
drivers/infiniband/hw/erdma/erdma_main.c:109: ib_unregister_device(ibdev);
drivers/infiniband/hw/erdma/erdma_main.c-110- }
--
drivers/infiniband/hw/erdma/erdma_main.c=615=static void erdma_ib_device_remove(struct pci_dev *pdev)
--
drivers/infiniband/hw/erdma/erdma_main.c-619- unregister_netdevice_notifier(&dev->netdev_nb);
drivers/infiniband/hw/erdma/erdma_main.c:620: ib_unregister_device(&dev->ibdev);
drivers/infiniband/hw/erdma/erdma_main.c-621-
--
drivers/infiniband/hw/hns/hns_roce_main.c=700=static void hns_roce_unregister_device(struct hns_roce_dev *hr_dev,
--
drivers/infiniband/hw/hns/hns_roce_main.c-715- unregister_netdevice_notifier(&iboe->nb);
drivers/infiniband/hw/hns/hns_roce_main.c:716: ib_unregister_device(&hr_dev->ib_dev);
drivers/infiniband/hw/hns/hns_roce_main.c-717-}
--
drivers/infiniband/hw/hns/hns_roce_main.c=799=static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
--
drivers/infiniband/hw/hns/hns_roce_main.c-894-error_failed_setup_mtu_mac:
drivers/infiniband/hw/hns/hns_roce_main.c:895: ib_unregister_device(ib_dev);
drivers/infiniband/hw/hns/hns_roce_main.c-896-
--
drivers/infiniband/hw/ionic/ionic_ibdev.c=296=static void ionic_destroy_ibdev(struct ionic_ibdev *dev)
--
drivers/infiniband/hw/ionic/ionic_ibdev.c-298- ionic_kill_rdma_admin(dev, false);
drivers/infiniband/hw/ionic/ionic_ibdev.c:299: ib_unregister_device(&dev->ibdev);
drivers/infiniband/hw/ionic/ionic_ibdev.c-300- ionic_stats_cleanup(dev);
--
drivers/infiniband/hw/irdma/icrdma_if.c=315=static void icrdma_remove(struct auxiliary_device *aux_dev)
--
drivers/infiniband/hw/irdma/icrdma_if.c-323- ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, false);
drivers/infiniband/hw/irdma/icrdma_if.c:324: irdma_ib_unregister_device(iwdev);
drivers/infiniband/hw/irdma/icrdma_if.c-325- icrdma_deinit_interrupts(iwdev->rf, cdev_info);
--
drivers/infiniband/hw/irdma/main.c=124=static void ig3rdma_vport_remove(struct auxiliary_device *aux_dev)
--
drivers/infiniband/hw/irdma/main.c-135-
drivers/infiniband/hw/irdma/main.c:136: irdma_ib_unregister_device(iwdev);
drivers/infiniband/hw/irdma/main.c-137-}
--
drivers/infiniband/hw/irdma/verbs.c=5625=void irdma_port_ibevent(struct irdma_device *iwdev)
--
drivers/infiniband/hw/irdma/verbs.c-5640- */
drivers/infiniband/hw/irdma/verbs.c:5641:void irdma_ib_unregister_device(struct irdma_device *iwdev)
drivers/infiniband/hw/irdma/verbs.c-5642-{
--
drivers/infiniband/hw/irdma/verbs.c-5644- irdma_port_ibevent(iwdev);
drivers/infiniband/hw/irdma/verbs.c:5645: ib_unregister_device(&iwdev->ibdev);
drivers/infiniband/hw/irdma/verbs.c-5646-}
--
drivers/infiniband/hw/irdma/verbs.h=336=int irdma_ib_register_device(struct irdma_device *iwdev);
drivers/infiniband/hw/irdma/verbs.h:337:void irdma_ib_unregister_device(struct irdma_device *iwdev);
drivers/infiniband/hw/irdma/verbs.h-338-void irdma_ib_dealloc_device(struct ib_device *ibdev);
--
drivers/infiniband/hw/mana/device.c=240=static void mana_ib_remove(struct auxiliary_device *adev)
--
drivers/infiniband/hw/mana/device.c-246-
drivers/infiniband/hw/mana/device.c:247: ib_unregister_device(&dev->ib_dev);
drivers/infiniband/hw/mana/device.c-248- dma_pool_destroy(dev->av_pool);
--
drivers/infiniband/hw/mlx4/main.c=2611=static int mlx4_ib_probe(struct auxiliary_device *adev,
--
drivers/infiniband/hw/mlx4/main.c-2877-err_reg:
drivers/infiniband/hw/mlx4/main.c:2878: ib_unregister_device(&ibdev->ib_dev);
drivers/infiniband/hw/mlx4/main.c-2879-
--
drivers/infiniband/hw/mlx4/main.c=2973=static void mlx4_ib_remove(struct auxiliary_device *adev)
--
drivers/infiniband/hw/mlx4/main.c-2995- mlx4_ib_mad_cleanup(ibdev);
drivers/infiniband/hw/mlx4/main.c:2996: ib_unregister_device(&ibdev->ib_dev);
drivers/infiniband/hw/mlx4/main.c-2997- mlx4_ib_diag_cleanup(ibdev);
--
drivers/infiniband/hw/mlx5/main.c=4993=static void mlx5_ib_stage_ib_reg_cleanup(struct mlx5_ib_dev *dev)
drivers/infiniband/hw/mlx5/main.c-4994-{
drivers/infiniband/hw/mlx5/main.c:4995: ib_unregister_device(&dev->ib_dev);
drivers/infiniband/hw/mlx5/main.c-4996-}
--
drivers/infiniband/hw/mthca/mthca_provider.c=1201=void mthca_unregister_device(struct mthca_dev *dev)
--
drivers/infiniband/hw/mthca/mthca_provider.c-1203- mthca_stop_catas_poll(dev);
drivers/infiniband/hw/mthca/mthca_provider.c:1204: ib_unregister_device(&dev->ib_dev);
drivers/infiniband/hw/mthca/mthca_provider.c-1205-}
--
drivers/infiniband/hw/ocrdma/ocrdma_main.c=326=static void ocrdma_remove(struct ocrdma_dev *dev)
--
drivers/infiniband/hw/ocrdma/ocrdma_main.c-331- cancel_delayed_work_sync(&dev->eqd_work);
drivers/infiniband/hw/ocrdma/ocrdma_main.c:332: ib_unregister_device(&dev->ibdev);
drivers/infiniband/hw/ocrdma/ocrdma_main.c-333-
--
drivers/infiniband/hw/qedr/main.c=937=static void qedr_remove(struct qedr_dev *dev)
--
drivers/infiniband/hw/qedr/main.c-941- */
drivers/infiniband/hw/qedr/main.c:942: ib_unregister_device(&dev->ibdev);
drivers/infiniband/hw/qedr/main.c-943-
--
drivers/infiniband/hw/usnic/usnic_ib_main.c=466=static void usnic_ib_device_remove(struct usnic_ib_dev *us_ibdev)
--
drivers/infiniband/hw/usnic/usnic_ib_main.c-470- usnic_fwd_dev_free(us_ibdev->ufdev);
drivers/infiniband/hw/usnic/usnic_ib_main.c:471: ib_unregister_device(&us_ibdev->ib_dev);
drivers/infiniband/hw/usnic/usnic_ib_main.c-472- ib_dealloc_device(&us_ibdev->ib_dev);
--
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c=764=static int pvrdma_pci_probe(struct pci_dev *pdev,
--
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c-1025-err_unreg_ibdev:
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c:1026: ib_unregister_device(&dev->ib_dev);
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c-1027-err_disable_intr:
--
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c=1063=static void pvrdma_pci_remove(struct pci_dev *pdev)
--
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c-1080- /* Unregister ib device */
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c:1081: ib_unregister_device(&dev->ib_dev);
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c-1082-
--
drivers/infiniband/sw/rdmavt/vt.c=596=void rvt_unregister_device(struct rvt_dev_info *rdi)
--
drivers/infiniband/sw/rdmavt/vt.c-603-
drivers/infiniband/sw/rdmavt/vt.c:604: ib_unregister_device(&rdi->ibdev);
drivers/infiniband/sw/rdmavt/vt.c-605- rvt_wss_exit(rdi);
--
include/rdma/ib_verbs.h=3131=int ib_register_device(struct ib_device *device, const char *name,
include/rdma/ib_verbs.h-3132- struct device *dma_device);
include/rdma/ib_verbs.h:3133:void ib_unregister_device(struct ib_device *device);
include/rdma/ib_verbs.h-3134-void ib_unregister_driver(enum rdma_driver_id driver_id);
]
|
| 82/2 |
2026/09/11 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 64006
output: 21
thoughts: 3587
Thoughts: **My Analysis of a Kernel Use-After-Free Vulnerability**
Okay, so I've been digging into this potential use-after-free in the kernel, specifically around RDMA devices. It looks like `ib_unregister_device` is the key function here, triggered when the hardware device is removed or when certain RDMA devices (`rxe` or `siw`) are deleted. The asynchronous calls via `ib_unregister_device_queued` after netdev unregistration or a direct `RDMA_NLDEV_CMD_DELDEV` command are the crux of the problem. That `RDMA_NLDEV_CMD_DELDEV` also requires `CAP_NET_ADMIN` in `init_user_ns`, so an unprivileged user can't directly trigger this.
The question then becomes: can an unprivileged user indirectly trigger `ib_unregister_device`? I've considered scenarios involving network namespaces. If root moves a device into a namespace, and an unprivileged user then destroys that namespace, that unregistration sequence is kicked off. This triggers the bug if it has an associated `rxe` or `siw` device. Specifically, `rxe_notify` or `siw_netdev_event` queue `ib_unregister_device_queued`.
The problem is the race between net namespace destruction and the execution of `ib_unregister_work`. `cleanup_net` frees the `net->uevent_sock`, but `ib_unregister_work` still accesses it. This is a classic use-after-free scenario. This crash looks exploitable. It is a UAF of a `kmalloc-32` object and the object is `struct uevent_sock`. The use-after-free reads `ue_sk->sk` which is then passed to `netlink_broadcast`. Since the vulnerable UAF is in `net->uevent_sock`, an attacker can control the `sk` pointer passed to `uevent_net_broadcast_tagged` through a spray and overwrite. I can also control the flow of execution or memory.
I've explored whether a non-root user could create this condition via `unshare(CLONE_NEWNET)`. However, creating the device in the first place requires `CAP_NET_ADMIN`, preventing unprivileged users from directly crafting this scenario. It seems the net namespace *must* contain an RDMA device (created as root). But if created on the host by root, the net namespace will not contain an IB device.
The syzkaller report confirms this. Syzkaller, running as root, creates a new net namespace with `unshare`, then creates an RDMA device. Destroying the net namespace then triggers the crash in `ib_unregister_work`. Syzkaller effectively demonstrates the exploit, but the requirement for root-level capabilities limits the accessibility of this bug.
I dug further to see if `init_net` is susceptible. No, the bug only occurs when the net namespace is destroyed. And putting an IB device in a non-init net namespace requires `CAP_NET_ADMIN`. So it is not accessible from unprivileged processes.
My thought process then moved to look for any other ways to trigger the unregistration. Other netlink families, ioctls, configfs, and also physical or virtual netdevs. None of those seem to offer a way for a user without elevated privileges to trigger the `ib_unregister_device_queued` call path. I looked for a USB device that simulates an RDMA device as well. I also considered container destruction. The container scenario seems like a definite path to exploit this. Destroying a container with RDMA devices will trigger the bug. This makes it a reliable DoS (and potentially exploitable) for systems that use RDMA in containers. A container root might be able to trigger this.
I've mapped the exact call sequence to solidify this understanding. It starts with `cleanup_net` and ends with `kobject_uevent` accessing the freed `net->uevent_sock->sk`. The race is clear: `uevent_net_exit` frees the `sock` *before* the work queue executes. Finally, I went through the questions. The vulnerability is exploitable, results in a denial of service, and is only accessible by root (or a process with CAP_NET_ADMIN in init_user_ns). It is not triggered by guests, and is not an ethernet trigger. However, if the bug is caused by a container, it could be triggered by destroying a container with an RDMA device.
|
| 83/2 |
2026/09/11 00:26 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 666: static void cleanup_net(struct work_struct *work)
667: {
668: struct llist_node *net_kill_list;
669: struct net *net, *tmp, *last;
670: LIST_HEAD(net_exit_list);
671:
672: WRITE_ONCE(cleanup_net_task, current);
673:
674: /* Atomically snapshot the list of namespaces to cleanup */
675: net_kill_list = llist_del_all(&cleanup_list);
676:
677: down_read(&pernet_ops_rwsem);
678:
679: /* Don't let anyone else find us. */
680: down_write(&net_rwsem);
681: llist_for_each_entry(net, net_kill_list, cleanup_list) {
682: ns_tree_remove(net);
683: list_del_rcu(&net->list);
684: net->is_dying = true;
685: }
686: /* Cache last net. After we unlock rtnl, no one new net
687: * added to net_namespace_list can assign nsid pointer
688: * to a net from net_kill_list (see peernet2id_alloc()).
689: * So, we skip them in unhash_nsid().
690: *
691: * Note, that unhash_nsid() does not delete nsid links
692: * between net_kill_list's nets, as they've already
693: * deleted from net_namespace_list. But, this would be
694: * useless anyway, as netns_ids are destroyed there.
695: */
696: last = list_last_entry(&net_namespace_list, struct net, list);
697: up_write(&net_rwsem);
698:
699: unhash_nsid(last);
700:
701: llist_for_each_entry(net, net_kill_list, cleanup_list) {
702: idr_destroy(&net->netns_ids);
703: list_add_tail(&net->exit_list, &net_exit_list);
704: }
705:
706: ops_undo_list(&pernet_list, NULL, &net_exit_list, true);
707:
708: up_read(&pernet_ops_rwsem);
709:
710: /* Ensure there are no outstanding rcu callbacks using this
711: * network namespace.
712: */
713: rcu_barrier();
714:
715: net_complete_free();
716:
717: /* Finally it is safe to free my network namespace structure */
718: list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) {
719: list_del_init(&net->exit_list);
720: ns_common_free(net);
721: dec_net_namespaces(net->ucounts);
722: #ifdef CONFIG_KEYS
723: key_remove_domain(net->key_domain);
724: #endif
725: put_user_ns(net->user_ns);
726: net_passive_dec(net);
727: }
728: WRITE_ONCE(cleanup_net_task, NULL);
729: }
SourceFile:net/core/net_namespace.c]
|
| 84/2 |
2026/09/11 00:26 |
llm |
expert |
0m
Model:
Tokens:
input: 69624
output: 66
thoughts: 2175
Thoughts: **Analysis of the UAF Bug in Net Namespace Destruction**
Okay, let's break this down. It seems we have a use-after-free vulnerability tied to how the network namespace is destroyed. The core issue revolves around the order of operations when a namespace is cleaned up, specifically the interplay between deregistering network devices and releasing related resources.
Initially, I see that `ops_undo_list` orchestrates the exit process, calling `ops_exit_list`, which, in turn, handles the cleanup of various per-net devices and subsystems. Both `uevent_net_exit` and `default_device_exit_batch` are called during this phase, and their execution order is determined by the `pernet_list`. The `pernet_list` is ordered by how the subsystems are registered.
`uevent_net_init`, which is associated with network events (`uevent`), is registered relatively early, while `default_device_exit_batch`, handling the default device exit, is registered later. This means, during namespace destruction, `default_device_exit_batch` will be executed before `uevent_net_exit` due to the reverse iteration of the `ops_exit_list`.
The problem arises when we consider the interaction with RDMA devices. Specifically, `default_device_exit_batch` can trigger the unregistration of network devices. This unregistration process, for IB devices, involves `ib_unregister_work`, which is asynchronous. It’s queued to a workqueue, essentially delaying the actual `device_del` operation.
Here's the critical sequence: `default_device_exit_batch` unregisters the IB devices. Then the netdev triggers `NETDEV_UNREGISTER`, that triggers `ib_unregister_work`. Then `uevent_net_exit` gets called, which frees `net->uevent_sock`. *Then* `ib_unregister_work` runs (likely later). When `ib_unregister_work` runs, it tries to access the `net->uevent_sock` that has been freed! This is the UAF.
So it's a race, but heavily skewed. The workqueue is almost guaranteed to be called after `uevent_net_exit` completes.
The vulnerability is confirmed: It's a UAF of a `kmalloc-32` object that holds a pointer that is dereferenced later, resulting in a denial-of-service (kernel crash).
Regarding exploitability, it initially looked like an unprivileged user could trigger this if they had access to a net namespace. However, this doesn't appear to be correct. Even if a user could create and destroy containers or namespaces, the IB device unregistration process relies on privileged operations. I investigated the capabilities of unprivileged users, and it looks like a user, even with `CAP_NET_ADMIN` in a user namespace, can't directly create, manage, or delete IB devices. Calls to the RDMA Netlink interface requires `CAP_NET_ADMIN` in the `init_user_ns`. So, no go there.
I considered alternative scenarios, like a "normal" network device being unregistered during namespace destruction but, thankfully, that doesn't trigger the UAF because the unregistration of standard devices is synchronous. `device_del` is called directly, *before* the `uevent_net_exit`, so `net->uevent_sock` is still valid. The asynchronous nature of IB device unregistration via the workqueue is what causes the window.
Therefore, the vulnerability remains a privilege escalation issue, specifically, it requires root to be able to create an IB device in the first place, and then to destroy the namespace. The race condition is specific to how RDMA devices are cleaned up.
|
| 85/2 |
2026/09/11 00:27 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 86/2 |
2026/09/11 00:27 |
llm |
expert-compressor |
0m
Model:
Reply: ### Workspace & Bug Investigation Summary
#### 1. Bug Overview and Call Stack Analysis
- **Bug Type**: Slab-use-after-free read (`__asan_report_load8_noabort`) of size 8 at address inside a freed 32-byte region belonging to `kmalloc-32`.
- **Faulting instruction/location**: `kobject_uevent_net_broadcast+0x110/0x53c lib/kobject_uevent.c:415`.
- Line 415: `ret = uevent_net_broadcast_tagged(net->uevent_sock->sk, env, action_string, devpath);`
- Specifically dereferencing `net->uevent_sock->sk`, where `net->uevent_sock` has already been freed.
- **Trigger Call Stack**:
- `ib_unregister_work+0x20/0x38 drivers/infiniband/core/device.c:1683` (running on workqueue `ib-unreg-wq`)
- `__ib_unregister_device+0x214/0x33c`
- `disable_device+0x184/0x240`
- `remove_compat_devs` -> `remove_one_compat_dev` -> `device_del`
- `kobject_uevent` -> `kobject_uevent_env` -> `kobject_uevent_net_broadcast`
- **Allocation Stack**:
- Allocated by task via `uevent_net_init+0xcc/0x2a0 lib/kobject_uevent.c:782` during network namespace setup (`setup_net` / `copy_net_ns` / `ksys_unshare`).
- Allocated structure is `struct uevent_sock` via `kzalloc_obj(*ue_sk)`.
- **Free Stack**:
- Freed by task via `uevent_net_exit+0x1b0/0x1cc lib/kobject_uevent.c:816` during `cleanup_net` (`ops_undo_list` / `ops_exit_list`).
- Memory freed via `kfree(ue_sk)` in `uevent_net_exit`.
---
#### 2. Root Cause & Mechanism
- **The Mechanism**:
1. An RDMA device (e.g., software RoCE `rxe` or soft-iWARP `siw`) is associated with a network interface in a non-initial network namespace (`net`).
2. When the network namespace exits, `cleanup_net()` tears down devices and runs pernet exit callbacks.
3. Network device unregistration triggers `NETDEV_UNREGISTER` notifier:
- `rxe_notify()` receives `NETDEV_UNREGISTER` and calls `ib_unregister_device_queued(&rxe->ib_dev)`.
- `ib_unregister_device_queued()` queues `&ib_dev->unregistration_work` onto `ib_unreg_wq` (`ib_unregister_work`).
4. In parallel, `cleanup_net()` continues executing pernet exit handlers in `cleanup_net()`, invoking `uevent_net_exit(net)`.
- `uevent_net_exit()` executes `netlink_kernel_release(ue_sk->sk)` and `kfree(ue_sk)`.
- Note: `net->uevent_sock` is freed, but the `net` struct itself may still be referenced or in teardown.
5. Concurrently, `ib_unregister_work()` executes asynchronously on `ib_unreg_wq`:
- Calls `__ib_unregister_device()`.
- Calls `disable_device()` -> `remove_compat_devs()` -> `remove_one_compat_dev()`.
- Calls `device_del(&cdev->dev)` which emits a uevent (`kobject_uevent()`).
- `kobject_uevent_net_broadcast()` resolves the device namespace via `kobj->ktype->namespace(kobj)`, calling `device_namespace()` -> `ib_class.namespace` (`net_namespace`).
- `net_namespace()` reads `coredev->rdma_net` (which points to the dying `net`).
- `kobject_uevent_net_broadcast()` then does `net->uevent_sock->sk`.
- Since `uevent_net_exit()` has already freed `net->uevent_sock`, this dereferences freed memory (`slab-use-after-free`).
---
#### 3. Relevant Code Snippets & Key Functions
- **`lib/kobject_uevent.c`**:
```c
static int kobject_uevent_net_broadcast(struct kobject *kobj, ...) {
...
if (!ns)
ret = uevent_net_broadcast_untagged(env, action_string, devpath);
else {
const struct net *net = container_of(ns, struct net, ns);
ret = uevent_net_broadcast_tagged(net->uevent_sock->sk, env, action_string, devpath);
}
return ret;
}
static void uevent_net_exit(struct net *net) {
struct uevent_sock *ue_sk = net->uevent_sock;
if (sock_net(ue_sk->sk)->user_ns == &init_user_ns) {
mutex_lock(&uevent_sock_mutex);
list_del(&ue_sk->list);
mutex_unlock(&uevent_sock_mutex);
}
netlink_kernel_release(ue_sk->sk);
kfree(ue_sk);
}
```
- **`drivers/infiniband/core/device.c`**:
```c
static const struct ns_common *net_namespace(const struct device *d) {
const struct ib_core_device *coredev =
container_of(d, struct ib_core_device, dev);
struct net *net = read_pnet(&coredev->rdma_net);
return net ? to_ns_common(net) : NULL;
}
void ib_unregister_device_queued(struct ib_device *ib_dev) {
get_device(&ib_dev->dev);
if (!queue_work(ib_unreg_wq, &ib_dev->unregistration_work))
put_device(&ib_dev->dev);
}
static void ib_unregister_work(struct work_struct *work) {
struct ib_device *ib_dev =
container_of(work, struct ib_device, unregistration_work);
__ib_unregister_device(ib_dev);
put_device(&ib_dev->dev);
}
```
- **`drivers/infiniband/sw/rxe/rxe_net.c`**:
```c
static int rxe_notify(struct notifier_block *not_blk, unsigned long event, void *arg) {
...
switch (event) {
case NETDEV_UNREGISTER:
ib_unregister_device_queued(&rxe->ib_dev);
rxe_net_del(&rxe->ib_dev);
break;
...
```
- **Capability Enforcement in RDMA Netlink (`drivers/infiniband/core/netlink.c` & `nldev.c`)**:
```c
// rdma_nl_rcv_msg:
if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
!netlink_capable(skb, CAP_NET_ADMIN)) {
err = -EPERM;
goto done;
}
// netlink_capable (net/netlink/af_netlink.c):
bool netlink_capable(const struct sk_buff *skb, int cap) {
return netlink_ns_capable(skb, &init_user_ns, cap);
}
```
- `RDMA_NLDEV_CMD_NEWLINK`, `RDMA_NLDEV_CMD_DELLINK`, `RDMA_NLDEV_CMD_SET`, `RDMA_NLDEV_CMD_NEWDEV`, `RDMA_NLDEV_CMD_DELDEV` all have `flags = RDMA_NL_ADMIN_PERM`.
- Because `netlink_capable()` checks `&init_user_ns`, operations require `CAP_NET_ADMIN` in the root initial user namespace.
---
#### 4. Approaches Tried, Results, and Investigation Status
- **Investigated Object**: `net->uevent_sock`. Traced its creation in `uevent_net_init` and destruction in `uevent_net_exit`.
- **Investigated UAF Access**: `kobject_uevent_net_broadcast` accessing `net->uevent_sock->sk` via `ib_class` device's `net_namespace` hook.
- **Investigated Trigger**:
- `ib_unregister_work` runs asynchronously from `ib_unreg_wq`.
- Queued by `ib_unregister_device_queued` when receiving `NETDEV_UNREGISTER` notifier (in `rxe` or `siw`).
- Asynchronous execution races with `cleanup_net` which invokes pernet ops undo (`uevent_net_exit`).
- **Investigated Reachability / Accessibility**:
- Can an unprivileged user reach this via unprivileged user namespaces (`CLONE_NEWUSER | CLONE_NEWNET`)?
- Checked `nldev_newlink`: calls `rdma_nl_rcv_msg()`.
- Flag `RDMA_NL_ADMIN_PERM` requires `netlink_capable(skb, CAP_NET_ADMIN)`.
- `netlink_capable()` specifically tests `&init_user_ns`.
- Therefore, a process in a user namespace with `CAP_NET_ADMIN` in its own namespace *fails* the capability check.
- Can an unprivileged user move an existing RDMA device to a netns?
- Moving RDMA device uses `RDMA_NLDEV_CMD_SET` -> `ib_device_set_netns_put()`.
- `RDMA_NLDEV_CMD_SET` also requires `RDMA_NL_ADMIN_PERM` (`netlink_capable` in `&init_user_ns`).
- Can an unprivileged user trigger creation via hardware probe or netdev events?
- Software RDMA drivers (`rdma_rxe`, `siw`) do not auto-create IB devices on netdev creation without Netlink/sysfs commands.
- Sysfs module parameters (`/sys/module/rdma_rxe/parameters/add`) require root in `init_user_ns`.
---
#### 5. Active Lines of Investigation / Hypotheses for Dimension Assessment
- **Exploitable**:
- Yes: Slab Use-After-Free (read of pointer `ue_sk->sk`, followed by passing `sk` to `uevent_net_broadcast_tagged()`, dereferencing socket object, potential memory corruption / hijacking control flow or leak).
- **Denial Of Service**:
- Yes: Kernel crash / page fault when accessing freed `ue_sk` or subsequent corrupted `sock`.
- **Accessible From Unprivileged Processes**:
- No: Cannot create netns or RDMA device without privileges.
- **Accessible From User Namespaces**:
- No: Creating or moving an RDMA device requires `CAP_NET_ADMIN` in `init_user_ns` via Netlink `netlink_capable()` or sysfs. Unprivileged user namespaces cannot bind `rxe`/`siw` to virtual network devices.
- **VM Guest Trigger**:
- Yes: Root in a VM guest can configure `rxe` on a loopback/virtio interface, create and destroy a netns, triggering the race and bug.
- **VM Host Trigger (CoCo)**:
- No: Not triggered by host-controlled PV virtio/hypercalls directly.
- **Ethernet Network Trigger / Other Remote**:
- No: Involves local netns teardown and workqueue race, not triggered by parsing untrusted ingress network packets.
- **Peripheral / Malicious Filesystem**:
- No: Unrelated to USB/peripherals or filesystem parsing.
*(Note: In next step, verify if any unprivileged path exists to auto-create RDMA devices, then call `set-results` and provide final assessment.)*
Tokens:
input: 47573
output: 2911
thoughts: 0
|
| 87/2 |
2026/09/11 00:27 |
llm |
expert |
0m
Model:
Tokens:
input: 25799
output: 842
thoughts: 1046
Thoughts: **Analysis of the kobject_uevent_net_broadcast UAF Vulnerability**
Okay, let's break this down. The core issue is a slab-use-after-free vulnerability in `kobject_uevent_net_broadcast` when it tries to access `net->uevent_sock->sk`. The crux of the problem is that `net->uevent_sock` is being freed in `uevent_net_exit` which is called during `cleanup_net`. Concurrently, `ib_unregister_work` is running, and that triggers `device_del`, which in turn, triggers a uevent. When this uevent broadcast happens, it attempts to locate the network namespace of the device. This then points to the now dying `net` and tries to access that freed socket.
So, is it exploitable? Absolutely, it's a use-after-free *read* of `ue_sk->sk`, followed by a dereference within `uevent_net_broadcast_tagged`. This could allow for memory corruption, potential information leaks, and most critically, control-flow hijacking if an attacker can control the freed memory region that is reallocated.
Is it a denial-of-service vulnerability? Yes, a definite yes. The kernel will crash due to accessing invalid, freed memory.
Can it be triggered by unprivileged processes? No. Creating or moving RDMA devices, necessary to set up this scenario, requires `CAP_NET_ADMIN` within the initial user namespace.
Can this be triggered from user namespaces? No. The capability checks for RDMA netlink operations, such as creating a new link (`RDMA_NLDEV_CMD_NEWLINK`), are done with `netlink_capable(skb, CAP_NET_ADMIN)`. This checks against `&init_user_ns`, effectively preventing the necessary operations from within user namespaces, even if those namespaces possess `CAP_NET_ADMIN`.
Now, the trickier part - VM triggers. Can a VM guest trigger it? Yes, a root user *within* a VM guest can configure RDMA devices (like `rxe` or `siw`) and then trigger the bug by creating and destroying network namespaces. The key here is *within* the guest.
But the question is "Determine if the bug can be triggered from the context of a typical KVM guest."...This is about guest to host!
The "VM Guest Trigger" is defined to consider accesses to standard Linux host paravirtualized features such as virtio-blk and virtio-net. It's usually talking about escaping the guest. So if the bug is just a local kernel bug, it's not a "VM Guest Trigger". This bug is about a local user in the guest, crashing the guest, and it isn't an escape. That means a guest can't trigger it on the host, so the correct answer is No.
And, if a guest can't trigger it on the host, then a host can't trigger it on the guest, so `VMHostTrigger` is also No.
No network, remote, peripheral, or filesystem triggers either. It's a localized kernel bug, not connected to any external interfaces.
Therefore, my final classification is:
* Exploitable: True
* DoS: True
* Unprivileged: False
* UserNamespace: False
* VMGuestTrigger: False
* VMHostTrigger: False
* NetworkTrigger: False
* RemoteTrigger: False
* PeripheralTrigger: False
* FilesystemTrigger: False
|
| 88/1 |
2026/09/11 00:27 |
action |
format-explanation |
0m
Results: map[Explanation:**Analysis of the Bug and its Security Impact**
**1. Root Cause and Mechanism**
The bug is a slab-use-after-free (UAF) in `kobject_uevent_net_broadcast()`. It
occurs due to a race condition during the teardown of a network namespace
(`netns`) that contains an RDMA device (e.g., software RoCE `rxe` or soft-iWARP
`siw`).
When a network namespace is destroyed, `cleanup_net()` executes per-net exit
callbacks. One of these callbacks is `uevent_net_exit()`, which frees
`net->uevent_sock`. Concurrently, the destruction of the network namespace
triggers a `NETDEV_UNREGISTER` event. The RDMA driver catches this event and
queues an asynchronous work item (`ib_unregister_work`) to unregister the RDMA
device.
When `ib_unregister_work` executes, it removes the device and triggers a
`kobject_uevent`. The uevent broadcasting mechanism attempts to resolve the
network namespace of the device, which still points to the dying `netns`. It
then accesses `net->uevent_sock->sk` to broadcast the event. Since
`net->uevent_sock` was already freed by `uevent_net_exit()`, this results in a
use-after-free read.
**2. Exploitability**
**Exploitable: Yes.**
The bug involves reading a pointer (`ue_sk->sk`) from a freed 32-byte slab
object (`kmalloc-32`) and subsequently passing this pointer to
`uevent_net_broadcast_tagged()`, which dereferences it as a socket object. An
attacker who can trigger this race condition could potentially use heap spraying
techniques to reallocate the freed `kmalloc-32` object with controlled data. By
controlling the `sk` pointer, the attacker could achieve arbitrary memory
read/write or hijack the kernel control flow when the socket object is
manipulated, leading to privilege escalation.
**3. Denial of Service (DoS)**
**Denial of Service: Yes.**
If the freed memory is not intentionally reallocated and controlled by an
attacker, the stale pointer dereference will cause a kernel panic (e.g., page
fault on unmapped memory or KASAN panic), leading to a system crash and denial
of service.
**4. Accessibility**
**Accessible from Unprivileged Processes: No.**
**Accessible from User Namespaces: No.**
Triggering this bug requires the ability to create or move an RDMA device into a
network namespace. The configuration of RDMA devices (like `rxe` or `siw`) is
done via the RDMA Netlink interface. The handlers for these operations (e.g.,
`RDMA_NLDEV_CMD_NEWLINK`, `RDMA_NLDEV_CMD_SET`) are flagged with
`RDMA_NL_ADMIN_PERM`. The capability check for this flag uses
`netlink_capable(skb, CAP_NET_ADMIN)`, which specifically checks for
`CAP_NET_ADMIN` in the **initial user namespace** (`&init_user_ns`). Therefore,
an unprivileged user, even if they create a new user namespace and acquire
`CAP_NET_ADMIN` within that namespace, will fail the capability check and cannot
configure RDMA devices to trigger the bug.
**5. Other Triggers**
* **VM Guest / Host Trigger:** No. This is a local kernel vulnerability in the
RDMA subsystem and network namespace teardown. It does not involve guest-to-host
escape mechanisms (like virtio or VM exits) or host-to-guest confidential
computing attack vectors.
* **Network / Remote Trigger:** No. The bug is triggered by local network
namespace and device management operations, not by parsing untrusted ingress
network traffic.
* **Peripheral / Filesystem Trigger:** No. The bug is unrelated to the plugging
of physical peripherals or the parsing of malicious filesystems.]
|