| 0/0 |
2026/05/23 13:07 |
flow |
assessment-security |
38m
Results: map[DenialOfService:true Explanation:The bug report indicates an RCU stall (softlockup) occurring while the CPU is
executing `__batadv_dat_purge` (or similar periodic purge functions in the
batman-adv subsystem).
### Analysis of the Bug
The root cause of the RCU stall is a problematic locking pattern in
`__batadv_dat_purge`. The function iterates over a hash table (which has 1024
buckets by default) and locks each bucket individually using `spin_lock_bh()`
and `spin_unlock_bh()`.
When `spin_unlock_bh()` is called, it enables bottom halves (softirqs). If there
are pending softirqsβsuch as network packets waiting to be
processedβ`spin_unlock_bh()` will invoke `do_softirq()` to process them. The
softirq processing is bounded by `net_rx_action` to a maximum of 2 jiffies or
300 packets.
However, if there is a continuous storm of packets (e.g., due to a bridging loop
or a network flood), `spin_unlock_bh()` will spend the full 2 jiffies processing
packets at *every single iteration* of the 1024-bucket loop. This means the
entire `__batadv_dat_purge` function can take up to 2048 jiffies (e.g., ~20
seconds at HZ=100) to complete. Because this loop runs in a workqueue context
without ever calling `cond_resched()`, the CPU does not go through an RCU
quiescent state for the entire duration, triggering the RCU stall warning and
effectively locking up the CPU.
### Security Impact
- **Exploitable**: No. This is purely a CPU stall/softlockup issue. There is no
memory corruption, use-after-free, or out-of-bounds access involved.
- **Denial of Service**: Yes. The bug locks up the CPU for extended periods
(tens of seconds), causing severe latency spikes or triggering kernel panics if
`panic_on_rcu_stall` is enabled.
- **Unprivileged / User Namespace**: Yes. An unprivileged user can create a new
network namespace, instantiate a `batadv` interface (as `rtnl_link_ops` for
batman-adv does not restrict creation to the init namespace), and intentionally
create a bridging loop using `veth` pairs. The bridging loop will generate the
packet storm required to trigger the stall when the periodic DAT purge worker
runs.
- **Network Trigger**: Yes. If a system administrator has legitimately
configured batman-adv, a remote attacker can trigger this DoS by sending a
massive flood of packets (e.g., a UDP flood) to the machine. The flood will keep
the softirq backlog full, causing the periodic `batadv_dat_purge` worker to
stall the CPU. Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/23 13:07 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/23 13:07 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/3efa2d8cff7fa70e9ec9a97984e956ef2cd79281]
|
| 3/1 |
2026/05/23 13:08 |
action |
kernel-builder |
18m
Results: map[KernelObj:/app/workdir/cache/build/d1a1134912821ad6ca5b2f01486eebc04225b0a2]
|
| 4/1 |
2026/05/23 13:26 |
action |
codesearch-prepare |
12m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/23 13:39 |
agent |
expert |
6m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true 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 greeping
".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 or elevated privileges.
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 completly 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 tranfers, that's 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 exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
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 Confidetial 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:
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
rcu: Tasks blocked on level-0 rcu_node (CPUs 0-1): P31702/1:b..l P31706/1:b..l P31450/1:b..l
rcu: (detected by 0, t=10502 jiffies, g=240265, q=917 ncpus=1)
task:syz-executor state:R running task stack:24664 pid:31450 tgid:31450 ppid:31440 task_flags:0x400140 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0xfee/0x6120 kernel/sched/core.c:6911
preempt_schedule_common+0x42/0xc0 kernel/sched/core.c:7095
preempt_schedule_thunk+0x16/0x30 arch/x86/entry/thunk.S:12
__local_bh_enable_ip+0xff/0x120 kernel/softirq.c:457
spin_unlock_bh include/linux/spinlock.h:395 [inline]
nsim_fib_event_schedule_work drivers/net/netdevsim/fib.c:1013 [inline]
nsim_fib_event_nb+0x383/0xe40 drivers/net/netdevsim/fib.c:1043
call_fib_notifier+0x3c/0x80 net/core/fib_notifier.c:24
call_fib_entry_notifier net/ipv4/fib_trie.c:90 [inline]
fib_leaf_notify net/ipv4/fib_trie.c:2176 [inline]
fib_table_notify net/ipv4/fib_trie.c:2194 [inline]
fib_notify+0x360/0x5a0 net/ipv4/fib_trie.c:2217
fib4_dump+0x48/0x60 net/ipv4/fib_notifier.c:45
fib_net_dump net/core/fib_notifier.c:69 [inline]
register_fib_notifier+0x123/0x470 net/core/fib_notifier.c:107
nsim_fib_create+0x8f5/0xc10 drivers/net/netdevsim/fib.c:1596
nsim_drv_probe+0xd5a/0x14b0 drivers/net/netdevsim/dev.c:1688
call_driver_probe drivers/base/dd.c:643 [inline]
really_probe+0x241/0xa60 drivers/base/dd.c:721
__driver_probe_device+0x1de/0x400 drivers/base/dd.c:863
driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:893
__device_attach_driver+0x1df/0x340 drivers/base/dd.c:1021
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
__device_attach+0x1e4/0x4d0 drivers/base/dd.c:1093
device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1148
bus_probe_device+0x64/0x160 drivers/base/bus.c:613
device_add+0x11d9/0x1950 drivers/base/core.c:3691
nsim_bus_dev_new drivers/net/netdevsim/bus.c:471 [inline]
new_device_store+0x40b/0x700 drivers/net/netdevsim/bus.c:191
bus_attr_store+0x74/0xb0 drivers/base/bus.c:172
sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:142
kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:352
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x6ac/0x1070 fs/read_write.c:688
ksys_write+0x12a/0x250 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x106/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fa81d55cfce
RSP: 002b:00007ffc70670718 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 000055555e936500 RCX: 00007fa81d55cfce
RDX: 0000000000000003 RSI: 00007ffc706707a0 RDI: 0000000000000005
RBP: 00007fa81d633540 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
R13: 00007ffc706707a0 R14: 00007fa81e344620 R15: 0000000000000003
</TASK>
task:rm state:R running task stack:25416 pid:31706 tgid:31706 ppid:31677 task_flags:0x400000 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0xfee/0x6120 kernel/sched/core.c:6911
preempt_schedule_irq+0x50/0x90 kernel/sched/core.c:7238
irqentry_exit+0x17b/0x670 kernel/entry/common.c:239
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0010:lock_release+0x19e/0x320 kernel/locking/lockdep.c:5893
Code: ff 65 0f c1 05 8b 6e 29 12 83 f8 01 0f 85 3d 01 00 00 9c 58 f6 c4 02 0f 85 28 01 00 00 41 f7 c6 00 02 00 00 0f 85 de 00 00 00 <48> 8b 44 24 10 65 48 2b 05 dd 26 29 12 0f 85 63 01 00 00 48 83 c4
RSP: 0018:ffffc90004697058 EFLAGS: 00000206
RAX: 0000000000000046 RBX: ffffffff8e7e77a0 RCX: ffffc90004697064
RDX: 0000000000000001 RSI: ffffffff8de5b10c RDI: ffffffff8c1b1220
RBP: ffffffff81b7c2fe R08: 0000000000000001 R09: 0000000000000007
R10: 0000000000000200 R11: 000000000000ac07 R12: ffff88801dfdbd00
R13: ffffc90004697110 R14: 0000000000000202 R15: 0000000000000002
rcu_lock_release include/linux/rcupdate.h:322 [inline]
rcu_read_unlock include/linux/rcupdate.h:881 [inline]
class_rcu_destructor include/linux/rcupdate.h:1193 [inline]
unwind_next_frame+0x3c3/0x1ea0 arch/x86/kernel/unwind_orc.c:495
arch_stack_walk+0x94/0xf0 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0x8e/0xc0 kernel/stacktrace.c:122
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:415
kmalloc_noprof include/linux/slab.h:950 [inline]
slab_free_hook mm/slub.c:2637 [inline]
slab_free mm/slub.c:6165 [inline]
kmem_cache_free+0x41f/0x6a0 mm/slub.c:6295
vms_complete_munmap_vmas+0x7ac/0xdd0 mm/vma.c:1342
__mmap_complete mm/vma.c:2588 [inline]
__mmap_region+0xa09/0x29e0 mm/vma.c:2768
mmap_region+0x180/0x3e0 mm/vma.c:2837
do_mmap+0xc63/0x12f0 mm/mmap.c:559
vm_mmap_pgoff+0x29e/0x470 mm/util.c:581
ksys_mmap_pgoff+0x3c8/0x650 mm/mmap.c:605
__do_sys_mmap arch/x86/kernel/sys_x86_64.c:89 [inline]
__se_sys_mmap arch/x86/kernel/sys_x86_64.c:82 [inline]
__x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:82
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x106/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f80a56fb242
RSP: 002b:00007ffe9d0380d8 EFLAGS: 00000206 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f80a5407000 RCX: 00007f80a56fb242
RDX: 0000000000000005 RSI: 0000000000008000 RDI: 00007f80a5407000
RBP: 0000000000000812 R08: 0000000000000003 R09: 0000000000003000
R10: 0000000000000812 R11: 0000000000000206 R12: 00007ffe9d038128
R13: 00007f80a56d0580 R14: 00007ffe9d038550 R15: 00000fffd3a0701e
</TASK>
task:syz.5.7864 state:R running task stack:27856 pid:31702 tgid:31697 ppid:31079 task_flags:0x400040 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0xfee/0x6120 kernel/sched/core.c:6911
preempt_schedule_irq+0x50/0x90 kernel/sched/core.c:7238
irqentry_exit+0x17b/0x670 kernel/entry/common.c:239
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0010:lock_acquire+0x5e/0x380 kernel/locking/lockdep.c:5872
Code: 05 fb 2d 29 12 83 f8 07 0f 87 f0 00 00 00 48 0f a3 05 c6 69 f5 0e 0f 82 c2 02 00 00 8b 35 8e 9d f5 0e 85 f6 0f 85 dd 00 00 00 <48> 8b 44 24 30 65 48 2b 05 9d 2d 29 12 0f 85 02 03 00 00 48 83 c4
RSP: 0018:ffffc900045d7398 EFLAGS: 00000206
RAX: 0000000000000046 RBX: 0000000000000000 RCX: 0000000000000001
RDX: 0000000000000000 RSI: ffffffff8de5b10c RDI: ffffffff8c1b1220
RBP: ffffffff8e7e77a0 R08: 000000000e53ecb2 R09: 0000000000000007
R10: 0000000000000200 R11: 0000000000000000 R12: 0000000000000002
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
rcu_lock_acquire include/linux/rcupdate.h:312 [inline]
rcu_read_lock include/linux/rcupdate.h:850 [inline]
class_rcu_constructor include/linux/rcupdate.h:1193 [inline]
unwind_next_frame+0xd1/0x1ea0 arch/x86/kernel/unwind_orc.c:495
arch_stack_walk+0x94/0xf0 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0x8e/0xc0 kernel/stacktrace.c:122
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_save_track+0x14/0x30 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4538 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
kmem_cache_alloc_node_noprof+0x25a/0x6f0 mm/slub.c:4918
__alloc_skb+0x140/0x710 net/core/skbuff.c:702
alloc_skb include/linux/skbuff.h:1383 [inline]
sock_wmalloc+0xd4/0x120 net/core/sock.c:2828
l2tp_ip_sendmsg+0x1b6/0x1920 net/l2tp/l2tp_ip.c:464
inet_sendmsg+0x11c/0x140 net/ipv4/af_inet.c:865
sock_sendmsg_nosec net/socket.c:727 [inline]
__sock_sendmsg net/socket.c:742 [inline]
____sys_sendmsg+0x98d/0xb70 net/socket.c:2592
___sys_sendmsg+0x190/0x1e0 net/socket.c:2646
__sys_sendmmsg+0x205/0x430 net/socket.c:2735
__do_sys_sendmmsg net/socket.c:2762 [inline]
__se_sys_sendmmsg net/socket.c:2759 [inline]
__x64_sys_sendmmsg+0x9c/0x100 net/socket.c:2759
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x106/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe51599c799
RSP: 002b:00007fe516864028 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007fe515c16090 RCX: 00007fe51599c799
RDX: 00000000000009a6 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007fe515a32c99 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000007000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fe515c16128 R14: 00007fe515c16090 R15: 00007fff3277d058
</TASK>
rcu: rcu_preempt kthread starved for 1348 jiffies! g240265 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0
rcu: Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior.
rcu: RCU grace-period kthread stack dump:
task:rcu_preempt state:R running task stack:27736 pid:16 tgid:16 ppid:2 task_flags:0x208040 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0xfee/0x6120 kernel/sched/core.c:6911
__schedule_loop kernel/sched/core.c:6993 [inline]
schedule+0xdd/0x390 kernel/sched/core.c:7008
schedule_timeout+0x127/0x280 kernel/time/sleep_timeout.c:99
rcu_gp_fqs_loop+0x1a9/0x900 kernel/rcu/tree.c:2095
rcu_gp_kthread+0x179/0x230 kernel/rcu/tree.c:2297
kthread+0x370/0x450 kernel/kthread.c:436
ret_from_fork+0x754/0xd80 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
rcu: Stack dump where RCU GP kthread last ran:
CPU: 0 UID: 0 PID: 3410 Comm: kworker/R-bat_e Tainted: G L syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
Workqueue: bat_events batadv_dat_purge
RIP: 0010:debug_lockdep_rcu_enabled+0x26/0x40 kernel/rcu/update.c:320
Code: 90 90 90 90 f3 0f 1e fa 8b 05 82 ed 4b 05 85 c0 74 20 8b 05 60 20 4c 05 85 c0 74 16 65 48 8b 05 88 b0 7f 08 8b 80 54 0b 00 00 <85> c0 0f 94 c0 0f b6 c0 e9 3d 2c 03 00 66 2e 0f 1f 84 00 00 00 00
RSP: 0018:ffffc900000069e0 EFLAGS: 00000202
RAX: 0000000000000000 RBX: ffff888079412e80 RCX: ffffffff8a3a2deb
RDX: ffff8880337d1e80 RSI: ffffffff8a3a2df5 RDI: ffff888079412e90
RBP: dffffc0000000000 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffff888079412f80
R13: ffffc90000006a90 R14: fffff52000000d53 R15: 0000000000000001
FS: 0000000000000000(0000) GS:ffff888124346000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f3d1a7e6b10 CR3: 00000000782ee000 CR4: 00000000003526f0
Call Trace:
<IRQ>
fib6_node_lookup_1+0x113/0x9d0 net/ipv6/ip6_fib.c:1630
fib6_node_lookup+0xe9/0x190 net/ipv6/ip6_fib.c:1700
fib6_table_lookup+0xb1/0xa10 net/ipv6/route.c:2243
ip6_pol_route+0x1cc/0x1230 net/ipv6/route.c:2283
pol_lookup_func include/net/ip6_fib.h:617 [inline]
fib6_rule_lookup+0x52f/0x720 net/ipv6/fib6_rules.c:120
ip6_route_input_lookup net/ipv6/route.c:2352 [inline]
ip6_route_input+0x662/0xc50 net/ipv6/route.c:2655
ip6_rcv_finish_core.isra.0+0x1a9/0x5a0 net/ipv6/ip6_input.c:66
ip6_rcv_finish+0x130/0x300 net/ipv6/ip6_input.c:77
ip_sabotage_in+0x21e/0x290 net/bridge/br_netfilter_hooks.c:990
nf_hook_entry_hookfn include/linux/netfilter.h:158 [inline]
nf_hook_slow+0xbf/0x220 net/netfilter/core.c:623
nf_hook.constprop.0+0x2a6/0x750 include/linux/netfilter.h:273
NF_HOOK include/linux/netfilter.h:316 [inline]
ipv6_rcv+0xa4/0x3d0 net/ipv6/ip6_input.c:311
__netif_receive_skb_one_core+0x12d/0x1e0 net/core/dev.c:6164
__netif_receive_skb+0x1f/0x120 net/core/dev.c:6277
netif_receive_skb_internal net/core/dev.c:6363 [inline]
netif_receive_skb+0x139/0x820 net/core/dev.c:6422
NF_HOOK include/linux/netfilter.h:318 [inline]
NF_HOOK include/linux/netfilter.h:312 [inline]
br_pass_frame_up+0x346/0x490 net/bridge/br_input.c:70
br_handle_frame_finish+0xa74/0x1f60 net/bridge/br_input.c:235
br_nf_hook_thresh+0x30d/0x420 net/bridge/br_netfilter_hooks.c:1167
br_nf_pre_routing_finish_ipv6+0x769/0xfb0 net/bridge/br_netfilter_ipv6.c:154
NF_HOOK include/linux/netfilter.h:318 [inline]
br_nf_pre_routing_ipv6+0x39c/0x8b0 net/bridge/br_netfilter_ipv6.c:184
br_nf_pre_routing+0x90d/0x1550 net/bridge/br_netfilter_hooks.c:508
nf_hook_entry_hookfn include/linux/netfilter.h:158 [inline]
nf_hook_bridge_pre net/bridge/br_input.c:291 [inline]
br_handle_frame+0xcdd/0x1520 net/bridge/br_input.c:442
__netif_receive_skb_core.constprop.0+0x6c5/0x3550 net/core/dev.c:6051
__netif_receive_skb_one_core+0xb0/0x1e0 net/core/dev.c:6162
__netif_receive_skb+0x1f/0x120 net/core/dev.c:6277
process_backlog+0x37a/0x1580 net/core/dev.c:6628
__napi_poll.constprop.0+0xaf/0x450 net/core/dev.c:7692
napi_poll net/core/dev.c:7755 [inline]
net_rx_action+0xa40/0xf20 net/core/dev.c:7912
handle_softirqs+0x1eb/0x9e0 kernel/softirq.c:622
do_softirq kernel/softirq.c:523 [inline]
do_softirq+0xac/0xe0 kernel/softirq.c:510
</IRQ>
<TASK>
__local_bh_enable_ip+0xf8/0x120 kernel/softirq.c:450
spin_unlock_bh include/linux/spinlock.h:395 [inline]
__batadv_dat_purge.part.0+0x294/0x3c0 net/batman-adv/distributed-arp-table.c:185
__batadv_dat_purge net/batman-adv/distributed-arp-table.c:166 [inline]
batadv_dat_purge+0x4b/0xa0 net/batman-adv/distributed-arp-table.c:204
process_one_work+0xa23/0x19a0 kernel/workqueue.c:3276
process_scheduled_works kernel/workqueue.c:3359 [inline]
rescuer_thread+0x905/0x14a0 kernel/workqueue.c:3583
kthread+0x370/0x450 kernel/kthread.c:436
ret_from_fork+0x754/0xd80 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
net_ratelimit: 7065 callbacks suppressed
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:1b, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:e2:79:e7:04:dc:34, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:1b, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:e2:79:e7:04:dc:34, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:1b, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:e2:79:e7:04:dc:34, vlan:0)
net_ratelimit: 13186 callbacks suppressed
bridge0: received packet on veth0_to_bridge with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:e2:79:e7:04:dc:34, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:1b, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:e2:79:e7:04:dc:34, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:1b, vlan:0)
bridge0: received packet on veth0_to_bridge with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:0c, vlan:0)
Reply: The bug report indicates an RCU stall (softlockup) occurring while the CPU is executing `__batadv_dat_purge` (or similar periodic purge functions in the batman-adv subsystem).
### Analysis of the Bug
The root cause of the RCU stall is a problematic locking pattern in `__batadv_dat_purge`. The function iterates over a hash table (which has 1024 buckets by default) and locks each bucket individually using `spin_lock_bh()` and `spin_unlock_bh()`.
When `spin_unlock_bh()` is called, it enables bottom halves (softirqs). If there are pending softirqsβsuch as network packets waiting to be processedβ`spin_unlock_bh()` will invoke `do_softirq()` to process them. The softirq processing is bounded by `net_rx_action` to a maximum of 2 jiffies or 300 packets.
However, if there is a continuous storm of packets (e.g., due to a bridging loop or a network flood), `spin_unlock_bh()` will spend the full 2 jiffies processing packets at *every single iteration* of the 1024-bucket loop. This means the entire `__batadv_dat_purge` function can take up to 2048 jiffies (e.g., ~20 seconds at HZ=100) to complete. Because this loop runs in a workqueue context without ever calling `cond_resched()`, the CPU does not go through an RCU quiescent state for the entire duration, triggering the RCU stall warning and effectively locking up the CPU.
### Security Impact
- **Exploitable**: No. This is purely a CPU stall/softlockup issue. There is no memory corruption, use-after-free, or out-of-bounds access involved.
- **Denial of Service**: Yes. The bug locks up the CPU for extended periods (tens of seconds), causing severe latency spikes or triggering kernel panics if `panic_on_rcu_stall` is enabled.
- **Unprivileged / User Namespace**: Yes. An unprivileged user can create a new network namespace, instantiate a `batadv` interface (as `rtnl_link_ops` for batman-adv does not restrict creation to the init namespace), and intentionally create a bridging loop using `veth` pairs. The bridging loop will generate the packet storm required to trigger the stall when the periodic DAT purge worker runs.
- **Network Trigger**: Yes. If a system administrator has legitimately configured batman-adv, a remote attacker can trigger this DoS by sending a massive flood of packets (e.g., a UDP flood) to the machine. The flood will keep the softirq backlog full, causing the periodic `batadv_dat_purge` worker to stall the CPU.
|
| 6/2 |
2026/05/23 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 14663
output: 48
thoughts: 1165
Thoughts: **RCU Stall Investigation: A Deep Dive into the Networking Stack**
Okay, so I'm looking at this bug report and the initial red flag screams "RCU stall." The kernel log is pretty clear: an RCU preempt kthread has been starved, and the stack trace is where things get interesting. It looks like the stall occurs while the `kworker` thread is in `fib6_node_lookup_1`. I see the "Tainted: [L]=SOFTLOCKUP" too, that always gets my attention.
Let me break down this trace, which looks like this, it seems like a networking issue that starts with `__batadv_dat_purge` and winds its way through the stack: It starts with a `batadv` purge, which releases a spinlock (enabling softirqs) that eventually leads to processing network backlog. Then, it goes through `br_handle_frame` and through bridge netfilter, then IPv6, then routing (`ip6_route_input`), which inevitably calls fib6 routing (`fib6_node_lookup_1`).
A softlockup here is almost certainly related to the networking stack. My first thought is an infinite loop in `fib6_node_lookup_1`. Or, could it be netfilter on the bridge? Could this be a packet loop causing the problem?
Wait a second...I'm seeing messages about the bridge receiving packets with its own address as the source. "bridge0: received packet on bridge_slave_0 with own address as source address" and "bridge0: received packet on veth0_to_bridge with own address as source address" - this *screams* bridging loop! If so, it's either a configuration problem or a network topology problem, perhaps triggered by a user namespace that can configure the bridges and veths.
Alright, back to that stack trace... it's a bit of a breadcrumb trail. We go from `__batadv_dat_purge` down to `fib6_node_lookup_1`, which calls fib6 rule, fib6 table.
I'm starting to focus on `fib6_node_lookup_1` as the source, but it could still be a packet loop. Let's see if the fib6 lookup has an infinite loop itself. Wait, I remember, that loop in the `fib6_node_lookup_1` has a loop:
```c
if (key->dir == 1)
n = rcu_dereference(n->right);
else
n = rcu_dereference(n->left);
```
If the fib6 tree is corrupted, that loop could go on forever. Alright, time to dive into the source code for `fib6_node_lookup_1` in `net/ipv6/ip6_fib.c` and figure this out.
|
| 7/2 |
2026/05/23 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/ipv6/ip6_fib.c IncludeLines:true Name:fib6_node_lookup_1]
Results: map[SourceCode:1610: static struct fib6_node *fib6_node_lookup_1(struct fib6_node *root,
1611: struct lookup_args *args)
1612: {
1613: struct fib6_node *fn;
1614: __be32 dir;
1615:
1616: if (unlikely(args->offset == 0))
1617: return NULL;
1618:
1619: /*
1620: * Descend on a tree
1621: */
1622:
1623: fn = root;
1624:
1625: for (;;) {
1626: struct fib6_node *next;
1627:
1628: dir = addr_bit_set(args->addr, fn->fn_bit);
1629:
1630: next = dir ? rcu_dereference(fn->right) :
1631: rcu_dereference(fn->left);
1632:
1633: if (next) {
1634: fn = next;
1635: continue;
1636: }
1637: break;
1638: }
1639:
1640: while (fn) {
1641: struct fib6_node *subtree = FIB6_SUBTREE(fn);
1642:
1643: if (subtree || fn->fn_flags & RTN_RTINFO) {
1644: struct fib6_info *leaf = rcu_dereference(fn->leaf);
1645: struct rt6key *key;
1646:
1647: if (!leaf)
1648: goto backtrack;
1649:
1650: key = (struct rt6key *) ((u8 *)leaf + args->offset);
1651:
1652: if (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) {
1653: #ifdef CONFIG_IPV6_SUBTREES
1654: if (subtree) {
1655: struct fib6_node *sfn;
1656: sfn = fib6_node_lookup_1(subtree,
1657: args + 1);
1658: if (!sfn)
1659: goto backtrack;
1660: fn = sfn;
1661: }
1662: #endif
1663: if (fn->fn_flags & RTN_RTINFO)
1664: return fn;
1665: }
1666: }
1667: backtrack:
1668: if (fn->fn_flags & RTN_ROOT)
1669: break;
1670:
1671: fn = rcu_dereference(fn->parent);
1672: }
1673:
1674: return NULL;
1675: }
SourceFile:net/ipv6/ip6_fib.c]
|
| 8/2 |
2026/05/23 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 17355
output: 47
thoughts: 1859
Thoughts: **Analyzing the RCU Stall: Bridging Loop Suspect**
Okay, so the report points to an RCU stall within `fib6_node_lookup_1`, specifically related to `rcu_dereference` and `debug_lockdep_rcu_enabled`. My first thought is a corrupted FIB tree leading to an infinite loop, or perhaps a ridiculously deep tree. However, the `fn->fn_bit` check suggests the tree traversal is at least *conceptually* correct and moving deeper, which is interesting. Time to rule out a known bug in `fib6_node_lookup_1` or consider if this is just a side effect of some other problem.
The logs, however, immediately pique my interest. Those messages about a bridge receiving packets with its *own* MAC address as the source? That screams bridging loop. The "net_ratelimit" messages further solidify this suspicion β that suppression is usually from a packet storm. So, a packet loop in the bridge is generating a ton of traffic, which keeps the softirq busy enough to cause the RCU stall by keeping the CPU busy and not allowing RCU grace periods to occur.
But wait, why is the stall in `fib6_node_lookup_1`? It's likely just where the CPU happened to be when the NMI watchdog or RCU stall detector kicked in. It's a relatively expensive function in the receive path, so it makes sense as a place for the problem to become apparent.
Now, if it's a packet loop, normally the softirq would process packets up to a budget (`net_rx_action`), and then yield. But here, the softirq is called from `spin_unlock_bh`! This is unusual. Examining the code path, it goes through `__local_bh_enable_ip` -> `do_softirq` -> `net_rx_action`. When `do_softirq` is called from `local_bh_enable`, it is processing softirqs. If there is a packet storm, `net_rx_action` processes a limited number of packets (`netdev_budget`, or `netdev_budget_usecs`). But, could the packet loop be happening *synchronously*?
No, the normal bridge path is `br_handle_frame` -> `br_pass_frame_up` -> `netif_receive_skb` -> ... Hold on a second, `br_pass_frame_up` calls `netif_receive_skb` directly, which means the packet is processed *synchronously*! If a packet is received on a bridge port, and the bridge forwards it to the same bridge or to a separate bridge port, the packet may loop. The bridging code may be queuing or dropping the packet.
Looking deeper, `br_nf_pre_routing` calls an `NF_HOOK` for IPv6, and the hook is... Ah, the stack trace provides the answer! `br_nf_pre_routing` -> `br_nf_pre_routing_ipv6` -> `br_nf_pre_routing_finish_ipv6` -> `br_nf_hook_thresh` -> `br_handle_frame_finish` -> `br_pass_frame_up` -> `netif_receive_skb` -> `ipv6_rcv` then an `NF_HOOK` which leads back to `ip_sabotage_in`. So the initial packet received then undergoes processing by `ipv6_rcv` and then gets passed to the bridge.
So, `ip_sabotage_in` does what? I'm missing that, let's trace the hook. Wait, `ip_sabotage_in` is in `br_netfilter_hooks.c`. It steals the packet! The packets are being received on the bridge, then routed back to the bridge? Yep, it's `ip_sabotage_in` that is causing the problem.
|
| 9/2 |
2026/05/23 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/bridge/br_netfilter_hooks.c IncludeLines:true Name:ip_sabotage_in]
Results: map[SourceCode: 973: /* IP/SABOTAGE *****************************************************/
974: /* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING
975: * for the second time. */
976: static unsigned int ip_sabotage_in(void *priv,
977: struct sk_buff *skb,
978: const struct nf_hook_state *state)
979: {
980: struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
981:
982: if (nf_bridge) {
983: if (nf_bridge->sabotage_in_done)
984: return NF_ACCEPT;
985:
986: if (!nf_bridge->in_prerouting &&
987: !netif_is_l3_master(skb->dev) &&
988: !netif_is_l3_slave(skb->dev)) {
989: nf_bridge->sabotage_in_done = 1;
990: state->okfn(state->net, state->sk, skb);
991: return NF_STOLEN;
992: }
993: }
994:
995: return NF_ACCEPT;
996: }
SourceFile:net/bridge/br_netfilter_hooks.c]
|
| 10/2 |
2026/05/23 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 20528
output: 24
thoughts: 262
Thoughts: **My Analysis of the Packet Routing Loop**
Okay, so I've traced the path of this troublesome packet. It looks like `ip_sabotage_in` is making a direct call to `ip6_rcv_finish`, specifically because itβs bypassing the normal netfilter hooks and returning `NF_STOLEN`. `ip6_rcv_finish` then calls `ip6_rcv_finish_core`, which in turn calls `ip6_route_input` and performs a fib6 lookup. This sequence itself seems perfectly standard for bridge netfilter operation β nothing immediately stands out as inherently wrong.
However, the problem is obviously a loop or some kind of stalling behavior. The key clue, as is so often the case, lies in the log messages. I'm seeing packets entering the bridge (`bridge0`) with their *own* source MAC address. Specifically:
* `bridge0: received packet on bridge_slave_0 with own address as source address (addr:aa:aa:aa:aa:aa:1b, vlan:0)`
* `bridge0: received packet on veth0_to_bridge with own address as source address (addr:e2:79:e7:04:dc:34, vlan:0)`
The `br_handle_frame` function is the one printing this, which is significant. This means the bridge is *receiving* packets that it's *also* supposed to be forwarding, and the source MACs match the bridge interface's own MAC. This points directly to the loop!
|
| 11/2 |
2026/05/23 13:39 |
tool |
grepper |
0m
Args: map[Expression:received packet on.*with own address as source address]
Results: map[Output:net/bridge/br_fdb.c=989=void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
--
net/bridge/br_fdb.c-1002- if (net_ratelimit())
net/bridge/br_fdb.c:1003: br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
net/bridge/br_fdb.c-1004- source->dev->name, addr, vid);
]
|
| 12/2 |
2026/05/23 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 21311
output: 45
thoughts: 12
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:
**Checking `br_fdb_update`**
Alright, let's take a look at `br_fdb_update`. I need to quickly refresh my mental map of how this function interacts with the rest of the system. I'm assuming it's related to the bridge forwarding database, so I'm already thinking about potential race conditions with other updates, consistency guarantees, and how it handles different types of frame traffic β multicast, unicast, and broadcast. Specifically, I'm going to be checking its locking mechanisms β are they granular enough to prevent bottlenecks without sacrificing data integrity? What about error handling and recovery? Is it robust in the face of unexpected network events like link flaps or ARP storms? I hope the logging is adequate. I'm wondering if there's any obvious performance bottlenecks lurking within the code that haven't been caught in previous testing. Time to dig in and verify my assumptions with a thorough scan.
|
| 13/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/bridge/br_fdb.c IncludeLines:true Name:br_fdb_update]
Results: map[SourceCode: 989: void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
990: const unsigned char *addr, u16 vid, unsigned long flags)
991: {
992: struct net_bridge_fdb_entry *fdb;
993:
994: /* some users want to always flood. */
995: if (hold_time(br) == 0)
996: return;
997:
998: fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
999: if (likely(fdb)) {
1000: /* attempt to update an entry for a local interface */
1001: if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) {
1002: if (net_ratelimit())
1003: br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
1004: source->dev->name, addr, vid);
1005: } else {
1006: unsigned long now = jiffies;
1007: bool fdb_modified = false;
1008:
1009: if (now != READ_ONCE(fdb->updated)) {
1010: WRITE_ONCE(fdb->updated, now);
1011: fdb_modified = __fdb_mark_active(fdb);
1012: }
1013:
1014: /* fastpath: update of existing entry */
1015: if (unlikely(source != READ_ONCE(fdb->dst) &&
1016: !test_bit(BR_FDB_STICKY, &fdb->flags))) {
1017: br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
1018: WRITE_ONCE(fdb->dst, source);
1019: fdb_modified = true;
1020: /* Take over HW learned entry */
1021: if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,
1022: &fdb->flags)))
1023: clear_bit(BR_FDB_ADDED_BY_EXT_LEARN,
1024: &fdb->flags);
1025: /* Clear locked flag when roaming to an
1026: * unlocked port.
1027: */
1028: if (unlikely(test_bit(BR_FDB_LOCKED, &fdb->flags)))
1029: clear_bit(BR_FDB_LOCKED, &fdb->flags);
1030: }
1031:
1032: if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) {
1033: set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
1034: if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED,
1035: &fdb->flags))
1036: atomic_dec(&br->fdb_n_learned);
1037: }
1038: if (unlikely(fdb_modified)) {
1039: trace_br_fdb_update(br, source, addr, vid, flags);
1040: fdb_notify(br, fdb, RTM_NEWNEIGH, true);
1041: }
1042: }
1043: } else {
1044: spin_lock(&br->hash_lock);
1045: fdb = fdb_create(br, source, addr, vid, flags);
1046: if (fdb) {
1047: trace_br_fdb_update(br, source, addr, vid, flags);
1048: fdb_notify(br, fdb, RTM_NEWNEIGH, true);
1049: }
1050: /* else we lose race and someone else inserts
1051: * it first, don't bother updating
1052: */
1053: spin_unlock(&br->hash_lock);
1054: }
1055: }
SourceFile:net/bridge/br_fdb.c]
|
| 14/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 22794
output: 42
thoughts: 148
Thoughts: **Analyzing the Network Loop Warning**
Okay, so I'm seeing this warning, and it's telling me a packet has arrived with a source MAC already known as a local address in the Forwarding Database (FDB). Right away, my expert intuition screams "network loop!" That's the classic indicator. But, I need to understand *why* this is leading to an RCU stall. RCU stalls are serious, they're indicative of a significant problem, so I need to go deeper.
The core of the issue is this: the loop processing is happening in a `softirq` context. If the loop is truly infinite and executed synchronously, well, that's a recipe for disaster. The softirq context won't yield, locking up the CPU and leading to an RCU stall.
Wait a second, what constitutes a *synchronous* loop in this context? I need to think this through carefully. Ah, got it. Consider a `veth` interface. If a packet is transmitted out of a `veth` interface, it's immediately received on the peer `veth` interface within the *same* context if it isn't deferred. That's a perfect example of a synchronous loop condition.
Now, I need to check `veth_xmit`. That's where the answer lies. I need to understand the exact flow to see how this all connects.
|
| 15/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/veth.c IncludeLines:true Name:veth_xmit]
Results: map[SourceCode: 347: static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
348: {
349: struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
350: struct veth_rq *rq = NULL;
351: struct netdev_queue *txq;
352: struct net_device *rcv;
353: int length = skb->len;
354: bool use_napi = false;
355: int ret, rxq;
356:
357: rcu_read_lock();
358: rcv = rcu_dereference(priv->peer);
359: if (unlikely(!rcv) || !pskb_may_pull(skb, ETH_HLEN)) {
360: kfree_skb(skb);
361: goto drop;
362: }
363:
364: rcv_priv = netdev_priv(rcv);
365: rxq = skb_get_queue_mapping(skb);
366: if (rxq < rcv->real_num_rx_queues) {
367: rq = &rcv_priv->rq[rxq];
368:
369: /* The napi pointer is available when an XDP program is
370: * attached or when GRO is enabled
371: * Don't bother with napi/GRO if the skb can't be aggregated
372: */
373: use_napi = rcu_access_pointer(rq->napi) &&
374: veth_skb_is_eligible_for_gro(dev, rcv, skb);
375: }
376:
377: skb_tx_timestamp(skb);
378:
379: ret = veth_forward_skb(rcv, skb, rq, use_napi);
380: switch (ret) {
381: case NET_RX_SUCCESS: /* same as NETDEV_TX_OK */
382: if (!use_napi)
383: dev_sw_netstats_tx_add(dev, 1, length);
384: else
385: __veth_xdp_flush(rq);
386: break;
387: case NETDEV_TX_BUSY:
388: /* If a qdisc is attached to our virtual device, returning
389: * NETDEV_TX_BUSY is allowed.
390: */
391: txq = netdev_get_tx_queue(dev, rxq);
392:
393: if (qdisc_txq_has_no_queue(txq)) {
394: dev_kfree_skb_any(skb);
395: goto drop;
396: }
397: /* Restore Eth hdr pulled by dev_forward_skb/eth_type_trans */
398: __skb_push(skb, ETH_HLEN);
399: netif_tx_stop_queue(txq);
400: /* Makes sure NAPI peer consumer runs. Consumer is responsible
401: * for starting txq again, until then ndo_start_xmit (this
402: * function) will not be invoked by the netstack again.
403: */
404: __veth_xdp_flush(rq);
405: break;
406: case NET_RX_DROP: /* same as NET_XMIT_DROP */
407: drop:
408: atomic64_inc(&priv->dropped);
409: ret = NET_XMIT_DROP;
410: break;
411: default:
412: net_crit_ratelimited("%s(%s): Invalid return code(%d)",
413: __func__, dev->name, ret);
414: }
415: rcu_read_unlock();
416:
417: return ret;
418: }
SourceFile:drivers/net/veth.c]
|
| 16/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 24478
output: 44
thoughts: 27
Thoughts: Okay, here's my summary, presented as a stream of thought:
**Kernel Packet Reception Path - The veth_forward_skb Question**
Alright, let's break this down. My focus right now is that `veth_forward_skb` function. I need to understand its role in the packet forwarding process, specifically where that incoming packet ends up within the network stack. The core of this question boils down to *how* the packet is delivered to the upper layers once it arrives on the veth interface.
My understanding is that veth is a virtual Ethernet pair, acting as a bridge between network namespaces or containers, right? So, when `veth_forward_skb` is called, itβs about taking a packet that has arrived on one end of the veth pair and delivering it to the other.
So, *how* does it do that delivery? Does it use `netif_rx`? Or perhaps the newer, possibly more efficient `netif_receive_skb`? I need to clarify this specific point because the choice of function has implications for how interrupts are handled, the data copying/sharing, and overall network performance.
Are there specific performance differences in the usage? Where is the packet in the queue when `netif_rx` or `netif_receive_skb` is used? Are there scenarios where one is preferred over the other on the reception side? I need to analyze the code paths and any related documentation to confirm the exact function used and understand *why* that specific function was chosen in the context of `veth_forward_skb`. I need to think about the typical use cases and how these functions interact.
|
| 17/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/veth.c IncludeLines:true Name:veth_forward_skb]
Results: map[SourceCode: 320: static int veth_forward_skb(struct net_device *dev, struct sk_buff *skb,
321: struct veth_rq *rq, bool xdp)
322: {
323: return __dev_forward_skb(dev, skb) ?: xdp ?
324: veth_xdp_rx(rq, skb) :
325: __netif_rx(skb);
326: }
SourceFile:drivers/net/veth.c]
|
| 18/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 25065
output: 42
thoughts: 207
Thoughts: **My Analysis of the Network Packet Reception Path**
Okay, so `__netif_rx(skb)`... right, it *queues* the incoming packet to the backlog queue specific to the current CPU. Important distinction: it doesn't process it right then and there. It kicks off a softirq, which is the key. So, if itβs on the backlog, `process_backlog` must be the processor.
Now, where does `process_backlog` fit in? Ah, yes, it's called from `net_rx_action`. Got it. `net_rx_action` seems to be the main receiver loop, processing packets up to a `netdev_budget` limit, which is 300, it looks like. Then it returns, which is crucial for overall system responsiveness. That makes sense, keeps things from monopolizing the CPU.
But... if `net_rx_action` returns, it *re-arms* the softirq. Hmm, that suggests a loop, doesnβt it? If the softirq is armed and we're inside `do_softirq`, triggered by `local_bh_enable`, would `do_softirq` just spin? No, no, that canβt be right. `do_softirq` is definitely not an infinite loop. So, it calls `__do_softirq`, which I need to check out more closely. Time to dive into `__do_softirq` and understand what it does.
|
| 19/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/softirq.c IncludeLines:true Name:__do_softirq]
Results: map[SourceCode: 654: asmlinkage __visible void __softirq_entry __do_softirq(void)
655: {
656: handle_softirqs(false);
657: }
SourceFile:kernel/softirq.c]
|
| 20/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 25733
output: 41
thoughts: 11
Thoughts: Okay, here's my attempt at summarizing the thought process, as if I were thinking it:
**Diving into `handle_softirqs`**
Right, let's take a look at `handle_softirqs`. I need to refresh my understanding of how this crucial function operates. It's the core of soft interrupt handling, so pinpointing the flow and any potential bottlenecks is key. I'll need to remember the interrupt context, how the softirq vectors are processed, and the interactions with the scheduler. I'll mentally map the code in my head, focusing on things like the `irq_work` mechanism, any lock contention that might arise, and potential race conditions. I'm going to want to verify the atomic operations used to protect shared data structures and ensure they are all correctly implemented. Any potential issues with nested softirq calls are of particular interest. Let's see how well it scales under load, the interrupt latency. I want to look at where the priorities are set and how the system responds to changing load conditions. Essentially, I'm thinking about the entire softirq processing chain and mentally simulating how it behaves under varying circumstances.
|
| 21/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/softirq.c IncludeLines:true Name:handle_softirqs]
Results: map[SourceCode: 579: static void handle_softirqs(bool ksirqd)
580: {
581: unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
582: unsigned long old_flags = current->flags;
583: int max_restart = MAX_SOFTIRQ_RESTART;
584: struct softirq_action *h;
585: bool in_hardirq;
586: __u32 pending;
587: int softirq_bit;
588:
589: /*
590: * Mask out PF_MEMALLOC as the current task context is borrowed for the
591: * softirq. A softirq handled, such as network RX, might set PF_MEMALLOC
592: * again if the socket is related to swapping.
593: */
594: current->flags &= ~PF_MEMALLOC;
595:
596: pending = local_softirq_pending();
597:
598: softirq_handle_begin();
599: in_hardirq = lockdep_softirq_start();
600: account_softirq_enter(current);
601:
602: restart:
603: /* Reset the pending bitmask before enabling irqs */
604: set_softirq_pending(0);
605:
606: local_irq_enable();
607:
608: h = softirq_vec;
609:
610: while ((softirq_bit = ffs(pending))) {
611: unsigned int vec_nr;
612: int prev_count;
613:
614: h += softirq_bit - 1;
615:
616: vec_nr = h - softirq_vec;
617: prev_count = preempt_count();
618:
619: kstat_incr_softirqs_this_cpu(vec_nr);
620:
621: trace_softirq_entry(vec_nr);
622: h->action();
623: trace_softirq_exit(vec_nr);
624: if (unlikely(prev_count != preempt_count())) {
625: pr_err("huh, entered softirq %u %s %p with preempt_count %08x, exited with %08x?\n",
626: vec_nr, softirq_to_name[vec_nr], h->action,
627: prev_count, preempt_count());
628: preempt_count_set(prev_count);
629: }
630: h++;
631: pending >>= softirq_bit;
632: }
633:
634: if (!IS_ENABLED(CONFIG_PREEMPT_RT) && ksirqd)
635: rcu_softirq_qs();
636:
637: local_irq_disable();
638:
639: pending = local_softirq_pending();
640: if (pending) {
641: if (time_before(jiffies, end) && !need_resched() &&
642: --max_restart)
643: goto restart;
644:
645: wakeup_softirqd();
646: }
647:
648: account_softirq_exit(current);
649: lockdep_softirq_end(in_hardirq);
650: softirq_handle_end();
651: current_restore_flags(old_flags, PF_MEMALLOC);
652: }
SourceFile:kernel/softirq.c]
|
| 22/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 27137
output: 45
thoughts: 756
Thoughts: **Analyzing a Potential Softlockup**
Okay, so I'm looking at this softlockup, and initially, the `handle_softirqs` function caught my eye. It loops for up to 10 iterations, or until 2 jiffies have passed, then calls `wakeup_softirqd()` and returns. This seems safe in itself β it *shouldn't* cause a stall or softlockup because of the time limit. The function returns, and `__local_bh_enable_ip` does as well, letting the task continue.
But then I see the stack trace: `__batadv_dat_purge` is involved, and it's calling `__local_bh_enable_ip`. And `__local_bh_enable_ip` calls `do_softirq` which, in turn, calls `handle_softirqs`. So if `handle_softirqs` returns, `__local_bh_enable_ip` *should* return. Why is it stuck in `fib6_node_lookup_1`? That's the key.
Could there be a loop *within* `fib6_node_lookup_1`? Let's look at the code again. Ah, there's that loop:
```c
for (;;) {
struct fib6_node *next;
dir = addr_bit_set(args->addr, fn->fn_bit);
next = dir ? rcu_dereference(fn->right) :
rcu_dereference(fn->left);
if (next) {
fn = next;
continue;
}
break;
}
```
If that tree has a cycle, this loop goes on forever! Is that possible? Could there be a bug where a cycle somehow gets created in the `fib6` tree? It's the only real explanation for what I'm seeing. The stack trace indicates it's right at this line: `next = dir ? rcu_dereference(fn->right) : rcu_dereference(fn->left);`
But the `next` pointer isn't NULL; it's going down the tree. It could be a very *deep* tree, but the maximum depth of a `fib6` tree is only 128 (IPv6 is 128 bits). And then I remember about `fn->fn_bit`. If there *were* a cycle, `fn->fn_bit` wouldn't be strictly increasing. Is there a known bug where the tree gets a cycle? I need to check that.
Or, is this NOT a cycle? Could the softlockup be caused by a packet loop that's processed *synchronously*?
But wait! I was thinking that `__netif_rx` queues the packet and returns, but I think the problem is that `br_pass_frame_up` calls `netif_receive_skb` which does *not* behave like that!
|
| 23/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/bridge/br_input.c IncludeLines:true Name:br_pass_frame_up]
Results: map[SourceCode: 33: static int br_pass_frame_up(struct sk_buff *skb, bool promisc)
34: {
35: struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev;
36: struct net_bridge *br = netdev_priv(brdev);
37: struct net_bridge_vlan_group *vg;
38:
39: dev_sw_netstats_rx_add(brdev, skb->len);
40:
41: vg = br_vlan_group_rcu(br);
42:
43: /* Reset the offload_fwd_mark because there could be a stacked
44: * bridge above, and it should not think this bridge it doing
45: * that bridge's work forwarding out its ports.
46: */
47: br_switchdev_frame_unmark(skb);
48:
49: /* Bridge is just like any other port. Make sure the
50: * packet is allowed except in promisc mode when someone
51: * may be running packet capture.
52: */
53: if (!(brdev->flags & IFF_PROMISC) &&
54: !br_allowed_egress(vg, skb)) {
55: kfree_skb(skb);
56: return NET_RX_DROP;
57: }
58:
59: indev = skb->dev;
60: skb->dev = brdev;
61: skb = br_handle_vlan(br, NULL, vg, skb);
62: if (!skb)
63: return NET_RX_DROP;
64: /* update the multicast stats if the packet is IGMP/MLD */
65: br_multicast_count(br, NULL, skb, br_multicast_igmp_type(skb),
66: BR_MCAST_DIR_TX);
67:
68: BR_INPUT_SKB_CB(skb)->promisc = promisc;
69:
70: return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
71: dev_net(indev), NULL, skb, indev, NULL,
72: br_netif_receive_skb);
73: }
SourceFile:net/bridge/br_input.c]
|
| 24/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 29282
output: 47
thoughts: 27
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this networking area:
**Analyzing the Bridge Receive Path**
Right, so `br_pass_frame_up` is a key function in the bridging code, and I need to understand its role. It's immediately evident that this function is where the network frame begins its ascent through the network stack. Specifically, it uses `NF_HOOK` which is how the kernel's Netfilter subsystem gets involved. The critical detail here is that `br_pass_frame_up` is invoking `NF_HOOK` with `br_netif_receive_skb`. So the bridge is intercepting the frame, which is expected. The fact that `br_netif_receive_skb` is the hook function means that this is where the bridging logic will interact with the frame, likely deciding whether to forward it, drop it, or send it to userspace, based on the bridge's configuration and learning state. This highlights the modular and extensible nature of the Netfilter framework that the kernel provides. The bridge, by using `NF_HOOK`, can allow for further processing of the frame via iptables, connection tracking, etc. I need to now examine the code for `br_netif_receive_skb` to be certain, to fully understand how this process works.
|
| 25/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/bridge/br_input.c IncludeLines:true Name:br_netif_receive_skb]
Results: map[SourceCode: 26: static int
27: br_netif_receive_skb(struct net *net, struct sock *sk, struct sk_buff *skb)
28: {
29: br_drop_fake_rtable(skb);
30: return netif_receive_skb(skb);
31: }
SourceFile:net/bridge/br_input.c]
|
| 26/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 29767
output: 41
thoughts: 273
Thoughts: **My Analysis of Packet Reception in the Linux Kernel**
Okay, so I'm tracing the path a packet takes when it's received. Right, `netif_receive_skb` seems to handle the initial reception synchronously, that much is clear. Diving deeper, it calls `__netif_receive_skb`, which then calls `__netif_receive_skb_core`. Makes sense, the core logic should be in there. If it's an IPv6 packet, we're off to `ipv6_rcv`. From there, `ipv6_rcv` triggers the pre-routing Netfilter hook with `NF_HOOK`. If something like `ip_sabotage_in` intercepts the packet, it hands it off to `ip6_rcv_finish`.
Right, `ip6_rcv_finish` kicks off the routing process with `ip6_route_input`, which does the FIB lookup for IPv6. Then the routing happens, and if the destination is a local interface, it might be transmitted. Now, if it's going out over a virtual ethernet (veth) interface, `veth_xmit` is called, and that calls `veth_forward_skb`, which ends up calling either `__netif_rx(skb)` or `veth_xdp_rx`.
But waitβ¦ something's not sitting right. *`__netif_rx` doesn't seem to process the packet immediately!* It queues it to the backlog! That means itβs asynchronous. The transmission isn't synchronous after all. Need to verify that `__netif_rx` call. It's time to double-check my understanding of how `__netif_rx` works; asynchronous packet processing is not what I was expecting at this stage.
|
| 27/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/dev.c IncludeLines:true Name:__netif_rx]
Results: map[SourceCode:5679: /**
5680: * __netif_rx - Slightly optimized version of netif_rx
5681: * @skb: buffer to post
5682: *
5683: * This behaves as netif_rx except that it does not disable bottom halves.
5684: * As a result this function may only be invoked from the interrupt context
5685: * (either hard or soft interrupt).
5686: */
5687: int __netif_rx(struct sk_buff *skb)
5688: {
5689: int ret;
5690:
5691: lockdep_assert_once(hardirq_count() | softirq_count());
5692:
5693: trace_netif_rx_entry(skb);
5694: ret = netif_rx_internal(skb);
5695: trace_netif_rx_exit(ret);
5696: return ret;
5697: }
SourceFile:net/core/dev.c]
|
| 28/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 30785
output: 42
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in network driver internals:
**Processing Incoming Network Packets**
Right, so `netif_rx_internal` is the core function for receiving packets. It's essentially the entry point, the first place the incoming data hits. My mind instantly goes to where the rubber meets the road: what happens *after* the initial receive process? It's clear that it calls `enqueue_to_backlog`. That function is the workhorse here, isn't it? It means that, after initial checks and maybe some basic processing within `netif_rx_internal`, the packet is being slated for further handling. It's not processed immediately; it's being added to a queue. I need to keep in mind which backlog queue. If it is global or per cpu, and how that impacts performance.
This is critical to how the driver handles network congestion and prioritizes traffic.
|
| 29/2 |
2026/05/23 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/dev.c IncludeLines:true Name:netif_rx_internal]
Results: map[SourceCode:5647: static int netif_rx_internal(struct sk_buff *skb)
5648: {
5649: int ret;
5650:
5651: net_timestamp_check(READ_ONCE(net_hotdata.tstamp_prequeue), skb);
5652:
5653: trace_netif_rx(skb);
5654:
5655: #ifdef CONFIG_RPS
5656: if (static_branch_unlikely(&rps_needed)) {
5657: struct rps_dev_flow voidflow, *rflow = &voidflow;
5658: int cpu;
5659:
5660: rcu_read_lock();
5661:
5662: cpu = get_rps_cpu(skb->dev, skb, &rflow);
5663: if (cpu < 0)
5664: cpu = smp_processor_id();
5665:
5666: ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
5667:
5668: rcu_read_unlock();
5669: } else
5670: #endif
5671: {
5672: unsigned int qtail;
5673:
5674: ret = enqueue_to_backlog(skb, smp_processor_id(), &qtail);
5675: }
5676: return ret;
5677: }
SourceFile:net/core/dev.c]
|
| 30/2 |
2026/05/23 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 31503
output: 28
thoughts: 403
Thoughts: **Analyzing Potential RCU Stall**
Okay, so `enqueue_to_backlog` clearly puts the packet onto the CPU's backlog queue. That means it *isn't* processed synchronously. It'll get handled by `process_backlog` later. Right, and `process_backlog` is called from `net_rx_action`. Got it. `net_rx_action` processes up to the `netdev_budget` of 300 packets. Hmm, if there's a packet loop, `net_rx_action` processes 300, then returns. Then, `handle_softirqs` loops up to 10 times, processing a total of 3000 packets. And then, finally, `handle_softirqs` returns, calls `wakeup_softirqd()`, and then `__local_bh_enable_ip` *should* return. So, a softirq shouldn't run forever... So, why am I seeing an RCU stall?
Hold on. `__local_bh_enable_ip` calls `do_softirq`, which calls `__do_softirq`. If `__do_softirq` returns, then `__local_bh_enable_ip` returns. But wait... what if `__local_bh_enable_ip` is called with interrupts disabled? No, `spin_unlock_bh` doesn't disable interrupts. Okay, scratch that. Then, what is the problem?
Wait a second... could there be a loop *within* `fib6_node_lookup_1`? If there's a cycle in `fib6_node_lookup_1`, it would loop infinitely *inside* that function! I need to check for a known bug in either `fib6_node_lookup_1` or maybe `fib6_add`. That's where I need to look.
|
| 31/2 |
2026/05/23 13:41 |
tool |
git-log |
0m
Args: map[MessageRegexps:[fib6 loop rcu]]
Results: map[Output:2ffb4f5c2ccb ipv6: fix NULL pointer deref in ip6_rt_get_dev_rcu()
f8d8ce1b515a ipv6: fix possible infinite loop in fib6_info_uses_dev()
54e6fe9dd3b0 ipv6: prevent infinite loop in rt6_nlmsg_size()
71c0efb6d12f ipv6: Factorise ip6_route_multipath_add().
d9ccb18f83ea ipv6: Fix soft lockups in fib6_select_path under high next hop churn
5a08d0065a91 ipv6: add debug checks in fib6_info_release()
821bbf79fe46 ipv6: Fix KASAN: slab-out-of-bounds Read in fib6_nh_flush_exceptions
28259bac7f1d ipv6: fix suspecious RCU usage warning
843d926b003e ipv6: avoid lockdep issue in fib6_del()
1bfa26ff8c4b ipv6: fix possible deadlock in rt6_age_examine_exception()
]
|
| 32/2 |
2026/05/23 13:41 |
llm |
expert |
0m
Model:
Tokens:
input: 32640
output: 25
thoughts: 19
Thoughts: Here's my thought process, as if I were considering those search terms:
**Delving into Code with a Purpose**
Okay, so I'm thinking, let's start digging into the codebase. I want to understand how a specific function is used and its relationship to a specific construct. My initial instinct is to search for the function `fib6_node_lookup_1`. I'm specifically interested in how this function is *used*, and I suspect that usage will involve some sort of iterative process or repetition. That's why the term `loop` is also in my mind. The search with those two terms will likely help me quickly identify the areas of code that are most relevant to what I'm trying to figure out. I can narrow down my search by exploring the loops around it. I'm expecting some patterns emerge.
|
| 33/2 |
2026/05/23 13:41 |
tool |
git-log |
0m
Args: map[MessageRegexps:[fib6_node_lookup_1]]
Results: map[Output:88209141392a netfilter: nft_fib_netdev: Terminate rule eval if protocol=IPv6 and ipv6 module is disabled
]
|
| 34/2 |
2026/05/23 13:41 |
llm |
expert |
0m
Model:
Tokens:
input: 32911
output: 40
thoughts: 1036
Thoughts: **Analyzing a Potential Network Routing Issue**
Okay, first things first, I need to figure out why this `fib6_node_lookup_1` function might be hanging. The stack trace points to a potential infinite loop within the tree traversal. If `fib6_node_lookup_1` is looping, that implies a cycle in the routing tree itself. Now, how could that happen? Is the `args->offset` potentially zero, which would cause an immediate return? Nope, there's a check for that. Could the `fn->fn_bit` not be strictly increasing, leading to a loop being constructed during the addition process? It's possible `fib6_add` messed up and introduced a cycle, but I need to dive deeper.
But wait, `fib6_node_lookup_1` is just a standard tree traversal using left and right pointers based on bit values. If `next` points back to an ancestor, that's where the loop happens. So, the only way I can see this looping is if `next` somehow got set to point to a previously visited node. That means there's a likely bug in `fib6_add` or `fib6_del`. The function is calling `rcu_dereference` to get the next node.
The stack trace points to the `rcu_dereference` line. If it's stuck there, it's either an infinite loop in the tree or perhaps it's a softlockup due to a packet loop, where the CPU is just spending most of its time in this function. But I know `handle_softirqs` returns after a short period, so an RCU stall seems unlikely.
However, I just realized that `handle_softirqs` returns, but what if the packet loop *isn't* going through `netif_rx`? What if the loop is actually synchronous? I need to trace this packet loop again. The logs show packets looping between `bridge_slave_0` and `veth0_to_bridge`. These interfaces are both on a bridge. A packet is received on `bridge_slave_0`, the bridge forwards it to `veth0_to_bridge`, which in turn calls `dev_queue_xmit`. `dev_queue_xmit` then calls `veth_xmit`. But `veth_xmit` doesn't immediately send the packet. It calls `veth_forward_skb`, which calls `__netif_rx` (unless XDP is in use), and that queues the packet to the backlog.
So, the loop isn't synchronous! The backlog queue is in use, and there is an asynchronous processing aspect.
Here's the sequence:
1. `process_backlog` dequeues a packet.
2. `__netif_receive_skb` processes it.
3. The bridge forwards it to veth.
4. `veth_xmit` queues it to the backlog.
5. `process_backlog` continues.
But here's the kicker: If `veth_xmit` queues the packet to the SAME CPU's backlog queue, the backlog queue will just grow! However, there's a `quota` in `process_backlog`, which limits the number of packets processed, so the growth isn't unlimited.
|
| 35/2 |
2026/05/23 13:42 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/dev.c IncludeLines:true Name:process_backlog]
Results: map[SourceCode:6606: static int process_backlog(struct napi_struct *napi, int quota)
6607: {
6608: struct softnet_data *sd = container_of(napi, struct softnet_data, backlog);
6609: bool again = true;
6610: int work = 0;
6611:
6612: /* Check if we have pending ipi, its better to send them now,
6613: * not waiting net_rx_action() end.
6614: */
6615: if (sd_has_rps_ipi_waiting(sd)) {
6616: local_irq_disable();
6617: net_rps_action_and_irq_enable(sd);
6618: }
6619:
6620: napi->weight = READ_ONCE(net_hotdata.dev_rx_weight);
6621: while (again) {
6622: struct sk_buff *skb;
6623:
6624: local_lock_nested_bh(&softnet_data.process_queue_bh_lock);
6625: while ((skb = __skb_dequeue(&sd->process_queue))) {
6626: local_unlock_nested_bh(&softnet_data.process_queue_bh_lock);
6627: rcu_read_lock();
6628: __netif_receive_skb(skb);
6629: rcu_read_unlock();
6630: if (++work >= quota) {
6631: rps_input_queue_head_add(sd, work);
6632: return work;
6633: }
6634:
6635: local_lock_nested_bh(&softnet_data.process_queue_bh_lock);
6636: }
6637: local_unlock_nested_bh(&softnet_data.process_queue_bh_lock);
6638:
6639: backlog_lock_irq_disable(sd);
6640: if (skb_queue_empty(&sd->input_pkt_queue)) {
6641: /*
6642: * Inline a custom version of __napi_complete().
6643: * only current cpu owns and manipulates this napi,
6644: * and NAPI_STATE_SCHED is the only possible flag set
6645: * on backlog.
6646: * We can use a plain write instead of clear_bit(),
6647: * and we dont need an smp_mb() memory barrier.
6648: */
6649: napi->state &= NAPIF_STATE_THREADED;
6650: again = false;
6651: } else {
6652: local_lock_nested_bh(&softnet_data.process_queue_bh_lock);
6653: skb_queue_splice_tail_init(&sd->input_pkt_queue,
6654: &sd->process_queue);
6655: local_unlock_nested_bh(&softnet_data.process_queue_bh_lock);
6656: }
6657: backlog_unlock_irq_enable(sd);
6658: }
6659:
6660: if (work)
6661: rps_input_queue_head_add(sd, work);
6662: return work;
6663: }
SourceFile:net/core/dev.c]
|
| 36/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 35678
output: 49
thoughts: 500
Thoughts: **RCU Stall Investigation**
Okay, here's what I'm thinking... The `process_backlog` function returns `work` when it hits its `quota`. Then the `net_rx_action` function, seeing that `process_backlog` returned `quota`, will keep the NAPI in the poll list, and keep polling other NAPIs. Eventually, `net_rx_action` will either hit its budget (300) or time limit (2 jiffies) and return. Then `handle_softirqs` is called, looping up to 10 times or 2 jiffies. After that loop, `handle_softirqs` returns, calling `wakeup_softirqd()`. Finally, `__local_bh_enable_ip` is called and returns. This *should* mean the softirq loop terminates and yields to the task.
But... if the softirq loop terminates, why am I seeing this RCU stall? That's the real question. Returning from softirq context should allow the task to resume. Wait, maybe the problem is the task itself? Could the task be stuck in a loop calling `local_bh_enable`? No, the task is `kworker/R-bat_e` executing `batadv_dat_purge`.
`batadv_dat_purge` calls `spin_unlock_bh`, which then calls `__local_bh_enable_ip`. Okay, so once `__local_bh_enable_ip` returns, `batadv_dat_purge` should finish and return. The worker thread then should process the next work item or sleep. So, the worker thread is NOT in an infinite loop. So again, why the stall?
The error message says "rcu: rcu_preempt kthread starved for 1348 jiffies!". That means the CPU hasn't reached a quiescent state in 13.48 seconds. If `handle_softirqs` returns, does *that* mean it's a quiescent state? No, not automatically. Returning from softirq to the task context doesn't guarantee a quiescent state unless the task is preempted or calls `schedule()`. But... `batadv_dat_purge` is a workqueue function. When *it* returns, the worker thread *will* call `cond_resched()` or `schedule()`, which *is* a quiescent state!
Wait... is it possible `batadv_dat_purge` *itself* is stuck in a loop? That is where I must focus.
|
| 37/2 |
2026/05/23 13:42 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/distributed-arp-table.c IncludeLines:true Name:batadv_dat_purge]
Results: map[SourceCode: 189: /**
190: * batadv_dat_purge() - periodic task that deletes old entries from the local
191: * DAT hash table
192: * @work: kernel work struct
193: */
194: static void batadv_dat_purge(struct work_struct *work)
195: {
196: struct delayed_work *delayed_work;
197: struct batadv_priv_dat *priv_dat;
198: struct batadv_priv *bat_priv;
199:
200: delayed_work = to_delayed_work(work);
201: priv_dat = container_of(delayed_work, struct batadv_priv_dat, work);
202: bat_priv = container_of(priv_dat, struct batadv_priv, dat);
203:
204: __batadv_dat_purge(bat_priv, batadv_dat_to_purge);
205: batadv_dat_start_timer(bat_priv);
206: }
SourceFile:net/batman-adv/distributed-arp-table.c]
|
| 38/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 37112
output: 50
thoughts: 13
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing `__batadv_dat_purge`**
Alright, let's dive into this `__batadv_dat_purge` function. I need to refresh my understanding of its role in BATMAN-adv's data management. I'm assuming it's related to purging stale or expired data, likely related to forwarding tables, originator tables, or perhaps even mesh link information. My immediate thoughts go to considerations around synchronization and locking; itβs a critical section, and any incorrect handling there could lead to significant performance issues or even data corruption in the mesh. Iβll need to understand the criteria used for purging β is it based on timestamps, sequence numbers, TTLs, or a combination? And, most importantly, I want to get a picture of how the garbage collection interacts with network events and overall performance.
|
| 39/2 |
2026/05/23 13:42 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/distributed-arp-table.c IncludeLines:true Name:__batadv_dat_purge]
Results: map[SourceCode: 146: /**
147: * __batadv_dat_purge() - delete entries from the DAT local storage
148: * @bat_priv: the bat priv with all the mesh interface information
149: * @to_purge: function in charge to decide whether an entry has to be purged or
150: * not. This function takes the dat_entry as argument and has to
151: * returns a boolean value: true is the entry has to be deleted,
152: * false otherwise
153: *
154: * Loops over each entry in the DAT local storage and deletes it if and only if
155: * the to_purge function passed as argument returns true.
156: */
157: static void __batadv_dat_purge(struct batadv_priv *bat_priv,
158: bool (*to_purge)(struct batadv_dat_entry *))
159: {
160: spinlock_t *list_lock; /* protects write access to the hash lists */
161: struct batadv_dat_entry *dat_entry;
162: struct hlist_node *node_tmp;
163: struct hlist_head *head;
164: u32 i;
165:
166: if (!bat_priv->dat.hash)
167: return;
168:
169: for (i = 0; i < bat_priv->dat.hash->size; i++) {
170: head = &bat_priv->dat.hash->table[i];
171: list_lock = &bat_priv->dat.hash->list_locks[i];
172:
173: spin_lock_bh(list_lock);
174: hlist_for_each_entry_safe(dat_entry, node_tmp, head,
175: hash_entry) {
176: /* if a helper function has been passed as parameter,
177: * ask it if the entry has to be purged or not
178: */
179: if (to_purge && !to_purge(dat_entry))
180: continue;
181:
182: hlist_del_rcu(&dat_entry->hash_entry);
183: batadv_dat_entry_put(dat_entry);
184: }
185: spin_unlock_bh(list_lock);
186: }
187: }
SourceFile:net/batman-adv/distributed-arp-table.c]
|
| 40/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 38095
output: 49
thoughts: 576
Thoughts: **RCU Stall Investigation: A Deep Dive into `__batadv_dat_purge`**
Okay, let's break this down. My initial observation is that `__batadv_dat_purge` is looping over a hash table, and it's using `spin_lock_bh` and `spin_unlock_bh` on *each* bucket. The immediate red flag is that `spin_unlock_bh` has the potential to trigger softirq processing. If we're seeing a packet storm, which is likely the trigger for all of this, then `spin_unlock_bh` *will* process softirqs.
Specifically, `spin_unlock_bh` calls `__local_bh_enable_ip`, which in turn, invokes `do_softirq` if any softirqs are pending. And, due to the packet storm, they absolutely *will* be pending. Now, here's the kicker: `do_softirq` is limited to processing either 3000 packets or 2 jiffies before returning. This means that for each bucket processed, we spend a potentially significant amount of time β potentially 2 jiffies β handling softirqs.
Now, imagine a hash table with a substantial number of buckets, say 1024. If we spend 2 jiffies per bucket, the total time in `__batadv_dat_purge` could balloon to 2048 jiffies! That's 20.48 seconds at HZ=100 or 2.048 seconds at HZ=1000. Then, I remembered the RCU stall being at 1348 jiffies - so this theory seems quite sound.
The critical piece here is the lack of a yield. The task executing `__batadv_dat_purge` *never* calls `schedule()` or `cond_resched()`. It's not relinquishing the CPU, and therefore, it's not entering a quiescent state. This means if there's a constant packet storm, `__batadv_dat_purge` will take an absurd amount of time to complete, essentially bogging down the CPU. Because at *every* bucket it processes softirqs for up to 2 jiffies.
Therefore, this explains the RCU stall perfectly! The CPU gets stuck in `__batadv_dat_purge`, constantly locking a bucket, processing softirqs for up to 2 jiffies, then repeating. The absence of `cond_resched()` means the task never reaches an RCU quiescent state, causing the RCU stall! Now, let's check the size of `bat_priv->dat.hash->size` and confirm our suspicions!
|
| 41/2 |
2026/05/23 13:42 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/distributed-arp-table.c IncludeLines:true Name:batadv_dat_init]
Results: map[SourceCode: 802: /**
803: * batadv_dat_init() - initialise the DAT internals
804: * @bat_priv: the bat priv with all the mesh interface information
805: *
806: * Return: 0 in case of success, a negative error code otherwise
807: */
808: int batadv_dat_init(struct batadv_priv *bat_priv)
809: {
810: if (bat_priv->dat.hash)
811: return 0;
812:
813: bat_priv->dat.hash = batadv_hash_new(1024);
814:
815: if (!bat_priv->dat.hash)
816: return -ENOMEM;
817:
818: INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
819: batadv_dat_start_timer(bat_priv);
820:
821: batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,
822: NULL, NULL, BATADV_TVLV_DAT, 1,
823: BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
824: batadv_dat_tvlv_container_update(bat_priv);
825: return 0;
826: }
SourceFile:net/batman-adv/distributed-arp-table.c]
|
| 42/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 39755
output: 47
thoughts: 310
Thoughts: **Analyzing a Potential RCU Stall in batadv**
Okay, so the hash table size is 1024, got it. That means `__batadv_dat_purge` iterates 1024 times. And in each loop, it calls `spin_unlock_bh`. Now, if we're dealing with a packet storm, like a bridging loop, that `spin_unlock_bh` is going to trigger softirq processing. The `handle_softirqs` function gets called and processes those softirqs. And remember, that has a time limit, up to `MAX_SOFTIRQ_TIME`, which is 2 jiffies.
So, each iteration in the loop takes 2 jiffies. 1024 iterations times 2 jiffies equals a whopping 2048 jiffies! The problem here is that during those 2048 jiffies, the CPU *isn't* hitting a quiescent state. It's just churning through a workqueue function, no `cond_resched()`. Bingo β this is where the RCU stall warning comes from! The kernel is complaining that "rcu: rcu_preempt kthread starved for 1348 jiffies!"
Now, the important question: is this a security vulnerability? It's not a remote code execution, but it's definitely a Denial of Service (DoS). A network packet storm, specifically a bridging loop, is the trigger. And thinking about it, an unprivileged user in a user namespace can *definitely* create a bridging loop. They can set up a bridge, create veth pairs, and connect them, effectively looping the traffic. But can they create a batman-adv interface in that same user namespace? That's the key question, the attack vector... I need to verify that.
|
| 43/2 |
2026/05/23 13:42 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/soft-interface.c IncludeLines:true Name:batadv_link_ops]
Results: map[SourceCode:1124: struct rtnl_link_ops batadv_link_ops __read_mostly = {
1125: .kind = "batadv",
1126: .priv_size = sizeof(struct batadv_priv),
1127: .setup = batadv_meshif_init_early,
1128: .maxtype = IFLA_BATADV_MAX,
1129: .policy = batadv_ifla_policy,
1130: .validate = batadv_meshif_validate,
1131: .newlink = batadv_meshif_newlink,
1132: .dellink = batadv_meshif_destroy_netlink,
1133: };
SourceFile:net/batman-adv/mesh-interface.c]
|
| 44/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 40734
output: 43
thoughts: 36
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Navigating the Batadv Network Namespace Integration**
Hmm, so I'm looking at the `batadv_link_ops` structure again, trying to wrap my head around this network namespace integration, and I have a nagging feeling. I expected to find a `netns_refund` or something similar defined within this structure, but it's not there. This seems a bit⦠uncharacteristic. Are there perhaps other mechanisms at play here?
The immediate question that springs to mind is, okay, if it's not handled directly in `batadv_link_ops`, then how is it handled. Is `batadv_link_ops` actually registered with `rtnl_link_register`? That's the key. That registration is the common entry point for link device and link attribute operation callbacks. Checking the registration might give some clues. And if it _is_ registered, where are the callbacks? I'll probably need to chase that down to see how they manage namespace handling in this particular context. This could be using a completely different mechanism, or it could be relying on the core link functionality. Either way, that's where I need to dig next.
|
| 45/2 |
2026/05/23 13:42 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/main.c IncludeLines:true Name:batadv_init]
Results: map[SourceCode: 89: static int __init batadv_init(void)
90: {
91: int ret;
92:
93: ret = batadv_tt_cache_init();
94: if (ret < 0)
95: return ret;
96:
97: INIT_LIST_HEAD(&batadv_hardif_list);
98: batadv_algo_init();
99:
100: batadv_recv_handler_init();
101:
102: batadv_v_init();
103: batadv_iv_init();
104: batadv_tp_meter_init();
105:
106: batadv_event_workqueue = create_singlethread_workqueue("bat_events");
107: if (!batadv_event_workqueue)
108: goto err_create_wq;
109:
110: register_netdevice_notifier(&batadv_hard_if_notifier);
111: rtnl_link_register(&batadv_link_ops);
112: batadv_netlink_register();
113:
114: pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
115: BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
116:
117: return 0;
118:
119: err_create_wq:
120: batadv_tt_cache_destroy();
121:
122: return -ENOMEM;
123: }
SourceFile:net/batman-adv/main.c]
|
| 46/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 41583
output: 24
thoughts: 169
Thoughts: **Analyzing the `batadv` Link Registration**
Okay, so I see the `rtnl_link_register(&batadv_link_ops);` call. My initial thought is, "Right, that registers the `batadv` link operations, good." But then the question arises β is this registration limited to the initial network namespace, or is it global? I immediately start thinking about whether `batadv_link_ops` implements something like `netns_refund`. If it *doesn't* have such a mechanism, does that imply it's available in all namespaces?
Wait a second⦠I'm remembering that `rtnl_link_register` *does* register link operations globally unless a `netns_refund` equivalent is present, or a similar function is specified. That's the key. So, I need to understand what that actually means. My next thought: any user namespace granted `CAP_NET_ADMIN` privileges could potentially create a `batadv` interface, correct?
The next question comes to mind: is `batadv` actually network namespace aware? I need to clarify. I should check immediately: does `batadv_link_ops` contain `netns_refund` or some other similar mechanism for managing network namespaces? Or, more broadly, does `batadv_init` register any pernet operations? That's where the answer lies.
|
| 47/2 |
2026/05/23 13:42 |
tool |
grepper |
0m
Error:
Args: map[Expression:register_pernet_subsys.*batadv]
Results:
|
| 48/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 42082
output: 23
thoughts: 12
Thoughts: Okay, let's dive into this. Here's my thought process on checking `register_pernet_device`, summarized as though I'm thinking it:
**Analyzing the `register_pernet_device` Function**
Alright, `register_pernet_device`. My immediate instinct is to dissect this function's purpose within the broader networking context. Where does it sit in the device registration process? Is this for *persistent* network devices, or are we dealing with something more ephemeral, like dynamically created interfaces? I need to understand its scope first; is it for a specific type of device, or more general? What network namespace is it relevant to?
I'm assuming it handles registration, which means it likely interacts with some kernel data structures, probably within the network stack. It's almost guaranteed to be involved in the `net_device` struct. The core question is: what's the lifecycle this function covers? Is it just the initial device setup, or does it handle more? Does it potentially manage callbacks for device events? It's crucial to know this to track the state of a device. I need to check the function signature β arguments, return type β to get a grasp on its function parameters and how it handles potential errors.
I'll be looking for any potential race conditions and concurrency issues if this function is called from multiple contexts (e.g., interrupt handlers, tasklets, workqueues). Is there adequate locking in place to protect against simultaneous device modifications? I'll also check how it handles failure. How does it report errors? Are there specific error codes? And, most importantly, does it clean up properly if something goes wrong during the registration process? Resource leaks are a common source of problems. I'll need to identify any potential vulnerabilities that can be exploited by malicious devices. Is it validating device properties or handling any kind of untrusted data?
Ultimately, the goal is a complete understanding: how it works, how it interacts with the rest of the network stack, and how robust and secure it is. Let's dig in.
|
| 49/2 |
2026/05/23 13:42 |
tool |
grepper |
0m
Error:
Args: map[Expression:register_pernet_device.*batadv]
Results:
|
| 50/2 |
2026/05/23 13:42 |
llm |
expert |
0m
Model:
Tokens:
input: 42563
output: 47
thoughts: 13
Thoughts: Okay, let's dive into this. Here's my thought process on dissecting `batadv_netlink_register`:
**Examining the `batadv_netlink_register` Function**
Alright, I'm going to take a look at `batadv_netlink_register`. My initial expectation is that this function will be the entry point for handling Batadv-specific netlink communication. This likely involves: setting up the appropriate netlink family, defining message types and their corresponding handlers, and, importantly, registering this entire Batadv netlink interface with the kernel. I anticipate this function will be crucial for Batadv to receive configuration updates, transmit control messages, and potentially receive status reports from user space. I'll be looking to see how it integrates with the overall Batadv architecture and its data structures. I'm going to look for references to netlink operations and the appropriate registration calls. I'll need to understand what it does and where it fits in Batadv.
|
| 51/2 |
2026/05/23 13:43 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/netlink.c IncludeLines:true Name:batadv_netlink_register]
Results: map[SourceCode:1541: /**
1542: * batadv_netlink_register() - register batadv genl netlink family
1543: */
1544: void __init batadv_netlink_register(void)
1545: {
1546: int ret;
1547:
1548: ret = genl_register_family(&batadv_netlink_family);
1549: if (ret)
1550: pr_warn("unable to register netlink family\n");
1551: }
SourceFile:net/batman-adv/netlink.c]
|
| 52/2 |
2026/05/23 13:43 |
llm |
expert |
0m
Model:
Tokens:
input: 43013
output: 28
thoughts: 849
Thoughts: **Analyzing the RCU Stall in Relation to Network Namespace Awareness and SoftIRQ Processing**
Okay, so I'm thinking through this network device issue. If a device doesn't register network operations, does that automatically mean it's not namespace-aware? Not necessarily, as long as the operations don't explicitly prevent it in the `rtnl_link_ops` structure. In fact, `rtnl_link_register` allows device creation in any namespace, so that's not the root cause.
Wait, it looks like this is actually an RCU stall. A stall is generally just a warning, and the system shouldn't crash unless `panic_on_rcu_stall` is set, which is rare in a production environment. So, typically, itβs a warning, potentially temporary.
But here's a crucial thought: if the bridging loop *continues indefinitely*, the CPU could get stuck. Because `__batadv_dat_purge` completes after 2048 jiffies, but the bridging loop continues to generate packets, keeping the softirq busy.
I need to think this through. If the bridging loop is infinite, the softirq is constantly busy. However, `net_rx_action` limits the softirq processing time to 2 jiffies before yielding. If there are no other tasks calling `spin_unlock_bh` in a tight loop, the softirq processing will be handled by `ksoftirqd`. `ksoftirqd` is a normal task that can be preempted and it calls `cond_resched()`.
So an infinite bridging loop normally consumes 100% of one (or multiple) CPU, but it *shouldn't* cause an RCU stall, because `ksoftirqd` calls `cond_resched()`. But here's the kicker: the *only* reason for the RCU stall is because `__batadv_dat_purge` loops 1024 times, and within *each* iteration, it calls `spin_unlock_bh`, which processes softirqs for 2 jiffies *without* calling `cond_resched()`!
Consequently, `__batadv_dat_purge` takes 2048 jiffies to complete, which could be longer than the RCU stall timeout (usually 21 seconds). Considering that 2048 jiffies at HZ=100 is 20.48 seconds, at HZ=250 is 8.19 seconds, and at HZ=1000 is 2.048 seconds, depending on the HZ, this could be an issue.
Now, the log is reporting an RCU stall and the "rcu: rcu_preempt kthread starved for 1348 jiffies!", I'm starting to think that the RCU stall timeout is likely 21 seconds, meaning 1348 jiffies corresponds to 13.48 seconds (if HZ=100). The duration depends on the value of HZ in the kernel.
So, if `__batadv_dat_purge` takes a long time, it triggers an RCU stall. Is this a real bug? Yes, it is! `__batadv_dat_purge` should likely call `cond_resched()` or minimize softirq processing.
However, calling `spin_unlock_bh` in a loop has been known to be problematic, because it processes softirqs and if there's a continuous packet flood, `spin_unlock_bh` will be stuck processing them for 2 jiffies. Many similar cases in the kernel that loop and call `spin_unlock_bh` have been fixed by calling `local_bh_enable()` and `cond_resched()`. I should check if there's a fix for this within the `batman-adv` code.
|
| 53/2 |
2026/05/23 13:43 |
tool |
git-log |
0m
Args: map[MessageRegexps:[batadv_dat_purge rcu]]
Results:
|
| 54/2 |
2026/05/23 13:43 |
llm |
expert |
0m
Model:
Tokens:
input: 44746
output: 23
thoughts: 23
Thoughts: Here's my thought process, as if I were considering this issue:
**Investigating Potential Data Corruption/Lockup in Batadv**
Okay, first things first, I need to get a handle on this. I'm going to start by searching specifically for the kernel function `batadv_dat_purge`. The reason I'm focusing on that function is because it's closely tied to data management and cleanup within the BATMAN-adv mesh networking protocol. Any issues there could lead to data inconsistencies or, potentially, trigger a stall. I'm also including the terms `softlockup` or `stall` in the query. These are critical keywords because they signal the *symptoms* of a problem I'm trying to diagnose - the system hanging or becoming unresponsive. By combining those two searches, I can see how likely it is that `batadv_dat_purge` is involved when these symptoms are present. This should help me pinpoint where to dig deeper.
|
| 55/2 |
2026/05/23 13:43 |
tool |
git-log |
0m
Args: map[MessageRegexps:[batadv_dat_purge]]
Results: map[Output:abac3ac97fe8 batman-adv: Broken sync while rescheduling delayed work
]
|
| 56/2 |
2026/05/23 13:43 |
llm |
expert |
0m
Model:
Tokens:
input: 45027
output: 50
thoughts: 18
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing `__batadv_dat_purge` in the Current Codebase**
Okay, time to dive into the latest version. Let's start by zeroing in on `__batadv_dat_purge`. I need to refresh my understanding of how this function is currently implemented within the overall batadv framework. It's crucial to understand how it interacts with the data structures and garbage collection mechanisms, especially in light of the recent performance discussions. I need to make sure I grasp the current strategy for handling stale or outdated data, and how the purging process impacts both link state and routing information. Is it optimized for various scenarios, or are there lingering bottlenecks? I'll probably start by cross-referencing this function with the relevant data structures (batadv_dat, batadv_neigh, etc.) and see how it interacts with the timers. Any recent commits or changes to this section will require careful scrutiny. Ultimately, I need to form a solid mental model of its behavior.
|
| 57/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/distributed-arp-table.c IncludeLines:true Name:__batadv_dat_purge]
Results: map[SourceCode: 146: /**
147: * __batadv_dat_purge() - delete entries from the DAT local storage
148: * @bat_priv: the bat priv with all the mesh interface information
149: * @to_purge: function in charge to decide whether an entry has to be purged or
150: * not. This function takes the dat_entry as argument and has to
151: * returns a boolean value: true is the entry has to be deleted,
152: * false otherwise
153: *
154: * Loops over each entry in the DAT local storage and deletes it if and only if
155: * the to_purge function passed as argument returns true.
156: */
157: static void __batadv_dat_purge(struct batadv_priv *bat_priv,
158: bool (*to_purge)(struct batadv_dat_entry *))
159: {
160: spinlock_t *list_lock; /* protects write access to the hash lists */
161: struct batadv_dat_entry *dat_entry;
162: struct hlist_node *node_tmp;
163: struct hlist_head *head;
164: u32 i;
165:
166: if (!bat_priv->dat.hash)
167: return;
168:
169: for (i = 0; i < bat_priv->dat.hash->size; i++) {
170: head = &bat_priv->dat.hash->table[i];
171: list_lock = &bat_priv->dat.hash->list_locks[i];
172:
173: spin_lock_bh(list_lock);
174: hlist_for_each_entry_safe(dat_entry, node_tmp, head,
175: hash_entry) {
176: /* if a helper function has been passed as parameter,
177: * ask it if the entry has to be purged or not
178: */
179: if (to_purge && !to_purge(dat_entry))
180: continue;
181:
182: hlist_del_rcu(&dat_entry->hash_entry);
183: batadv_dat_entry_put(dat_entry);
184: }
185: spin_unlock_bh(list_lock);
186: }
187: }
SourceFile:net/batman-adv/distributed-arp-table.c]
|
| 58/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 46046
output: 44
thoughts: 169
Thoughts: **Analyzing a Potential Security Vulnerability**
Okay, so I'm looking at this code and I see something that jumps out immediately: it's still using `spin_unlock_bh` without a `cond_resched()`. Now, that's usually a red flag for RCU stalls, right? But the real question is, if this is a known pattern that *can* cause an RCU stall, does that qualify as a security vulnerability? I'm leaning toward yes, given that it leads to a Denial of Service.
The next thing I need to figure out is, can an unprivileged user trigger this? That's the key. If it requires root, it's a lot less concerning. But... if an unprivileged user *could* potentially create a user namespace and manipulate network interfaces, that changes everything.
Let's see. If they can create a user namespace, can they then create a bridge, a veth pair, and *crucially*, a `batman-adv` interface? Wait, can they even create a `batman-adv` interface at all? I need to check if the `batadv_link_ops` allow this in a user namespace. It's time to dig into the code.
Alright, what if the network device type isn't specifically marked with `netns_refund` or something similar? Can it be created in a non-init netns? I'll check `rtnl_link_register` and related functions. Let's see how the netlink registration handles user namespaces and privilege separation. I need to understand the constraints here to determine the risk.
|
| 59/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/rtnetlink.c IncludeLines:true Name:rtnl_link_register]
Results: map[SourceCode: 591: /**
592: * rtnl_link_register - Register rtnl_link_ops with rtnetlink.
593: * @ops: struct rtnl_link_ops * to register
594: *
595: * Returns 0 on success or a negative error code.
596: */
597: int rtnl_link_register(struct rtnl_link_ops *ops)
598: {
599: struct rtnl_link_ops *tmp;
600: int err;
601:
602: /* Sanity-check max sizes to avoid stack buffer overflow. */
603: if (WARN_ON(ops->maxtype > RTNL_MAX_TYPE ||
604: ops->slave_maxtype > RTNL_SLAVE_MAX_TYPE))
605: return -EINVAL;
606:
607: /* The check for alloc/setup is here because if ops
608: * does not have that filled up, it is not possible
609: * to use the ops for creating device. So do not
610: * fill up dellink as well. That disables rtnl_dellink.
611: */
612: if ((ops->alloc || ops->setup) && !ops->dellink)
613: ops->dellink = unregister_netdevice_queue;
614:
615: err = init_srcu_struct(&ops->srcu);
616: if (err)
617: return err;
618:
619: mutex_lock(&link_ops_mutex);
620:
621: list_for_each_entry(tmp, &link_ops, list) {
622: if (!strcmp(ops->kind, tmp->kind)) {
623: err = -EEXIST;
624: goto unlock;
625: }
626: }
627:
628: list_add_tail_rcu(&ops->list, &link_ops);
629: unlock:
630: mutex_unlock(&link_ops_mutex);
631:
632: return err;
633: }
SourceFile:net/core/rtnetlink.c]
|
| 60/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 47264
output: 43
thoughts: 19
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Understanding the Link Creation Path in the Kernel**
Alright, so if a user out there is trying to conjure up a new link β let's say they're running `ip link add` or something similar β I immediately think about `rtnl_newlink`. That's the function, the *entry point* if you will, that's getting called. It's the central hub for handling this specific request. Itβs the first function in the kernel that needs to be invoked. I need to understand what happens *within* `rtnl_newlink`, and what follows. Knowing this is the first function invoked is key for troubleshooting, debugging, and understanding the sequence of events.
|
| 61/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/rtnetlink.c IncludeLines:true Name:rtnl_newlink]
Results: map[SourceCode:3961: static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
3962: struct netlink_ext_ack *extack)
3963: {
3964: struct net *tgt_net, *link_net = NULL, *peer_net = NULL;
3965: struct nlattr **tb, **linkinfo, **data = NULL;
3966: struct rtnl_link_ops *ops = NULL;
3967: struct rtnl_newlink_tbs *tbs;
3968: struct rtnl_nets rtnl_nets;
3969: int ops_srcu_index;
3970: int ret;
3971:
3972: tbs = kmalloc_obj(*tbs);
3973: if (!tbs)
3974: return -ENOMEM;
3975:
3976: tb = tbs->tb;
3977: ret = nlmsg_parse_deprecated(nlh, sizeof(struct ifinfomsg), tb,
3978: IFLA_MAX, ifla_policy, extack);
3979: if (ret < 0)
3980: goto free;
3981:
3982: ret = rtnl_ensure_unique_netns(tb, extack, false);
3983: if (ret < 0)
3984: goto free;
3985:
3986: linkinfo = tbs->linkinfo;
3987: if (tb[IFLA_LINKINFO]) {
3988: ret = nla_parse_nested_deprecated(linkinfo, IFLA_INFO_MAX,
3989: tb[IFLA_LINKINFO],
3990: ifla_info_policy, NULL);
3991: if (ret < 0)
3992: goto free;
3993: } else {
3994: memset(linkinfo, 0, sizeof(tbs->linkinfo));
3995: }
3996:
3997: if (linkinfo[IFLA_INFO_KIND]) {
3998: char kind[MODULE_NAME_LEN];
3999:
4000: nla_strscpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind));
4001: ops = rtnl_link_ops_get(kind, &ops_srcu_index);
4002: #ifdef CONFIG_MODULES
4003: if (!ops) {
4004: request_module("rtnl-link-%s", kind);
4005: ops = rtnl_link_ops_get(kind, &ops_srcu_index);
4006: }
4007: #endif
4008: }
4009:
4010: rtnl_nets_init(&rtnl_nets);
4011:
4012: if (ops) {
4013: if (ops->maxtype > RTNL_MAX_TYPE) {
4014: ret = -EINVAL;
4015: goto put_ops;
4016: }
4017:
4018: if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) {
4019: ret = nla_parse_nested_deprecated(tbs->attr, ops->maxtype,
4020: linkinfo[IFLA_INFO_DATA],
4021: ops->policy, extack);
4022: if (ret < 0)
4023: goto put_ops;
4024:
4025: data = tbs->attr;
4026: }
4027:
4028: if (ops->validate) {
4029: ret = ops->validate(tb, data, extack);
4030: if (ret < 0)
4031: goto put_ops;
4032: }
4033:
4034: if (ops->peer_type) {
4035: peer_net = rtnl_get_peer_net(ops, tb, data, extack);
4036: if (IS_ERR(peer_net)) {
4037: ret = PTR_ERR(peer_net);
4038: goto put_ops;
4039: }
4040: if (peer_net)
4041: rtnl_nets_add(&rtnl_nets, peer_net);
4042: }
4043: }
4044:
4045: tgt_net = rtnl_link_get_net_capable(skb, sock_net(skb->sk), tb, CAP_NET_ADMIN);
4046: if (IS_ERR(tgt_net)) {
4047: ret = PTR_ERR(tgt_net);
4048: goto put_net;
4049: }
4050:
4051: rtnl_nets_add(&rtnl_nets, tgt_net);
4052:
4053: if (tb[IFLA_LINK_NETNSID]) {
4054: int id = nla_get_s32(tb[IFLA_LINK_NETNSID]);
4055:
4056: link_net = get_net_ns_by_id(tgt_net, id);
4057: if (!link_net) {
4058: NL_SET_ERR_MSG(extack, "Unknown network namespace id");
4059: ret = -EINVAL;
4060: goto put_net;
4061: }
4062:
4063: rtnl_nets_add(&rtnl_nets, link_net);
4064:
4065: if (!netlink_ns_capable(skb, link_net->user_ns, CAP_NET_ADMIN)) {
4066: ret = -EPERM;
4067: goto put_net;
4068: }
4069: }
4070:
4071: rtnl_nets_lock(&rtnl_nets);
4072: ret = __rtnl_newlink(skb, nlh, ops, tgt_net, link_net, peer_net, tbs, data, extack);
4073: rtnl_nets_unlock(&rtnl_nets);
4074:
4075: put_net:
4076: rtnl_nets_destroy(&rtnl_nets);
4077: put_ops:
4078: if (ops)
4079: rtnl_link_ops_put(ops, ops_srcu_index);
4080: free:
4081: kfree(tbs);
4082: return ret;
4083: }
SourceFile:net/core/rtnetlink.c]
|
| 62/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 49406
output: 44
thoughts: 157
Thoughts: **Analyzing Potential Privileged Interface Creation in User Namespaces**
Okay, here's what's running through my head. The `rtnl_newlink` function is checking for `CAP_NET_ADMIN` within the target namespace. This immediately flags a potential vulnerability: a non-privileged user can create their own user namespace, which by default grants them `CAP_NET_ADMIN` *within that namespace*. This allows them to create and manipulate network interfaces within that isolated environment.
The real question is, can they leverage this to create a `batadv` interface? It's been a while since I dug into the `batadv` code specifically, so I need to think this through. My immediate concern is whether or not the `batadv` module's operations permit interface creation outside the initial network namespace. If the core functions within `batadv_link_ops` don't incorporate a `netns_refund` or similar mechanism, we might have a problem. I'm thinking about how the system handles namespace awareness.
Wait, are there fields related to namespace awareness in `rtnl_link_ops`? Am I misremembering something? Does it have a `netns_refund` field? No, that's not right. What am I thinking of? Is it `netns_aware` or something similar? I need to go back and check the definition of `rtnl_link_ops` to make sure I'm using the correct terminology and see exactly what's present in that struct. That's the critical piece of this puzzle.
|
| 63/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/net/rtnetlink.h IncludeLines:true Name:rtnl_link_ops]
Results: map[SourceCode: 106: /**
107: * struct rtnl_link_ops - rtnetlink link operations
108: *
109: * @list: Used internally, protected by link_ops_mutex and SRCU
110: * @srcu: Used internally
111: * @kind: Identifier
112: * @netns_refund: Physical device, move to init_net on netns exit
113: * @peer_type: Peer device specific netlink attribute number (e.g. VETH_INFO_PEER)
114: * @maxtype: Highest device specific netlink attribute number
115: * @policy: Netlink policy for device specific attribute validation
116: * @validate: Optional validation function for netlink/changelink parameters
117: * @alloc: netdev allocation function, can be %NULL and is then used
118: * in place of alloc_netdev_mqs(), in this case @priv_size
119: * and @setup are unused. Returns a netdev or ERR_PTR().
120: * @priv_size: sizeof net_device private space
121: * @setup: net_device setup function
122: * @newlink: Function for configuring and registering a new device
123: * @changelink: Function for changing parameters of an existing device
124: * @dellink: Function to remove a device
125: * @get_size: Function to calculate required room for dumping device
126: * specific netlink attributes
127: * @fill_info: Function to dump device specific netlink attributes
128: * @get_xstats_size: Function to calculate required room for dumping device
129: * specific statistics
130: * @fill_xstats: Function to dump device specific statistics
131: * @get_num_tx_queues: Function to determine number of transmit queues
132: * to create when creating a new device.
133: * @get_num_rx_queues: Function to determine number of receive queues
134: * to create when creating a new device.
135: * @get_link_net: Function to get the i/o netns of the device
136: * @get_linkxstats_size: Function to calculate the required room for
137: * dumping device-specific extended link stats
138: * @fill_linkxstats: Function to dump device-specific extended link stats
139: */
140: struct rtnl_link_ops {
141: struct list_head list;
142: struct srcu_struct srcu;
143:
144: const char *kind;
145:
146: size_t priv_size;
147: struct net_device *(*alloc)(struct nlattr *tb[],
148: const char *ifname,
149: unsigned char name_assign_type,
150: unsigned int num_tx_queues,
151: unsigned int num_rx_queues);
152: void (*setup)(struct net_device *dev);
153:
154: bool netns_refund;
155: const u16 peer_type;
156: unsigned int maxtype;
157: const struct nla_policy *policy;
158: int (*validate)(struct nlattr *tb[],
159: struct nlattr *data[],
160: struct netlink_ext_ack *extack);
161:
162: int (*newlink)(struct net_device *dev,
163: struct rtnl_newlink_params *params,
164: struct netlink_ext_ack *extack);
165: int (*changelink)(struct net_device *dev,
166: struct nlattr *tb[],
167: struct nlattr *data[],
168: struct netlink_ext_ack *extack);
169: void (*dellink)(struct net_device *dev,
170: struct list_head *head);
171:
172: size_t (*get_size)(const struct net_device *dev);
173: int (*fill_info)(struct sk_buff *skb,
174: const struct net_device *dev);
175:
176: size_t (*get_xstats_size)(const struct net_device *dev);
177: int (*fill_xstats)(struct sk_buff *skb,
178: const struct net_device *dev);
179: unsigned int (*get_num_tx_queues)(void);
180: unsigned int (*get_num_rx_queues)(void);
181:
182: unsigned int slave_maxtype;
183: const struct nla_policy *slave_policy;
184: int (*slave_changelink)(struct net_device *dev,
185: struct net_device *slave_dev,
186: struct nlattr *tb[],
187: struct nlattr *data[],
188: struct netlink_ext_ack *extack);
189: size_t (*get_slave_size)(const struct net_device *dev,
190: const struct net_device *slave_dev);
191: int (*fill_slave_info)(struct sk_buff *skb,
192: const struct net_device *dev,
193: const struct net_device *slave_dev);
194: struct net *(*get_link_net)(const struct net_device *dev);
195: size_t (*get_linkxstats_size)(const struct net_device *dev,
196: int attr);
197: int (*fill_linkxstats)(struct sk_buff *skb,
198: const struct net_device *dev,
199: int *prividx, int attr);
200: };
SourceFile:include/net/rtnetlink.h]
|
| 64/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 51689
output: 49
thoughts: 1034
Thoughts: **Analysis of a Potential Denial of Service Vulnerability**
Okay, so here's the breakdown of what I'm seeing. There's no dependency on a `netns_aware` flag, which is interesting. Any `rtnl_link_ops` implementation should allow link creation within a user namespace, provided `CAP_NET_ADMIN` is present within that namespace. This means an unprivileged user can create their own namespace, set up a bridge, a veth pair, and a batman-adv interface, effectively building a bridging loop. Classic.
That loop triggers a packet storm, as expected. This then leads to the `batadv_dat_purge` routine being invoked, specifically through a delayed work queue. During its execution, the function enters a tight loop of 1024 iterations, each calling `spin_unlock_bh`, which subsequently processes softirqs. Because of the packet storm, these softirqs are taking an unusually long time β two jiffies each! This means `batadv_dat_purge` effectively blocks for 2048 jiffies, which is about 20.48 seconds (or 2.048 seconds).
The crucial point here is the RCU stall warning. Is this a real security vulnerability? Well, it's certainly a Denial of Service. The question is, does it *crash* the system? By default, `panic_on_rcu_stall` is off, so it's just a warning. The system continues to run, but for that 20-second window (or 2-second), the CPU is essentially pegged at 100%, and unable to perform any other tasks. This might be considered a denial of service.
The thing is, a bridging loop already causes 100% CPU usage! The system is constantly processing packets either in softirq or ksoftirqd, or in `batadv_dat_purge`. The only difference with `batadv_dat_purge` is that the CPU is stuck in a workqueue thread with BH disabled for 2 jiffies at a time, but it doesn't call `cond_resched()` for those 2048 jiffies. This leads to the RCU stall warning.
Is this a real DoS? Yes, because of the RCU stall. If `panic_on_rcu_stall` *were* enabled, it could lead to a system panic. At the very least, we're looking at a severe latency spike β upwards of 20 seconds of unresponsiveness on that CPU.
What's really concerning is that this is accessible to unprivileged processes through user namespaces. This is key. The attack is now local.
Is it exploitable? No, thankfully, it's just a softlockup/RCU stall. No memory corruption involved, which is good news. Let's characterize this:
* Exploitable: **False**
* DenialOfService: **True**
* Unprivileged: **True** (via user namespaces)
* UserNamespace: **True**
* VMGuestTrigger: **False**
* VMHostTrigger: **False**
* NetworkTrigger: **False** (it requires local configuration of a bridging loop, or maybe it can be triggered remotely if the attacker can send packets that loop? But the loop is a configuration issue. The attacker can just send packets to a misconfigured network. But the bug is triggered by the user namespace configuration).
Hang on, can this be triggered remotely? If the network is *already* misconfigured with a bridging loop, then yes, any packet sent to it will cause a storm. If not, then an attacker can't trigger it remotely. So:
* NetworkTrigger: **False**
* PeripheralTrigger: **False**
* FilesystemTrigger: **False**
Alright, let's double-check the memory corruption angle. The bug report is helpful:
```
rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
...
rcu: rcu_preempt kthread starved for 1348 jiffies!
```
Classic RCU stall. No KASAN reports, no use-after-free, or out-of-bounds access. The stack traces nail it down: `batadv_dat_purge` -> `spin_unlock_bh` -> `do_softirq` -> `net_rx_action` -> ... -> `fib6_node_lookup_1`. Other CPUs are just stuck waiting for the grace period. This confirms it's purely a CPU stall/DoS.
Summarizing our findings:
* Exploitable: False
* DenialOfService: True
* Unprivileged:
|
| 65/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/soft-interface.c IncludeLines:true Name:batadv_meshif_newlink]
Results: map[SourceCode:1051: /**
1052: * batadv_meshif_newlink() - pre-initialize and register new batadv link
1053: * @dev: network device to register
1054: * @params: rtnl newlink parameters
1055: * @extack: extended ACK report struct
1056: *
1057: * Return: 0 if successful or error otherwise.
1058: */
1059: static int batadv_meshif_newlink(struct net_device *dev,
1060: struct rtnl_newlink_params *params,
1061: struct netlink_ext_ack *extack)
1062: {
1063: struct batadv_priv *bat_priv = netdev_priv(dev);
1064: struct nlattr **data = params->data;
1065: const char *algo_name;
1066: int err;
1067:
1068: if (data && data[IFLA_BATADV_ALGO_NAME]) {
1069: algo_name = nla_data(data[IFLA_BATADV_ALGO_NAME]);
1070: err = batadv_algo_select(bat_priv, algo_name);
1071: if (err)
1072: return -EINVAL;
1073: }
1074:
1075: return register_netdevice(dev);
1076: }
SourceFile:net/batman-adv/mesh-interface.c]
|
| 66/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 54228
output: 50
thoughts: 26
Thoughts: Here's my attempt at summarizing those thoughts, speaking as the person having them, keeping in mind the user is an expert:
**Investigating Initialization Routines**
Okay, so I'm looking at this code, and it's striking me that there's no check for `init_net` anywhere in this section. That feels like a potential oversight, something we should definitely verify, especially given how critical net namespace initialization is in this context.
My immediate follow-up thought is about the `batadv_meshif_init_early` function. Could it possibly be taking care of the functionality related to `init_net`? Perhaps there's an earlier initialization stage that mitigates the need for a specific check here? I'll need to dig into that function's implementation to see if it implicitly handles this, or if we have a real vulnerability in the net namespace initialization. I'll also check other initialization paths.
|
| 67/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/soft-interface.c IncludeLines:true Name:batadv_meshif_init_early]
Results: map[SourceCode: 998: /**
999: * batadv_meshif_init_early() - early stage initialization of mesh interface
1000: * @dev: registered network device to modify
1001: */
1002: static void batadv_meshif_init_early(struct net_device *dev)
1003: {
1004: ether_setup(dev);
1005:
1006: dev->netdev_ops = &batadv_netdev_ops;
1007: dev->needs_free_netdev = true;
1008: dev->priv_destructor = batadv_meshif_free;
1009: dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
1010: dev->priv_flags |= IFF_NO_QUEUE;
1011: dev->lltx = true;
1012: dev->netns_immutable = true;
1013:
1014: /* can't call min_mtu, because the needed variables
1015: * have not been initialized yet
1016: */
1017: dev->mtu = ETH_DATA_LEN;
1018: dev->max_mtu = BATADV_MAX_MTU;
1019:
1020: /* generate random address */
1021: eth_hw_addr_random(dev);
1022:
1023: dev->ethtool_ops = &batadv_ethtool_ops;
1024: }
SourceFile:net/batman-adv/mesh-interface.c]
|
| 68/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 54950
output: 45
thoughts: 454
Thoughts: **Analyzing the Network Namespace Vulnerability and RCU Stall**
Okay, so I'm thinking about this code and how it relates to network namespaces. The key line, `dev->netns_immutable = true;`, makes it clear that once a device is created, it's stuck in that namespace. But, and this is important, it *can* be created in any namespace in the first place, meaning it *is* accessible from user namespaces. We need to keep that in mind when assessing the potential impact.
Now, let's revisit this RCU stall issue. The problem stems from `batadv_dat_purge` iterating through that hash table with its 1024 buckets and calling `spin_unlock_bh` on each one. Here's where it gets interesting. With a constant stream of softirqs, like from a packet storm, `spin_unlock_bh` hogs the CPU, processing those softirqs for up to 2 jiffies *per bucket*. That means `batadv_dat_purge` could chug along for a whopping 2048 jiffies without giving up the CPU or signaling a quiescent state. That's what triggers the RCU stall warning.
My initial thought was, could this only be triggered via a bridging loop? But hang on... what if a remote attacker could generate enough packet traffic to keep the softirq busy *without* a bridging setup? Could they cause the same stall? The answer, I think, is yes. If a machine gets hammered with packets β a DDoS, for example β `spin_unlock_bh` still eats up 2 jiffies at each bucket. So, a remote attacker, by flooding the target, could essentially stall the CPU for 2048 jiffies. Wait, but isn't there something about packet limits in `net_rx_action`? It's limited to 300 packets or 2 jiffies. If the attacker can keep the backlog full, `net_rx_action` will always take 2 jiffies. Then `batadv_dat_purge` will still take 2048 jiffies! So yes, this could be triggered remotely with a packet flood!
The key here is that if `batman-adv` is active, and `batadv_dat_purge` is scheduled and running (which it does periodically if DAT is enabled), it's vulnerable. And now I have to ask myself, is DAT enabled by default? We need to verify that...
|
| 69/2 |
2026/05/23 13:44 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/main.c IncludeLines:true Name:batadv_mesh_init]
Results: map[SourceCode: 139: /**
140: * batadv_mesh_init() - Initialize mesh interface
141: * @mesh_iface: netdev struct of the mesh interface
142: *
143: * Return: 0 on success or negative error number in case of failure
144: */
145: int batadv_mesh_init(struct net_device *mesh_iface)
146: {
147: struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
148: int ret;
149:
150: spin_lock_init(&bat_priv->forw_bat_list_lock);
151: spin_lock_init(&bat_priv->forw_bcast_list_lock);
152: spin_lock_init(&bat_priv->tt.changes_list_lock);
153: spin_lock_init(&bat_priv->tt.req_list_lock);
154: spin_lock_init(&bat_priv->tt.roam_list_lock);
155: spin_lock_init(&bat_priv->tt.last_changeset_lock);
156: spin_lock_init(&bat_priv->tt.commit_lock);
157: spin_lock_init(&bat_priv->gw.list_lock);
158: #ifdef CONFIG_BATMAN_ADV_MCAST
159: spin_lock_init(&bat_priv->mcast.mla_lock);
160: spin_lock_init(&bat_priv->mcast.want_lists_lock);
161: #endif
162: spin_lock_init(&bat_priv->tvlv.container_list_lock);
163: spin_lock_init(&bat_priv->tvlv.handler_list_lock);
164: spin_lock_init(&bat_priv->meshif_vlan_list_lock);
165: spin_lock_init(&bat_priv->tp_list_lock);
166:
167: INIT_HLIST_HEAD(&bat_priv->forw_bat_list);
168: INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
169: INIT_HLIST_HEAD(&bat_priv->gw.gateway_list);
170: #ifdef CONFIG_BATMAN_ADV_MCAST
171: INIT_HLIST_HEAD(&bat_priv->mcast.want_all_unsnoopables_list);
172: INIT_HLIST_HEAD(&bat_priv->mcast.want_all_ipv4_list);
173: INIT_HLIST_HEAD(&bat_priv->mcast.want_all_ipv6_list);
174: #endif
175: INIT_LIST_HEAD(&bat_priv->tt.changes_list);
176: INIT_HLIST_HEAD(&bat_priv->tt.req_list);
177: INIT_LIST_HEAD(&bat_priv->tt.roam_list);
178: #ifdef CONFIG_BATMAN_ADV_MCAST
179: INIT_HLIST_HEAD(&bat_priv->mcast.mla_list);
180: #endif
181: INIT_HLIST_HEAD(&bat_priv->tvlv.container_list);
182: INIT_HLIST_HEAD(&bat_priv->tvlv.handler_list);
183: INIT_HLIST_HEAD(&bat_priv->meshif_vlan_list);
184: INIT_HLIST_HEAD(&bat_priv->tp_list);
185:
186: bat_priv->gw.generation = 0;
187:
188: ret = batadv_originator_init(bat_priv);
189: if (ret < 0) {
190: atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
191: goto err_orig;
192: }
193:
194: ret = batadv_tt_init(bat_priv);
195: if (ret < 0) {
196: atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
197: goto err_tt;
198: }
199:
200: ret = batadv_v_mesh_init(bat_priv);
201: if (ret < 0) {
202: atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
203: goto err_v;
204: }
205:
206: ret = batadv_bla_init(bat_priv);
207: if (ret < 0) {
208: atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
209: goto err_bla;
210: }
211:
212: ret = batadv_dat_init(bat_priv);
213: if (ret < 0) {
214: atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
215: goto err_dat;
216: }
217:
218: batadv_gw_init(bat_priv);
219: batadv_mcast_init(bat_priv);
220:
221: atomic_set(&bat_priv->gw.reselect, 0);
222: atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);
223:
224: return 0;
225:
226: err_dat:
227: batadv_bla_free(bat_priv);
228: err_bla:
229: batadv_v_mesh_free(bat_priv);
230: err_v:
231: batadv_tt_free(bat_priv);
232: err_tt:
233: batadv_originator_free(bat_priv);
234: err_orig:
235: batadv_purge_outstanding_packets(bat_priv, NULL);
236: atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
237:
238: return ret;
239: }
SourceFile:net/batman-adv/main.c]
|
| 70/2 |
2026/05/23 13:44 |
llm |
expert |
0m
Model:
Tokens:
input: 57790
output: 51
thoughts: 81
Thoughts: Okay, here's my take on those thoughts, framed as my own internal analysis:
**Analyzing the Batman-adv RCU Stall Vulnerability**
Right, so `batadv_dat_init` is unconditionally invoked during mesh initialization. That's key. If I'm thinking like an attacker, I realize that flooding a batman-adv node with packets β and I mean *a lot* of them β would potentially trigger an RCU stall. Every time `batadv_dat_purge` kicks off, which... hold on, is that every ten seconds? That's right, `batadv_dat_purge` runs every 10 seconds. And that makes all the difference, now doesn't it? The attackers have a 10 second window in which they can cause this RCU stall.
|
| 71/2 |
2026/05/23 13:45 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/distributed-arp-table.c IncludeLines:true Name:batadv_dat_start_timer]
Results: map[SourceCode: 97: /**
98: * batadv_dat_start_timer() - initialise the DAT periodic worker
99: * @bat_priv: the bat priv with all the mesh interface information
100: */
101: static void batadv_dat_start_timer(struct batadv_priv *bat_priv)
102: {
103: queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work,
104: msecs_to_jiffies(10000));
105: }
SourceFile:net/batman-adv/distributed-arp-table.c]
|
| 72/2 |
2026/05/23 13:45 |
llm |
expert |
0m
Model:
Tokens:
input: 58285
output: 49
thoughts: 935
Thoughts: **Analyzing a Potentially Severe Denial of Service Vulnerability in batman-adv**
Okay, so I'm thinking about this issue... it seems like there's a serious problem here. Every 10 seconds, if there's a continuous packet flood, the CPU could stall for 20 seconds. Wait, if it's stalling for 20 seconds *every* 10 seconds, that's a complete CPU lockup! Because it runs, then queues again immediately? No, `queue_delayed_work` queues the work for 10 seconds from now. So it's 20 seconds run, 10 seconds sleep, 20 seconds run. That's a severe Denial of Service.
Can this be triggered remotely? Looks like it! If an attacker can send a flood of packets (like a UDP flood) to a machine running batman-adv, they can cause this stall. But wait, does the packet flood *need* to be processed *by* batman-adv? No! `spin_unlock_bh` processes *all* pending softirqs, including packets received on *any* interface. So even if the attacker sends a flood to `eth0`, and `eth0` isn't part of batman-adv, `spin_unlock_bh` in `batadv_dat_purge` will *still* process those packets, because `spin_unlock_bh` calls `__local_bh_enable_ip`, which calls `do_softirq`, which processes `NET_RX_SOFTIRQ`, and that processes all the backlog and NAPI for all interfaces! Therefore, *any* packet flood to *any* interface on a machine running batman-adv will cause this RCU stall.
That means this is remotely triggerable via Ethernet network! NetworkTrigger is true. And it's remotely triggerable if the flood can come from the internet, so RemoteTrigger is also true.
Wait, though... a packet flood *already* causes high CPU usage. But typically, a packet flood doesn't cause an RCU stall, because `ksoftirqd` or `net_rx_action` yield the CPU. With batman-adv running, the packet flood *does* cause an RCU stall, which might even trigger a kernel panic if `panic_on_rcu_stall` is set.
So, is this a real vulnerability? Absolutely. It's a known class of bugs (softlockup/RCU stall due to `spin_unlock_bh` in a loop). So: Exploitable: false, DenialOfService: true, Unprivileged: true, UserNamespace: true, VMGuestTrigger: false, VMHostTrigger: false, NetworkTrigger: true, RemoteTrigger: true, PeripheralTrigger: false, FilesystemTrigger: false.
Okay, let's double-check about `spin_unlock_bh`. Yes, it *does* process softirqs: `spin_unlock_bh` -> `__local_bh_enable_ip` -> `do_softirq`. If softirqs are pending, it processes them. And a packet flood *guarantees* pending softirqs. Each `spin_unlock_bh` call processes softirqs for up to 2 jiffies. The loop runs 1024 times so it's a solid 2048 jiffies!
Let's look at the bug report again. Ah, it shows a bridging loop: "bridge0: received packet on bridge_slave_0 with own address as source address." This was created by syzkaller (which runs unprivileged in a user namespace). The bridging loop caused a massive packet storm. Then `batadv_dat_purge` runs and gets stuck processing softirqs from that loop. This triggers the RCU stall. So syzkaller found it locally with a bridging loop. But a remote attacker can trigger this with a remote packet flood, so NetworkTrigger is true.
Let's verify that `batadv_dat_purge` is the only function affected. No, there are other purge functions in batman-adv: `batadv_bla_claim_purge`, `batadv_nc_purge_orig`, and `batadv_tt_purge`. Do *they* also use `spin_unlock_bh` in a loop? That needs further investigation.
|
| 73/2 |
2026/05/23 13:45 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/batman-adv/translation-table.c IncludeLines:true Name:batadv_tt_local_purge]
Results: map[SourceCode:1295: /**
1296: * batadv_tt_local_purge() - purge inactive tt local entries
1297: * @bat_priv: the bat priv with all the mesh interface information
1298: * @timeout: parameter deciding whether a given tt local entry is considered
1299: * inactive or not
1300: */
1301: static void batadv_tt_local_purge(struct batadv_priv *bat_priv,
1302: int timeout)
1303: {
1304: struct batadv_hashtable *hash = bat_priv->tt.local_hash;
1305: struct hlist_head *head;
1306: spinlock_t *list_lock; /* protects write access to the hash lists */
1307: u32 i;
1308:
1309: for (i = 0; i < hash->size; i++) {
1310: head = &hash->table[i];
1311: list_lock = &hash->list_locks[i];
1312:
1313: spin_lock_bh(list_lock);
1314: batadv_tt_local_purge_list(bat_priv, head, timeout);
1315: spin_unlock_bh(list_lock);
1316: }
1317: }
SourceFile:net/batman-adv/translation-table.c]
|
| 74/2 |
2026/05/23 13:45 |
llm |
expert |
0m
Model:
Tokens:
input: 60597
output: 66
thoughts: 1421
Thoughts: **Analyzing the Batman-Adv RCU Stall Vulnerability**
Okay, so I've been digging into this `batadv_tt_local_purge` function, and it's looping over a hash table of 1024 entries, just like `local_hash`, calling `spin_unlock_bh` in each iteration. That's a classic batman-adv pattern. Now, the core question is, what can trigger an RCU stall here? Does an empty hash table matter? Turns out, it *doesn't*. Even with an empty table, the code still iterates 1024 times because it's looping over `bat_priv->dat.hash->size`. It calls `spin_lock_bh` and `spin_unlock_bh` in each iteration, regardless of whether the bucket actually contains data.
So, *even an empty hash table* can cause an RCU stall if there's a packet flood because of those spinlock calls. The attacker doesn't even need to populate the DAT table; just having batman-adv enabled is enough. That's a pretty low barrier to entry.
The attack vector is clear: an unprivileged user can create a user namespace, then create a `batadv` interface, and then a bridging loop (or initiate a packet flood). That triggers `batadv_dat_purge` and, boom, RCU stall. Alternatively, a remote attacker can send a packet flood if batman-adv is configured. This is definitely a Denial of Service.
Now, let's categorize this. I've concluded:
* **Exploitable: False** (No memory corruption, just a stall)
* **DenialOfService: True** (RCU stall, CPU lockup)
* **Unprivileged: True** (User namespace allows triggering)
* **UserNamespace: True** (Needed to create the interface and bridging loop)
* **VMGuestTrigger: False** (Not specific to VMs)
* **VMHostTrigger: False** (Not specific to VM hosts)
* **NetworkTrigger: True** (Triggerable via network packet flood)
* **RemoteTrigger: False** (While a remote attacker could cause this, it is not a non-Ethernet specific bug)
* **PeripheralTrigger: False**
* **FilesystemTrigger: False**
That "RemoteTrigger" classification is the trickier one. While the packet flood *is* remote, in the context of network vulnerabilities, a *NetworkTrigger* usually covers any network-based trigger, whereas *RemoteTrigger* is more focused on non-Ethernet remotes (like WiFi or Bluetooth). Since this can be triggered by Ethernet, it makes more sense to have this as `NetworkTrigger` and not `RemoteTrigger` even though it *could* be triggered over WiFi. Batman-adv *is* often used over WiFi, but the root cause is in the softirq processing itself, not the WiFi MAC layer.
I've rechecked: there are multiple purge functions, but it seems `batadv_dat_purge` is key. There's no memory corruption, just the loop calling `spin_lock_bh` and `spin_unlock_bh`.
Here's the final summary:
This is an RCU stall caused by `__batadv_dat_purge` (and similar batman-adv functions) iterating over a 1024-bucket hash table and calling `spin_lock_bh`/`spin_unlock_bh` for each. A continuous softirq stream (like a bridging loop or packet flood) can cause `spin_unlock_bh` to process softirqs for up to 2 jiffies on each iteration. This makes the loop take up to 2048 jiffies to finish without yielding or reporting quiescence. That triggers an RCU stall warning and effectively locks the CPU. An unprivileged user can trigger this by creating a user namespace, configuring a batman-adv interface, and creating a bridging loop. A remote attacker can trigger this on a system with batman-adv configured by flooding the network with packets to keep the softirqs busy. It's a Denial of Service, but it does not lead to memory corruption or privilege escalation.
My dimensions are:
* Exploitable: false
* DenialOfService: true
* Unprivileged: true
* UserNamespace: true
* VMGuestTrigger: false
* VMHostTrigger: false
* NetworkTrigger: true
* RemoteTrigger: false
* PeripheralTrigger: false
* FilesystemTrigger: false
Ready to call the `set-results` tool.
|
| 75/2 |
2026/05/23 13:45 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 76/2 |
2026/05/23 13:45 |
llm |
expert |
0m
Model:
Tokens:
input: 63147
output: 613
thoughts: 13
Thoughts: Okay, here's the summary, rendered in the first person, assuming the user is an expert:
**Final Reasoning and Conclusion**
Alright, the data's in, the analyses are done, and the findings are conclusive. I'm now at the point of finalizing my reasoning. There's no further processing needed, all parameters have been accounted for, and the implications of this outcome are clear. This section is where I'll connect the dots and present my definitive interpretation of the results, drawing on my deep understanding of the subject matter to articulate why these specific outcomes are what they are. I'll need to clarify the scope, the limits, and the most probable inferences that can be drawn with confidence.
|
| 77/1 |
2026/05/23 13:45 |
action |
format-explanation |
0m
Results: map[Explanation:The bug report indicates an RCU stall (softlockup) occurring while the CPU is
executing `__batadv_dat_purge` (or similar periodic purge functions in the
batman-adv subsystem).
### Analysis of the Bug
The root cause of the RCU stall is a problematic locking pattern in
`__batadv_dat_purge`. The function iterates over a hash table (which has 1024
buckets by default) and locks each bucket individually using `spin_lock_bh()`
and `spin_unlock_bh()`.
When `spin_unlock_bh()` is called, it enables bottom halves (softirqs). If there
are pending softirqsβsuch as network packets waiting to be
processedβ`spin_unlock_bh()` will invoke `do_softirq()` to process them. The
softirq processing is bounded by `net_rx_action` to a maximum of 2 jiffies or
300 packets.
However, if there is a continuous storm of packets (e.g., due to a bridging loop
or a network flood), `spin_unlock_bh()` will spend the full 2 jiffies processing
packets at *every single iteration* of the 1024-bucket loop. This means the
entire `__batadv_dat_purge` function can take up to 2048 jiffies (e.g., ~20
seconds at HZ=100) to complete. Because this loop runs in a workqueue context
without ever calling `cond_resched()`, the CPU does not go through an RCU
quiescent state for the entire duration, triggering the RCU stall warning and
effectively locking up the CPU.
### Security Impact
- **Exploitable**: No. This is purely a CPU stall/softlockup issue. There is no
memory corruption, use-after-free, or out-of-bounds access involved.
- **Denial of Service**: Yes. The bug locks up the CPU for extended periods
(tens of seconds), causing severe latency spikes or triggering kernel panics if
`panic_on_rcu_stall` is enabled.
- **Unprivileged / User Namespace**: Yes. An unprivileged user can create a new
network namespace, instantiate a `batadv` interface (as `rtnl_link_ops` for
batman-adv does not restrict creation to the init namespace), and intentionally
create a bridging loop using `veth` pairs. The bridging loop will generate the
packet storm required to trigger the stall when the periodic DAT purge worker
runs.
- **Network Trigger**: Yes. If a system administrator has legitimately
configured batman-adv, a remote attacker can trigger this DoS by sending a
massive flood of packets (e.g., a UDP flood) to the machine. The flood will keep
the softirq backlog full, causing the periodic `batadv_dat_purge` worker to
stall the CPU.]
|