| 0/0 |
2026/09/11 01:03 |
flow |
assessment-security |
38m
Results: map[DenialOfService:true Explanation:**Analysis of the Bug**
The bug report indicates a `BUG: workqueue lockup` in the WireGuard driver. The
workqueue watchdog detected that worker threads in `pool 6` have been stuck for
59 seconds. The stack traces show that the stuck workers are executing
WireGuard's workqueue functions: `wg_packet_decrypt_worker` and
`wg_packet_handshake_receive_worker`.
Looking at the source code for these workers (e.g.,
`wg_packet_handshake_receive_worker` in `drivers/net/wireguard/receive.c`):
```c
void wg_packet_handshake_receive_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker,
work)->ptr;
struct wg_device *wg = container_of(queue, struct wg_device,
handshake_queue);
struct sk_buff *skb;
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
wg_receive_handshake_packet(wg, skb);
dev_kfree_skb(skb);
atomic_dec(&wg->handshake_queue_len);
cond_resched();
}
}
```
The worker processes packets in a `while` loop as long as
`ptr_ring_consume_bh()` returns a packet. `ptr_ring_consume_bh()` temporarily
disables and then re-enables bottom halves (softirqs). This allows network RX
softirqs to run concurrently and continuously refill the `ptr_ring` with new
incoming packets.
If the incoming packet rate is sufficiently high, the `ptr_ring` will never be
empty, and the `while` loop will never terminate. Although the loop calls
`cond_resched()` to yield the CPU to other tasks (preventing a hard CPU lockup
or RCU stall), it never actually returns from the work function back to the
workqueue core (`process_scheduled_works()`).
The workqueue core updates the worker pool's `last_progress_ts` only when a work
item finishes. Because the WireGuard worker never returns, `last_progress_ts` is
never updated. Eventually, the workqueue watchdog (`wq_watchdog_timer_fn`)
notices that the pool hasn't made progress for more than the threshold (default
30 seconds) and triggers the `BUG: workqueue lockup`.
**Security Impact Assessment**
* **Exploitable:** No. This is a pure scheduling/watchdog issue. There is no
memory corruption, out-of-bounds access, use-after-free, or information leak. It
cannot be used for privilege escalation or to leak kernel memory.
* **Denial Of Service:** Yes. The bug triggers a `BUG()` which will flood the
kernel logs and can panic the system if `panic_on_wq_watchdog` or
`panic_on_oops` is enabled. Even without a panic, the worker thread monopolizes
a workqueue pool slot indefinitely, which can starve other kernel subsystems
relying on the same workqueue.
* **Network / Remote Trigger:** Yes. WireGuard listens on a UDP port. An
attacker can trigger this bug remotely by flooding the WireGuard UDP port with
packets (e.g., handshake initiation packets). The packets don't even need to be
fully authenticated to be queued into the `handshake_queue.ring`.
* **Accessible From Unprivileged Processes / User Namespaces:** Yes. A local
unprivileged user (or a user in a user namespace) can send UDP packets to the
local WireGuard listening port (e.g., via `127.0.0.1`) to flood the queue and
trigger the lockup. Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/11 01:03 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/09/11 01:03 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/e4df1e35f73e8871a0bb5986e0a3f7f88903d380]
|
| 3/1 |
2026/09/11 01:04 |
action |
kernel-builder |
19m
Results: map[KernelObj:/app/workdir/cache/build/4052259e3ac679a0ea4a40bb36f332ce6ba3596e]
|
| 4/1 |
2026/09/11 01:24 |
action |
codesearch-prepare |
10m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/11 01:34 |
agent |
expert |
7m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true 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 grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0 nice=0 stuck for 59s!
Showing busy workqueues and worker pools:
workqueue events: flags=0x100
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=5 refcnt=6
pending: 5*nsim_dev_hwstats_traffic_work
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=15 refcnt=16
pending: 5*nsim_dev_hwstats_traffic_work, 2*psi_avgs_work, 5*ovs_dp_masks_rebalance, drm_fb_helper_damage_work, 2*psi_avgs_work
workqueue events_unbound: flags=0x2
pwq 8: cpus=0-1 flags=0x6 nice=0 active=21 refcnt=22
in-flight: 5779:nsim_dev_trap_report_work for 4s ,6767:cfg80211_wiphy_work for 109s cfg80211_wiphy_work ,54:nsim_dev_trap_report_work for 1s ,7465:nsim_dev_trap_report_work for 3s ,3433:cfg80211_wiphy_work for 90s cfg80211_wiphy_work ,40:cfg80211_wiphy_work for 103s cfg80211_wiphy_work ,6761:cfg80211_wiphy_work for 110s cfg80211_wiphy_work ,1242:cfg80211_wiphy_work for 103s cfg80211_wiphy_work
pending: 2*nsim_dev_trap_report_work, macvlan_process_broadcast, toggle_allocation_gate, flush_memcg_stats_dwork, 3*nsim_dev_trap_report_work
pwq 8: cpus=0-1 flags=0x6 nice=0 active=13 refcnt=14
in-flight: 6770:linkwatch_event for 110s ,13:cfg80211_wiphy_work for 101s cfg80211_wiphy_work ,12:cfg80211_wiphy_work for 100s cfg80211_wiphy_work ,1421:cfg80211_wiphy_work for 102s cfg80211_wiphy_work ,392:nsim_dev_trap_report_work for 6s ,5777:cfg80211_wiphy_work for 72s cfg80211_wiphy_work ,6764:nsim_dev_trap_report_work for 5s ,6765:cfg80211_wiphy_work for 100s cfg80211_wiphy_work
workqueue events_power_efficient: flags=0x82
pwq 8: cpus=0-1 flags=0x6 nice=0 active=6 refcnt=7
in-flight: 3646:reg_check_chans_work for 39s ,6763:crda_timeout_work for 106s ,634:gc_worker for 45s
pending: check_lifetime, fb_flashcursor, wg_ratelimiter_gc_entries
pwq 8: cpus=0-1 flags=0x6 nice=0 active=4 refcnt=5
in-flight: 6762:neigh_periodic_work for 92s
pending: 2*neigh_managed_work, check_lifetime
workqueue events_dfl_long: flags=0x2
pwq 8: cpus=0-1 flags=0x6 nice=0 active=6 refcnt=7
in-flight: 6766:defense_work_handler for 1s
pending: 5*defense_work_handler
workqueue mm_percpu_wq: flags=0x108
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=1 refcnt=2
pending: vmstat_update
workqueue ipv6_addrconf: flags=0x6000a
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=7 MAYDAY
in-flight: 2821(RESCUER):addrconf_verify_work for 17s
inactive: addrconf_verify_work
workqueue krxrpcd: flags=0x2001a
pwq 9: cpus=0-1 node=0 flags=0x4 nice=-20 active=1 refcnt=4
pending: rxrpc_peer_keepalive_worker
workqueue bat_events: flags=0x6000a
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=45 MAYDAY
in-flight: 2853(RESCUER):batadv_tt_purge for 17s
inactive: 2*batadv_tt_purge, batadv_mcast_mla_update, batadv_bla_periodic_work, batadv_dat_purge, batadv_bla_periodic_work, 2*batadv_dat_purge, batadv_bla_periodic_work, batadv_dat_purge, batadv_bla_periodic_work, 4*batadv_mcast_mla_update, batadv_iv_send_outstanding_bat_ogm_packet, batadv_purge_orig, batadv_iv_send_outstanding_bat_ogm_packet, batadv_purge_orig, 8*batadv_iv_send_outstanding_bat_ogm_packet, 2*batadv_purge_orig, 2*batadv_iv_send_outstanding_bat_ogm_packet, batadv_purge_orig, 3*batadv_iv_send_outstanding_bat_ogm_packet, batadv_bla_periodic_work, batadv_dat_purge, 2*batadv_tt_purge
workqueue hci3: flags=0x20012
pwq 9: cpus=0-1 node=0 flags=0x4 nice=-20 active=1 refcnt=4
in-flight: 4709:hci_cmd_sync_work for 24s
workqueue wg-kex-wg0: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg0: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_tx_worker, wg_packet_encrypt_worker
workqueue wg-kex-wg1: flags=0x124
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=1 refcnt=2
in-flight: 4812:wg_packet_handshake_receive_worker for 1s
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_receive_worker
workqueue wg-kex-wg1: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
in-flight: 100:wg_packet_handshake_send_worker for 15s
workqueue wg-crypt-wg1: flags=0x128
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=2 refcnt=3
in-flight: 9:wg_packet_encrypt_worker for 13s wg_packet_encrypt_worker
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_tx_worker, wg_packet_encrypt_worker, wg_packet_decrypt_worker
workqueue wg-kex-wg2: flags=0x124
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=2 refcnt=3
in-flight: 4354:wg_packet_handshake_receive_worker for 34s wg_packet_handshake_receive_worker
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
in-flight: 24:wg_packet_handshake_receive_worker for 66s
pending: wg_packet_handshake_receive_worker
workqueue wg-crypt-wg2: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_decrypt_worker, wg_packet_encrypt_worker, wg_packet_tx_worker
workqueue hci1: flags=0x20012
pwq 9: cpus=0-1 node=0 flags=0x4 nice=-20 active=1 refcnt=4
in-flight: 50:hci_cmd_sync_work for 13s
workqueue wg-crypt-wg0: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_encrypt_worker, wg_packet_tx_worker
workqueue wg-kex-wg1: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg1: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_tx_worker, wg_packet_encrypt_worker
workqueue wg-kex-wg2: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg2: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_encrypt_worker, wg_packet_tx_worker
workqueue hci4: flags=0x20012
pwq 9: cpus=0-1 node=0 flags=0x4 nice=-20 active=1 refcnt=4
in-flight: 4715:hci_cmd_sync_work for 8s
workqueue wg-kex-wg0: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg0: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_tx_worker, wg_packet_encrypt_worker
workqueue wg-kex-wg1: flags=0x124
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_receive_worker
workqueue wg-kex-wg1: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg1: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_tx_worker, wg_packet_encrypt_worker, wg_packet_decrypt_worker
workqueue wg-kex-wg2: flags=0x124
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=1 refcnt=2
in-flight: 867:wg_packet_handshake_receive_worker for 20s
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_receive_worker
workqueue wg-crypt-wg2: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_decrypt_worker, wg_packet_encrypt_worker, wg_packet_tx_worker
workqueue hci0: flags=0x20012
pwq 9: cpus=0-1 node=0 flags=0x4 nice=-20 active=1 refcnt=4
in-flight: 4720:hci_cmd_sync_work for 3s
workqueue wg-kex-wg0: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg0: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_encrypt_worker, wg_packet_tx_worker
workqueue wg-crypt-wg1: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_tx_worker, wg_packet_encrypt_worker, wg_packet_decrypt_worker
workqueue wg-kex-wg2: flags=0x124
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=2 refcnt=3
in-flight: 10:wg_packet_handshake_receive_worker for 35s wg_packet_handshake_receive_worker
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
in-flight: 6073:wg_packet_handshake_receive_worker for 71s
pending: wg_packet_handshake_receive_worker
workqueue wg-crypt-wg2: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=4 refcnt=5
in-flight: 6013:wg_packet_decrypt_worker for 59s
pending: wg_packet_encrypt_worker, wg_packet_tx_worker, wg_packet_decrypt_worker
workqueue wg-kex-wg0: flags=0x6
pwq 8: cpus=0-1 flags=0x6 nice=0 active=1 refcnt=2
pending: wg_packet_handshake_send_worker
workqueue wg-crypt-wg0: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=2 refcnt=3
pending: wg_packet_tx_worker, wg_packet_encrypt_worker
workqueue wg-crypt-wg1: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_encrypt_worker, wg_packet_tx_worker, wg_packet_decrypt_worker
workqueue wg-kex-wg2: flags=0x124
pwq 2: cpus=0 node=0 flags=0x0 nice=0 active=1 refcnt=2
in-flight: 4813:wg_packet_handshake_receive_worker for 10s
workqueue wg-crypt-wg2: flags=0x128
pwq 6: cpus=1 node=0 flags=0x0 nice=0 active=3 refcnt=4
pending: wg_packet_decrypt_worker, wg_packet_encrypt_worker, wg_packet_tx_worker
pool 2: cpus=0 node=0 flags=0x0 nice=0 hung=0s workers=9 idle: 4793 4800 6315
pool 6: cpus=1 node=0 flags=0x0 nice=0 hung=59s workers=9 idle: 4809 1502 26 4712 4858 6058
pool 8: cpus=0-1 flags=0x6 nice=0 hung=1s workers=23 manager: 7466
pool 9: cpus=0-1 node=0 flags=0x4 nice=-20 hung=0s workers=8 idle: 4722 4707 4714 4719
Showing backtraces of busy workers in stalled worker pools:
pool 6:
task:kworker/1:6 state:R running task stack:0 pid:6013 tgid:6013 ppid:2 task_flags:0x4208060 flags:0x00000010
Workqueue: wg-crypt-wg2 wg_packet_decrypt_worker
Call trace:
__switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:775 (T)
context_switch kernel/sched/core.c:5520 [inline]
__schedule+0x1370/0x2d80 kernel/sched/core.c:7270
preempt_schedule_common+0xd4/0x190 kernel/sched/core.c:7449
preempt_schedule+0x60/0x78 kernel/sched/core.c:7473
__local_bh_enable_ip+0x20c/0x35c kernel/softirq.c:480
__raw_spin_unlock_bh include/linux/spinlock_api_smp.h:237 [inline]
_raw_spin_unlock_bh+0x3c/0x4c kernel/locking/spinlock.c:245
spin_unlock_bh include/linux/spinlock.h:407 [inline]
ptr_ring_consume_bh include/linux/ptr_ring.h:399 [inline]
wg_packet_decrypt_worker+0x980/0xa00 drivers/net/wireguard/receive.c:499
process_one_work kernel/workqueue.c:3387 [inline]
process_scheduled_works+0x91c/0x1250 kernel/workqueue.c:3470
worker_thread+0x798/0xbd0 kernel/workqueue.c:3551
kthread+0x304/0x3d4 kernel/kthread.c:436
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:838
pool 6:
task:kworker/1:0 state:R running task stack:0 pid:24 tgid:24 ppid:2 task_flags:0x4208060 flags:0x20000010
Workqueue: wg-kex-wg2 wg_packet_handshake_receive_worker
Call trace:
__switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:775 (T)
context_switch kernel/sched/core.c:5520 [inline]
__schedule+0x1370/0x2d80 kernel/sched/core.c:7270
preempt_schedule_common+0xd4/0x190 kernel/sched/core.c:7449
preempt_schedule+0x60/0x78 kernel/sched/core.c:7473
__local_bh_enable_ip+0x20c/0x35c kernel/softirq.c:480
local_bh_enable include/linux/bottom_half.h:33 [inline]
put_cpu_fpsimd_context arch/arm64/kernel/fpsimd.c:251 [inline]
kernel_neon_begin+0x29c/0x400 arch/arm64/kernel/fpsimd.c:1940
class_ksimd_constructor arch/arm64/include/asm/simd.h:48 [inline]
poly1305_blocks+0x110/0x204 lib/crypto/arm64/poly1305.h:30
poly1305_update+0x168/0x39c lib/crypto/poly1305.c:59
__chacha20poly1305_decrypt+0x1f4/0x39c lib/crypto/chacha20poly1305.c:146
chacha20poly1305_decrypt+0x238/0x5e4 lib/crypto/chacha20poly1305.c:186
message_decrypt+0x50/0x90 drivers/net/wireguard/noise.c:477
wg_noise_handshake_consume_initiation+0x1a0/0x53c drivers/net/wireguard/noise.c:612
wg_receive_handshake_packet drivers/net/wireguard/receive.c:144 [inline]
wg_packet_handshake_receive_worker+0x54c/0xcf8 drivers/net/wireguard/receive.c:213
process_one_work kernel/workqueue.c:3387 [inline]
process_scheduled_works+0x91c/0x1250 kernel/workqueue.c:3470
worker_thread+0x798/0xbd0 kernel/workqueue.c:3551
kthread+0x304/0x3d4 kernel/kthread.c:436
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:838
pool 6:
task:kworker/1:8 state:R running task stack:0 pid:6073 tgid:6073 ppid:2 task_flags:0x4208060 flags:0x00000010
Workqueue: wg-kex-wg2 wg_packet_handshake_receive_worker
Call trace:
__switch_to+0x2b4/0x6e4 arch/arm64/kernel/process.c:775 (T)
context_switch kernel/sched/core.c:5520 [inline]
__schedule+0x1370/0x2d80 kernel/sched/core.c:7270
preempt_schedule_common+0xd4/0x190 kernel/sched/core.c:7449
preempt_schedule+0x60/0x78 kernel/sched/core.c:7473
__local_bh_enable_ip+0x20c/0x35c kernel/softirq.c:480
local_bh_enable include/linux/bottom_half.h:33 [inline]
rcu_read_unlock_bh include/linux/rcupdate.h:923 [inline]
wg_index_hashtable_insert+0x78c/0x7fc drivers/net/wireguard/peerlookup.c:161
wg_noise_handshake_create_response+0x274/0x430 drivers/net/wireguard/noise.c:713
wg_packet_send_handshake_response+0xe8/0x264 drivers/net/wireguard/send.c:94
wg_receive_handshake_packet drivers/net/wireguard/receive.c:154 [inline]
wg_packet_handshake_receive_worker+0x570/0xcf8 drivers/net/wireguard/receive.c:213
process_one_work kernel/workqueue.c:3387 [inline]
process_scheduled_works+0x91c/0x1250 kernel/workqueue.c:3470
worker_thread+0x798/0xbd0 kernel/workqueue.c:3551
kthread+0x304/0x3d4 kernel/kthread.c:436
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:838
Reply: **Analysis of the Bug**
The bug report indicates a `BUG: workqueue lockup` in the WireGuard driver. The workqueue watchdog detected that worker threads in `pool 6` have been stuck for 59 seconds. The stack traces show that the stuck workers are executing WireGuard's workqueue functions: `wg_packet_decrypt_worker` and `wg_packet_handshake_receive_worker`.
Looking at the source code for these workers (e.g., `wg_packet_handshake_receive_worker` in `drivers/net/wireguard/receive.c`):
```c
void wg_packet_handshake_receive_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct wg_device *wg = container_of(queue, struct wg_device, handshake_queue);
struct sk_buff *skb;
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
wg_receive_handshake_packet(wg, skb);
dev_kfree_skb(skb);
atomic_dec(&wg->handshake_queue_len);
cond_resched();
}
}
```
The worker processes packets in a `while` loop as long as `ptr_ring_consume_bh()` returns a packet. `ptr_ring_consume_bh()` temporarily disables and then re-enables bottom halves (softirqs). This allows network RX softirqs to run concurrently and continuously refill the `ptr_ring` with new incoming packets.
If the incoming packet rate is sufficiently high, the `ptr_ring` will never be empty, and the `while` loop will never terminate. Although the loop calls `cond_resched()` to yield the CPU to other tasks (preventing a hard CPU lockup or RCU stall), it never actually returns from the work function back to the workqueue core (`process_scheduled_works()`).
The workqueue core updates the worker pool's `last_progress_ts` only when a work item finishes. Because the WireGuard worker never returns, `last_progress_ts` is never updated. Eventually, the workqueue watchdog (`wq_watchdog_timer_fn`) notices that the pool hasn't made progress for more than the threshold (default 30 seconds) and triggers the `BUG: workqueue lockup`.
**Security Impact Assessment**
* **Exploitable:** No. This is a pure scheduling/watchdog issue. There is no memory corruption, out-of-bounds access, use-after-free, or information leak. It cannot be used for privilege escalation or to leak kernel memory.
* **Denial Of Service:** Yes. The bug triggers a `BUG()` which will flood the kernel logs and can panic the system if `panic_on_wq_watchdog` or `panic_on_oops` is enabled. Even without a panic, the worker thread monopolizes a workqueue pool slot indefinitely, which can starve other kernel subsystems relying on the same workqueue.
* **Network / Remote Trigger:** Yes. WireGuard listens on a UDP port. An attacker can trigger this bug remotely by flooding the WireGuard UDP port with packets (e.g., handshake initiation packets). The packets don't even need to be fully authenticated to be queued into the `handshake_queue.ring`.
* **Accessible From Unprivileged Processes / User Namespaces:** Yes. A local unprivileged user (or a user in a user namespace) can send UDP packets to the local WireGuard listening port (e.g., via `127.0.0.1`) to flood the queue and trigger the lockup.
|
| 6/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 12199
output: 22
thoughts: 1201
Thoughts: **Analyzing a WireGuard Workqueue Lockup**
Okay, so I've got this bug report: "BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0 nice=0 stuck for 59s!" Right off the bat, it's a kernel panic, specifically related to a workqueue. The stack traces point directly to WireGuard, with the `wg_packet_decrypt_worker` and `wg_packet_handshake_receive_worker` functions being the culprits in multiple kworkers.
This feels like a workqueue saturation problem in WireGuard, likely due to a deluge of incoming packets, either handshakes or encrypted data. But is this a genuine bug or a saturation warning? I need to dig deeper. The warning is triggered by `wq_watchdog_timer_fn` in `kernel/workqueue.c`. It looks like the watchdog timer kicks in when a worker pool has been busy for longer than `wq_watchdog_thresh` (usually 30 seconds) without completing any work, or maybe is just constantly busy.
Okay, let's break this down further. The timer checks if `pool->watchdog_ts` is older than the threshold. The timestamp is updated either when a worker finishes a task or when the pool becomes idle. This implies that either a single work item is taking way too long, or the pool is getting starved of CPU time. The stack traces show workers are in the 'R' state – running. They're being preempted, which means they're *doing* work, but are they stuck in a tight loop?
Looking at `wg_packet_decrypt_worker` and `wg_packet_handshake_receive_worker` now. They're both processing packets from a queue. Let's start with `wg_packet_decrypt_worker`, specifically the `ptr_ring_consume_bh` function.
```c
void wg_packet_decrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct crypt_queue,
work);
struct sk_buff *skb;
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state =
likely(decrypt_packet(skb, PACKET_CB(skb)->keypair)) ?
PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
wg_queue_enqueue_per_peer_rx(skb, state);
if (need_resched())
cond_resched();
}
}
```
Okay, `ptr_ring_consume_bh` disables and enables BHs. This means it's looping through a ring buffer. The code calls `cond_resched()` if the scheduler suggests it needs to reschedule. However, this is the crux of the problem: `cond_resched()` doesn't update `pool->watchdog_ts`. That timestamp is only updated when the entire work item is complete (i.e., when `wg_packet_decrypt_worker` returns).
If another CPU is constantly filling the ring buffer, or if the queue is simply swamped with packets, `wg_packet_decrypt_worker` could run indefinitely without ever returning to update that `pool->watchdog_ts`. I need to understand the ring buffer size though. That function uses a ring buffer of fixed size. It appears to be `MAX_CRYPTO_QUEUE_DEPTH`, which I *think* is 4096. Okay, let me confirm.
|
| 7/2 |
2026/09/11 01:34 |
tool |
grepper |
0m
Error:
Args: map[Expression:MAX_CRYPTO_QUEUE_DEPTH]
Results:
|
| 8/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 14215
output: 20
thoughts: 19
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the WireGuard Queueing Header**
Okay, time to get my hands dirty. I'm going to jump straight into the `drivers/net/wireguard/queueing.h` file. I'm guessing this is where the core packet queue management for WireGuard is defined, and that's precisely where I need to start if I'm going to understand its performance characteristics. I'm especially interested in concurrency considerations and how they've handled potential bottlenecks, lock design, and any clever techniques used for efficient packet processing and flow control. Hopefully, there are some insightful comments that clearly describe the critical sections and data structures used for the queue. The kernel engineers are usually pretty meticulous, so I'm expecting some well-defined interfaces and perhaps some lock-free data structures. It will be interesting to see whether they’re using ring buffers, or something more sophisticated. And, of course, the interplay between the queueing strategy and the cryptographic operations is always a crucial area to assess.
|
| 9/2 |
2026/09/11 01:34 |
tool |
grepper |
0m
Args: map[Expression:define MAX_.*_QUEUE]
Results: map[Output:arch/um/drivers/virtio_uml.c-39-
arch/um/drivers/virtio_uml.c:40:#define MAX_SUPPORTED_QUEUE_SIZE 256
arch/um/drivers/virtio_uml.c-41-
--
drivers/char/ipmi/ipmi_msghandler.c=110=MODULE_PARM_DESC(panic_op, "Sets if the IPMI driver will attempt to store panic information in the event log in the event of a panic. Set to 'none' for no, 'ev...
--
drivers/char/ipmi/ipmi_msghandler.c-112-
drivers/char/ipmi/ipmi_msghandler.c:113:#define MAX_EVENTS_IN_QUEUE 25
drivers/char/ipmi/ipmi_msghandler.c-114-
--
drivers/crypto/cavium/nitrox/nitrox_dev.h-11-/* Maximum queues in PF mode */
drivers/crypto/cavium/nitrox/nitrox_dev.h:12:#define MAX_PF_QUEUES 64
drivers/crypto/cavium/nitrox/nitrox_dev.h-13-/* Maximum device queues */
drivers/crypto/cavium/nitrox/nitrox_dev.h:14:#define MAX_DEV_QUEUES (MAX_PF_QUEUES)
drivers/crypto/cavium/nitrox/nitrox_dev.h-15-/* Maximum UCD Blocks */
--
drivers/crypto/ccp/ccp-dev.h-31-
drivers/crypto/ccp/ccp-dev.h:32:#define MAX_HW_QUEUES 5
drivers/crypto/ccp/ccp-dev.h-33-#define MAX_CMD_QLEN 100
--
drivers/crypto/ccree/cc_driver.h=46=enum cc_std_body {
--
drivers/crypto/ccree/cc_driver.h-102-
drivers/crypto/ccree/cc_driver.h:103:#define MAX_REQUEST_QUEUE_SIZE 4096
drivers/crypto/ccree/cc_driver.h-104-#define MAX_MLLI_BUFF_SIZE 2080
--
drivers/dma/amd/ae4dma/ae4dma.h-24-
drivers/dma/amd/ae4dma/ae4dma.h:25:#define MAX_AE4_HW_QUEUES 16
drivers/dma/amd/ae4dma/ae4dma.h-26-
--
drivers/dma/amd/ptdma/ptdma.h-29-
drivers/dma/amd/ptdma/ptdma.h:30:#define MAX_HW_QUEUES 1
drivers/dma/amd/ptdma/ptdma.h-31-#define MAX_CMD_QLEN 100
--
drivers/gpu/drm/xe/xe_guc_submit.c=843=static void guc_exec_queue_send_cgp_sync(struct xe_exec_queue *q)
drivers/gpu/drm/xe/xe_guc_submit.c-844-{
drivers/gpu/drm/xe/xe_guc_submit.c:845:#define MAX_MULTI_QUEUE_CGP_SYNC_SIZE (2)
drivers/gpu/drm/xe/xe_guc_submit.c-846- struct xe_guc *guc = exec_queue_to_guc(q);
--
drivers/gpu/drm/xe/xe_guc_submit.c=860=static void __register_exec_queue_group(struct xe_exec_queue *q,
--
drivers/gpu/drm/xe/xe_guc_submit.c-863- struct xe_guc *guc = exec_queue_to_guc(q);
drivers/gpu/drm/xe/xe_guc_submit.c:864:#define MAX_MULTI_QUEUE_REG_SIZE (8)
drivers/gpu/drm/xe/xe_guc_submit.c-865- u32 action[MAX_MULTI_QUEUE_REG_SIZE];
--
drivers/infiniband/hw/hfi1/user_sdma.h-24- */
drivers/infiniband/hw/hfi1/user_sdma.h:25:#define MAX_PKTS_PER_QUEUE 16
drivers/infiniband/hw/hfi1/user_sdma.h-26-
--
drivers/infiniband/ulp/rtrs/rtrs-pri.h-33- */
drivers/infiniband/ulp/rtrs/rtrs-pri.h:34:#define MAX_SESS_QUEUE_DEPTH 65535
drivers/infiniband/ulp/rtrs/rtrs-pri.h-35-
--
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h=343=enum {
--
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h-347-};
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h:348:#define MAX_ETH_TXQ_IDX(bp) (BNX2X_NUM_NON_CNIC_QUEUES(bp) * (bp)->max_cos)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h-349-#define FCOE_TXQ_IDX(bp) (MAX_ETH_TXQ_IDX(bp) + FCOE_TXQ_IDX_OFFSET)
--
drivers/net/ethernet/cavium/liquidio/octeon_config.h=405=struct octeon_config {
--
drivers/net/ethernet/cavium/liquidio/octeon_config.h-457-/* Maximum number of Octeon Instruction (command) queues */
drivers/net/ethernet/cavium/liquidio/octeon_config.h:458:#define MAX_OCTEON_INSTR_QUEUES(oct) \
drivers/net/ethernet/cavium/liquidio/octeon_config.h-459- (OCTEON_CN23XX_PF(oct) ? CN23XX_MAX_INPUT_QUEUES : \
--
drivers/net/ethernet/cavium/liquidio/octeon_config.h-462-/* Maximum number of Octeon Instruction (command) queues */
drivers/net/ethernet/cavium/liquidio/octeon_config.h:463:#define MAX_OCTEON_OUTPUT_QUEUES(oct) \
drivers/net/ethernet/cavium/liquidio/octeon_config.h-464- (OCTEON_CN23XX_PF(oct) ? CN23XX_MAX_OUTPUT_QUEUES : \
--
drivers/net/ethernet/cavium/liquidio/octeon_config.h-466-
drivers/net/ethernet/cavium/liquidio/octeon_config.h:467:#define MAX_POSSIBLE_OCTEON_INSTR_QUEUES CN23XX_MAX_INPUT_QUEUES
drivers/net/ethernet/cavium/liquidio/octeon_config.h:468:#define MAX_POSSIBLE_OCTEON_OUTPUT_QUEUES CN23XX_MAX_OUTPUT_QUEUES
drivers/net/ethernet/cavium/liquidio/octeon_config.h-469-
--
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-14-#define MAX_QUEUE_SET 128
drivers/net/ethernet/cavium/thunder/nicvf_queues.h:15:#define MAX_RCV_QUEUES_PER_QS 8
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-16-#define MAX_RCV_BUF_DESC_RINGS_PER_QS 2
drivers/net/ethernet/cavium/thunder/nicvf_queues.h:17:#define MAX_SND_QUEUES_PER_QS 8
drivers/net/ethernet/cavium/thunder/nicvf_queues.h:18:#define MAX_CMP_QUEUES_PER_QS 8
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-19-
--
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-63-#define MIN_SND_QUEUE_LEN (1ULL << (SND_QUEUE_SIZE0 + 10))
drivers/net/ethernet/cavium/thunder/nicvf_queues.h:64:#define MAX_SND_QUEUE_LEN (1ULL << (SND_QUEUE_SIZE6 + 10))
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-65-#define SND_QUEUE_THRESH 2ULL
--
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-75-#define MIN_CMP_QUEUE_LEN (1ULL << (CMP_QUEUE_SIZE0 + 10))
drivers/net/ethernet/cavium/thunder/nicvf_queues.h:76:#define MAX_CMP_QUEUE_LEN (1ULL << (CMP_QUEUE_SIZE6 + 10))
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-77-#define CMP_QUEUE_CQE_THRESH (NAPI_POLL_WEIGHT / 2)
--
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-92-
drivers/net/ethernet/cavium/thunder/nicvf_queues.h:93:#define MAX_CQES_FOR_TX ((SND_QUEUE_LEN / MIN_SQ_DESC_PER_PKT_XMIT) * \
drivers/net/ethernet/cavium/thunder/nicvf_queues.h-94- MAX_CQE_PER_PKT_XMIT)
--
drivers/net/ethernet/faraday/ftgmac100.c=43=struct ftgmac100_match_data {
--
drivers/net/ethernet/faraday/ftgmac100.c-47-/* Arbitrary values, I am not sure the HW has limits */
drivers/net/ethernet/faraday/ftgmac100.c:48:#define MAX_RX_QUEUE_ENTRIES 1024
drivers/net/ethernet/faraday/ftgmac100.c:49:#define MAX_TX_QUEUE_ENTRIES 1024
drivers/net/ethernet/faraday/ftgmac100.c-50-#define MIN_RX_QUEUE_ENTRIES 32
--
drivers/net/ethernet/intel/fm10k/fm10k.h-18-
drivers/net/ethernet/intel/fm10k/fm10k.h:19:#define MAX_QUEUES FM10K_MAX_QUEUES_PF
drivers/net/ethernet/intel/fm10k/fm10k.h-20-
--
drivers/net/ethernet/intel/ixgbe/ixgbe.h=409=enum ixgbe_ring_f_enum {
--
drivers/net/ethernet/intel/ixgbe/ixgbe.h-425-#define IXGBE_MAX_FCOE_INDICES 8
drivers/net/ethernet/intel/ixgbe/ixgbe.h:426:#define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
drivers/net/ethernet/intel/ixgbe/ixgbe.h:427:#define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
drivers/net/ethernet/intel/ixgbe/ixgbe.h-428-#define IXGBE_MAX_XDP_QS (IXGBE_MAX_FDIR_INDICES + 1)
--
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h=90=struct ixgbevf_ring {
--
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h-129-
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h:130:#define MAX_RX_QUEUES IXGBE_VF_MAX_RX_QUEUES
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h:131:#define MAX_TX_QUEUES IXGBE_VF_MAX_TX_QUEUES
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h:132:#define MAX_XDP_QUEUES IXGBE_VF_MAX_TX_QUEUES
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h-133-#define IXGBEVF_MAX_RSS_QUEUES 2
--
drivers/net/fddi/skfp/h/targetos.h-91-
drivers/net/fddi/skfp/h/targetos.h:92:#define MAX_TX_QUEUE_LEN 20 // number of packets queued by driver
drivers/net/fddi/skfp/h/targetos.h-93-#define MAX_FRAME_SIZE 4550
--
drivers/net/tun.c=107=struct tap_filter {
--
drivers/net/tun.c-114- * to max number of VCPUs in guest. */
drivers/net/tun.c:115:#define MAX_TAP_QUEUES 256
drivers/net/tun.c-116-#define MAX_TAP_FLOWS 4096
--
drivers/net/vmxnet3/vmxnet3_defs.h=780=struct Vmxnet3_MemoryRegion {
--
drivers/net/vmxnet3/vmxnet3_defs.h-786-
drivers/net/vmxnet3/vmxnet3_defs.h:787:#define MAX_MEMORY_REGION_PER_QUEUE 16
drivers/net/vmxnet3/vmxnet3_defs.h-788-#define MAX_MEMORY_REGION_PER_DEVICE 256
--
drivers/net/wireless/ath/ath6kl/core.h-59-
drivers/net/wireless/ath/ath6kl/core.h:60:#define MAX_DEFAULT_SEND_QUEUE_DEPTH (MAX_DEF_COOKIE_NUM / WMM_NUM_AC)
drivers/net/wireless/ath/ath6kl/core.h-61-
--
drivers/net/wireless/rsi/rsi_main.h=62=extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
--
drivers/net/wireless/rsi/rsi_main.h-79-#define NUM_SOFT_QUEUES 6
drivers/net/wireless/rsi/rsi_main.h:80:#define MAX_HW_QUEUES 12
drivers/net/wireless/rsi/rsi_main.h-81-#define INVALID_QUEUE 0xff
--
drivers/net/wireless/ti/wl1251/acx.h=1129=struct wl1251_acx_tx_queue_config {
--
drivers/net/wireless/ti/wl1251/acx.h-1134-
drivers/net/wireless/ti/wl1251/acx.h:1135:#define MAX_TX_QUEUE_CONFIGS 5
drivers/net/wireless/ti/wl1251/acx.h:1136:#define MAX_TX_QUEUES 4
drivers/net/wireless/ti/wl1251/acx.h-1137-struct wl1251_acx_config_memory {
--
drivers/scsi/hpsa_cmd.h=694=struct TransTable_struct {
--
drivers/scsi/hpsa_cmd.h-699- __le32 RepQCtrAddrHigh32;
drivers/scsi/hpsa_cmd.h:700:#define MAX_REPLY_QUEUES 64
drivers/scsi/hpsa_cmd.h-701- struct vals32 RepQAddr[MAX_REPLY_QUEUES];
--
drivers/scsi/megaraid/megaraid_sas_fusion.h-38-#define MEGASAS_FUSION_MAX_RESET_TRIES 3
drivers/scsi/megaraid/megaraid_sas_fusion.h:39:#define MAX_MSIX_QUEUES_FUSION 128
drivers/scsi/megaraid/megaraid_sas_fusion.h-40-#define RDPQ_MAX_INDEX_IN_ONE_CHUNK 16
--
drivers/scsi/mpt3sas/mpt3sas_base.c=67=static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS];
--
drivers/scsi/mpt3sas/mpt3sas_base.c-72- /* maximum controller queue depth */
drivers/scsi/mpt3sas/mpt3sas_base.c:73:#define MAX_HBA_QUEUE_DEPTH 30000
drivers/scsi/mpt3sas/mpt3sas_base.c-74-#define MAX_CHAIN_DEPTH 100000
--
drivers/scsi/ncr53c8xx.c=916=typedef u32 tagmap_t;
--
drivers/scsi/ncr53c8xx.c-960-#ifdef SCSI_NCR_CAN_QUEUE
drivers/scsi/ncr53c8xx.c:961:#define MAX_START (SCSI_NCR_CAN_QUEUE + 4)
drivers/scsi/ncr53c8xx.c-962-#else
--
drivers/scsi/sym53c8xx_2/sym_hipd.h-177- */
drivers/scsi/sym53c8xx_2/sym_hipd.h:178:#define MAX_QUEUE SYM_CONF_MAX_QUEUE
drivers/scsi/sym53c8xx_2/sym_hipd.h-179-
--
drivers/staging/octeon/ethernet-defines.h-32-/* Maximum number of SKBs to try to free per xmit packet. */
drivers/staging/octeon/ethernet-defines.h:33:#define MAX_OUT_QUEUE_DEPTH 1000
drivers/staging/octeon/ethernet-defines.h-34-
--
drivers/staging/octeon/ethernet-tx.c=45=static DECLARE_TASKLET(cvm_oct_tx_cleanup_tasklet, cvm_oct_tx_do_cleanup);
--
drivers/staging/octeon/ethernet-tx.c-47-/* Maximum number of SKBs to try to free per xmit packet. */
drivers/staging/octeon/ethernet-tx.c:48:#define MAX_SKB_TO_FREE (MAX_OUT_QUEUE_DEPTH * 2)
drivers/staging/octeon/ethernet-tx.c-49-
--
drivers/staging/rtl8723bs/include/hal_com.h=74=enum rt_media_status {
--
drivers/staging/rtl8723bs/include/hal_com.h-81-/* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */
drivers/staging/rtl8723bs/include/hal_com.h:82:/* define MAX_TX_QUEUE 9 */
drivers/staging/rtl8723bs/include/hal_com.h-83-
--
fs/dlm/ast.c=223=void dlm_callback_suspend(struct dlm_ls *ls)
--
fs/dlm/ast.c-235-
fs/dlm/ast.c:236:#define MAX_CB_QUEUE 25
fs/dlm/ast.c-237-
--
include/linux/if_tap.h=21=static inline struct ptr_ring *tap_get_ptr_ring(struct file *f)
--
include/linux/if_tap.h-30- */
include/linux/if_tap.h:31:#define MAX_TAP_QUEUES 256
include/linux/if_tap.h-32-
--
include/linux/qed/common_hsi.h-84-/* Number of LL2 RAM based queues */
include/linux/qed/common_hsi.h:85:#define MAX_NUM_LL2_RX_RAM_QUEUES 32
include/linux/qed/common_hsi.h-86-
include/linux/qed/common_hsi.h-87-/* Number of LL2 context based queues */
include/linux/qed/common_hsi.h:88:#define MAX_NUM_LL2_RX_CTX_QUEUES 208
include/linux/qed/common_hsi.h:89:#define MAX_NUM_LL2_RX_QUEUES \
include/linux/qed/common_hsi.h-90- (MAX_NUM_LL2_RX_RAM_QUEUES + MAX_NUM_LL2_RX_CTX_QUEUES)
--
include/linux/qed/common_hsi.h-127-
include/linux/qed/common_hsi.h:128:#define MAX_NUM_L2_QUEUES_K2 (320)
include/linux/qed/common_hsi.h:129:#define MAX_NUM_L2_QUEUES_BB (256)
include/linux/qed/common_hsi.h:130:#define MAX_NUM_L2_QUEUES (MAX_NUM_L2_QUEUES_K2)
include/linux/qed/common_hsi.h-131-
--
include/linux/qed/common_hsi.h-355-/* Number of TX queues in the QM */
include/linux/qed/common_hsi.h:356:#define MAX_QM_TX_QUEUES_K2 512
include/linux/qed/common_hsi.h:357:#define MAX_QM_TX_QUEUES_BB 448
include/linux/qed/common_hsi.h:358:#define MAX_QM_TX_QUEUES MAX_QM_TX_QUEUES_K2
include/linux/qed/common_hsi.h-359-
include/linux/qed/common_hsi.h-360-/* Number of Other queues in the QM */
include/linux/qed/common_hsi.h:361:#define MAX_QM_OTHER_QUEUES_BB 64
include/linux/qed/common_hsi.h:362:#define MAX_QM_OTHER_QUEUES_K2 128
include/linux/qed/common_hsi.h:363:#define MAX_QM_OTHER_QUEUES MAX_QM_OTHER_QUEUES_K2
include/linux/qed/common_hsi.h-364-
--
include/net/mana/mana.h=35=enum mana_priv_flag_bits {
--
include/net/mana/mana.h-52- */
include/net/mana/mana.h:53:#define MAX_RX_BUFFERS_PER_QUEUE 8192
include/net/mana/mana.h-54-#define DEF_RX_BUFFERS_PER_QUEUE 1024
--
include/net/mana/mana.h-60- */
include/net/mana/mana.h:61:#define MAX_TX_BUFFERS_PER_QUEUE 16384
include/net/mana/mana.h-62-#define DEF_TX_BUFFERS_PER_QUEUE 256
--
include/uapi/linux/ethtool.h=1774=enum ethtool_sfeatures_retval_bits {
--
include/uapi/linux/ethtool.h-1783-
include/uapi/linux/ethtool.h:1784:#define MAX_NUM_QUEUE 4096
include/uapi/linux/ethtool.h-1785-
--
kernel/locking/lockdep.c=1440=static int add_lock_to_list(struct lock_class *this,
--
kernel/locking/lockdep.c-1471- */
kernel/locking/lockdep.c:1472:#define MAX_CIRCULAR_QUEUE_SIZE (1UL << CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS)
kernel/locking/lockdep.c-1473-#define CQ_MASK (MAX_CIRCULAR_QUEUE_SIZE-1)
--
net/mac80211/mesh_hwmp.c-18-
net/mac80211/mesh_hwmp.c:19:#define MAX_PREQ_QUEUE_LEN 64
net/mac80211/mesh_hwmp.c-20-
--
sound/core/seq/seq_queue.c=209=struct snd_seq_queue *snd_seq_queue_find_name(char *name)
--
sound/core/seq/seq_queue.c-227-
sound/core/seq/seq_queue.c:228:#define MAX_CELL_PROCESSES_IN_QUEUE 1000
sound/core/seq/seq_queue.c-229-
--
sound/usb/misc/ua101.c=21=MODULE_LICENSE("GPL v2");
--
sound/usb/misc/ua101.c-38-#define MAX_PACKET_SIZE 672 /* hardware specific */
sound/usb/misc/ua101.c:39:#define MAX_MEMORY_BUFFERS DIV_ROUND_UP(MAX_QUEUE_LENGTH, \
sound/usb/misc/ua101.c-40- PAGE_SIZE / MAX_PACKET_SIZE)
]
|
| 10/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 20997
output: 22
thoughts: 59
Thoughts: Here's my thought process, as if I were working on this:
**Digging into the WireGuard Queue Depth**
Okay, so I need to understand this `MAX_CRYPTO_QUEUE_DEPTH` constant. Let's start by confirming its location: Yep, it's definitely in `drivers/net/wireguard/queueing.h`. Just want to double-check that, though. I'll run a quick `grep` for `MAX_CRYPTO_QUEUE_DEPTH` again, just to make sure I didn't misread it, or maybe it’s not a simple `#define` and is being handled differently – I've seen some clever tricks in this kernel code before. Wouldn't want to miss anything subtle about how that value is actually used. Need to be thorough.
|
| 11/2 |
2026/09/11 01:34 |
tool |
grepper |
0m
Error:
Args: map[Expression:MAX_CRYPTO_QUEUE_DEPTH]
Results:
|
| 12/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 21264
output: 38
thoughts: 19
Thoughts: Here's my summary, as if I were thinking these thoughts:
**Examining the WireGuard Queueing Header**
Okay, time to dig in. To really understand how WireGuard is handling its packet queueing, I think the best approach is to go straight to the source. Let's not waste time with abstract explanations or generic network documentation right now. My intuition is telling me that the most precise information will be found by examining the code itself, so let's check `drivers/net/wireguard/queueing.h` directly. Understanding this header file, and its associated functions, will likely lay the groundwork for understanding the rest of the queueing mechanism. I expect to find the data structures used to store packets, any locking primitives involved, and probably some of the core function prototypes related to enqueueing, dequeueing, and packet handling within the queue. I want to build a mental map of how WireGuard orchestrates packet flow at a low level. Let's see what we find.
|
| 13/2 |
2026/09/11 01:34 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireguard/queueing.h FirstLine:1 LineCount:100]
Results: map[Contents: 1: /* SPDX-License-Identifier: GPL-2.0 */
2: /*
3: * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4: */
5:
6: #ifndef _WG_QUEUEING_H
7: #define _WG_QUEUEING_H
8:
9: #include "peer.h"
10: #include <linux/types.h>
11: #include <linux/skbuff.h>
12: #include <linux/ip.h>
13: #include <linux/ipv6.h>
14: #include <net/ip_tunnels.h>
15:
16: struct wg_device;
17: struct wg_peer;
18: struct multicore_worker;
19: struct crypt_queue;
20: struct prev_queue;
21: struct sk_buff;
22:
23: /* queueing.c APIs: */
24: int wg_packet_queue_init(struct crypt_queue *queue, work_func_t function,
25: unsigned int len);
26: void wg_packet_queue_free(struct crypt_queue *queue, bool purge);
27: struct multicore_worker __percpu *
28: wg_packet_percpu_multicore_worker_alloc(work_func_t function, void *ptr);
29:
30: /* receive.c APIs: */
31: void wg_packet_receive(struct wg_device *wg, struct sk_buff *skb);
32: void wg_packet_handshake_receive_worker(struct work_struct *work);
33: /* NAPI poll function: */
34: int wg_packet_rx_poll(struct napi_struct *napi, int budget);
35: /* Workqueue worker: */
36: void wg_packet_decrypt_worker(struct work_struct *work);
37:
38: /* send.c APIs: */
39: void wg_packet_send_queued_handshake_initiation(struct wg_peer *peer,
40: bool is_retry);
41: void wg_packet_send_handshake_response(struct wg_peer *peer);
42: void wg_packet_send_handshake_cookie(struct wg_device *wg,
43: struct sk_buff *initiating_skb,
44: __le32 sender_index);
45: void wg_packet_send_keepalive(struct wg_peer *peer);
46: void wg_packet_purge_staged_packets(struct wg_peer *peer);
47: void wg_packet_send_staged_packets(struct wg_peer *peer);
48: /* Workqueue workers: */
49: void wg_packet_handshake_send_worker(struct work_struct *work);
50: void wg_packet_tx_worker(struct work_struct *work);
51: void wg_packet_encrypt_worker(struct work_struct *work);
52:
53: enum packet_state {
54: PACKET_STATE_UNCRYPTED,
55: PACKET_STATE_CRYPTED,
56: PACKET_STATE_DEAD
57: };
58:
59: struct packet_cb {
60: u64 nonce;
61: struct noise_keypair *keypair;
62: atomic_t state;
63: u32 mtu;
64: u8 ds;
65: };
66:
67: #define PACKET_CB(skb) ((struct packet_cb *)((skb)->cb))
68: #define PACKET_PEER(skb) (PACKET_CB(skb)->keypair->entry.peer)
69:
70: static inline bool wg_check_packet_protocol(struct sk_buff *skb)
71: {
72: __be16 real_protocol = ip_tunnel_parse_protocol(skb);
73: return real_protocol && skb->protocol == real_protocol;
74: }
75:
76: static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating)
77: {
78: u8 l4_hash = skb->l4_hash;
79: u8 sw_hash = skb->sw_hash;
80: u32 hash = skb->hash;
81: skb_scrub_packet(skb, true);
82: memset(&skb->headers, 0, sizeof(skb->headers));
83: if (encapsulating) {
84: skb->l4_hash = l4_hash;
85: skb->sw_hash = sw_hash;
86: skb->hash = hash;
87: }
88: skb->queue_mapping = 0;
89: skb->nohdr = 0;
90: skb->peeked = 0;
91: skb->mac_len = 0;
92: skb->dev = NULL;
93: #ifdef CONFIG_NET_SCHED
94: skb->tc_index = 0;
95: #endif
96: skb_reset_redirect(skb);
97: skb->hdr_len = skb_headroom(skb);
98: skb_reset_mac_header(skb);
99: skb_reset_network_header(skb);
100: skb_reset_transport_header(skb);
]
|
| 14/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 23102
output: 21
thoughts: 33
Thoughts: Here's my take on the thought process, as requested:
**Navigating the WireGuard Codebase**
Alright, time to dive in. I need to get my bearings, so I'm thinking I'll start by exploring the core wireguard driver code. My initial thought is to either look at `drivers/net/wireguard/device.h` to get a high-level view of the device structure and associated data, or perhaps jump into `drivers/net/wireguard/queueing.c` to see how the packet queueing is handled within the driver. That should give me a solid foundation for understanding the architecture. From there, I can drill down as needed.
|
| 15/2 |
2026/09/11 01:34 |
tool |
grepper |
0m
Args: map[Expression:MAX_QUEUED_PACKETS]
Results: map[Output:drivers/net/wireguard/device.c=310=static int wg_newlink(struct net_device *dev,
--
drivers/net/wireguard/device.c-352- ret = wg_packet_queue_init(&wg->encrypt_queue, wg_packet_encrypt_worker,
drivers/net/wireguard/device.c:353: MAX_QUEUED_PACKETS);
drivers/net/wireguard/device.c-354- if (ret < 0)
--
drivers/net/wireguard/device.c-357- ret = wg_packet_queue_init(&wg->decrypt_queue, wg_packet_decrypt_worker,
drivers/net/wireguard/device.c:358: MAX_QUEUED_PACKETS);
drivers/net/wireguard/device.c-359- if (ret < 0)
--
drivers/net/wireguard/messages.h=40=enum limits {
--
drivers/net/wireguard/messages.h-52- MAX_STAGED_PACKETS = 128,
drivers/net/wireguard/messages.h:53: MAX_QUEUED_PACKETS = 1024 /* TODO: replace this with DQL */
drivers/net/wireguard/messages.h-54-};
--
drivers/net/wireguard/queueing.c=72=bool wg_prev_queue_enqueue(struct prev_queue *queue, struct sk_buff *skb)
drivers/net/wireguard/queueing.c-73-{
drivers/net/wireguard/queueing.c:74: if (!atomic_add_unless(&queue->count, 1, MAX_QUEUED_PACKETS))
drivers/net/wireguard/queueing.c-75- return false;
]
|
| 16/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 23752
output: 41
thoughts: 103
Thoughts: **Analyzing Packet Consumption in WireGuard**
Okay, so I'm looking at this code and I see that `MAX_QUEUED_PACKETS` is set to 1024. That immediately tells me `wg_packet_decrypt_worker` can potentially process up to 1024 packets at a time. My concern now is the interaction with the ring buffer. I'm thinking, if `wg_packet_receive` is constantly stuffing the ring buffer, and `ptr_ring_consume_bh` pulls packets off it, could the `wg_packet_decrypt_worker`'s loop end up running indefinitely? It feels like a race condition is possible if the consumption isn't fast enough. Time to go back and take another, closer look at the `wg_packet_decrypt_worker` function. I need to make sure I'm not missing something critical about how it handles the ring buffer under high load.
|
| 17/2 |
2026/09/11 01:34 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_decrypt_worker]
Results: map[SourceCode: 493: void wg_packet_decrypt_worker(struct work_struct *work)
494: {
495: struct crypt_queue *queue = container_of(work, struct multicore_worker,
496: work)->ptr;
497: struct sk_buff *skb;
498:
499: while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
500: enum packet_state state =
501: likely(decrypt_packet(skb, PACKET_CB(skb)->keypair)) ?
502: PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
503: wg_queue_enqueue_per_peer_rx(skb, state);
504: if (need_resched())
505: cond_resched();
506: }
507: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 18/2 |
2026/09/11 01:34 |
llm |
expert |
0m
Model:
Tokens:
input: 24374
output: 40
thoughts: 43
Thoughts: Here's my take on the thought process, as requested:
**Deconstructing a Critical Function Call**
Okay, so I'm looking at this code and immediately something jumps out – `ptr_ring_consume_bh`. I know that name. It's that function that's responsible for, essentially, taking a piece of data out of the circular buffer, a critical operation. But the "bh" suffix is what really catches my eye. It's a clear signal that this function is messing with bottom halves, or softirqs, which means it's manipulating the interrupt context, likely for synchronization.
My immediate assumption is that the function *disables* bottom halves, performs the consume operation, and *then* re-enables them. This is a common pattern to guarantee atomicity during buffer access, ensuring nothing else can interrupt and mess with our data while it's being read.
This sequence is super important because even a small race condition here would introduce all sorts of subtle, hard-to-debug concurrency problems. Now, I *need* to be sure that I know how the function is implemented. I want to check `ptr_ring_consume_bh` and ensure it's doing what I think it is. This is a critical point in the system, and it could be very complex, so I have to check it.
|
| 19/2 |
2026/09/11 01:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/ptr_ring.h Name:ptr_ring_consume_bh]
Results: map[SourceCode: 393: static inline void *ptr_ring_consume_bh(struct ptr_ring *r)
394: {
395: void *ptr;
396:
397: spin_lock_bh(&r->consumer_lock);
398: ptr = __ptr_ring_consume(r);
399: spin_unlock_bh(&r->consumer_lock);
400:
401: return ptr;
402: }
SourceFile:include/linux/ptr_ring.h]
|
| 20/2 |
2026/09/11 01:35 |
llm |
expert |
0m
Model:
Tokens:
input: 24905
output: 38
thoughts: 204
Thoughts: **Analyzing a Potential Workqueue Bottleneck**
Okay, so `spin_unlock_bh` is re-enabling bottom halves. Got it. Now, thinking about this `wg_packet_decrypt_worker`, if it's processing a constant stream of packets, it's going to loop indefinitely. Hold on... `ptr_ring_consume_bh` seems to be disabling and re-enabling bottom halves as well. That’s a key area to watch.
If `need_resched()` is true, it calls `cond_resched()`, but `cond_resched()` only yields the CPU to *other tasks*. It doesn't seem to yield to other workqueue items on the *same* worker pool, which is a problem. If this `wg_packet_decrypt_worker` is stuck in a tight loop, the workqueue watchdog is going to kick in. The worker will never return to the workqueue core, therefore `pool->watchdog_ts` won’t be updated.
Wait a second, does preemption update `pool->watchdog_ts`? No, it looks like it's only updated when a work item *finishes*. So preemption doesn't help. This confirms that the looping worker is the problem. Right, time to dig into `kernel/workqueue.c` to check how the `wq_watchdog_timer_fn` actually behaves. I need to understand this better.
|
| 21/2 |
2026/09/11 01:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/workqueue.c Name:wq_watchdog_timer_fn]
Results: map[SourceCode:7927: static void wq_watchdog_timer_fn(struct timer_list *unused)
7928: {
7929: unsigned long thresh = READ_ONCE(wq_watchdog_thresh) * HZ;
7930: unsigned int max_stall_time = 0;
7931: bool lockup_detected = false;
7932: bool cpu_pool_stall = false;
7933: unsigned long now = jiffies;
7934: struct worker_pool *pool;
7935: unsigned int stall_time;
7936: int pi;
7937:
7938: if (!thresh)
7939: return;
7940:
7941: for_each_pool(pool, pi) {
7942: unsigned long pool_ts, touched, ts;
7943:
7944: pool->cpu_stall = false;
7945: if (list_empty(&pool->worklist))
7946: continue;
7947:
7948: /*
7949: * If a virtual machine is stopped by the host it can look to
7950: * the watchdog like a stall.
7951: */
7952: kvm_check_and_clear_guest_paused();
7953:
7954: /* get the latest of pool and touched timestamps */
7955: if (pool->cpu >= 0)
7956: touched = READ_ONCE(per_cpu(wq_watchdog_touched_cpu, pool->cpu));
7957: else
7958: touched = READ_ONCE(wq_watchdog_touched);
7959: pool_ts = READ_ONCE(pool->last_progress_ts);
7960:
7961: if (time_after(pool_ts, touched))
7962: ts = pool_ts;
7963: else
7964: ts = touched;
7965:
7966: /*
7967: * Did we stall?
7968: *
7969: * Do a lockless check first to do not disturb the system.
7970: *
7971: * Prevent false positives by double checking the timestamp
7972: * under pool->lock. The lock makes sure that the check reads
7973: * an updated pool->last_progress_ts when this CPU saw
7974: * an already updated pool->worklist above. It seems better
7975: * than adding another barrier into __queue_work() which
7976: * is a hotter path.
7977: */
7978: if (time_after(now, ts + thresh)) {
7979: scoped_guard(raw_spinlock_irqsave, &pool->lock) {
7980: pool_ts = pool->last_progress_ts;
7981: if (time_after(pool_ts, touched))
7982: ts = pool_ts;
7983: else
7984: ts = touched;
7985: }
7986: if (!time_after(now, ts + thresh))
7987: continue;
7988:
7989: lockup_detected = true;
7990: stall_time = jiffies_to_msecs(now - pool_ts) / 1000;
7991: max_stall_time = max(max_stall_time, stall_time);
7992: if (is_percpu_pool(pool) && !(pool->flags & POOL_BH)) {
7993: pool->cpu_stall = true;
7994: cpu_pool_stall = true;
7995: }
7996: pr_emerg("BUG: workqueue lockup - pool");
7997: pr_cont_pool_info(pool);
7998: pr_cont(" stuck for %us!\n", stall_time);
7999: }
8000: }
8001:
8002: if (lockup_detected)
8003: show_all_workqueues();
8004:
8005: if (cpu_pool_stall)
8006: show_cpu_pools_busy_workers();
8007:
8008: if (lockup_detected)
8009: panic_on_wq_watchdog(max_stall_time);
8010:
8011: wq_watchdog_reset_touched();
8012: mod_timer(&wq_watchdog_timer, jiffies + thresh);
8013: }
SourceFile:kernel/workqueue.c]
|
| 22/2 |
2026/09/11 01:35 |
llm |
expert |
0m
Model:
Tokens:
input: 26756
output: 39
thoughts: 173
Thoughts: **Analyzing Potential Progress Stalling in the WireGuard Decryption Process**
Okay, so I'm looking at this `pool->last_progress_ts` update. It's supposed to be updated when a work item finishes, which should tell us something about the progress being made. But, if `wg_packet_decrypt_worker` gets stuck in an infinite loop, presumably because the ring buffer is constantly being refilled, then `pool->last_progress_ts` is never going to get updated. That's a problem.
Wait, though... the ring buffer consumption is handled by `ptr_ring_consume_bh`. And the size of this ring buffer is defined as `MAX_QUEUED_PACKETS`, which, according to the code, is 1024. So, it's not unlimited.
Okay, let's step back and consider the context. `wg_packet_receive` is filling the ring, and that runs in a softirq (NAPI), while `wg_packet_decrypt_worker` operates in process context within a workqueue. This is important.
Right, so `wg_packet_receive` is the enqueuing side, specifically putting packets into `wg->decrypt_queue.ring`. I need to double-check `wg_packet_receive` now to verify what's going on on that end. The interplay between NAPI and the workqueue is key here. I need to be absolutely sure how these two contexts are interacting, particularly in scenarios where the system is under heavy load.
|
| 23/2 |
2026/09/11 01:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_receive]
Results: map[SourceCode: 542: void wg_packet_receive(struct wg_device *wg, struct sk_buff *skb)
543: {
544: if (unlikely(prepare_skb_header(skb, wg) < 0))
545: goto err;
546: switch (SKB_TYPE_LE32(skb)) {
547: case cpu_to_le32(MESSAGE_HANDSHAKE_INITIATION):
548: case cpu_to_le32(MESSAGE_HANDSHAKE_RESPONSE):
549: case cpu_to_le32(MESSAGE_HANDSHAKE_COOKIE): {
550: int cpu, ret = -EBUSY;
551:
552: if (unlikely(!rng_is_initialized()))
553: goto drop;
554: if (atomic_read(&wg->handshake_queue_len) > MAX_QUEUED_INCOMING_HANDSHAKES / 2) {
555: if (spin_trylock_bh(&wg->handshake_queue.ring.producer_lock)) {
556: ret = __ptr_ring_produce(&wg->handshake_queue.ring, skb);
557: spin_unlock_bh(&wg->handshake_queue.ring.producer_lock);
558: }
559: } else
560: ret = ptr_ring_produce_bh(&wg->handshake_queue.ring, skb);
561: if (ret) {
562: drop:
563: net_dbg_skb_ratelimited("%s: Dropping handshake packet from %pISpfsc\n",
564: wg->dev->name, skb);
565: goto err;
566: }
567: atomic_inc(&wg->handshake_queue_len);
568: cpu = wg_cpumask_next_online(&wg->handshake_queue.last_cpu);
569: /* Queues up a call to packet_process_queued_handshake_packets(skb): */
570: queue_work_on(cpu, wg->handshake_receive_wq,
571: &per_cpu_ptr(wg->handshake_queue.worker, cpu)->work);
572: break;
573: }
574: case cpu_to_le32(MESSAGE_DATA):
575: PACKET_CB(skb)->ds = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
576: wg_packet_consume_data(wg, skb);
577: break;
578: default:
579: WARN(1, "Non-exhaustive parsing of packet header lead to unknown packet type!\n");
580: goto err;
581: }
582: return;
583:
584: err:
585: dev_kfree_skb(skb);
586: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 24/2 |
2026/09/11 01:35 |
llm |
expert |
0m
Model:
Tokens:
input: 28148
output: 41
thoughts: 24
Thoughts: Okay, here's my take on those thoughts, framed as my own:
**Analyzing Packet Consumption and Decryption**
Alright, so `wg_packet_consume_data` is responsible for enqueuing something onto the `decrypt_queue`. I need to verify what's happening there, right? This is likely a critical section for performance and security in this wireguard implementation. I immediately think about the potential bottlenecks: Are we dealing with any contention on the queue itself? What's the cost of the enqueue operation? Is this a lockless design or using mutexes? I need to understand the data structures involved, the locking primitives if any, and the throughput requirements of this stage. It is likely that this function is an optimization opportunity. I need to dig into the `decrypt_queue` implementation to fully understand the implications. Time to start tracing the data flow!
|
| 25/2 |
2026/09/11 01:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_consume_data]
Results: map[SourceCode: 509: static void wg_packet_consume_data(struct wg_device *wg, struct sk_buff *skb)
510: {
511: __le32 idx = ((struct message_data *)skb->data)->key_idx;
512: struct wg_peer *peer = NULL;
513: int ret;
514:
515: rcu_read_lock_bh();
516: PACKET_CB(skb)->keypair =
517: (struct noise_keypair *)wg_index_hashtable_lookup(
518: wg->index_hashtable, INDEX_HASHTABLE_KEYPAIR, idx,
519: &peer);
520: if (unlikely(!wg_noise_keypair_get(PACKET_CB(skb)->keypair)))
521: goto err_keypair;
522:
523: if (unlikely(READ_ONCE(peer->is_dead)))
524: goto err;
525:
526: ret = wg_queue_enqueue_per_device_and_peer(&wg->decrypt_queue, &peer->rx_queue, skb,
527: wg->packet_crypt_wq);
528: if (unlikely(ret == -EPIPE))
529: wg_queue_enqueue_per_peer_rx(skb, PACKET_STATE_DEAD);
530: if (likely(!ret || ret == -EPIPE)) {
531: rcu_read_unlock_bh();
532: return;
533: }
534: err:
535: wg_noise_keypair_put(PACKET_CB(skb)->keypair, false);
536: err_keypair:
537: rcu_read_unlock_bh();
538: wg_peer_put(peer);
539: dev_kfree_skb(skb);
540: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 26/2 |
2026/09/11 01:35 |
llm |
expert |
0m
Model:
Tokens:
input: 28974
output: 48
thoughts: 26
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this area:
**Decrypt Queue Enqueueing**
Right, so `wg_queue_enqueue_per_device_and_peer` is responsible for getting packets, presumably decrypted ones, into the system. The specific queue it's targeting is `wg->decrypt_queue`. This tells me that this function is the central point for handling incoming, decrypted traffic. It's the gatekeeper, deciding what goes where *after* the initial decryption stage. I'd need to look at the surrounding code to understand the context – is it prioritizing certain peers? Is there any load balancing involved? And crucially, what happens *after* a packet is enqueued on this `decrypt_queue`? Is there a separate thread or mechanism processing the items, or is it handled synchronously? My immediate next thoughts would be about the locking around this enqueue operation. Is it thread-safe? What are the potential contention points? Are we optimizing for performance with lock-free data structures? This is all pretty standard, but the details in this context are important.
|
| 27/2 |
2026/09/11 01:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/queueing.c Name:wg_queue_enqueue_per_device_and_peer]
Results: map[SourceCode: 152: static inline int wg_queue_enqueue_per_device_and_peer(
153: struct crypt_queue *device_queue, struct prev_queue *peer_queue,
154: struct sk_buff *skb, struct workqueue_struct *wq)
155: {
156: int cpu;
157:
158: atomic_set_release(&PACKET_CB(skb)->state, PACKET_STATE_UNCRYPTED);
159: /* We first queue this up for the peer ingestion, but the consumer
160: * will wait for the state to change to CRYPTED or DEAD before.
161: */
162: if (unlikely(!wg_prev_queue_enqueue(peer_queue, skb)))
163: return -ENOSPC;
164:
165: /* Then we queue it up in the device queue, which consumes the
166: * packet as soon as it can.
167: */
168: cpu = wg_cpumask_next_online(&device_queue->last_cpu);
169: if (unlikely(ptr_ring_produce_bh(&device_queue->ring, skb)))
170: return -EPIPE;
171: queue_work_on(cpu, wq, &per_cpu_ptr(device_queue->worker, cpu)->work);
172: return 0;
173: }
SourceFile:drivers/net/wireguard/queueing.h]
|
| 28/2 |
2026/09/11 01:35 |
llm |
expert |
0m
Model:
Tokens:
input: 29711
output: 45
thoughts: 575
Thoughts: **My Analysis of the Packet Decryption Workqueue**
Okay, so I'm thinking through this `wg_packet_decrypt_worker` and how it interacts with the packet ring buffer. My first concern is the potential for the ring to fill up, remembering that its size, `MAX_QUEUED_PACKETS`, is 1024. If `ptr_ring_produce_bh` fails because the ring is full, does that imply the worker will stop after processing at most 1024 packets? No, wait a minute, `ptr_ring_consume_bh` pulls packets *from* the ring. The `wg_packet_receive` function, which populates the ring, might be running concurrently on a different CPU, continuously adding data.
Hmm, but wait, `wg_packet_decrypt_worker` is pinned to a specific CPU, while `wg_packet_receive` is interrupt-driven, so it could be on a different core. If the network card keeps interrupting on CPU 0 and the decrypt worker is on CPU 1, then CPU 0 can keep filling the ring while CPU 1 is consuming. In a worst-case scenario, if CPU 0 is producing faster than CPU 1 consumes, it's possible the workqueue item could get stuck in an infinite loop.
But, a thought, `wg_packet_decrypt_worker` calls `cond_resched()`. Does `cond_resched()` prevent the workqueue watchdog from triggering? No, the watchdog tracks `pool->last_progress_ts` which is only updated when the work item *completes* and returns to the workqueue core. `cond_resched()` just yields the CPU, it doesn't return to the workqueue. Therefore, if this is an endless loop, the workqueue watchdog *will* trigger.
Is that the bug? Yes, it is. A workqueue item *should not* loop indefinitely. It should process a discrete batch of work, then re-queue itself if needed, or better, let the workqueue core handle scheduling.
Wait... if `ptr_ring_consume_bh` returns NULL, the loop terminates. That means if the producer is faster than the consumer the ring will fill up, but the consumer will keep consuming. But hold on, if the producer is faster, the `ptr_ring_produce_bh` function *should* return `-ENOSPC` or `-EPIPE` because the ring is full. However, the consumer is still running, right? The consumer will never catch up in this scenario, if the producer is faster?
Actually, if the producer is faster, the consumer will take one packet, and the producer will immediately put one packet back. So the ring will never be empty, meaning that `ptr_ring_consume_bh` will never return NULL. Thus, `wg_packet_decrypt_worker` will loop indefinitely.
Okay, this is a classic unbounded workqueue item problem. I've seen this pattern before. Let me see if there's an existing patch or discussion about this specific issue...
|
| 29/2 |
2026/09/11 01:35 |
tool |
git-log |
0m
Args: map[CodeRegexp:wg_packet_decrypt_worker Count:10 SourcePath:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 30/2 |
2026/09/11 01:35 |
llm |
expert |
0m
Model:
Tokens:
input: 31027
output: 42
thoughts: 38
Thoughts: Okay, here's my take on those thoughts, framed as my own:
**Investigating a Git Log Anomaly**
Hold on a second, something feels off about this `git log` output. It's not quite what I expected. I need to dig deeper. My gut tells me there might be some related issues buried in the recent history of that `drivers/net/wireguard/receive.c` file. Specifically, I'm thinking about threading and potential lockup scenarios.
Let's try a focused search. I'm going to run a `git log` command, specifically targeting that file, but I need to include keywords to refine the results. I should search for commits that mention "workqueue" or "lockup." That should narrow things down and potentially expose the root cause of this odd behavior I'm seeing. Hopefully, that will give me some insight into what's going on.
|
| 31/2 |
2026/09/11 01:36 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[workqueue wireguard] PathPrefix:drivers/net/wireguard/]
Results:
|
| 32/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 31313
output: 29
thoughts: 18
Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience:
**Analyzing Code History for WireGuard and Workqueue Interactions**
Alright, so I need to dig into the project's commit history. My gut tells me there might be something interesting in the interplay between WireGuard and the kernel's workqueue mechanism. It's a common area for subtle concurrency bugs or performance bottlenecks, and I want to see if any specific interactions or optimizations have been made, or if there are any potential issues I should be aware of. My intuition leans toward finding areas where WireGuard might be submitting work to the queue or where the workqueue is interacting with WireGuard's data structures. So, I need to start by doing a thorough search, casting a wide net. I'll search for both "wireguard" *and* "workqueue" across *all* commits. This should give me a solid foundation for further investigation, allowing me to identify relevant commits efficiently. Then, I can filter and analyze those commits for anything truly important.
|
| 33/2 |
2026/09/11 01:36 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[wireguard workqueue]]
Results:
|
| 34/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 31592
output: 29
thoughts: 10
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Initial Association: Wireguard & System Lockups**
Alright, my brain just flicked on a potential connection. The word "wireguard" immediately triggers a thought about the possibility of system "lockup" – a pretty broad term, of course. I'm already thinking about potential scenarios where these two might intersect. We're probably talking about some kind of performance issue or a system instability that's manifesting somehow. It could be something fundamental to the core of Wireguard, or maybe an interaction with the environment it is deployed in. More details are definitely needed, but that's my initial, gut reaction. Let's see where this goes.
|
| 35/2 |
2026/09/11 01:36 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[wireguard lockup]]
Results:
|
| 36/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 31804
output: 31
thoughts: 22
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the WireGuard Receive Path**
Alright, let's cut the fluff and go straight to the source. Time to dig into the heart of the matter – the receive path for WireGuard. Instead of relying on vague recollections or documentation, I'm going to pull up the `git log` for `drivers/net/wireguard/receive.c`. Seeing the commit history directly will give me the clearest picture of how this section has evolved, any recent bug fixes or performance optimizations, and perhaps even illuminate the rationale behind particular design choices. This targeted approach should quickly refresh my understanding of the receive-side processing, any lingering pain points, or potential areas for further investigation or improvement. Let's see what the revision history has to say.
|
| 37/2 |
2026/09/11 01:36 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 38/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 32075
output: 21
thoughts: 77
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Debugging a Suspect Git Log**
Hold on a second... the `git log` output is only showing a single commit? That's deeply suspicious. With a project like this, it's virtually impossible there's *only* one commit. My initial thought is that the `git log` command itself might be the culprit. Perhaps it's being limited by some default behavior, like stopping at the first match due to filtering or an incomplete checkout of the tree. I need to be sure the log is comprehensive.
Rather than diving into more complex git commands immediately, I'm going to leverage `grepper`. I'll use it to quickly search for recent modifications within `drivers/net/wireguard/receive.c`. That should give me a more granular view and help me pinpoint if there have actually been any recent changes, or if the lack of commits in `git log` is genuinely a problem, or just a display issue. A quick `grepper` search will likely cut right through the issue.
|
| 39/2 |
2026/09/11 01:36 |
tool |
grepper |
0m
Args: map[Expression:wg_packet_decrypt_worker]
Results: map[Output:drivers/net/wireguard/device.c=310=static int wg_newlink(struct net_device *dev,
--
drivers/net/wireguard/device.c-356-
drivers/net/wireguard/device.c:357: ret = wg_packet_queue_init(&wg->decrypt_queue, wg_packet_decrypt_worker,
drivers/net/wireguard/device.c-358- MAX_QUEUED_PACKETS);
--
drivers/net/wireguard/queueing.h=34=int wg_packet_rx_poll(struct napi_struct *napi, int budget);
drivers/net/wireguard/queueing.h-35-/* Workqueue worker: */
drivers/net/wireguard/queueing.h:36:void wg_packet_decrypt_worker(struct work_struct *work);
drivers/net/wireguard/queueing.h-37-
--
drivers/net/wireguard/receive.c=438=int wg_packet_rx_poll(struct napi_struct *napi, int budget)
--
drivers/net/wireguard/receive.c-492-
drivers/net/wireguard/receive.c:493:void wg_packet_decrypt_worker(struct work_struct *work)
drivers/net/wireguard/receive.c-494-{
]
|
| 40/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 32742
output: 44
thoughts: 29
Thoughts: Here's my take on the thought process, as if it were my own:
**Investigating a WireGuard Receive Path**
Alright, time to dive in. I need to refresh my memory on how WireGuard handles incoming packets. Specifically, I'm focusing on the receive path. Let's start by pinpointing the function responsible for receiving the handshake – that's a key part of the connection process. I'm going to jump into the `drivers/net/wireguard/receive.c` file and zero in on the `wg_packet_handshake_receive_worker` function. That name sounds like the likely candidate; it's a good starting point for understanding how the handshake process is handled when a packet arrives. Hopefully, this function's logic will give me the insights I need.
|
| 41/2 |
2026/09/11 01:36 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_handshake_receive_worker]
Results: map[SourceCode: 206: void wg_packet_handshake_receive_worker(struct work_struct *work)
207: {
208: struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
209: struct wg_device *wg = container_of(queue, struct wg_device, handshake_queue);
210: struct sk_buff *skb;
211:
212: while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
213: wg_receive_handshake_packet(wg, skb);
214: dev_kfree_skb(skb);
215: atomic_dec(&wg->handshake_queue_len);
216: cond_resched();
217: }
218: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 42/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 33248
output: 42
thoughts: 267
Thoughts: **My Assessment of the WireGuard Vulnerability**
Okay, so I'm looking at this code snippet, and I'm seeing a pattern that's raising some red flags: `while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL)`. It's a classic ring buffer consumption loop, but if that ring is constantly being filled with new packets, this thing is going to run *forever*. That's the first question: is this exploitable?
Alright, let's play this out. An attacker could flood a WireGuard port with a continuous stream of either handshake or data packets. If they can send those packets *fast enough*, we're talking about that worker thread getting stuck in an infinite loop. And if that happens, we've got a workqueue lockup. I know this from experience, those often trigger a "BUG" message in the kernel logs.
Wait a second, the "BUG" message is only a warning by default. But if `panic_on_wq_watchdog` is enabled, then it's a kernel panic! I need to check the defaults. Okay, `panic_on_wq_watchdog` is zero by default, which is not ideal, but not as bad as a panic.
Now I'm thinking about the implications. Even without a panic, that worker thread being stuck in a loop will consume 100% of a CPU core. And what if the attacker targets *multiple* queues? They could potentially lock up multiple CPUs, taking the entire system down. This definitely looks like a Denial of Service vulnerability.
Can this be triggered remotely? Absolutely. All an attacker needs is to send UDP packets to the WireGuard port. That's a huge problem. Now, I have to check, does the attacker need to be authenticated? We're talking about the `wg_packet_handshake_receive_worker` so that is probably the first place to look. I need to dig into the `wg_receive_handshake_packet` function to see what checks are done to confirm whether it is legitimate.
|
| 43/2 |
2026/09/11 01:36 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_receive_handshake_packet]
Results: map[SourceCode: 92: static void wg_receive_handshake_packet(struct wg_device *wg,
93: struct sk_buff *skb)
94: {
95: enum cookie_mac_state mac_state;
96: struct wg_peer *peer = NULL;
97: /* This is global, so that our load calculation applies to the whole
98: * system. We don't care about races with it at all.
99: */
100: static u64 last_under_load;
101: bool packet_needs_cookie;
102: bool under_load;
103:
104: if (SKB_TYPE_LE32(skb) == cpu_to_le32(MESSAGE_HANDSHAKE_COOKIE)) {
105: net_dbg_skb_ratelimited("%s: Receiving cookie response from %pISpfsc\n",
106: wg->dev->name, skb);
107: wg_cookie_message_consume(
108: (struct message_handshake_cookie *)skb->data, wg);
109: return;
110: }
111:
112: under_load = atomic_read(&wg->handshake_queue_len) >=
113: MAX_QUEUED_INCOMING_HANDSHAKES / 8;
114: if (under_load) {
115: last_under_load = ktime_get_coarse_boottime_ns();
116: } else if (last_under_load) {
117: under_load = !wg_birthdate_has_expired(last_under_load, 1);
118: if (!under_load)
119: last_under_load = 0;
120: }
121: mac_state = wg_cookie_validate_packet(&wg->cookie_checker, skb,
122: under_load);
123: if ((under_load && mac_state == VALID_MAC_WITH_COOKIE) ||
124: (!under_load && mac_state == VALID_MAC_BUT_NO_COOKIE)) {
125: packet_needs_cookie = false;
126: } else if (under_load && mac_state == VALID_MAC_BUT_NO_COOKIE) {
127: packet_needs_cookie = true;
128: } else {
129: net_dbg_skb_ratelimited("%s: Invalid MAC of handshake, dropping packet from %pISpfsc\n",
130: wg->dev->name, skb);
131: return;
132: }
133:
134: switch (SKB_TYPE_LE32(skb)) {
135: case cpu_to_le32(MESSAGE_HANDSHAKE_INITIATION): {
136: struct message_handshake_initiation *message =
137: (struct message_handshake_initiation *)skb->data;
138:
139: if (packet_needs_cookie) {
140: wg_packet_send_handshake_cookie(wg, skb,
141: message->sender_index);
142: return;
143: }
144: peer = wg_noise_handshake_consume_initiation(message, wg);
145: if (unlikely(!peer)) {
146: net_dbg_skb_ratelimited("%s: Invalid handshake initiation from %pISpfsc\n",
147: wg->dev->name, skb);
148: return;
149: }
150: wg_socket_set_peer_endpoint_from_skb(peer, skb);
151: net_dbg_ratelimited("%s: Receiving handshake initiation from peer %llu (%pISpfsc)\n",
152: wg->dev->name, peer->internal_id,
153: &peer->endpoint.addr);
154: wg_packet_send_handshake_response(peer);
155: break;
156: }
157: case cpu_to_le32(MESSAGE_HANDSHAKE_RESPONSE): {
158: struct message_handshake_response *message =
159: (struct message_handshake_response *)skb->data;
160:
161: if (packet_needs_cookie) {
162: wg_packet_send_handshake_cookie(wg, skb,
163: message->sender_index);
164: return;
165: }
166: peer = wg_noise_handshake_consume_response(message, wg);
167: if (unlikely(!peer)) {
168: net_dbg_skb_ratelimited("%s: Invalid handshake response from %pISpfsc\n",
169: wg->dev->name, skb);
170: return;
171: }
172: wg_socket_set_peer_endpoint_from_skb(peer, skb);
173: net_dbg_ratelimited("%s: Receiving handshake response from peer %llu (%pISpfsc)\n",
174: wg->dev->name, peer->internal_id,
175: &peer->endpoint.addr);
176: if (wg_noise_handshake_begin_session(&peer->handshake,
177: &peer->keypairs)) {
178: wg_timers_session_derived(peer);
179: wg_timers_handshake_complete(peer);
180: /* Calling this function will either send any existing
181: * packets in the queue and not send a keepalive, which
182: * is the best case, Or, if there's nothing in the
183: * queue, it will send a keepalive, in order to give
184: * immediate confirmation of the session.
185: */
186: wg_packet_send_keepalive(peer);
187: }
188: break;
189: }
190: }
191:
192: if (unlikely(!peer)) {
193: WARN(1, "Somehow a wrong type of packet wound up in the handshake queue!\n");
194: return;
195: }
196:
197: local_bh_disable();
198: update_rx_stats(peer, skb->len);
199: local_bh_enable();
200:
201: wg_timers_any_authenticated_packet_received(peer);
202: wg_timers_any_authenticated_packet_traversal(peer);
203: wg_peer_put(peer);
204: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 44/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 35929
output: 19
thoughts: 329
Thoughts: **Analyzing a Potential WireGuard Handshake Vulnerability**
Okay, so I'm thinking through this WireGuard handshake process and I've hit a potential snag. I'm focusing on the packet validation steps, specifically around the MAC checks. It initially seems like the `wg_receive_handshake_packet` function validates the MAC, and `wg_cookie_validate_packet` does the same. If the MAC is bad, it just drops the packet, right? But hold on... an attacker could just generate packets with *valid* MACs. And here's the kicker: MAC1 is calculated using the responder's *public* key, which the attacker obviously knows. So, yes, they *can* generate valid MAC1s.
Under load, the system requires a MAC2 (cookie). An attacker could simply *request* a cookie, and then start sending packets with both valid MAC1 and MAC2. Essentially, they could flood the handshake queue.
Now, I'm recalling that `wg_packet_handshake_receive_worker` processes those packets. If the queue is flooded, this worker would just... loop. And here's where it gets interesting: I see `cond_resched()` called within that loop. I'm wondering now if `cond_resched()` could actually *prevent* the workqueue watchdog from triggering. That could be a serious problem.
Let me dig a little deeper into `cond_resched()`. My understanding is that it yields the CPU to other tasks, but does it make the workqueue progress. I know the workqueue watchdog checks if the worker pool is making progress. Progress is essentially defined by a work item finishing. If a work item loops indefinitely, it never finishes, meaning `pool->last_progress_ts` never gets updated.
Wait, is there any other way `pool->last_progress_ts` is updated? I need to double-check `kernel/workqueue.c` to see how `last_progress_ts` is being handled. This could be the key to understanding if the watchdog can be bypassed.
|
| 45/2 |
2026/09/11 01:36 |
tool |
grepper |
0m
Args: map[Expression:last_progress_ts]
Results: map[Output:kernel/workqueue.c=195=struct worker_pool {
--
kernel/workqueue.c-201-
kernel/workqueue.c:202: unsigned long last_progress_ts; /* L: last forward progress timestamp */
kernel/workqueue.c-203- bool cpu_stall; /* WD: stalled cpu bound pool */
--
kernel/workqueue.c=1746=static void __pwq_activate_work(struct pool_workqueue *pwq,
--
kernel/workqueue.c-1753- if (list_empty(&pwq->pool->worklist))
kernel/workqueue.c:1754: pwq->pool->last_progress_ts = jiffies;
kernel/workqueue.c-1755- move_linked_works(work, &pwq->pool->worklist, NULL);
--
kernel/workqueue.c=2321=static void __queue_work(int cpu, struct workqueue_struct *wq,
--
kernel/workqueue.c-2444- if (list_empty(&pool->worklist))
kernel/workqueue.c:2445: pool->last_progress_ts = jiffies;
kernel/workqueue.c-2446-
--
kernel/workqueue.c=3459=static void process_scheduled_works(struct worker *worker)
--
kernel/workqueue.c-3466- if (first) {
kernel/workqueue.c:3467: worker->pool->last_progress_ts = jiffies;
kernel/workqueue.c-3468- first = false;
--
kernel/workqueue.c=4958=static int init_worker_pool(struct worker_pool *pool)
--
kernel/workqueue.c-4964- pool->flags |= POOL_DISASSOCIATED;
kernel/workqueue.c:4965: pool->last_progress_ts = jiffies;
kernel/workqueue.c-4966- INIT_LIST_HEAD(&pool->worklist);
--
kernel/workqueue.c=6658=static void show_one_worker_pool(struct worker_pool *pool)
--
kernel/workqueue.c-6670- if (!list_empty(&pool->worklist))
kernel/workqueue.c:6671: hung = jiffies_to_msecs(jiffies - pool->last_progress_ts) / 1000;
kernel/workqueue.c-6672-
--
kernel/workqueue.c=7927=static void wq_watchdog_timer_fn(struct timer_list *unused)
--
kernel/workqueue.c-7958- touched = READ_ONCE(wq_watchdog_touched);
kernel/workqueue.c:7959: pool_ts = READ_ONCE(pool->last_progress_ts);
kernel/workqueue.c-7960-
--
kernel/workqueue.c-7972- * under pool->lock. The lock makes sure that the check reads
kernel/workqueue.c:7973: * an updated pool->last_progress_ts when this CPU saw
kernel/workqueue.c-7974- * an already updated pool->worklist above. It seems better
--
kernel/workqueue.c-7979- scoped_guard(raw_spinlock_irqsave, &pool->lock) {
kernel/workqueue.c:7980: pool_ts = pool->last_progress_ts;
kernel/workqueue.c-7981- if (time_after(pool_ts, touched))
]
|
| 46/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 37645
output: 33
thoughts: 487
Thoughts: **Analyzing a Potential Workqueue Lockup in WireGuard**
Okay, so I'm digging into this WireGuard workqueue issue. The `pool->last_progress_ts` timestamp gets updated in `process_scheduled_works`, right? Specifically, inside the loop that processes scheduled work items. And that `last_progress_ts` update only happens at the beginning of the loop in `process_scheduled_works`. I can see that.
But here's the kicker: `process_one_work` *executes* the work function. If, for some reason, one of these work functions, say `wg_packet_handshake_receive_worker` or `wg_packet_decrypt_worker`, gets stuck in an infinite loop inside `process_one_work`, then `process_scheduled_works` *never* loops again. Meaning, that timestamp, `pool->last_progress_ts`, never gets updated. Bingo! That would definitely trigger the workqueue watchdog, as I suspected.
Now, the critical question: how can these work functions loop forever? I have to look into the details of `ptr_ring_consume_bh`. Let's re-examine that function. It consumes from the ring, yeah. The ring is populated by `wg_packet_receive`, which runs in NAPI (softirq).
However! `wg_packet_decrypt_worker` actually disables BH (bottom halves) when it calls `ptr_ring_consume_bh` with `spin_lock_bh`. *But* it reenables them when it returns. That's key. This means softirqs *can* run between iterations of the loop in `ptr_ring_consume_bh`. That opens the door for NAPI to run, `wg_packet_receive` to get called, and potentially fill the ring. If the ring is continuously filled, and the consuming function does not finish, the loop can indeed run indefinitely!
So, the issue isn't that a softirq blocks the workqueue, but that the workqueue blocks the softirq. Since `ptr_ring_consume_bh` disables bh, the ring becomes full and `wg_packet_receive` is no longer able to free packets to the ring due to the lock in `wg_packet_decrypt_worker`.
Okay, is this a known problem? Time to hit the search engines. Let's try some keywords: "wireguard workqueue lockup", "wireguard ptr_ring_consume_bh loop". Let's see what the community has to say about it.
|
| 47/2 |
2026/09/11 01:36 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[wireguard workqueue loop]]
Results:
|
| 48/2 |
2026/09/11 01:36 |
llm |
expert |
0m
Model:
Tokens:
input: 38725
output: 29
thoughts: 14
Thoughts: Okay, here's my attempt at summarizing those thoughts from a first-person, expert perspective:
**Initial Investigation: Wireguard & Watchdog**
Alright, let's get down to brass tacks. My initial thought process is to quickly scope out the intersection of "wireguard" and "watchdog" – two key elements in a secure and robust network infrastructure. Given my expertise, I'm likely thinking about scenarios where a watchdog process is crucial for maintaining the uptime and proper functioning of a WireGuard VPN connection. It could involve monitoring the tunnel's state, checking for network connectivity, or even ensuring the WireGuard service itself remains healthy. I'm immediately running through the potential implementations in my head: scripting, systemd unit configurations with appropriate dependencies, perhaps custom code for edge cases. I'm also considering the specific platform: Linux, embedded systems, or even cloud deployments. Different platforms have various options for watchdog processes. Now the real digging begins.
|
| 49/2 |
2026/09/11 01:37 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[wireguard watchdog]]
Results:
|
| 50/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 38980
output: 31
thoughts: 16
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Investigating Potential WireGuard Concurrency Issues**
Okay, so I'm thinking, "wireguard" and "cond_resched" – that's a specific combination. My immediate thought is that these terms together likely point to a potential concurrency or scheduling issue within a WireGuard context. 'cond_resched' typically signals conditional rescheduling, which usually suggests some kind of locking contention or resource starvation where a task is forced to yield the CPU and wait for a condition to be met before resuming.
My mind's already racing, wondering about the specific scenarios that might trigger this. Is this in the kernel module itself, user-space components interacting with it, or maybe something downstream in networking? Are we looking at a performance bottleneck, a subtle race condition, or a full-blown deadlock?
I'm mentally preparing for a deep dive into the code. The search terms suggest looking at the kernel implementation, specifically any use of synchronization primitives like mutexes, spinlocks, or even atomic operations, within the WireGuard module and its interactions with the kernel's scheduler. The focus would be on how these primitives are used to protect shared data and resources. Any interaction with kernel facilities like workqueues or tasklets would be an important consideration, as well.
I’m also considering how WireGuard's asynchronous nature, particularly its handling of packets and connections, might exacerbate these kinds of issues. Any context switches within the networking stack would be another place to look. Ultimately, I'm expecting to find a point where a task is blocked waiting for a resource to become available, likely leading to some kind of slowdown or, in extreme cases, a system hang. So, let’s get started.
|
| 51/2 |
2026/09/11 01:37 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[wireguard cond_resched]]
Results:
|
| 52/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 39409
output: 31
thoughts: 16
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Investigating a Potential WireGuard Scheduling Issue**
Okay, so I'm thinking, "wireguard" and "need_resched". My mind immediately jumps to potential race conditions or contention issues within the WireGuard kernel module, specifically around how it interacts with the scheduler. The `need_resched` flag, in that context, is a red flag. It points to scenarios where a task might be relinquishing the CPU, and I need to understand *why* in the context of WireGuard's operation.
I'm probably thinking about the interrupt handlers, especially with high packet rates, and how those interactions are managed. Are we seeing excessive preemption? Is a WireGuard context potentially starving other important tasks? The "need_resched" flag, when coupled with a critical network-facing system like WireGuard, could indicate significant latency concerns, or even potential stability problems if not handled correctly. I need to dig into the WireGuard code itself, specifically the scheduling-related parts of the module, and possibly trace execution paths to understand the context in which `need_resched` is being set. I'm imagining the potential bottlenecks, the synchronization primitives being used, and if they're appropriately tuned for this use case. This investigation is going to involve diving deep into the kernel and tracing calls.
|
| 53/2 |
2026/09/11 01:37 |
tool |
git-log |
0m
Args: map[Count:10 MessageRegexps:[wireguard need_resched]]
Results:
|
| 54/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 39758
output: 31
thoughts: 22
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving Back into the WireGuard Receive Path**
Alright, time to revisit the `drivers/net/wireguard/receive.c` file. I need to take another look at its git history. I'm probably picking up on a subtle bug or optimization opportunity in the data path. Maybe I'm troubleshooting a recent regression, or perhaps I'm evaluating the impact of a proposed change. I'll be sifting through commits, focusing on any modifications to the receive processing logic, looking for potential areas of concern in performance, security, or error handling. Gotta ensure the accelerated receive path is still robust. I'll pay close attention to the lock contention and any changes related to packet fragmentation or reassembly. It's all about ensuring maximum efficiency and minimal latency in that critical receive path for WireGuard. Let's see what the revision history uncovers.
|
| 55/2 |
2026/09/11 01:37 |
tool |
git-log |
0m
Args: map[Count:50 PathPrefix:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 56/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 40053
output: 21
thoughts: 109
Thoughts: **Investigating a Git Log Oddity**
Okay, hold on a second. I'm looking at some `git log` output, and it's showing me commit `5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled` for the file `drivers/net/wireguard/receive.c`. That's... unexpected. My initial intuition says something's off here. Either the `git log` tool is malfunctioning, which wouldn't be the first time I've encountered that, or perhaps there's something genuinely peculiar about the kernel tree's history for this file. It's not impossible for complex branching and merging to create these sorts of anomalies.
Let's not jump to conclusions about the kernel tree itself just yet. Instead of wrestling with `git log` further, I'll switch gears to a more reliable method. I'll reach for `grepper` to search within `drivers/net/wireguard/receive.c` for `wg_packet_decrypt_worker`. This approach should confirm the functionality, or give me a clear result, if there is no function in this file with that name. It's a faster way to confirm whether the function is in this file and to give me a clue as to what's happening.
|
| 57/2 |
2026/09/11 01:37 |
tool |
grepper |
0m
Args: map[Expression:wg_packet_decrypt_worker]
Results: map[Output:drivers/net/wireguard/device.c=310=static int wg_newlink(struct net_device *dev,
--
drivers/net/wireguard/device.c-356-
drivers/net/wireguard/device.c:357: ret = wg_packet_queue_init(&wg->decrypt_queue, wg_packet_decrypt_worker,
drivers/net/wireguard/device.c-358- MAX_QUEUED_PACKETS);
--
drivers/net/wireguard/queueing.h=34=int wg_packet_rx_poll(struct napi_struct *napi, int budget);
drivers/net/wireguard/queueing.h-35-/* Workqueue worker: */
drivers/net/wireguard/queueing.h:36:void wg_packet_decrypt_worker(struct work_struct *work);
drivers/net/wireguard/queueing.h-37-
--
drivers/net/wireguard/receive.c=438=int wg_packet_rx_poll(struct napi_struct *napi, int budget)
--
drivers/net/wireguard/receive.c-492-
drivers/net/wireguard/receive.c:493:void wg_packet_decrypt_worker(struct work_struct *work)
drivers/net/wireguard/receive.c-494-{
]
|
| 58/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 40807
output: 41
thoughts: 16
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Re-Examining the Packet Decryption Worker**
Okay, time to circle back to `wg_packet_decrypt_worker`. I want to really scrutinize this function again. It's the critical path, so any optimizations or vulnerabilities here are going to have a big impact. I'm thinking about the threading model, potential locking bottlenecks, and whether we're truly maximizing parallel decryption throughput. Are we still comfortable with the current approach, given recent findings about speculative execution and side-channel attacks? I need to refresh my memory on the current implementation details – specifically, the scheduling logic and any potential areas for contention, like access to the AEAD context or key material. It might be worth benchmarking this again with a more rigorous set of test vectors, specifically those that might trigger edge cases or unexpected performance degradation. Let's see what's what.
|
| 59/2 |
2026/09/11 01:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_decrypt_worker]
Results: map[SourceCode: 493: void wg_packet_decrypt_worker(struct work_struct *work)
494: {
495: struct crypt_queue *queue = container_of(work, struct multicore_worker,
496: work)->ptr;
497: struct sk_buff *skb;
498:
499: while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
500: enum packet_state state =
501: likely(decrypt_packet(skb, PACKET_CB(skb)->keypair)) ?
502: PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
503: wg_queue_enqueue_per_peer_rx(skb, state);
504: if (need_resched())
505: cond_resched();
506: }
507: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 60/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 41345
output: 44
thoughts: 84
Thoughts: Okay, let me break this down.
**Vulnerability Analysis: Workqueue Starvation**
Hmm, `cond_resched()` is yielding the CPU, that's good in principle, but it doesn't return to the workqueue core, and that's where things get interesting. The implication is, if the loop condition within `wg_packet_handshake_receive_worker` (or wherever this is happening) is *never* met, then the workqueue watchdog is going to kick in.
I need to confirm there's no inherent loop termination condition. Alright, looks like there's no limit defined. That's a problem. If an attacker can inject packets quickly enough, they could potentially keep this loop spinning indefinitely. This leads to starvation. And the potential attacker has the ability to cause denial of service.
The fact that `wg_packet_handshake_receive_worker` also has a loop is also troubling. I'll need to dig into that function as well to confirm if the same flaw exists.
|
| 61/2 |
2026/09/11 01:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_handshake_receive_worker]
Results: map[SourceCode: 206: void wg_packet_handshake_receive_worker(struct work_struct *work)
207: {
208: struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
209: struct wg_device *wg = container_of(queue, struct wg_device, handshake_queue);
210: struct sk_buff *skb;
211:
212: while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
213: wg_receive_handshake_packet(wg, skb);
214: dev_kfree_skb(skb);
215: atomic_dec(&wg->handshake_queue_len);
216: cond_resched();
217: }
218: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 62/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 41953
output: 41
thoughts: 23
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing the WireGuard Packet Encryption Worker**
Right, so I'm focusing in on `wg_packet_encrypt_worker` within `drivers/net/wireguard/send.c`. This is where the rubber meets the road, isn't it? This is the heart of the *send* path – where the actual encryption of outgoing WireGuard packets happens. I need to understand the concurrency model here, the critical sections, and how this worker interacts with the other modules within the WireGuard implementation. I'm immediately thinking about:
* **Performance:** What's the throughput like? Are there any bottlenecks related to crypto primitives, memory allocation, or the scheduler? Are we seeing any contention?
* **Security:** This is the encryption *itself*. This worker has to do its job correctly. We need to look for side channels or possible vulnerabilities here. Any timing-based exploits? Is the key derivation safe?
* **Context:** What are the inputs to this function? Is it getting the packet data directly, or are we dealing with intermediate buffers? Is the IV generation deterministic, or does it vary? Where and how does the data get copied into and out of the function?
* **Locking:** The concurrency of packet sending and encryption is crucial. Are spinlocks involved? Are we dealing with mutexes? How is this worker synchronized with the rest of the network stack, and with other WireGuard threads? Is the locking strategy efficient, preventing unnecessary delays?
* **Error Handling:** What happens when encryption fails? Are we silently dropping packets? Are we logging errors? Are we retrying? What's the impact on the connection?
I'm mentally stepping through the code now. I want to see how the packet is processed, understand the crypto algorithms that are used and how the key material is derived and used. Specifically, I'll be looking for any potential for misuse of the underlying crypto or for any code that might introduce bugs or vulnerabilities. I need to map out the memory layout, data structures and any interactions with hardware crypto engines (if present). I'll be checking any edge cases or potential vulnerabilities in terms of what data is fed into the function.
|
| 63/2 |
2026/09/11 01:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/send.c Name:wg_packet_encrypt_worker]
Results: map[SourceCode: 287: void wg_packet_encrypt_worker(struct work_struct *work)
288: {
289: struct crypt_queue *queue = container_of(work, struct multicore_worker,
290: work)->ptr;
291: struct sk_buff *first, *skb, *next;
292:
293: while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
294: enum packet_state state = PACKET_STATE_CRYPTED;
295:
296: skb_list_walk_safe(first, skb, next) {
297: if (likely(encrypt_packet(skb,
298: PACKET_CB(first)->keypair))) {
299: wg_reset_packet(skb, true);
300: } else {
301: state = PACKET_STATE_DEAD;
302: break;
303: }
304: }
305: wg_queue_enqueue_per_peer_tx(first, state);
306: if (need_resched())
307: cond_resched();
308: }
309: }
SourceFile:drivers/net/wireguard/send.c]
|
| 64/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 42878
output: 38
thoughts: 494
Thoughts: **Analyzing a Potential Workqueue Lockup Vulnerability**
Okay, so I'm looking at this code and immediately see something concerning: unbounded loops. It seems if an attacker can flood the network with packets at a high rate, they could potentially trigger a workqueue lockup, which is definitely not ideal. Let's break this down.
The attacker sends packets, which hit the NIC. That triggers an interrupt, which then schedules NAPI. NAPI polls the NIC, grabs the packets, and calls `netif_receive_skb`. This then routes to WireGuard, where `wg_packet_receive` enqueues them into either the handshake or decrypt ring buffer. Now, here's where it gets interesting: if the queue is *full*, `ptr_ring_produce_bh` returns an error, and the packet is dropped. But there is a worker thread consuming packets from that queue. If there's consumption, there should be space, right?
The NAPI thread, running in a softirq, can preempt the worker, or run concurrently if they're on different CPUs. If they are on different CPUs, NAPI can continually feed the queue, while the worker continually consumes. If this queue never becomes empty because the NAPI thread is constantly adding to it, `ptr_ring_consume_bh` will never return NULL, and the worker thread will *never* return from its work function.
Then, the workqueue watchdog steps in. After 30 seconds of no progress from the worker pool, it raises a BUG message. So, is this a Denial of Service? Yep, it's causing a workqueue lockup warning! If `panic_on_wq_watchdog` is enabled, this is a full-blown kernel panic. Even if it's not set, it's still monopolizing a CPU, right?
Wait, hold on, there's `cond_resched()` called. So, the worker actually yields the CPU to other tasks. It doesn't monopolize the CPU, which is important. This means other tasks *can* still run. However, the workqueue watchdog will *still* trigger because the work item never finishes. That is the issue! Let me double-check the `wq_watchdog_timer_fn` again to make sure that the watchdog isn't doing anything else.
|
| 65/2 |
2026/09/11 01:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/workqueue.c Name:wq_watchdog_timer_fn]
Results: map[SourceCode:7927: static void wq_watchdog_timer_fn(struct timer_list *unused)
7928: {
7929: unsigned long thresh = READ_ONCE(wq_watchdog_thresh) * HZ;
7930: unsigned int max_stall_time = 0;
7931: bool lockup_detected = false;
7932: bool cpu_pool_stall = false;
7933: unsigned long now = jiffies;
7934: struct worker_pool *pool;
7935: unsigned int stall_time;
7936: int pi;
7937:
7938: if (!thresh)
7939: return;
7940:
7941: for_each_pool(pool, pi) {
7942: unsigned long pool_ts, touched, ts;
7943:
7944: pool->cpu_stall = false;
7945: if (list_empty(&pool->worklist))
7946: continue;
7947:
7948: /*
7949: * If a virtual machine is stopped by the host it can look to
7950: * the watchdog like a stall.
7951: */
7952: kvm_check_and_clear_guest_paused();
7953:
7954: /* get the latest of pool and touched timestamps */
7955: if (pool->cpu >= 0)
7956: touched = READ_ONCE(per_cpu(wq_watchdog_touched_cpu, pool->cpu));
7957: else
7958: touched = READ_ONCE(wq_watchdog_touched);
7959: pool_ts = READ_ONCE(pool->last_progress_ts);
7960:
7961: if (time_after(pool_ts, touched))
7962: ts = pool_ts;
7963: else
7964: ts = touched;
7965:
7966: /*
7967: * Did we stall?
7968: *
7969: * Do a lockless check first to do not disturb the system.
7970: *
7971: * Prevent false positives by double checking the timestamp
7972: * under pool->lock. The lock makes sure that the check reads
7973: * an updated pool->last_progress_ts when this CPU saw
7974: * an already updated pool->worklist above. It seems better
7975: * than adding another barrier into __queue_work() which
7976: * is a hotter path.
7977: */
7978: if (time_after(now, ts + thresh)) {
7979: scoped_guard(raw_spinlock_irqsave, &pool->lock) {
7980: pool_ts = pool->last_progress_ts;
7981: if (time_after(pool_ts, touched))
7982: ts = pool_ts;
7983: else
7984: ts = touched;
7985: }
7986: if (!time_after(now, ts + thresh))
7987: continue;
7988:
7989: lockup_detected = true;
7990: stall_time = jiffies_to_msecs(now - pool_ts) / 1000;
7991: max_stall_time = max(max_stall_time, stall_time);
7992: if (is_percpu_pool(pool) && !(pool->flags & POOL_BH)) {
7993: pool->cpu_stall = true;
7994: cpu_pool_stall = true;
7995: }
7996: pr_emerg("BUG: workqueue lockup - pool");
7997: pr_cont_pool_info(pool);
7998: pr_cont(" stuck for %us!\n", stall_time);
7999: }
8000: }
8001:
8002: if (lockup_detected)
8003: show_all_workqueues();
8004:
8005: if (cpu_pool_stall)
8006: show_cpu_pools_busy_workers();
8007:
8008: if (lockup_detected)
8009: panic_on_wq_watchdog(max_stall_time);
8010:
8011: wq_watchdog_reset_touched();
8012: mod_timer(&wq_watchdog_timer, jiffies + thresh);
8013: }
SourceFile:kernel/workqueue.c]
|
| 66/2 |
2026/09/11 01:37 |
llm |
expert |
0m
Model:
Tokens:
input: 45208
output: 45
thoughts: 68
Thoughts: Okay, let me break this down.
**Investigating a Workqueue Watchdog Panic**
Right, so I've got a crash, and the kernel's throwing a BUG message and showing me a snapshot of the workqueues. Classic watchdog scenario if `panic_on_wq_watchdog` is enabled, right? Panic means something got seriously stuck.
My first thought: is this a known issue? I need to check the kernel's commit history. This smells like a potential loop or runaway process in `wg_packet_decrypt_worker`. Let's see if anyone's already addressed this by limiting the iteration count within that function. Time to dive into the git logs.
|
| 67/2 |
2026/09/11 01:37 |
tool |
git-log |
0m
Args: map[CodeRegexp:MAX_QUEUED_PACKETS Count:10 SourcePath:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 68/2 |
2026/09/11 01:38 |
llm |
expert |
0m
Model:
Tokens:
input: 45511
output: 15
thoughts: 44
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Investigating a Suspected `git log` Anomaly**
Alright, hang on a second. Something feels off with `git log` lately. It's behaving strangely, and I need to quickly ascertain if there's been some kind of regression or unexpected behavior. I'm going to set it aside for the moment though, as this is critical.
I need to quickly assess whether the recent modifications have introduced any constraints. Given the topic, I'm going to use `grepper` – a much more efficient tool for this kind of quick search within the codebase – to zero in on specific aspects. I'm going to look for instances of "budget" or "limit" within the `drivers/net/wireguard/receive.c` file. This is the logical starting point for investigating potential bandwidth or resource allocation changes. I'm focusing on those keywords because they often relate to resource management in network drivers. I have a hunch that something in that area may be the issue at hand.
|
| 69/2 |
2026/09/11 01:38 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 19375 lines.
Use more precise expression if possible.
Documentation/ABI/stable/sysfs-driver-mlxreg-io=318=Description: This file assigns power management control ownership.
--
Documentation/ABI/stable/sysfs-driver-mlxreg-io-320- will automatically power off one or more line previously
Documentation/ABI/stable/sysfs-driver-mlxreg-io:321: powered line cards in case system power budget is getting
Documentation/ABI/stable/sysfs-driver-mlxreg-io-322- insufficient. It could be in case when some of power units lost
--
Documentation/ABI/stable/sysfs-driver-mlxreg-io-327- not allow to power on any new line card in case system power
Documentation/ABI/stable/sysfs-driver-mlxreg-io:328: budget is insufficient.
Documentation/ABI/stable/sysfs-driver-mlxreg-io-329- Same in case software will try to power on several line cards
Documentation/ABI/stable/sysfs-driver-mlxreg-io-330- at once - hardware will power line cards while system has
Documentation/ABI/stable/sysfs-driver-mlxreg-io:331: enough power budget.
Documentation/ABI/stable/sysfs-driver-mlxreg-io-332- Default is 0.
--
Documentation/ABI/testing/sysfs-driver-uniwill-laptop=98=Description:
--
Documentation/ABI/testing/sysfs-driver-uniwill-laptop-100- power via the USB ports when hibernating or powered off. Might also increase the
Documentation/ABI/testing/sysfs-driver-uniwill-laptop:101: power budget available to USB ports on some devices. Writing "1"/"0" into this
Documentation/ABI/testing/sysfs-driver-uniwill-laptop-102- file enables/disables this functionality. Enabling both USB powershare and AC auto
--
Documentation/RCU/Design/Requirements/Requirements.rst=2424=In addition, RCU must make do with a sub-100-microsecond real-time
Documentation/RCU/Design/Requirements/Requirements.rst:2425:latency budget. In fact, on smaller systems with the -rt patchset, the
Documentation/RCU/Design/Requirements/Requirements.rst-2426-Linux kernel provides sub-20-microsecond real-time latencies for the
--
Documentation/RCU/Design/Requirements/Requirements.rst=2428=therefore be sufficient for these sorts of configurations. To my
Documentation/RCU/Design/Requirements/Requirements.rst:2429:surprise, the sub-100-microsecond real-time latency budget `applies to
Documentation/RCU/Design/Requirements/Requirements.rst-2430-even the largest systems
--
Documentation/admin-guide/blockdev/zram.rst=431=The "writeback_limit_enable"'s default value is 0 so that it doesn't limit
Documentation/admin-guide/blockdev/zram.rst:432:any writeback. IOW, if admin wants to apply writeback budget, they should
Documentation/admin-guide/blockdev/zram.rst-433-enable writeback_limit_enable via::
--
Documentation/admin-guide/blockdev/zram.rst=437=Once writeback_limit_enable is set, zram doesn't allow any writeback
Documentation/admin-guide/blockdev/zram.rst:438:until admin sets the budget via /sys/block/zramX/writeback_limit.
Documentation/admin-guide/blockdev/zram.rst-439-
--
Documentation/admin-guide/blockdev/zram.rst=444=like below::
--
Documentation/admin-guide/blockdev/zram.rst-451-
Documentation/admin-guide/blockdev/zram.rst:452:If admins want to allow further write again once the budget is exhausted,
Documentation/admin-guide/blockdev/zram.rst-453-they could do it like below::
--
Documentation/admin-guide/blockdev/zram.rst-457-
Documentation/admin-guide/blockdev/zram.rst:458:If an admin wants to see the remaining writeback budget since last set::
Documentation/admin-guide/blockdev/zram.rst-459-
--
Documentation/admin-guide/blockdev/zram.rst=468=writeback happened until you reset the zram to allocate extra writeback
Documentation/admin-guide/blockdev/zram.rst:469:budget in next setting is user's job.
Documentation/admin-guide/blockdev/zram.rst-470-
--
Documentation/admin-guide/media/avermedia.rst=16=The Avermedia DVB-T
--
Documentation/admin-guide/media/avermedia.rst-18-
Documentation/admin-guide/media/avermedia.rst:19:The Avermedia DVB-T is a budget PCI DVB card. It has 3 inputs:
Documentation/admin-guide/media/avermedia.rst-20-
--
Documentation/admin-guide/media/cx23885-cardlist.rst=3=cx23885 cards list
--
Documentation/admin-guide/media/cx23885-cardlist.rst-209- * - 48
Documentation/admin-guide/media/cx23885-cardlist.rst:210: - Technotrend TT-budget CT2-4500 CI
Documentation/admin-guide/media/cx23885-cardlist.rst-211- - 13c2:3013
--
Documentation/admin-guide/media/dvb_intro.rst=44=Digital TV.
Documentation/admin-guide/media/dvb_intro.rst-45-
Documentation/admin-guide/media/dvb_intro.rst:46:The purpose of a simple budget digital TV card (DVB-T,C or S) is to
Documentation/admin-guide/media/dvb_intro.rst-47-simply:
--
Documentation/admin-guide/media/other-usb-cardlist.rst=66=stk1160 STK1160 USB video capture dongle 05e1:0408
Documentation/admin-guide/media/other-usb-cardlist.rst:67:dvb-ttusb-budget Technotrend/Hauppauge Nova-USB devices 0b48:1003, 0b48:1004,
Documentation/admin-guide/media/other-usb-cardlist.rst-68- 0b48:1005
--
Documentation/admin-guide/media/saa7134-cardlist.rst=3=SAA7134 cards list
--
Documentation/admin-guide/media/saa7134-cardlist.rst-741- * - 181
Documentation/admin-guide/media/saa7134-cardlist.rst:742: - TechoTrend TT-budget T-3000
Documentation/admin-guide/media/saa7134-cardlist.rst-743- - 13c2:2804
--
Documentation/admin-guide/media/usb-cardlist.rst=47=dvb-as102 Abilis AS102 DVB receiver
Documentation/admin-guide/media/usb-cardlist.rst:48:dvb-ttusb-budget Technotrend/Hauppauge Nova - USB devices
Documentation/admin-guide/media/usb-cardlist.rst-49-dvb-usb-a800 AVerMedia AverTV DVB-T USB 2.0 (A800)
--
Documentation/admin-guide/pm/cpufreq.rst=619=threshold for the whole package) under certain conditions, for example if the
Documentation/admin-guide/pm/cpufreq.rst:620:whole chip is not fully utilized and below its intended thermal or power budget.
Documentation/admin-guide/pm/cpufreq.rst-621-
--
Documentation/admin-guide/pm/cpufreq_drivers.rst=13=AMD PowerNow! Drivers
--
Documentation/admin-guide/pm/cpufreq_drivers.rst-122- the requested frequency. If the request for the target frequency could not be
Documentation/admin-guide/pm/cpufreq_drivers.rst:123: satisfied by platform firmware, then it usually means that power budget
Documentation/admin-guide/pm/cpufreq_drivers.rst-124- conditions are in place, and "power capping" is taking place.
--
Documentation/admin-guide/pm/cpufreq_drivers.rst-170- a percentage of the nominal (ie: maximum) CPU frequency. The output buffer
Documentation/admin-guide/pm/cpufreq_drivers.rst:171: also signifies if the CPU frequency is limited by a power budget condition.
Documentation/admin-guide/pm/cpufreq_drivers.rst-172-
--
Documentation/admin-guide/pm/intel-speed-select.rst=364=proportional priority is to provide each core with the requested min., then
Documentation/admin-guide/pm/intel-speed-select.rst:365:distribute all remaining (excess/deficit) budgets in proportion to a defined
Documentation/admin-guide/pm/intel-speed-select.rst-366-weight. This proportional priority can be configured using "core-power config"
--
Documentation/admin-guide/sysctl/net.rst=143=RPS (e.g. RFS, aRFS) processing is competing with the registered NAPI poll function
Documentation/admin-guide/sysctl/net.rst:144:of the driver for the per softirq cycle netdev_budget. This parameter influences
Documentation/admin-guide/sysctl/net.rst:145:the proportion of the configured netdev_budget that is spent on RPS based packet
Documentation/admin-guide/sysctl/net.rst-146-processing during RX softirq cycles. It is further meant for making current
--
Documentation/admin-guide/sysctl/net.rst=281=and controlled by the dynamic_debug facility.
Documentation/admin-guide/sysctl/net.rst-282-
Documentation/admin-guide/sysctl/net.rst:283:netdev_budget
Documentation/admin-guide/sysctl/net.rst-284--------------
--
Documentation/admin-guide/sysctl/net.rst=288=probed in a round-robin manner. Also, a polling cycle may not exceed
Documentation/admin-guide/sysctl/net.rst:289:netdev_budget_usecs microseconds, even if netdev_budget has not been
Documentation/admin-guide/sysctl/net.rst-290-exhausted.
Documentation/admin-guide/sysctl/net.rst-291-
Documentation/admin-guide/sysctl/net.rst:292:netdev_budget_usecs
Documentation/admin-guide/sysctl/net.rst-293----------------------
--
Documentation/admin-guide/sysctl/net.rst=295=Maximum number of microseconds in one NAPI polling cycle. Polling
Documentation/admin-guide/sysctl/net.rst:296:will exit when either netdev_budget_usecs have elapsed during the
Documentation/admin-guide/sysctl/net.rst:297:poll cycle or the number of packets processed reaches netdev_budget.
Documentation/admin-guide/sysctl/net.rst-298-
--
Documentation/admin-guide/thermal/intel_powerclamp.rst=34=Consider the situation where a system’s power consumption must be
Documentation/admin-guide/thermal/intel_powerclamp.rst:35:reduced at runtime, due to power budget, thermal constraint, or noise
Documentation/admin-guide/thermal/intel_powerclamp.rst-36-level, and where active cooling is not preferred. Software managed
--
Documentation/block/bfq-iosched.rst=159=plus a lot of code, are borrowed from CFQ.
--
Documentation/block/bfq-iosched.rst-165- (process) at a time, and implements this service model by
Documentation/block/bfq-iosched.rst:166: associating every queue with a budget, measured in number of
Documentation/block/bfq-iosched.rst-167- sectors.
Documentation/block/bfq-iosched.rst-168-
Documentation/block/bfq-iosched.rst:169: - After a queue is granted access to the device, the budget of the
Documentation/block/bfq-iosched.rst-170- queue is decremented, on each request dispatch, by the size of the
--
Documentation/block/bfq-iosched.rst-174- only if one of the following events occurs: 1) the queue finishes
Documentation/block/bfq-iosched.rst:175: its budget, 2) the queue empties, 3) a "budget timeout" fires.
Documentation/block/bfq-iosched.rst-176-
Documentation/block/bfq-iosched.rst:177: - The budget timeout prevents processes doing random I/O from
Documentation/block/bfq-iosched.rst-178- holding the device for too long and dramatically reducing
--
Documentation/block/bfq-iosched.rst-247- fluctuates, and regardless of: the device parameters, the current
Documentation/block/bfq-iosched.rst:248: workload and the budgets assigned to the queue.
Documentation/block/bfq-iosched.rst-249-
Documentation/block/bfq-iosched.rst:250: - The last, budget-independence, property (although probably
Documentation/block/bfq-iosched.rst-251- counterintuitive in the first place) is definitely beneficial, for
--
Documentation/block/bfq-iosched.rst-255- deviation with respect to an ideal service is proportional to
Documentation/block/bfq-iosched.rst:256: the maximum budget (slice) assigned to queues. As a consequence,
Documentation/block/bfq-iosched.rst-257- BFQ can keep this deviation tight, not only because of the
Documentation/block/bfq-iosched.rst-258- accurate service of B-WF2Q+, but also because BFQ *does not*
Documentation/block/bfq-iosched.rst:259: need to assign a larger budget to a queue to let the queue
Documentation/block/bfq-iosched.rst-260- receive a higher fraction of the device throughput.
--
Documentation/block/bfq-iosched.rst-262- - Second, BFQ is free to choose, for every process (queue), the
Documentation/block/bfq-iosched.rst:263: budget that best fits the needs of the process, or best
Documentation/block/bfq-iosched.rst-264- leverages the I/O pattern of the process. In particular, BFQ
Documentation/block/bfq-iosched.rst:265: updates queue budgets with a simple feedback-loop algorithm that
Documentation/block/bfq-iosched.rst-266- allows a high throughput to be achieved, while still providing
--
Documentation/block/bfq-iosched.rst-268- the in-service queue expires, this algorithm computes the next
Documentation/block/bfq-iosched.rst:269: budget of the queue so as to:
Documentation/block/bfq-iosched.rst-270-
Documentation/block/bfq-iosched.rst:271: - Let large budgets be eventually assigned to the queues
Documentation/block/bfq-iosched.rst-272- associated with I/O-bound applications performing sequential
--
Documentation/block/bfq-iosched.rst-275-
Documentation/block/bfq-iosched.rst:276: - Let small budgets be eventually assigned to the queues
Documentation/block/bfq-iosched.rst-277- associated with time-sensitive applications (which typically
Documentation/block/bfq-iosched.rst-278- perform sporadic and short I/O), because, the smaller the
Documentation/block/bfq-iosched.rst:279: budget assigned to a queue waiting for service is, the sooner
Documentation/block/bfq-iosched.rst-280- B-WF2Q+ will serve that queue (Subsec 3.3 in [2]).
--
Documentation/block/bfq-iosched.rst=303=on how to maximise throughput, see slice_idle, timeout_sync and
Documentation/block/bfq-iosched.rst:304:max_budget. The other performance-related parameters have been
Documentation/block/bfq-iosched.rst-305-inherited from, and have been preserved mostly for compatibility with
--
Documentation/block/bfq-iosched.rst=471=following parameter is set to zero.
Documentation/block/bfq-iosched.rst-472-
Documentation/block/bfq-iosched.rst:473:max_budget
Documentation/block/bfq-iosched.rst-474-----------
--
Documentation/block/bfq-iosched.rst=482=and latency guarantees.
Documentation/block/bfq-iosched.rst-483-
Documentation/block/bfq-iosched.rst:484:The default value is 0, which enables auto-tuning: BFQ sets max_budget
Documentation/block/bfq-iosched.rst-485-to the maximum number of sectors that can be served during
--
Documentation/block/bfq-iosched.rst=488=For specific devices, some users have occasionally reported to have
Documentation/block/bfq-iosched.rst:489:reached a higher throughput by setting max_budget explicitly, i.e., by
Documentation/block/bfq-iosched.rst:490:setting max_budget to a higher value than 0. In particular, they have
Documentation/block/bfq-iosched.rst:491:set max_budget to higher values than those to which BFQ would have set
Documentation/block/bfq-iosched.rst-492-it with auto-tuning. An alternative way to achieve this goal is to
Documentation/block/bfq-iosched.rst:493:just increase the value of timeout_sync, leaving max_budget equal to 0.
Documentation/block/bfq-iosched.rst-494-
--
Documentation/bpf/map_hash.rst=243=avoid exhaustion, by limiting aggregate reservation by all CPUs to half the map
Documentation/bpf/map_hash.rst:244:size. With a minimum of a single element and maximum budget of 128 at a time.
Documentation/bpf/map_hash.rst-245-
--
Documentation/devicetree/bindings/media/rc.yaml=13=properties:
--
Documentation/devicetree/bindings/media/rc.yaml-44- - rc-behold-columbus
Documentation/devicetree/bindings/media/rc.yaml:45: - rc-budget-ci-old
Documentation/devicetree/bindings/media/rc.yaml-46- - rc-cec
--
Documentation/devicetree/bindings/regulator/regulator.yaml=13=properties:
--
Documentation/devicetree/bindings/regulator/regulator.yaml-36-
Documentation/devicetree/bindings/regulator/regulator.yaml:37: regulator-power-budget-milliwatt:
Documentation/devicetree/bindings/regulator/regulator.yaml:38: description: power budget of the regulator
Documentation/devicetree/bindings/regulator/regulator.yaml-39-
--
Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/usb.txt=3=Required properties:
--
Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/usb.txt-16- "clk1" through "clk24": clock source is CLK1-CLK24, respectively
Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/usb.txt:17:- hub-power-budget : USB power budget for the root hub, in mA.
Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/usb.txt-18-- gpios : should specify GPIOs in this order: USBOE, USBTP, USBTN, USBRP,
--
Documentation/driver-api/media/drivers/contributors.rst=11=Thanks go to the following people for patches and contributions:
--
Documentation/driver-api/media/drivers/contributors.rst-82-
Documentation/driver-api/media/drivers/contributors.rst:83: - for his work on the budget drivers, the demux code,
Documentation/driver-api/media/drivers/contributors.rst-84- the module unloading problems, ...
--
Documentation/driver-api/media/drivers/contributors.rst-93-
Documentation/driver-api/media/drivers/contributors.rst:94: - for the support of the Fujitsu-Siemens Activy budget DVB-S
Documentation/driver-api/media/drivers/contributors.rst-95-
--
Documentation/driver-api/media/drivers/contributors.rst-97-
Documentation/driver-api/media/drivers/contributors.rst:98: - for adding support for Typhoon DVB-S budget card
Documentation/driver-api/media/drivers/contributors.rst-99-
--
Documentation/driver-api/thermal/cpu-idle-cooling.rst=22=allow the component to cool down.
Documentation/driver-api/thermal/cpu-idle-cooling.rst-23-
Documentation/driver-api/thermal/cpu-idle-cooling.rst:24:Last but not least, the system can ask for a specific power budget but
Documentation/driver-api/thermal/cpu-idle-cooling.rst-25-because of the OPP density, we can only choose an OPP with a power
Documentation/driver-api/thermal/cpu-idle-cooling.rst:26:budget lower than the requested one and under-utilize the CPU, thus
Documentation/driver-api/thermal/cpu-idle-cooling.rst-27-losing performance. In other words, one OPP under-utilizes the CPU
Documentation/driver-api/thermal/cpu-idle-cooling.rst:28:with a power less than the requested power budget and the next OPP
Documentation/driver-api/thermal/cpu-idle-cooling.rst:29:exceeds the power budget. An intermediate OPP could have been used if
Documentation/driver-api/thermal/cpu-idle-cooling.rst-30-it were present.
--
Documentation/driver-api/thermal/cpu-idle-cooling.rst=38=injection period, we can mitigate the temperature by modulating the
Documentation/driver-api/thermal/cpu-idle-cooling.rst:39:power budget.
Documentation/driver-api/thermal/cpu-idle-cooling.rst-40-
--
Documentation/fault-injection/fault-injection.rst=97=configuration of fault-injection capabilities.
--
Documentation/fault-injection/fault-injection.rst-123-
Documentation/fault-injection/fault-injection.rst:124: specifies an initial resource "budget", decremented by "size"
Documentation/fault-injection/fault-injection.rst-125- on each call to should_fail(,size). Failure injection is
--
Documentation/filesystems/f2fs.rst=298=checkpoint_merge When checkpoint is enabled, this can be used to create a kernel
--
Documentation/filesystems/f2fs.rst-302- operation when the checkpoint is done in a process context in
Documentation/filesystems/f2fs.rst:303: a cgroup having low i/o budget and cpu shares. To make this
Documentation/filesystems/f2fs.rst-304- do better, we set the default i/o priority of the kernel daemon
--
Documentation/filesystems/xfs/xfs-online-fsck-design.rst=5185=Userspace is allowed to send a fatal signal to the process which will cause
Documentation/filesystems/xfs/xfs-online-fsck-design.rst-5186-``xfs_scrub`` to exit when it reaches a good stopping point, but there's no way
Documentation/filesystems/xfs/xfs-online-fsck-design.rst:5187:for userspace to provide a time budget to the kernel.
Documentation/filesystems/xfs/xfs-online-fsck-design.rst-5188-Given that the scrub codebase has helpers to detect fatal signals, it shouldn't
Documentation/filesystems/xfs/xfs-online-fsck-design.rst=5189=be too much work to allow userspace to specify a timeout for a scrub/repair
Documentation/filesystems/xfs/xfs-online-fsck-design.rst:5190:operation and abort the operation if it exceeds budget.
Documentation/filesystems/xfs/xfs-online-fsck-design.rst-5191-However, most repair functions have the property that once they begin to touch
--
Documentation/mm/hmm.rst=182=and is checked between retry attempts. HMM does not interrupt page fault
Documentation/mm/hmm.rst:183:handling when the timeout expires, but returns ``-EBUSY`` if the retry budget is
Documentation/mm/hmm.rst-184-exhausted before a stable range is obtained.
--
Documentation/netlink/specs/ethtool.yaml=13=definitions:
--
Documentation/netlink/specs/ethtool.yaml-155- -
Documentation/netlink/specs/ethtool.yaml:156: name: pse-event-over-budget
Documentation/netlink/specs/ethtool.yaml:157: doc: PSE turned off due to over budget situation
Documentation/netlink/specs/ethtool.yaml-158- -
--
Documentation/networking/device_drivers/ethernet/amazon/ena.rst=382=Tx
--
Documentation/networking/device_drivers/ethernet/amazon/ena.rst-413- * The function stops when the completion descriptors are completed or
Documentation/networking/device_drivers/ethernet/amazon/ena.rst:414: the budget is reached.
Documentation/networking/device_drivers/ethernet/amazon/ena.rst-415-
--
Documentation/networking/dsa/sja1105.rst=362=tunable delay lines as part of the MAC, which can be used to establish the
Documentation/networking/dsa/sja1105.rst:363:correct RGMII timing budget.
Documentation/networking/dsa/sja1105.rst-364-When powered up, these can shift the Rx and Tx clocks with a phase difference
--
Documentation/networking/ethtool-netlink.rst=1952=Port priority serves two functions:
--
Documentation/networking/ethtool-netlink.rst-1956- (lower values) power up first.
Documentation/networking/ethtool-netlink.rst:1957: - Shutdown Order: When the power budget is exceeded, ports with lower
Documentation/networking/ethtool-netlink.rst-1958- priority (higher values) are turned off first.
--
Documentation/networking/ip-sysctl.rst=1108=tcp_tso_rtt_log - INTEGER
--
Documentation/networking/ip-sysctl.rst-1113-
Documentation/networking/ip-sysctl.rst:1114: Old autosizing was splitting the pacing budget to send 1024 TSO
Documentation/networking/ip-sysctl.rst-1115- per second.
--
Documentation/networking/napi.rst=66=Later, after NAPI is scheduled, the driver's poll method will be
Documentation/networking/napi.rst:67:called to process the events/packets. The method takes a ``budget``
Documentation/networking/napi.rst-68-argument - drivers can process completions for any number of Tx
Documentation/networking/napi.rst:69:packets but should only process up to ``budget`` number of
Documentation/networking/napi.rst-70-Rx packets. Rx processing is usually much more expensive.
Documentation/networking/napi.rst-71-
Documentation/networking/napi.rst:72:In other words for Rx processing the ``budget`` argument limits how many
Documentation/networking/napi.rst-73-packets driver can process in a single poll. Rx specific APIs like page
Documentation/networking/napi.rst:74:pool or XDP cannot be used at all when ``budget`` is 0.
Documentation/networking/napi.rst:75:skb Tx processing should happen regardless of the ``budget``, but if
Documentation/networking/napi.rst-76-the argument is 0 driver cannot call any XDP (or page pool) APIs.
--
Documentation/networking/napi.rst-79-
Documentation/networking/napi.rst:80: The ``budget`` argument may be 0 if core tries to only process
Documentation/networking/napi.rst-81- skb Tx completions and no Rx or XDP packets.
--
Documentation/networking/napi.rst=83=The poll method returns the amount of work done. If the driver still
Documentation/networking/napi.rst:84:has outstanding work to do (e.g. ``budget`` was exhausted)
Documentation/networking/napi.rst:85:the poll method should return exactly ``budget``. In that case,
Documentation/networking/napi.rst-86-the NAPI instance will be serviced/polled again (without the
--
Documentation/networking/napi.rst=92=of the instance.
--
Documentation/networking/napi.rst-95-
Documentation/networking/napi.rst:96: The case of finishing all events and using exactly ``budget``
Documentation/networking/napi.rst-97- must be handled carefully. There is no way to report this
--
Documentation/networking/napi.rst-99- not call napi_complete_done() and wait to be called again,
Documentation/networking/napi.rst:100: or return ``budget - 1``.
Documentation/networking/napi.rst-101-
Documentation/networking/napi.rst:102: If the ``budget`` is 0 napi_complete_done() should never be called.
Documentation/networking/napi.rst-103-
--
Documentation/networking/napi.rst=140=IRQ should only be unmasked after a successful call to napi_complete_done():
--
Documentation/networking/napi.rst-143-
Documentation/networking/napi.rst:144: if (budget && napi_complete_done(&v->napi, work_done)) {
Documentation/networking/napi.rst-145- mydrv_unmask_rxtx_irq(v->idx);
Documentation/networking/napi.rst:146: return min(work_done, budget - 1);
Documentation/networking/napi.rst-147- }
--
Documentation/networking/napi.rst=293=In order to enable busy polling, there are two choices:
--
Documentation/networking/napi.rst-307- uint32_t busy_poll_usecs;
Documentation/networking/napi.rst:308: uint16_t busy_poll_budget;
Documentation/networking/napi.rst-309- uint8_t prefer_busy_poll;
--
Documentation/networking/napi.rst=333=enable this mode. See the above section for more details.
Documentation/networking/napi.rst-334-
Documentation/networking/napi.rst:335:The NAPI budget for busy polling is lower than the default (which makes
Documentation/networking/napi.rst-336-sense given the low latency intention of normal busy polling). This is
Documentation/networking/napi.rst:337:not the case with IRQ mitigation, however, so the budget can be adjusted
Documentation/networking/napi.rst-338-with the ``SO_BUSY_POLL_BUDGET`` socket option. For epoll-based busy polling
Documentation/networking/napi.rst:339:applications, the ``busy_poll_budget`` field can be adjusted to the desired value
Documentation/networking/napi.rst-340-in ``struct epoll_params`` and set on a specific epoll context using the ``EPIOCSPARAMS``
--
Documentation/networking/page_pool.rst=152=NAPI poller
--
Documentation/networking/page_pool.rst-161- dma_dir = page_pool_get_dma_dir(dring->page_pool);
Documentation/networking/page_pool.rst:162: while (done < budget) {
Documentation/networking/page_pool.rst-163- if (some error)
--
Documentation/networking/timestamping.rst=258=SOF_TIMESTAMPING_OPT_TSONLY:
--
Documentation/networking/timestamping.rst-261- alongside the original packet. This reduces the amount of memory
Documentation/networking/timestamping.rst:262: charged to the socket's receive budget (SO_RCVBUF) and delivers
Documentation/networking/timestamping.rst-263- the timestamp even if sysctl net.core.tstamp_allow_data is 0.
--
Documentation/networking/timestamping.rst=510=accordingly. Until the process calls recvmsg() on the error queue,
Documentation/networking/timestamping.rst:511:however, the full packet is queued, taking up budget from SO_RCVBUF.
Documentation/networking/timestamping.rst-512-
--
Documentation/power/powercap/dtpm.rst=10=normative and legally stated 'skin temperature'.
Documentation/power/powercap/dtpm.rst-11-
Documentation/power/powercap/dtpm.rst:12:Another aspect is to sustain the performance for a given power budget,
Documentation/power/powercap/dtpm.rst-13-for example virtual reality where the user can feel dizziness if the
--
Documentation/power/powercap/dtpm.rst=22=The Dynamic Thermal Power Management (DTPM) is a technique acting on
Documentation/power/powercap/dtpm.rst:23:the device power by limiting and/or balancing a power budget among
Documentation/power/powercap/dtpm.rst-24-different devices.
--
Documentation/process/management-style.rst=19=companies. If you sign purchase orders or you have any clue about the
Documentation/process/management-style.rst:20:budget of your group, you're almost certainly not a kernel manager.
Documentation/process/management-style.rst-21-These suggestions may or may not apply to you.
--
Documentation/scheduler/sched-rt-group.rst=24=Most notable:
--
Documentation/scheduler/sched-rt-group.rst-27- system when the period is smaller than either the available hrtimer
Documentation/scheduler/sched-rt-group.rst:28: resolution, or the time it takes to handle the budget refresh itself.
Documentation/scheduler/sched-rt-group.rst-29-
--
Documentation/translations/it_IT/process/management-style.rst=25=tradizionalmente hanno un ruolo direttivo all'interno delle aziende. Se vi
Documentation/translations/it_IT/process/management-style.rst:26:occupate di convalidare acquisti o avete una qualche idea sul budget del vostro
Documentation/translations/it_IT/process/management-style.rst-27-gruppo, probabilmente non siete un dirigente del kernel. Quindi i suggerimenti
--
Documentation/translations/zh_CN/networking/napi.rst=50=napi_schedule() 是调度 NAPI 轮询的基本方法。驱动程序应在其中断处理程序中调用此函数
--
Documentation/translations/zh_CN/networking/napi.rst-54-之后,在 NAPI 被调度后,驱动程序的 poll 方法将被调用以处理事件/数据包。该方法接受一个
Documentation/translations/zh_CN/networking/napi.rst:55:``budget`` 参数 - 驱动程序可以处理任意数量的发送 (Tx) 数据包完成,但处理最多处理
Documentation/translations/zh_CN/networking/napi.rst:56:``budget`` 个接收 (Rx) 数据包。处理接收数据包通常开销更大。
Documentation/translations/zh_CN/networking/napi.rst-57-
Documentation/translations/zh_CN/networking/napi.rst:58:换句话说,对于接收数据包的处理,``budget`` 参数限制了驱动程序在单次轮询中能够处理的数
Documentation/translations/zh_CN/networking/napi.rst:59:据包数量。当 ``budget`` 为 0 时,像页面池或 XDP 这类专门用于接收的 API 根本无法使用。
Documentation/translations/zh_CN/networking/napi.rst:60:无论 ``budget`` 的值是多少,skb 的发送处理都应该进行,但是如果 ``budget`` 参数为 0,
Documentation/translations/zh_CN/networking/napi.rst-61-驱动程序就不能调用任何 XDP(或页面池)API。
--
Documentation/translations/zh_CN/networking/napi.rst-64-
Documentation/translations/zh_CN/networking/napi.rst:65: 如果内核仅尝试处理skb的发送完成情况,而不处理接收 (Rx) 或 XDP 数据包,那么 ``budget``
Documentation/translations/zh_CN/networking/napi.rst-66- 参数可能为 0。
Documentation/translations/zh_CN/networking/napi.rst-67-
Documentation/translations/zh_CN/networking/napi.rst:68:轮询方法会返回已完成的工作量。如果驱动程序仍有未完成的工作(例如,``budget`` 已用完),
Documentation/translations/zh_CN/networking/napi.rst:69:轮询方法应精确返回 ``budget`` 的值。在这种情况下,NAPI 实例将再次被处理 / 轮询(无需
Documentation/translations/zh_CN/networking/napi.rst-70-重新调度)。
--
Documentation/translations/zh_CN/networking/napi.rst=73=napi_complete_done() 会释放实例的所有权。
--
Documentation/translations/zh_CN/networking/napi.rst-76-
Documentation/translations/zh_CN/networking/napi.rst:77: 当出现既完成了所有事件处理,又恰好达到了 ``budget`` 数量的情况时,必须谨慎处理。因为没
Documentation/translations/zh_CN/networking/napi.rst-78- 有办法将这种(很少出现的)情况报告给协议栈,所以驱动程序要么不调用 napi_complete_done()
Documentation/translations/zh_CN/networking/napi.rst:79: 并等待再次被调用,要么返回 ``budget - 1``。
Documentation/translations/zh_CN/networking/napi.rst-80-
Documentation/translations/zh_CN/networking/napi.rst:81: 当 ``budget`` 为 0 时,napi_complete_done() 绝对不能被调用。
Documentation/translations/zh_CN/networking/napi.rst-82-
--
Documentation/translations/zh_CN/networking/napi.rst=112=IRQ 仅应在成功调用 napi_complete_done() 后取消屏蔽:
--
Documentation/translations/zh_CN/networking/napi.rst-115-
Documentation/translations/zh_CN/networking/napi.rst:116: if (budget && napi_complete_done(&v->napi, work_done)) {
Documentation/translations/zh_CN/networking/napi.rst-117- mydrv_unmask_rxtx_irq(v->idx);
Documentation/translations/zh_CN/networking/napi.rst:118: return min(work_done, budget - 1);
Documentation/translations/zh_CN/networking/napi.rst-119- }
--
Documentation/translations/zh_CN/networking/napi.rst=231=epoll 上下文。这确保了每个工作线程的 epoll 上下文中所包含的文件描述符具有相同的 NAPI ID。
--
Documentation/translations/zh_CN/networking/napi.rst-248- uint32_t busy_poll_usecs;
Documentation/translations/zh_CN/networking/napi.rst:249: uint16_t busy_poll_budget;
Documentation/translations/zh_CN/networking/napi.rst-250- uint8_t prefer_busy_poll;
--
Documentation/translations/zh_CN/networking/napi.rst=267=epoll 的忙轮询应用程序,可以将 ``struct epoll_params`` 结构体中的 ``prefer_busy_poll``
--
Documentation/translations/zh_CN/networking/napi.rst-270-
Documentation/translations/zh_CN/networking/napi.rst:271:NAPI 忙轮询的 budget 低于默认值(这符合正常忙轮询的低延迟意图)。减少中断请求的场景中
Documentation/translations/zh_CN/networking/napi.rst:272:并非如此,因此 budget 可以通过 ``SO_BUSY_POLL_BUDGET`` 套接字选项进行调整。对于基于
Documentation/translations/zh_CN/networking/napi.rst:273:epoll 的忙轮询应用程序,可以通过调整 ``struct epoll_params`` 中的 ``busy_poll_budget``
Documentation/translations/zh_CN/networking/napi.rst-274-字段为特定值,并使用 ``EPIOCSPARAMS`` ioctl 在特定 epoll 上下文中设置。更多详细信
--
arch/arm/mach-pxa/spitz.c=771=static struct pxaohci_platform_data spitz_ohci_platform_data = {
--
arch/arm/mach-pxa/spitz.c-775- .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
arch/arm/mach-pxa/spitz.c:776: .power_budget = 150,
arch/arm/mach-pxa/spitz.c-777-};
--
arch/arm/mach-sa1100/assabet.c=89=static void __init assabet_init_gpio(void __iomem *reg, u32 def_val)
--
arch/arm/mach-sa1100/assabet.c-110- * With the ADV7171, LCD and backlight enabled, we go over
arch/arm/mach-sa1100/assabet.c:111: * budget on the MAX846 Li-Ion charger, and if no Li-Ion battery
arch/arm/mach-sa1100/assabet.c-112- * is connected, the Assabet crashes.
--
arch/parisc/include/uapi/asm/pdc.h-20-#define PDC_INVALID_ARG -10 /* Called with an invalid argument */
arch/parisc/include/uapi/asm/pdc.h:21:#define PDC_BUS_POW_WARN -12 /* Call could not complete in allowed power budget */
arch/parisc/include/uapi/asm/pdc.h-22-#define PDC_NOT_NARROW -17 /* Narrow mode not supported */
--
arch/um/drivers/vector_kern.c=72=static void vector_eth_configure(int n, struct arglist *def);
arch/um/drivers/vector_kern.c:73:static int vector_mmsg_rx(struct vector_private *vp, int budget);
arch/um/drivers/vector_kern.c-74-
--
arch/um/drivers/vector_kern.c=901=static int writev_tx(struct vector_private *vp, struct sk_buff *skb)
--
arch/um/drivers/vector_kern.c-944-
arch/um/drivers/vector_kern.c:945:static int vector_mmsg_rx(struct vector_private *vp, int budget)
arch/um/drivers/vector_kern.c-946-{
--
arch/um/drivers/vector_kern.c-961-
arch/um/drivers/vector_kern.c:962: if (budget > qi->max_depth)
arch/um/drivers/vector_kern.c:963: budget = qi->max_depth;
arch/um/drivers/vector_kern.c-964-
arch/um/drivers/vector_kern.c-965- packet_count = uml_vector_recvmmsg(
arch/um/drivers/vector_kern.c:966: vp->fds->rx_fd, qi->mmsg_vector, budget, 0);
arch/um/drivers/vector_kern.c-967-
--
arch/um/drivers/vector_kern.c=1109=static int vector_net_close(struct net_device *dev)
--
arch/um/drivers/vector_kern.c-1159-
arch/um/drivers/vector_kern.c:1160:static int vector_poll(struct napi_struct *napi, int budget)
arch/um/drivers/vector_kern.c-1161-{
--
arch/um/drivers/vector_kern.c-1170- if ((vp->options & VECTOR_RX) > 0)
arch/um/drivers/vector_kern.c:1171: err = vector_mmsg_rx(vp, budget);
arch/um/drivers/vector_kern.c-1172- else {
--
arch/um/drivers/vector_kern.c-1182- napi_schedule(napi);
arch/um/drivers/vector_kern.c:1183: if (work_done <= budget)
arch/um/drivers/vector_kern.c-1184- napi_complete_done(napi, work_done);
--
block/bfq-iosched.c-23- * on the slice-by-slice service scheme of CFQ. But BFQ assigns
block/bfq-iosched.c:24: * budgets, measured in number of sectors, to processes instead of
block/bfq-iosched.c-25- * time slices. The device is not granted to the in-service process
block/bfq-iosched.c-26- * for a given time slice, but until it has exhausted its assigned
block/bfq-iosched.c:27: * budget. This change from the time to the service domain enables BFQ
block/bfq-iosched.c-28- * to distribute the device throughput among processes as desired,
--
block/bfq-iosched.c-30- * internal queueing. BFQ uses an ad hoc internal scheduler, called
block/bfq-iosched.c:31: * B-WF2Q+, to schedule processes according to their budgets. More
]
|
| 70/2 |
2026/09/11 01:38 |
llm |
expert |
0m
Model:
Tokens:
input: 57432
output: 41
thoughts: 58
Thoughts: **Analyzing the WireGuard Receive Poll Function**
Okay, so I'm looking at the code, specifically within `drivers/net/wireguard/receive.c`, and I'm a bit perplexed. I noticed the word `budget` isn't used anywhere in this file, except within the `wg_packet_rx_poll` function signature: `wg_packet_rx_poll(struct napi_struct *napi, int budget)`. This immediately piques my interest. It implies that `budget` is a critical parameter specific to the receive polling mechanism. This needs further investigation. My next step is to dive deeper into how `wg_packet_rx_poll` actually utilizes that `budget` parameter. What's its function? How does it control the number of packets processed? Is it directly related to the NAPI (New API) framework's work-budgeting? I need to understand this to have a complete picture of the receive path's efficiency and potential bottlenecks within the WireGuard implementation.
|
| 71/2 |
2026/09/11 01:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_rx_poll]
Results: map[SourceCode: 438: int wg_packet_rx_poll(struct napi_struct *napi, int budget)
439: {
440: struct wg_peer *peer = container_of(napi, struct wg_peer, napi);
441: struct noise_keypair *keypair;
442: struct endpoint endpoint;
443: enum packet_state state;
444: struct sk_buff *skb;
445: int work_done = 0;
446: bool free;
447:
448: if (unlikely(budget <= 0))
449: return 0;
450:
451: while ((skb = wg_prev_queue_peek(&peer->rx_queue)) != NULL &&
452: (state = atomic_read_acquire(&PACKET_CB(skb)->state)) !=
453: PACKET_STATE_UNCRYPTED) {
454: wg_prev_queue_drop_peeked(&peer->rx_queue);
455: keypair = PACKET_CB(skb)->keypair;
456: free = true;
457:
458: if (unlikely(state != PACKET_STATE_CRYPTED))
459: goto next;
460:
461: if (unlikely(!counter_validate(&keypair->receiving_counter,
462: PACKET_CB(skb)->nonce))) {
463: net_dbg_ratelimited("%s: Packet has invalid nonce %llu (max %llu)\n",
464: peer->device->dev->name,
465: PACKET_CB(skb)->nonce,
466: READ_ONCE(keypair->receiving_counter.counter));
467: goto next;
468: }
469:
470: if (unlikely(wg_socket_endpoint_from_skb(&endpoint, skb)))
471: goto next;
472:
473: wg_reset_packet(skb, false);
474: wg_packet_consume_data_done(peer, skb, &endpoint);
475: free = false;
476:
477: next:
478: wg_noise_keypair_put(keypair, false);
479: wg_peer_put(peer);
480: if (unlikely(free))
481: dev_kfree_skb(skb);
482:
483: if (++work_done >= budget)
484: break;
485: }
486:
487: if (work_done < budget)
488: napi_complete_done(napi, work_done);
489:
490: return work_done;
491: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 72/2 |
2026/09/11 01:38 |
llm |
expert |
0m
Model:
Tokens:
input: 58586
output: 45
thoughts: 117
Thoughts: **Analyzing the WireGuard Packet Flow**
Okay, so `wg_packet_rx_poll` is the Network API (NAPI) poll function, meaning this is where the received packets come to be processed. And I see it pulls data from `peer->rx_queue`. Standard. Now, where are those packets coming from? Ah, `wg_packet_decrypt_worker` is the likely candidate. It’s pulling from `wg->decrypt_queue.ring`. That makes sense; decryption happens separately to prevent blocking the poll. And it’s enqueuing packets, *where* is it enqueuing them? Ah, it enqueues to `peer->rx_queue`, which I already know `wg_packet_rx_poll` pulls from. Specifically, it uses the function `wg_queue_enqueue_per_peer_rx` to do so. Alright, time to check what `wg_queue_enqueue_per_peer_rx` is doing. I need to understand that enqueue operation and potential locking semantics.
|
| 73/2 |
2026/09/11 01:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_queue_enqueue_per_peer_rx]
Results: map[SourceCode: 188: static inline void wg_queue_enqueue_per_peer_rx(struct sk_buff *skb, enum packet_state state)
189: {
190: /* We take a reference, because as soon as we call atomic_set, the
191: * peer can be freed from below us.
192: */
193: struct wg_peer *peer = wg_peer_get(PACKET_PEER(skb));
194:
195: atomic_set_release(&PACKET_CB(skb)->state, state);
196: napi_schedule(&peer->napi);
197: wg_peer_put(peer);
198: }
SourceFile:drivers/net/wireguard/queueing.h]
|
| 74/2 |
2026/09/11 01:38 |
llm |
expert |
0m
Model:
Tokens:
input: 59194
output: 42
thoughts: 752
Thoughts: **WireGuard Workqueue Lockup Vulnerability: A Deep Dive**
Okay, let's see. My initial thought process is this: I'm tracking how incoming packets are handled in WireGuard. I see that `wg_queue_enqueue_per_peer_rx` eventually calls `napi_schedule`, which is key. That connects packet decryption, done by `wg_packet_decrypt_worker`, to the NAPI mechanism. NAPI, in turn, calls `wg_packet_rx_poll` to actually get the data to the network stack. So far, so good, a standard NAPI-driven packet processing flow.
But, a red flag starts to wave because `wg_packet_decrypt_worker` runs in a workqueue. That means it can be preempted, and if it *loops* indefinitely, we're talking about a workqueue watchdog trigger. My mind is now racing... Is there an exit condition for that loop within `wg_packet_decrypt_worker`? I check the code, and no, there isn't a defined loop limit. It just keeps going as long as `ptr_ring_consume_bh` returns a packet.
Aha! This is where the potential vulnerability surfaces. If someone floods the system with packets, `ptr_ring_consume_bh` *will* always return a packet, and the loop continues, and continues, and continues. Then the ring is consumed from `wg->decrypt_queue.ring`. The size of that ring is `MAX_QUEUED_PACKETS` - 1024. Once that ring is full, packets will be dropped by `wg_packet_receive`.
Now, if we have two different CPUs (e.g. CPU 0 and CPU 1), and one is running the NAPI poll function (or softirq) from the NIC, and the other CPU is running `wg_packet_decrypt_worker`, then you can have a continuous process. CPU 0 can continuously fill the ring, and CPU 1 can consume from the ring. But because CPU 1 is running in a workqueue, `wg_packet_decrypt_worker` will never exit. That triggers the workqueue watchdog on CPU 1, which results in a lockup. The report is exactly what I'm thinking here: "BUG: workqueue lockup...". Bingo. It's the "wg_packet_decrypt_worker" specifically, which indicates the problem.
So, in summary, WireGuard's workqueue workers are vulnerable to an indefinite loop if presented with a constant stream of incoming packets, causing a workqueue lockup warning and leading to a denial-of-service condition.
But, is it exploitable? Yes, trivially. An attacker can launch a flood to the WireGuard port. Does the attacker need to be authenticated? Based on the code, to trigger `wg_packet_handshake_receive_worker`, the attacker only needs to send a handshake initiation or response packets. But hang on, `wg_receive_handshake_packet` *does* check the MAC, and under system load requires a cookie. If they don't have a valid cookie, the packet is dropped. But... the drop happens *inside* `wg_receive_handshake_packet`, which is called from the worker. I need to re-examine that function and the implications. We can bypass authentication this way.
|
| 75/2 |
2026/09/11 01:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_receive_handshake_packet]
Results: map[SourceCode: 92: static void wg_receive_handshake_packet(struct wg_device *wg,
93: struct sk_buff *skb)
94: {
95: enum cookie_mac_state mac_state;
96: struct wg_peer *peer = NULL;
97: /* This is global, so that our load calculation applies to the whole
98: * system. We don't care about races with it at all.
99: */
100: static u64 last_under_load;
101: bool packet_needs_cookie;
102: bool under_load;
103:
104: if (SKB_TYPE_LE32(skb) == cpu_to_le32(MESSAGE_HANDSHAKE_COOKIE)) {
105: net_dbg_skb_ratelimited("%s: Receiving cookie response from %pISpfsc\n",
106: wg->dev->name, skb);
107: wg_cookie_message_consume(
108: (struct message_handshake_cookie *)skb->data, wg);
109: return;
110: }
111:
112: under_load = atomic_read(&wg->handshake_queue_len) >=
113: MAX_QUEUED_INCOMING_HANDSHAKES / 8;
114: if (under_load) {
115: last_under_load = ktime_get_coarse_boottime_ns();
116: } else if (last_under_load) {
117: under_load = !wg_birthdate_has_expired(last_under_load, 1);
118: if (!under_load)
119: last_under_load = 0;
120: }
121: mac_state = wg_cookie_validate_packet(&wg->cookie_checker, skb,
122: under_load);
123: if ((under_load && mac_state == VALID_MAC_WITH_COOKIE) ||
124: (!under_load && mac_state == VALID_MAC_BUT_NO_COOKIE)) {
125: packet_needs_cookie = false;
126: } else if (under_load && mac_state == VALID_MAC_BUT_NO_COOKIE) {
127: packet_needs_cookie = true;
128: } else {
129: net_dbg_skb_ratelimited("%s: Invalid MAC of handshake, dropping packet from %pISpfsc\n",
130: wg->dev->name, skb);
131: return;
132: }
133:
134: switch (SKB_TYPE_LE32(skb)) {
135: case cpu_to_le32(MESSAGE_HANDSHAKE_INITIATION): {
136: struct message_handshake_initiation *message =
137: (struct message_handshake_initiation *)skb->data;
138:
139: if (packet_needs_cookie) {
140: wg_packet_send_handshake_cookie(wg, skb,
141: message->sender_index);
142: return;
143: }
144: peer = wg_noise_handshake_consume_initiation(message, wg);
145: if (unlikely(!peer)) {
146: net_dbg_skb_ratelimited("%s: Invalid handshake initiation from %pISpfsc\n",
147: wg->dev->name, skb);
148: return;
149: }
150: wg_socket_set_peer_endpoint_from_skb(peer, skb);
151: net_dbg_ratelimited("%s: Receiving handshake initiation from peer %llu (%pISpfsc)\n",
152: wg->dev->name, peer->internal_id,
153: &peer->endpoint.addr);
154: wg_packet_send_handshake_response(peer);
155: break;
156: }
157: case cpu_to_le32(MESSAGE_HANDSHAKE_RESPONSE): {
158: struct message_handshake_response *message =
159: (struct message_handshake_response *)skb->data;
160:
161: if (packet_needs_cookie) {
162: wg_packet_send_handshake_cookie(wg, skb,
163: message->sender_index);
164: return;
165: }
166: peer = wg_noise_handshake_consume_response(message, wg);
167: if (unlikely(!peer)) {
168: net_dbg_skb_ratelimited("%s: Invalid handshake response from %pISpfsc\n",
169: wg->dev->name, skb);
170: return;
171: }
172: wg_socket_set_peer_endpoint_from_skb(peer, skb);
173: net_dbg_ratelimited("%s: Receiving handshake response from peer %llu (%pISpfsc)\n",
174: wg->dev->name, peer->internal_id,
175: &peer->endpoint.addr);
176: if (wg_noise_handshake_begin_session(&peer->handshake,
177: &peer->keypairs)) {
178: wg_timers_session_derived(peer);
179: wg_timers_handshake_complete(peer);
180: /* Calling this function will either send any existing
181: * packets in the queue and not send a keepalive, which
182: * is the best case, Or, if there's nothing in the
183: * queue, it will send a keepalive, in order to give
184: * immediate confirmation of the session.
185: */
186: wg_packet_send_keepalive(peer);
187: }
188: break;
189: }
190: }
191:
192: if (unlikely(!peer)) {
193: WARN(1, "Somehow a wrong type of packet wound up in the handshake queue!\n");
194: return;
195: }
196:
197: local_bh_disable();
198: update_rx_stats(peer, skb->len);
199: local_bh_enable();
200:
201: wg_timers_any_authenticated_packet_received(peer);
202: wg_timers_any_authenticated_packet_traversal(peer);
203: wg_peer_put(peer);
204: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 76/2 |
2026/09/11 01:38 |
llm |
expert |
0m
Model:
Tokens:
input: 62636
output: 39
thoughts: 112
Thoughts: **My Analysis of a Potential Denial-of-Service Vulnerability**
Okay, so I'm looking at this code related to WireGuard handshake packets, and something immediately jumps out at me. If an attacker crafts packets with an invalid MAC address, the function `wg_receive_handshake_packet` bails out early, which is expected behavior for security. However, here's the kicker: the packet has already been pulled from the processing queue at that point. This means the worker thread, `wg_packet_handshake_receive_worker`, is going to keep looping and polling the empty queue.
That's a bit worrying. If someone can flood the system with these invalid packets quickly enough, `wg_packet_handshake_receive_worker` could get stuck in an endless loop, effectively starving the CPU. It's a classic denial-of-service vector. But hang on, let me quickly double-check something. Aren't invalid packets supposed to be dropped earlier, in `wg_packet_receive`? I need to verify that; it seems odd to me if packets are already dropped in a higher function call, for the lower level function to reprocess them. Let's see how `wg_packet_receive` handles these scenarios.
|
| 77/2 |
2026/09/11 01:38 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_receive]
Results: map[SourceCode: 542: void wg_packet_receive(struct wg_device *wg, struct sk_buff *skb)
543: {
544: if (unlikely(prepare_skb_header(skb, wg) < 0))
545: goto err;
546: switch (SKB_TYPE_LE32(skb)) {
547: case cpu_to_le32(MESSAGE_HANDSHAKE_INITIATION):
548: case cpu_to_le32(MESSAGE_HANDSHAKE_RESPONSE):
549: case cpu_to_le32(MESSAGE_HANDSHAKE_COOKIE): {
550: int cpu, ret = -EBUSY;
551:
552: if (unlikely(!rng_is_initialized()))
553: goto drop;
554: if (atomic_read(&wg->handshake_queue_len) > MAX_QUEUED_INCOMING_HANDSHAKES / 2) {
555: if (spin_trylock_bh(&wg->handshake_queue.ring.producer_lock)) {
556: ret = __ptr_ring_produce(&wg->handshake_queue.ring, skb);
557: spin_unlock_bh(&wg->handshake_queue.ring.producer_lock);
558: }
559: } else
560: ret = ptr_ring_produce_bh(&wg->handshake_queue.ring, skb);
561: if (ret) {
562: drop:
563: net_dbg_skb_ratelimited("%s: Dropping handshake packet from %pISpfsc\n",
564: wg->dev->name, skb);
565: goto err;
566: }
567: atomic_inc(&wg->handshake_queue_len);
568: cpu = wg_cpumask_next_online(&wg->handshake_queue.last_cpu);
569: /* Queues up a call to packet_process_queued_handshake_packets(skb): */
570: queue_work_on(cpu, wg->handshake_receive_wq,
571: &per_cpu_ptr(wg->handshake_queue.worker, cpu)->work);
572: break;
573: }
574: case cpu_to_le32(MESSAGE_DATA):
575: PACKET_CB(skb)->ds = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
576: wg_packet_consume_data(wg, skb);
577: break;
578: default:
579: WARN(1, "Non-exhaustive parsing of packet header lead to unknown packet type!\n");
580: goto err;
581: }
582: return;
583:
584: err:
585: dev_kfree_skb(skb);
586: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 78/2 |
2026/09/11 01:38 |
llm |
expert |
0m
Model:
Tokens:
input: 63904
output: 39
thoughts: 833
Thoughts: **WireGuard Handshake Queue Vulnerability Analysis**
Okay, so here's what I'm thinking. `wg_packet_receive` is pretty naive; it's only looking at the packet type. That means an attacker can just throw UDP packets at it with the handshake initiation code (1) and they'll get enqueued in the handshake queue. The problem is, the worker thread (`wg_packet_handshake_receive_worker`) then has to consume these, *and* validate the MAC.
If an attacker floods the system with these, the worker thread ends up in an infinite loop. It checks the MAC, drops the bad packets, and just keeps going. The bandwidth limits them, but the MAC check itself is pretty fast. The real issue is `wg_receive_handshake_packet` calls `wg_cookie_validate_packet`, which calculates the MAC. So the attacker is making the worker thread spend all its CPU time just computing and discarding MACs.
If the flood is fast enough, the ring fills up, which is what `wg_packet_receive` does. However, because packets are present, the worker thread will never finish and therefore the workqueue watchdog will kick in. This sounds like a known WireGuard issue, where packet floods can essentially lock up workqueues.
I remember `cond_resched()` is called in that loop. While it prevents *complete* CPU monopolization, it won't stop the watchdog from triggering because the work item never actually *completes*. The workqueue watchdog will spew a BUG message. And while `panic_on_wq_watchdog` is probably disabled by default, the kernel log gets spammed, and this can be a serious denial of service. It increases I/O overhead and slows down the system. Also, the worker thread consumes 100% of a CPU, and that's if they are sending packets to a single queue. Multiple queues could be targeted with packets.
It looks like the `handshake_receive_wq` is per-device. So `wg_packet_receive` distributes the work across all online CPUs. So, yes, with enough packets, an attacker can keep *all* CPUs busy computing MACs. That would mean a *complete* denial of service. The workqueue watchdog will trigger on all CPUs.
The thing is, it's not a hard lockup due to `cond_resched()`, but it's still a significant performance degradation, and the watchdog will still trigger.
I need to look for a fix. The solution would be to limit how many packets are processed in a single work item execution. Something like a `MAX_QUEUED_PACKETS` threshold or CPU time budget, and then requeue if there are more packets to process. Let's see if there's a patch for that in the kernel.
|
| 79/2 |
2026/09/11 01:39 |
tool |
git-log |
0m
Args: map[CodeRegexp:budget Count:10 SourcePath:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 80/2 |
2026/09/11 01:39 |
llm |
expert |
0m
Model:
Tokens:
input: 65422
output: 18
thoughts: 40
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Debugging the Stubborn Git Log**
Ugh, my `git log` utility is *still* giving me grief. It's really frustrating when that happens, especially when I'm knee-deep in something this complex. Fine, if `git log` is going to be difficult, I'll switch gears and try something more targeted. Let's dig into the code directly. My gut feeling is that the issue is around the scheduling of the kernel thread, so I'm going to quickly check how `need_resched` is used in that context. Let's see if `grepper` (or even a `grep -R`) can quickly turn up any usage of that macro within `drivers/net/wireguard/receive.c`. Hopefully, that will give me a point to start my investigation. This feels like the right place to be looking; the issue is more than likely with how the networking driver is handling it's scheduling.
|
| 81/2 |
2026/09/11 01:39 |
tool |
grepper |
0m
Args: map[Expression:need_resched]
Results: map[Output:
Full output is too long, showing 500 out of 2259 lines.
Use more precise expression if possible.
Documentation/RCU/Design/Requirements/Requirements.rst=1436=periods:
--
Documentation/RCU/Design/Requirements/Requirements.rst-1440- to provide an RCU quiescent state. RCU also causes those CPUs'
Documentation/RCU/Design/Requirements/Requirements.rst:1441: need_resched() invocations to return ``true``, but only after the
Documentation/RCU/Design/Requirements/Requirements.rst-1442- corresponding CPU's next scheduling-clock.
--
Documentation/RCU/Design/Requirements/Requirements.rst-1444- indefinitely in the kernel without scheduling-clock interrupts, which
Documentation/RCU/Design/Requirements/Requirements.rst:1445: defeats the above need_resched() strategem. RCU will therefore
Documentation/RCU/Design/Requirements/Requirements.rst-1446- invoke resched_cpu() on any ``nohz_full`` CPUs still holding out
--
Documentation/admin-guide/kernel-parameters.txt=98=Kernel parameters
--
Documentation/admin-guide/kernel-parameters.txt-6034-
Documentation/admin-guide/kernel-parameters.txt:6035: rcutorture.fwd_progress_need_resched= [KNL]
Documentation/admin-guide/kernel-parameters.txt-6036- Enclose cond_resched() calls within checks for
Documentation/admin-guide/kernel-parameters.txt:6037: need_resched() during tight-loop forward-progress
Documentation/admin-guide/kernel-parameters.txt-6038- testing.
--
Documentation/locking/mutex-design.rst=38=taken, depending on the state of the lock:
--
Documentation/locking/mutex-design.rst-46- while the lock owner is running and there are no other tasks ready
Documentation/locking/mutex-design.rst:47: to run that have higher priority (need_resched). The rationale is
Documentation/locking/mutex-design.rst-48- that if the lock owner is running, it is likely to release the lock
--
Documentation/locking/preempt-locking.rst=130=local_irq_save. Note, when doing so, you must be very careful to not cause
Documentation/locking/preempt-locking.rst:131:an event that would set need_resched and result in a preemption check. When
Documentation/locking/preempt-locking.rst-132-in doubt, rely on locking or explicit preemption disabling.
--
Documentation/scheduler/sched-arch.rst=24=Your cpu_idle routines need to obey the following rules:
--
Documentation/scheduler/sched-arch.rst-28-
Documentation/scheduler/sched-arch.rst:29:2. need_resched/TIF_NEED_RESCHED is only ever set, and will never
Documentation/scheduler/sched-arch.rst-30- be cleared until the running task has called schedule(). Idle
Documentation/scheduler/sched-arch.rst:31: threads need only ever query need_resched, and may never set or
Documentation/scheduler/sched-arch.rst-32- clear it.
Documentation/scheduler/sched-arch.rst-33-
Documentation/scheduler/sched-arch.rst:34:3. When cpu_idle finds (need_resched() == 'true'), it should call
Documentation/scheduler/sched-arch.rst-35- schedule(). It should not call schedule() otherwise.
--
Documentation/scheduler/sched-arch.rst-37-4. The only time interrupts need to be disabled when checking
Documentation/scheduler/sched-arch.rst:38: need_resched is if we are about to sleep the processor until
Documentation/scheduler/sched-arch.rst-39- the next interrupt (this doesn't provide any protection of
Documentation/scheduler/sched-arch.rst:40: need_resched, it prevents losing an interrupt):
Documentation/scheduler/sched-arch.rst-41-
--
Documentation/scheduler/sched-arch.rst-44- local_irq_disable();
Documentation/scheduler/sched-arch.rst:45: if (!need_resched()) {
Documentation/scheduler/sched-arch.rst-46- local_irq_enable();
--
Documentation/scheduler/sched-arch.rst-51-5. TIF_POLLING_NRFLAG can be set by idle routines that do not
Documentation/scheduler/sched-arch.rst:52: need an interrupt to wake them up when need_resched goes high.
Documentation/scheduler/sched-arch.rst:53: In other words, they must be periodically polling need_resched,
Documentation/scheduler/sched-arch.rst-54- although it may be reasonable to do some background work or enter
--
Documentation/scheduler/sched-arch.rst-58- an interrupt sleep, it needs to be cleared then a memory
Documentation/scheduler/sched-arch.rst:59: barrier issued (followed by a test of need_resched with
Documentation/scheduler/sched-arch.rst-60- interrupts disabled, as explained in 3).
--
Documentation/trace/rv/monitor_sched.rst=180=The need resched preempts (nrp) monitor ensures preemption requires
Documentation/trace/rv/monitor_sched.rst:181:``need_resched``. Only kernel preemption is considered, since preemption
Documentation/trace/rv/monitor_sched.rst-182-while returning to userspace, for this monitor, is indistinguishable from
--
Documentation/trace/rv/monitor_sched.rst=193=task is not running as this monitor does not track the outcome of scheduling.
Documentation/trace/rv/monitor_sched.rst-194-
Documentation/trace/rv/monitor_sched.rst:195:In theory, a preemption can only occur after the ``need_resched`` flag is set. In
Documentation/trace/rv/monitor_sched.rst-196-practice, however, it is possible to see a preemption where the flag is not
Documentation/trace/rv/monitor_sched.rst=197=set. This can happen in one specific condition::
Documentation/trace/rv/monitor_sched.rst-198-
Documentation/trace/rv/monitor_sched.rst:199: need_resched
Documentation/trace/rv/monitor_sched.rst-200- preempt_schedule()
--
Documentation/trace/rv/monitor_sched.rst-202- __schedule()
Documentation/trace/rv/monitor_sched.rst:203: !need_resched
Documentation/trace/rv/monitor_sched.rst-204- __schedule()
--
Documentation/trace/rv/monitor_sched.rst=207=when the flag is set), an interrupt occurs before scheduling and, on its exit
Documentation/trace/rv/monitor_sched.rst:208:path, it schedules, which clears the ``need_resched`` flag.
Documentation/trace/rv/monitor_sched.rst-209-When the preempted task runs again, the standard preemption started earlier
--
Documentation/trace/rv/monitor_sched.rst=216=occurred, as the situation above is hard to pinpoint::
--
Documentation/trace/rv/monitor_sched.rst-226- | schedule_entry | ^
Documentation/trace/rv/monitor_sched.rst:227: | schedule_entry_preempt | sched_need_resched | schedule_entry
Documentation/trace/rv/monitor_sched.rst-228- | | schedule_entry_preempt
--
Documentation/trace/rv/monitor_sched.rst-231- | +--- | | |
Documentation/trace/rv/monitor_sched.rst:232: | sched_need_resched | | rescheduling | -+
Documentation/trace/rv/monitor_sched.rst-233- | +--> | |
--
Documentation/trace/rv/monitor_sched.rst-238- | | | ---+
Documentation/trace/rv/monitor_sched.rst:239: | ---> | | | sched_need_resched
Documentation/trace/rv/monitor_sched.rst-240- | | preempt_irq | | irq_entry
--
Documentation/trace/rv/monitor_sched.rst-243- | +----------------------+ |
Documentation/trace/rv/monitor_sched.rst:244: | | schedule_entry | sched_need_resched
Documentation/trace/rv/monitor_sched.rst-245- | | schedule_entry_preempt |
--
Documentation/trace/rv/monitor_sched.rst-252-
Documentation/trace/rv/monitor_sched.rst:253:Due to how the ``need_resched`` flag on the preemption count works on arm64,
Documentation/trace/rv/monitor_sched.rst-254-this monitor is unstable on that architecture, as it often records preemption
--
Documentation/trace/rv/monitor_sched.rst=263=following types of switch:
--
Documentation/trace/rv/monitor_sched.rst-282- userspace. It can happen after a ``yield`` system call, from the idle task or
Documentation/trace/rv/monitor_sched.rst:283: if the ``need_resched`` flag is set. By definition, a task cannot yield while
Documentation/trace/rv/monitor_sched.rst-284- ``sleepable`` as that would be a suspension. A special case of a yield occurs
--
Documentation/trace/rv/monitor_sched.rst=347=The operations with preemption and irq disabled (opid) monitor ensures
Documentation/trace/rv/monitor_sched.rst:348:operations like ``wakeup`` and ``need_resched`` occur with interrupts and
Documentation/trace/rv/monitor_sched.rst-349-preemption disabled.
Documentation/trace/rv/monitor_sched.rst:350:``need_resched`` can be set by some RCU internals functions, in which case it
Documentation/trace/rv/monitor_sched.rst-351-doesn't match a task wakeup and might occur with only interrupts disabled.
--
Documentation/trace/rv/monitor_sched.rst=353=constraints when processing the events::
--
Documentation/trace/rv/monitor_sched.rst-357- v
Documentation/trace/rv/monitor_sched.rst:358: #=========# sched_need_resched;irq_off == 1
Documentation/trace/rv/monitor_sched.rst-359- H H sched_waking;irq_off == 1 && preempt_off == 1
--
Documentation/translations/zh_CN/locking/mutex-design.rst=37=kernel/locking/mutex.c中实现。这些锁使用一个原子变量(->owner)来跟踪
--
Documentation/translations/zh_CN/locking/mutex-design.rst-52-(ii) 中速路径:也就是乐观自旋,当锁的所有者正在运行并且没有其它优先级更高的
Documentation/translations/zh_CN/locking/mutex-design.rst:53: 任务(need_resched,需要重新调度)准备运行时,当前任务试图自旋来获得
Documentation/translations/zh_CN/locking/mutex-design.rst-54- 锁。原理是,如果锁的所有者正在运行,它很可能不久就会释放锁。互斥锁自旋体
--
Documentation/translations/zh_CN/scheduler/sched-arch.rst=31=CPU空转
--
Documentation/translations/zh_CN/scheduler/sched-arch.rst-36-
Documentation/translations/zh_CN/scheduler/sched-arch.rst:37:2. need_resched/TIF_NEED_RESCHED 只会被设置,并且在运行任务调用 schedule()
Documentation/translations/zh_CN/scheduler/sched-arch.rst:38: 之前永远不会被清除。空闲线程只需要查询need_resched,并且永远不会设置或清除它。
Documentation/translations/zh_CN/scheduler/sched-arch.rst-39-
Documentation/translations/zh_CN/scheduler/sched-arch.rst:40:3. 当cpu_idle发现(need_resched() == 'true'),它应该调用schedule()。否则
Documentation/translations/zh_CN/scheduler/sched-arch.rst-41- 它不应该调用schedule()。
Documentation/translations/zh_CN/scheduler/sched-arch.rst-42-
Documentation/translations/zh_CN/scheduler/sched-arch.rst:43:4. 在检查need_resched时,唯一需要禁用中断的情况是,我们要让处理器休眠到下一个中
Documentation/translations/zh_CN/scheduler/sched-arch.rst:44: 断(这并不对need_resched提供任何保护,它可以防止丢失一个中断):
Documentation/translations/zh_CN/scheduler/sched-arch.rst-45-
--
Documentation/translations/zh_CN/scheduler/sched-arch.rst-48- local_irq_disable();
Documentation/translations/zh_CN/scheduler/sched-arch.rst:49: if (!need_resched()) {
Documentation/translations/zh_CN/scheduler/sched-arch.rst-50- local_irq_enable();
--
Documentation/translations/zh_CN/scheduler/sched-arch.rst-54-
Documentation/translations/zh_CN/scheduler/sched-arch.rst:55:5. 当need_resched变为高电平时,TIF_POLLING_NRFLAG可以由不需要中断来唤醒它们
Documentation/translations/zh_CN/scheduler/sched-arch.rst:56: 的空闲程序设置。换句话说,它们必须定期轮询need_resched,尽管做一些后台工作或
Documentation/translations/zh_CN/scheduler/sched-arch.rst-57- 进入低CPU优先级可能是合理的。
--
Documentation/translations/zh_CN/scheduler/sched-arch.rst-59- - 5a. 如果TIF_POLLING_NRFLAG被设置,而我们确实决定进入一个中断睡眠,那
Documentation/translations/zh_CN/scheduler/sched-arch.rst:60: 么需要清除它,然后发出一个内存屏障(接着测试need_resched,禁用中断,如3中解释)。
Documentation/translations/zh_CN/scheduler/sched-arch.rst-61-
--
arch/alpha/kernel/entry.S=580=ret_to_user:
arch/alpha/kernel/entry.S:581: /* Make sure need_resched and sigpending don't change between
arch/alpha/kernel/entry.S-582- sampling and the rti. */
--
arch/arm/mach-omap2/cpuidle34xx.c=107=static int omap3_enter_idle(struct cpuidle_device *dev,
--
arch/arm/mach-omap2/cpuidle34xx.c-113-
arch/arm/mach-omap2/cpuidle34xx.c:114: if (omap_irq_pending() || need_resched())
arch/arm/mach-omap2/cpuidle34xx.c-115- goto return_sleep_time;
--
arch/arm/mach-omap2/pm33xx-core.c=217=static int am33xx_cpu_suspend(int (*fn)(unsigned long), unsigned long args)
--
arch/arm/mach-omap2/pm33xx-core.c-220-
arch/arm/mach-omap2/pm33xx-core.c:221: if (omap_irq_pending() || need_resched())
arch/arm/mach-omap2/pm33xx-core.c-222- return ret;
--
arch/arm64/include/asm/entry-common.h=16=static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
--
arch/arm64/include/asm/entry-common.h-29-
arch/arm64/include/asm/entry-common.h:30:static inline bool arch_irqentry_exit_need_resched(void)
arch/arm64/include/asm/entry-common.h-31-{
--
arch/arm64/include/asm/entry-common.h-54-
arch/arm64/include/asm/entry-common.h:55:#define arch_irqentry_exit_need_resched arch_irqentry_exit_need_resched
arch/arm64/include/asm/entry-common.h-56-
--
arch/arm64/include/asm/preempt.h=15=static inline void preempt_count_set(u64 pc)
--
arch/arm64/include/asm/preempt.h-28-
arch/arm64/include/asm/preempt.h:29:static inline void set_preempt_need_resched(void)
arch/arm64/include/asm/preempt.h-30-{
arch/arm64/include/asm/preempt.h:31: current_thread_info()->preempt.need_resched = 0;
arch/arm64/include/asm/preempt.h-32-}
arch/arm64/include/asm/preempt.h-33-
arch/arm64/include/asm/preempt.h:34:static inline void clear_preempt_need_resched(void)
arch/arm64/include/asm/preempt.h-35-{
arch/arm64/include/asm/preempt.h:36: current_thread_info()->preempt.need_resched = 1;
arch/arm64/include/asm/preempt.h-37-}
arch/arm64/include/asm/preempt.h-38-
arch/arm64/include/asm/preempt.h:39:static inline bool test_preempt_need_resched(void)
arch/arm64/include/asm/preempt.h-40-{
arch/arm64/include/asm/preempt.h:41: return !current_thread_info()->preempt.need_resched;
arch/arm64/include/asm/preempt.h-42-}
--
arch/arm64/include/asm/preempt.h=78=static inline bool __preempt_count_dec_and_test(void)
--
arch/arm64/include/asm/preempt.h-82-
arch/arm64/include/asm/preempt.h:83: /* Update only the count field, leaving need_resched unchanged */
arch/arm64/include/asm/preempt.h-84- WRITE_ONCE(ti->preempt.count, --pc);
--
arch/arm64/include/asm/preempt.h-88- * need of a reschedule. Otherwise, we need to reload the
arch/arm64/include/asm/preempt.h:89: * preempt_count in case the need_resched flag was cleared by an
arch/arm64/include/asm/preempt.h-90- * interrupt occurring between the non-atomic READ_ONCE/WRITE_ONCE
--
arch/arm64/include/asm/thread_info.h=24=struct thread_info {
--
arch/arm64/include/asm/thread_info.h-32-#ifdef CONFIG_CPU_BIG_ENDIAN
arch/arm64/include/asm/thread_info.h:33: u32 need_resched;
arch/arm64/include/asm/thread_info.h-34- u32 count;
--
arch/arm64/include/asm/thread_info.h-36- u32 count;
arch/arm64/include/asm/thread_info.h:37: u32 need_resched;
arch/arm64/include/asm/thread_info.h-38-#endif
--
arch/arm64/kvm/mmu.c=106=static bool need_split_memcache_topup_or_resched(struct kvm *kvm)
--
arch/arm64/kvm/mmu.c-110-
arch/arm64/kvm/mmu.c:111: if (need_resched() || rwlock_needbreak(&kvm->mmu_lock))
arch/arm64/kvm/mmu.c-112- return true;
--
arch/arm64/kvm/mmu.c=905=static int kvm_init_ipa_range(struct kvm_s2_mmu *mmu, unsigned long type)
--
arch/arm64/kvm/mmu.c-938- *
arch/arm64/kvm/mmu.c:939: * Also, the range of addresses can be large enough to cause need_resched
arch/arm64/kvm/mmu.c-940- * warnings, for instance on CONFIG_PREEMPT_NONE kernels. Hence, invoke
--
arch/hexagon/kernel/vm_entry.S=259=event_dispatch:
--
arch/hexagon/kernel/vm_entry.S-268- * or signals if CONFIG_PREEMPTION is not set. If set, then it has
arch/hexagon/kernel/vm_entry.S:269: * to jump to a need_resched kind of block.
arch/hexagon/kernel/vm_entry.S-270- * BTW, CONFIG_PREEMPTION is not supported yet.
--
arch/mips/kernel/entry.S=46=resume_userspace:
arch/mips/kernel/entry.S-47- local_irq_disable # make sure we dont miss an
arch/mips/kernel/entry.S:48: # interrupt setting need_resched
arch/mips/kernel/entry.S-49- # between sampling and return
--
arch/mips/kernel/entry.S=79=FEXPORT(syscall_exit)
--
arch/mips/kernel/entry.S-83-#endif
arch/mips/kernel/entry.S:84: local_irq_disable # make sure need_resched and
arch/mips/kernel/entry.S-85- # signals dont change between
--
arch/mips/kernel/entry.S=124=work_resched:
--
arch/mips/kernel/entry.S-127-
arch/mips/kernel/entry.S:128: local_irq_disable # make sure need_resched and
arch/mips/kernel/entry.S-129- # signals dont change between
--
arch/mips/kernel/entry.S=145=FEXPORT(syscall_exit_partial)
--
arch/mips/kernel/entry.S-149-#endif
arch/mips/kernel/entry.S:150: local_irq_disable # make sure need_resched doesn't
arch/mips/kernel/entry.S-151- # change between and return
--
arch/mips/kernel/idle.c=32=static void __cpuidle r3081_wait(void)
--
arch/mips/kernel/idle.c-38-/*
arch/mips/kernel/idle.c:39: * This variant is preferable as it allows testing need_resched and going to
arch/mips/kernel/idle.c-40- * sleep depending on the outcome atomically. Unfortunately the "It is
--
arch/mips/kernel/idle.c=45=void __cpuidle r4k_wait_irqoff(void)
arch/mips/kernel/idle.c-46-{
arch/mips/kernel/idle.c:47: if (!need_resched())
arch/mips/kernel/idle.c-48- __asm__(
--
arch/mips/kernel/idle.c=59=static void __cpuidle rm7k_wait_irqoff(void)
arch/mips/kernel/idle.c-60-{
arch/mips/kernel/idle.c:61: if (!need_resched())
arch/mips/kernel/idle.c-62- __asm__(
--
arch/mips/kvm/mips.c=1167=static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
--
arch/mips/kvm/mips.c-1201-
arch/mips/kvm/mips.c:1202: if (need_resched())
arch/mips/kvm/mips.c-1203- cond_resched();
--
arch/parisc/kernel/entry.S=922=intr_do_resched:
--
arch/parisc/kernel/entry.S-951- /* preempt the current task on returning to kernel
arch/parisc/kernel/entry.S:952: * mode from an interrupt, iff need_resched is set,
arch/parisc/kernel/entry.S-953- * and preempt_count is 0. otherwise, we continue on
--
arch/powerpc/kernel/irq_64.c=206=notrace __no_kcsan void arch_local_irq_restore(unsigned long mask)
--
arch/powerpc/kernel/irq_64.c-297- * perform resched if required (a replayed interrupt may set
arch/powerpc/kernel/irq_64.c:298: * need_resched).
arch/powerpc/kernel/irq_64.c-299- */
--
arch/powerpc/lib/vmx-helper.c=36=int exit_vmx_usercopy(void)
--
arch/powerpc/lib/vmx-helper.c-44- * not be saved and restored across context switch. However preempt
arch/powerpc/lib/vmx-helper.c:45: * kernels need to be preempted as soon as possible if need_resched is
arch/powerpc/lib/vmx-helper.c-46- * set and we are preemptible. The hack here is to schedule a
--
arch/powerpc/lib/vmx-helper.c-48- */
arch/powerpc/lib/vmx-helper.c:49: if (need_resched())
arch/powerpc/lib/vmx-helper.c-50- set_dec(1);
--
arch/riscv/kvm/mmu.c=104=static bool need_topup_split_caches_or_resched(struct kvm *kvm, int count)
--
arch/riscv/kvm/mmu.c-107-
arch/riscv/kvm/mmu.c:108: if (need_resched() || rwlock_needbreak(&kvm->mmu_lock))
arch/riscv/kvm/mmu.c-109- return true;
--
arch/s390/crypto/prng.c=511=static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
--
arch/s390/crypto/prng.c-520- while (nbytes) {
arch/s390/crypto/prng.c:521: if (need_resched()) {
arch/s390/crypto/prng.c-522- if (signal_pending(current)) {
--
arch/s390/crypto/prng.c=589=static ssize_t prng_sha512_read(struct file *file, char __user *ubuf,
--
arch/s390/crypto/prng.c-603- while (nbytes) {
arch/s390/crypto/prng.c:604: if (need_resched()) {
arch/s390/crypto/prng.c-605- if (signal_pending(current)) {
--
arch/s390/include/asm/lowcore.h=32=struct lowcore {
--
arch/s390/include/asm/lowcore.h-164- struct {
arch/s390/include/asm/lowcore.h:165: __u32 need_resched; /* 0x03a8 */
arch/s390/include/asm/lowcore.h-166- __u32 count; /* 0x03ac */
--
arch/s390/include/asm/preempt.h=42=static __always_inline void preempt_count_set(unsigned long pc)
--
arch/s390/include/asm/preempt.h-60-
arch/s390/include/asm/preempt.h:61:static __always_inline void set_preempt_need_resched(void)
arch/s390/include/asm/preempt.h-62-{
--
arch/s390/include/asm/preempt.h-65-
arch/s390/include/asm/preempt.h:66:static __always_inline void clear_preempt_need_resched(void)
arch/s390/include/asm/preempt.h-67-{
--
arch/s390/include/asm/preempt.h-70-
arch/s390/include/asm/preempt.h:71:static __always_inline bool test_preempt_need_resched(void)
arch/s390/include/asm/preempt.h-72-{
--
arch/s390/kvm/gmap/dat.c=800=static long dat_reset_skeys_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/dat.c-812-
arch/s390/kvm/gmap/dat.c:813: if (need_resched())
arch/s390/kvm/gmap/dat.c-814- return next;
--
arch/s390/kvm/gmap/dat.c=818=static long dat_reset_skeys_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/dat.c-831-
arch/s390/kvm/gmap/dat.c:832: if (need_resched())
arch/s390/kvm/gmap/dat.c-833- return next;
--
arch/s390/kvm/gmap/dat.c=1160=static long dat_reset_cmma_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/dat.c-1168- pgste_set_unlock(ptep, pgste);
arch/s390/kvm/gmap/dat.c:1169: if (need_resched())
arch/s390/kvm/gmap/dat.c-1170- return next;
--
arch/s390/kvm/gmap/gmap.c=910=static long _gmap_split_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/gmap.c-927-
arch/s390/kvm/gmap/gmap.c:928: if (need_resched())
arch/s390/kvm/gmap/gmap.c-929- return next;
--
arch/s390/kvm/gmap/gmap.c=984=static long _destroy_pages_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/gmap.c-988- __kvm_s390_pv_destroy_page(phys_to_page(pte_origin(*ptep)));
arch/s390/kvm/gmap/gmap.c:989: if (need_resched())
arch/s390/kvm/gmap/gmap.c-990- return next;
--
arch/s390/kvm/gmap/gmap.c=994=static long _destroy_pages_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/gmap.c-1005- __kvm_s390_pv_destroy_page(phys_to_page(cur));
arch/s390/kvm/gmap/gmap.c:1006: if (need_resched())
arch/s390/kvm/gmap/gmap.c-1007- return next;
--
arch/s390/kvm/gmap/gmap.c=1104=static long __set_cmma_clean_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/gmap.c-1111-
arch/s390/kvm/gmap/gmap.c:1112: if (need_resched())
arch/s390/kvm/gmap/gmap.c-1113- return next;
--
arch/s390/kvm/gmap/gmap.c=1117=static long __set_cmma_dirty_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
--
arch/s390/kvm/gmap/gmap.c-1126-
arch/s390/kvm/gmap/gmap.c:1127: if (need_resched())
arch/s390/kvm/gmap/gmap.c-1128- return next;
--
arch/s390/mm/pfault.c=92=static LIST_HEAD(pfault_list);
--
arch/s390/mm/pfault.c-105- * So when we get such an interrupt then we set the state of the current task
arch/s390/mm/pfault.c:106: * to uninterruptible and also set the need_resched flag. Both happens within
arch/s390/mm/pfault.c-107- * interrupt context(!). If we later on want to return to user space we
arch/s390/mm/pfault.c:108: * recognize the need_resched flag and then call schedule(). It's not very
arch/s390/mm/pfault.c-109- * obvious how this works...
--
arch/s390/mm/pfault.c=117=static void pfault_interrupt(struct ext_code ext_code,
--
arch/s390/mm/pfault.c-201- __set_current_state(TASK_UNINTERRUPTIBLE);
arch/s390/mm/pfault.c:202: set_need_resched_current();
arch/s390/mm/pfault.c-203- }
--
arch/sh/kernel/entry-common.S=90=ENTRY(resume_kernel)
--
arch/sh/kernel/entry-common.S-95- bf noresched
arch/sh/kernel/entry-common.S:96:need_resched:
arch/sh/kernel/entry-common.S-97- mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
arch/sh/kernel/entry-common.S:98: tst #_TIF_NEED_RESCHED, r0 ! need_resched set?
arch/sh/kernel/entry-common.S-99- bt noresched
--
arch/sh/kernel/entry-common.S-109- nop
arch/sh/kernel/entry-common.S:110: bra need_resched
arch/sh/kernel/entry-common.S-111- nop
--
arch/sparc/include/asm/thread_info_64.h=127=extern struct thread_info *current_thread_info(void);
--
arch/sparc/include/asm/thread_info_64.h-160- *
arch/sparc/include/asm/thread_info_64.h:161: * user: need_resched, notify_resume, sigpending, wsaved
arch/sparc/include/asm/thread_info_64.h-162- * kernel: fpdepth
--
arch/sparc/kernel/process_64.c=58=void arch_cpu_idle(void)
--
arch/sparc/kernel/process_64.c-76-
arch/sparc/kernel/process_64.c:77: if (!need_resched() && !cpu_is_offline(smp_processor_id())) {
arch/sparc/kernel/process_64.c-78- sun4v_cpu_yield();
--
arch/um/include/shared/kern_util.h=52=extern char *uml_strdup(const char *string);
arch/um/include/shared/kern_util.h:53:int uml_need_resched(void);
arch/um/include/shared/kern_util.h-54-
--
arch/um/kernel/process.c=226=int __uml_cant_sleep(void) {
--
arch/um/kernel/process.c-230-
arch/um/kernel/process.c:231:int uml_need_resched(void)
arch/um/kernel/process.c-232-{
arch/um/kernel/process.c:233: return need_resched();
arch/um/kernel/process.c-234-}
--
arch/um/os-Linux/time.c=135=void os_idle_sleep(void)
--
arch/um/os-Linux/time.c-139- /*
arch/um/os-Linux/time.c:140: * Block SIGALRM while performing the need_resched check.
arch/um/os-Linux/time.c-141- * Note that, because IRQs are disabled, the IPI signal is
--
arch/um/os-Linux/time.c-151- */
arch/um/os-Linux/time.c:152: if (!uml_need_resched() && !timer_alarm_pending())
arch/um/os-Linux/time.c-153- os_poll(1, &wake_signals);
--
arch/x86/crypto/aesni-intel_glue.c=1273=static void gcm_process_assoc(const struct aes_gcm_key *key, u8 ghash_acc[16],
--
arch/x86/crypto/aesni-intel_glue.c-1318- scatterwalk_done_src(&walk, orig_len_this_step);
arch/x86/crypto/aesni-intel_glue.c:1319: if (need_resched()) {
arch/x86/crypto/aesni-intel_glue.c-1320- kernel_fpu_end();
--
arch/x86/include/asm/mwait.h=93=static __always_inline void __sti_mwait(u32 eax, u32 ecx)
--
arch/x86/include/asm/mwait.h-100- * This uses new MONITOR/MWAIT instructions on P4 processors with PNI,
arch/x86/include/asm/mwait.h:101: * which can obviate IPI to trigger checking of need_resched.
arch/x86/include/asm/mwait.h:102: * We execute MONITOR against need_resched and enter optimized wait state
arch/x86/include/asm/mwait.h:103: * through MWAIT. Whenever someone changes need_resched, we would be woken
arch/x86/include/asm/mwait.h-104- * up from MWAIT (without an IPI).
--
arch/x86/include/asm/mwait.h=109=static __always_inline void mwait_idle_with_hints(u32 eax, u32 ecx)
arch/x86/include/asm/mwait.h-110-{
arch/x86/include/asm/mwait.h:111: if (need_resched())
arch/x86/include/asm/mwait.h-112- return;
--
arch/x86/include/asm/mwait.h-121-
arch/x86/include/asm/mwait.h:122: if (need_resched())
arch/x86/include/asm/mwait.h-123- goto out;
--
arch/x86/include/asm/preempt.h=48=static __always_inline void preempt_count_set(unsigned long pc)
--
arch/x86/include/asm/preempt.h-76-
arch/x86/include/asm/preempt.h:77:static __always_inline void set_preempt_need_resched(void)
arch/x86/include/asm/preempt.h-78-{
--
arch/x86/include/asm/preempt.h-81-
arch/x86/include/asm/preempt.h:82:static __always_inline void clear_preempt_need_resched(void)
arch/x86/include/asm/preempt.h-83-{
--
arch/x86/include/asm/preempt.h-86-
arch/x86/include/asm/preempt.h:87:static __always_inline bool test_preempt_need_resched(void)
arch/x86/include/asm/preempt.h-88-{
--
arch/x86/kernel/apm_32.c=835=static int apm_do_idle(void)
--
arch/x86/kernel/apm_32.c-841-
arch/x86/kernel/apm_32.c:842: if (!need_resched()) {
arch/x86/kernel/apm_32.c-843- idled = 1;
--
arch/x86/kernel/apm_32.c=900=static int apm_cpu_idle(struct cpuidle_device *dev,
--
arch/x86/kernel/apm_32.c-931-
arch/x86/kernel/apm_32.c:932: while (!need_resched()) {
arch/x86/kernel/apm_32.c-933- if (use_apm_idle) {
--
arch/x86/kernel/cpu/sgx/ioctl.c=415=static long sgx_ioc_enclave_add_pages(struct sgx_encl *encl, void __user *arg)
--
arch/x86/kernel/cpu/sgx/ioctl.c-449-
arch/x86/kernel/cpu/sgx/ioctl.c:450: if (need_resched())
arch/x86/kernel/cpu/sgx/ioctl.c-451- cond_resched();
]
|
| 82/2 |
2026/09/11 01:39 |
llm |
expert |
0m
Model:
Tokens:
input: 76788
output: 66
thoughts: 2015
Thoughts: **Analysis of a WireGuard Denial of Service Vulnerability**
Okay, let's break this down. It seems `need_resched()` is being called within `wg_packet_decrypt_worker`, which is good for yielding the CPU, but it doesn't actually *return* the work item. If this loop never terminates, that work item will run indefinitely. The workqueue watchdog will notice it hasn't finished after 30 seconds and will print a `BUG` message, which is the key here. This is a clear Denial of Service.
Can it be exploited remotely? Yes, by flooding the WireGuard port with UDP packets. Does the attacker need to know the port or public key? The attacker needs to know the port. The public key doesn't matter, since packets are dropped after being consumed from the queue.
The attack scenario is clear: send UDP packets with the first 4 bytes set to 1, (MESSAGE_HANDSHAKE_INITIATION), and this forces the worker thread into an infinite loop. It will yield the CPU (`cond_resched()`), so other tasks can run. However, the watchdog will trigger a BUG message, which is still a denial of service. The system will panic if `panic_on_wq_watchdog` is set, and it will exhaust the CPU or CPUs if the attacker can send enough packets. This results in CPU exhaustion and spamming the kernel log with BUG messages.
So, let's define the exploitability: It's not memory corruption or privilege escalation, so it's not "Exploitable". This is definitely a Denial of Service. It's accessible from unprivileged processes (local UDP packets can trigger it). It's accessible from user namespaces. It's triggered over the Ethernet network (remote UDP packets). It doesn't require malicious files or peripheral triggers.
Also, it prevents the WireGuard service from processing legitimate traffic, making the tunnel unavailable. The workqueue pool might become starved. Importantly, `wg_packet_handshake_receive_worker` uses an unbound workqueue, and it distributes the work across all online CPUs. So, an attacker could potentially lock up *all* CPUs with this attack. This is a severe CPU exhaustion DoS vulnerability.
Now, let's confirm the queue behavior. I need to make sure `wg_packet_receive` isn't dropping packets when the queue is full. Looks like it's doing so with a check to `atomic_read(&wg->handshake_queue_len)` and if greater than `MAX_QUEUED_INCOMING_HANDSHAKES/2` then lock, and then `__ptr_ring_produce`. Otherwise it will call `ptr_ring_produce_bh`.
But the worker thread consumes packets. If the NAPI thread is running on a different CPU, it can continuously feed the queue, while the worker keeps looping, leading to the same infinite loop problem.
The mitigation is simple: Limit the number of packets processed per work item execution and return. If the work item returns, the watchdog won't trigger because the core updates `pool->last_progress_ts`. Returning will allow other work items in the same workqueue to run. WireGuard uses dedicated workqueues. So, returning and re-queuing will allow other work items to run and prevent the watchdog from triggering.
Let me search for a commit that addresses this - looks like there's no need to find the specific commit, just need to evaluate the security impact. It's a Denial of Service. It's network and remote triggered. Local unprivileged users can trigger it.
Checking the bug report again confirms the stuck work items: `wg_packet_decrypt_worker` and `wg_packet_handshake_receive_worker` are indeed looping. The backtraces confirm they're actively running and being preempted (not deadlocked). They are just stuck in an infinite loop.
So, there's no memory corruption, just CPU exhaustion. The packets are dequeued and freed. No out-of-bounds access or use-after-free. It's a CPU exhaustion / workqueue lockup issue. Let's call `set-results` tool.
|
| 83/2 |
2026/09/11 01:39 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:true Unprivileged:true UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 84/2 |
2026/09/11 01:39 |
llm |
expert-compressor |
0m
Model:
Reply: ### 1. Approaches Tried and Results
- **Analyzed Bug Report**:
- Bug: `BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0 nice=0 stuck for 59s!`.
- Occurred on ARM64 (`arch/arm64/...`).
- Stalled workers in pool 6:
- PID 6013: `kworker/1:6` running `wg-crypt-wg2: wg_packet_decrypt_worker` (at `ptr_ring_consume_bh`).
- PID 24: `kworker/1:0` running `wg-kex-wg2: wg_packet_handshake_receive_worker` (at `wg_noise_handshake_consume_initiation` -> crypto/poly1305).
- PID 6073: `kworker/1:8` running `wg-kex-wg2: wg_packet_handshake_receive_worker` (at `wg_index_hashtable_insert`).
- All stuck workers are executing WireGuard workqueue functions (`wg_packet_decrypt_worker` and `wg_packet_handshake_receive_worker`).
- **Examined Workqueue Watchdog Mechanism (`kernel/workqueue.c:wq_watchdog_timer_fn`)**:
- Checked `pool->last_progress_ts` update conditions.
- `pool->last_progress_ts` is updated when work begins processing in `process_scheduled_works` (`if (first) worker->pool->last_progress_ts = jiffies;`).
- Crucially: If a work item stays inside its work handler function continuously without returning to `process_scheduled_works`, `pool->last_progress_ts` is never updated.
- `cond_resched()` yields CPU to other processes, but does NOT return from the work handler to workqueue core, so `last_progress_ts` is never refreshed while looping.
- If a work item loops longer than `thresh` (default 30s) while items remain on the pool worklist, `wq_watchdog_timer_fn` triggers `BUG: workqueue lockup` and calls `panic_on_wq_watchdog()`.
- **Analyzed WireGuard Worker Implementations**:
- `wg_packet_decrypt_worker` (`drivers/net/wireguard/receive.c:493`):
```c
void wg_packet_decrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct sk_buff *skb;
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state =
likely(decrypt_packet(skb, PACKET_CB(skb)->keypair)) ?
PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
wg_queue_enqueue_per_peer_rx(skb, state);
if (need_resched())
cond_resched();
}
}
```
- `wg_packet_handshake_receive_worker` (`drivers/net/wireguard/receive.c:206`):
```c
void wg_packet_handshake_receive_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct wg_device *wg = container_of(queue, struct wg_device, handshake_queue);
struct sk_buff *skb;
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
wg_receive_handshake_packet(wg, skb);
dev_kfree_skb(skb);
atomic_dec(&wg->handshake_queue_len);
cond_resched();
}
}
```
- `wg_packet_encrypt_worker` (`drivers/net/wireguard/send.c:287`):
```c
while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
...
if (need_resched())
cond_resched();
}
```
- **Analyzed Ring Production vs Consumption**:
- Producers (`wg_packet_receive` / `wg_packet_consume_data`): Invoked in softirq / NAPI / packet reception context, enqueues packets into `handshake_queue.ring` or `decrypt_queue.ring` using `ptr_ring_produce_bh` / `__ptr_ring_produce`.
- While worker loop calls `ptr_ring_consume_bh`, it unlocks `consumer_lock` and re-enables BH between packet decryptions. Softirqs can run, or producers on other CPUs can concurrently feed the ring.
- If incoming traffic rate is high, `ptr_ring_consume_bh(&queue->ring)` never returns `NULL`.
- Because there is no quota/budget (unlike NAPI budget) limiting the number of iterations per work execution before returning/rescheduling the work, the work function loops indefinitely.
- **Git Log Invocations (Dead ends / Issues)**:
- Several `git-log` attempts failed or returned a single commit (`5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled`). The git commit history in this repository environment appears shallow or restricted. Stop relying on `git-log`.
- Broad search for `budget` yielded 19k+ lines of unrelated matches across tree.
---
### 2. Current Hypotheses and Security Assessment Status
- **Nature of Bug**:
- Unbounded loop in WireGuard workqueue workers (`wg_packet_decrypt_worker`, `wg_packet_handshake_receive_worker`, `wg_packet_encrypt_worker`).
- When under continuous packet load, workers consume packets continuously without exiting the worker callback function.
- Workqueue watchdog detects that `pool->last_progress_ts` hasn't updated for > 30-59 seconds despite pending works on the worklist, declaring a workqueue lockup.
- **Exploitable**:
- No memory corruption, no wild pointers, no out-of-bounds access, no use-after-free, no uninitialized memory, no information leak to userspace.
- Pure scheduling / watchdog stall issue. Not exploitable for privilege escalation or info leak.
- **Denial of Service**:
- Can cause severe CPU consumption and triggers workqueue watchdog warning/BUG.
- By default, `panic_on_wq_watchdog` is 0 (check sysctl/kernel config/defaults), but workqueue watchdog outputs `BUG: workqueue lockup` (printed as `pr_emerg("BUG: workqueue lockup - pool...")` at `kernel/workqueue.c:7996`). Note: `pr_emerg` is logged, and if `panic_on_wq_watchdog` is enabled it panics. Even without panic, worker thread monopolizes worker pool slot, starving other items queued on that workqueue/pool.
- **Reachability / Triggers**:
- **Ethernet Network Trigger / Remote**: WireGuard listens on a UDP port for handshake and encrypted data packets. An external network attacker sending UDP packets to the WireGuard port can flood the queue. Handshake initiation packets with valid MAC1 (derived from device's known public key) will be accepted into `handshake_queue` without authentication!
- **Accessible From Unprivileged Processes**: Can an unprivileged local process trigger this?
- If WireGuard interface is configured, local unprivileged user can send UDP packets to 127.0.0.1 or local IP / WireGuard UDP port.
- WireGuard interfaces themselves are created with `CAP_NET_ADMIN` (usually root or netns root). But traffic can be sent to the listening UDP port by unprivileged users if bound to 0.0.0.0 / accessible interface.
- Need to verify kernel config regarding `CONFIG_PANIC_ON_WQ_WATCHDOG` and WireGuard socket creation / reachability.
---
### 3. Critical Files, Code Snippets, and Configuration
- **`kernel/workqueue.c`**:
- `wq_watchdog_timer_fn()`: checks `time_after(now, ts + thresh)`. If stall detected:
```c
pr_emerg("BUG: workqueue lockup - pool");
...
if (lockup_detected)
panic_on_wq_watchdog(max_stall_time);
```
- `panic_on_wq_watchdog()`: panics only if `wq_watchdog_panics` / `CONFIG_WQ_WATCHDOG` panic option is set.
- **`drivers/net/wireguard/receive.c`**:
- Lines 206-218 (`wg_packet_handshake_receive_worker`):
```c
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
wg_receive_handshake_packet(wg, skb);
dev_kfree_skb(skb);
atomic_dec(&wg->handshake_queue_len);
cond_resched();
}
```
- Lines 493-507 (`wg_packet_decrypt_worker`):
```c
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state = ...;
wg_queue_enqueue_per_peer_rx(skb, state);
if (need_resched())
cond_resched();
}
```
- Lines 542-586 (`wg_packet_receive`):
- Handshake packets (initiation, response, cookie) queued into `wg->handshake_queue.ring`.
- Data packets dispatched via `wg_packet_consume_data` into `wg->decrypt_queue`.
- **`drivers/net/wireguard/send.c`**:
- Lines 287-309 (`wg_packet_encrypt_worker`): similar loop with `ptr_ring_consume_bh`.
---
### 4. Watch Out / Potential Traps and Loops
- **Do NOT run `git-log`**: The repository git history is either truncated or does not have commits matching git-log queries.
- **Do NOT run unconstrained greps on common terms like `budget`**: Results in 20,000 lines.
- **Still Need to Check**:
1. Kernel config (`.config`) for `CONFIG_WQ_WATCHDOG`, `CONFIG_PANIC_ON_WQ_WATCHDOG`, etc.
2. Whether unprivileged users can send UDP packets to WireGuard listening endpoint (standard UDP socket created by `net_device` in WireGuard, usually bound to a port specified by config).
3. Reachability dimensions: Unprivileged local process, User Namespaces, Network (Ethernet / Remote), VM Guest, Peripheral, Malicious FS.
4. Final exploitability determination: DoS only vs Exploitable. Set results accordingly.
Tokens:
input: 53078
output: 2592
thoughts: 0
|
| 85/2 |
2026/09/11 01:40 |
llm |
expert |
0m
Model:
Tokens:
input: 33264
output: 44
thoughts: 0
|
| 86/2 |
2026/09/11 01:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_handshake_receive_worker]
Results: map[SourceCode: 206: void wg_packet_handshake_receive_worker(struct work_struct *work)
207: {
208: struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
209: struct wg_device *wg = container_of(queue, struct wg_device, handshake_queue);
210: struct sk_buff *skb;
211:
212: while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
213: wg_receive_handshake_packet(wg, skb);
214: dev_kfree_skb(skb);
215: atomic_dec(&wg->handshake_queue_len);
216: cond_resched();
217: }
218: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 87/2 |
2026/09/11 01:40 |
llm |
expert |
0m
Model:
Tokens:
input: 33571
output: 41
thoughts: 0
|
| 88/2 |
2026/09/11 01:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/receive.c Name:wg_packet_decrypt_worker]
Results: map[SourceCode: 493: void wg_packet_decrypt_worker(struct work_struct *work)
494: {
495: struct crypt_queue *queue = container_of(work, struct multicore_worker,
496: work)->ptr;
497: struct sk_buff *skb;
498:
499: while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
500: enum packet_state state =
501: likely(decrypt_packet(skb, PACKET_CB(skb)->keypair)) ?
502: PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
503: wg_queue_enqueue_per_peer_rx(skb, state);
504: if (need_resched())
505: cond_resched();
506: }
507: }
SourceFile:drivers/net/wireguard/receive.c]
|
| 89/2 |
2026/09/11 01:40 |
llm |
expert |
0m
Model:
Tokens:
input: 33892
output: 41
thoughts: 0
|
| 90/2 |
2026/09/11 01:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireguard/send.c Name:wg_packet_encrypt_worker]
Results: map[SourceCode: 287: void wg_packet_encrypt_worker(struct work_struct *work)
288: {
289: struct crypt_queue *queue = container_of(work, struct multicore_worker,
290: work)->ptr;
291: struct sk_buff *first, *skb, *next;
292:
293: while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
294: enum packet_state state = PACKET_STATE_CRYPTED;
295:
296: skb_list_walk_safe(first, skb, next) {
297: if (likely(encrypt_packet(skb,
298: PACKET_CB(first)->keypair))) {
299: wg_reset_packet(skb, true);
300: } else {
301: state = PACKET_STATE_DEAD;
302: break;
303: }
304: }
305: wg_queue_enqueue_per_peer_tx(first, state);
306: if (need_resched())
307: cond_resched();
308: }
309: }
SourceFile:drivers/net/wireguard/send.c]
|
| 91/2 |
2026/09/11 01:40 |
llm |
expert |
0m
Model:
Tokens:
input: 34311
output: 42
thoughts: 0
|
| 92/2 |
2026/09/11 01:40 |
tool |
git-log |
0m
Args: map[CodeRegexp:cond_resched Count:10 SourcePath:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 93/2 |
2026/09/11 01:40 |
llm |
expert |
0m
Model:
Tokens:
input: 34397
output: 42
thoughts: 0
|
| 94/2 |
2026/09/11 01:40 |
tool |
git-log |
0m
Args: map[CodeRegexp:need_resched Count:10 SourcePath:drivers/net/wireguard/receive.c]
Results: map[Output:5445d6419962 arm64: Don't read GMID_EL1 when MTE is disabled
]
|
| 95/2 |
2026/09/11 01:41 |
llm |
expert |
0m
Model:
Tokens:
input: 34483
output: 826
thoughts: 1085
Thoughts: **Analyzing the WireGuard Workqueue Lockup**
Okay, so I've been digging into this WireGuard workqueue lockup. It's stemming from an unbounded loop within the workqueue workers (`wg_packet_handshake_receive_worker`, `wg_packet_decrypt_worker`, and `wg_packet_encrypt_worker`). These workers are tasked with processing packets pulled from a `ptr_ring` using `ptr_ring_consume_bh()`. The crux of the issue is that if the packet arrival rate is high enough, `ptr_ring_consume_bh()` never returns `NULL`, and the worker gets stuck in an infinite `while` loop.
Now, the code does call `cond_resched()`, or `if (need_resched()) cond_resched()`, which gives up the CPU. This seems to prevent a hard lockup or RCU stall, right? The catch, however, is that `cond_resched()` doesn't actually return back to the workqueue core (`process_scheduled_works()`). So, the workqueue watchdog (`wq_watchdog_timer_fn()`) kicks in, checking `pool->last_progress_ts`. This timestamp is only updated when a work item *finishes* and the next one *starts* (or when the pool is idle). Since the worker is permanently in the loop, that timestamp *never* gets updated, and the watchdog eventually throws a `BUG: workqueue lockup`.
My assessment is that this is *not* exploitable in the sense of causing memory corruption or information leaks. It's a watchdog timeout because of a long-running work item. However, it's definitely a Denial of Service. The `BUG` can cause a panic (depending on configuration) or, at the very least, generate a lot of noise and starve other work items on the same workqueue/pool.
The really nasty part is the network attack surface. An attacker can flood the WireGuard UDP port with packets – handshake initiation or data packets. The handshake packets are directly queued into `wg->handshake_queue.ring` from the UDP receive path (`wg_packet_receive()`), and data packets go into `wg->decrypt_queue.ring`. Because it is UDP, this can be triggered remotely.
Looking closely at `wg_packet_receive()` to confirm, especially how handshake packets are processed, it seems an attacker can indeed send packets continuously. As long as the worker processes them and decrements `handshake_queue_len`, the `MAX_QUEUED_INCOMING_HANDSHAKES` limit (4096) isn't reached, and new packets are added. The worker loop itself, with `ptr_ring_consume_bh`, has BH disabled/enabled, allowing softirqs (like network RX) to run and refill the ring. So, yes, the loop *can* run forever with a high enough packet rate.
So, the issue *can* be triggered by unprivileged users (e.g., via `sendto()` to `127.0.0.1:wg_port`), and the same holds true for user namespaces. My gut feeling is the solution here is to impose a budget or a time limit, or to simply return from the work item and re-queue it.
|
| 96/1 |
2026/09/11 01:41 |
action |
format-explanation |
0m
Results: map[Explanation:**Analysis of the Bug**
The bug report indicates a `BUG: workqueue lockup` in the WireGuard driver. The
workqueue watchdog detected that worker threads in `pool 6` have been stuck for
59 seconds. The stack traces show that the stuck workers are executing
WireGuard's workqueue functions: `wg_packet_decrypt_worker` and
`wg_packet_handshake_receive_worker`.
Looking at the source code for these workers (e.g.,
`wg_packet_handshake_receive_worker` in `drivers/net/wireguard/receive.c`):
```c
void wg_packet_handshake_receive_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker,
work)->ptr;
struct wg_device *wg = container_of(queue, struct wg_device,
handshake_queue);
struct sk_buff *skb;
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
wg_receive_handshake_packet(wg, skb);
dev_kfree_skb(skb);
atomic_dec(&wg->handshake_queue_len);
cond_resched();
}
}
```
The worker processes packets in a `while` loop as long as
`ptr_ring_consume_bh()` returns a packet. `ptr_ring_consume_bh()` temporarily
disables and then re-enables bottom halves (softirqs). This allows network RX
softirqs to run concurrently and continuously refill the `ptr_ring` with new
incoming packets.
If the incoming packet rate is sufficiently high, the `ptr_ring` will never be
empty, and the `while` loop will never terminate. Although the loop calls
`cond_resched()` to yield the CPU to other tasks (preventing a hard CPU lockup
or RCU stall), it never actually returns from the work function back to the
workqueue core (`process_scheduled_works()`).
The workqueue core updates the worker pool's `last_progress_ts` only when a work
item finishes. Because the WireGuard worker never returns, `last_progress_ts` is
never updated. Eventually, the workqueue watchdog (`wq_watchdog_timer_fn`)
notices that the pool hasn't made progress for more than the threshold (default
30 seconds) and triggers the `BUG: workqueue lockup`.
**Security Impact Assessment**
* **Exploitable:** No. This is a pure scheduling/watchdog issue. There is no
memory corruption, out-of-bounds access, use-after-free, or information leak. It
cannot be used for privilege escalation or to leak kernel memory.
* **Denial Of Service:** Yes. The bug triggers a `BUG()` which will flood the
kernel logs and can panic the system if `panic_on_wq_watchdog` or
`panic_on_oops` is enabled. Even without a panic, the worker thread monopolizes
a workqueue pool slot indefinitely, which can starve other kernel subsystems
relying on the same workqueue.
* **Network / Remote Trigger:** Yes. WireGuard listens on a UDP port. An
attacker can trigger this bug remotely by flooding the WireGuard UDP port with
packets (e.g., handshake initiation packets). The packets don't even need to be
fully authenticated to be queued into the `handshake_queue.ring`.
* **Accessible From Unprivileged Processes / User Namespaces:** Yes. A local
unprivileged user (or a user in a user namespace) can send UDP packets to the
local WireGuard listening port (e.g., via `127.0.0.1`) to flood the queue and
trigger the lockup.]
|