| 0/0 |
2026/05/24 09:44 |
flow |
assessment-security |
45m
Results: map[DenialOfService:true Explanation:Based on the analysis of the bug report and the kernel source code, here is the
assessment of the vulnerability:
### Root Cause Analysis
The bug is an infinite loop / CPU stall in the `advance_sched` hrtimer callback
of the `sch_taprio` network scheduler.
When configuring the `taprio` qdisc, the kernel validates the `interval` of
schedule entries to ensure it is large enough to transmit a minimum-sized
Ethernet frame (`ETH_ZLEN`). This minimum duration is calculated based on the
network device's link speed (`picos_per_byte`).
For devices with very high link speedsβsuch as `veth` (which defaults to 10000
Mbps) or `tun` (which can be configured to arbitrary speeds up to `0x7fffffff`
via ethtool)βthe calculated `min_duration` can be extremely small, down to just
`1 ns` (or `48 ns` for `veth`).
If a user configures the `taprio` qdisc with such a small `interval`, the
`advance_sched` timer callback will increment the timer's next expiration time
by only `1 ns` (or `48 ns`) and return `HRTIMER_RESTART`. Because the execution
time of the `advance_sched` function and the hrtimer subsystem overhead is
significantly larger than this tiny interval, the timer's expiration time will
never catch up to the current time (`basenow`).
This causes the hrtimer subsystem to repeatedly execute the timer callback in an
infinite loop (or an exponentially growing loop) in hardirq context, completely
starving the CPU. This leads to the observed RCU stall, soft lockup, and a
complete system freeze.
### Security Impact
* **Exploitable:** **No.** The bug is a pure logic error leading to an infinite
loop in interrupt context. It does not cause memory corruption, out-of-bounds
accesses, or use-after-free conditions. Therefore, it cannot be exploited for
arbitrary code execution or privilege escalation.
* **Denial Of Service:** **Yes.** Triggering the bug causes the CPU to be
permanently stuck in an interrupt context loop, leading to an RCU stall, soft
lockups, and a system crash/freeze.
* **Accessible From Unprivileged Processes:** **No.** Configuring network
schedulers (qdiscs) requires `CAP_NET_ADMIN` capabilities, which a standard
unprivileged user does not have in the initial network namespace.
* **Accessible From User Namespaces:** **Yes.** An unprivileged user can create
a new user namespace and a new network namespace, gaining `CAP_NET_ADMIN` within
that namespace. They can then create a `veth` or `tun` device and attach the
malicious `taprio` qdisc configuration to it, successfully triggering the Denial
of Service on the host.
* **VM Guest Trigger:** **No.** This is a network scheduler bug, not related to
virtualization or KVM guest exits.
* **VM Host Trigger in The Confidential Computing Context:** **No.**
* **Ethernet Network Trigger:** **No.** The bug is triggered synchronously
during the configuration of the qdisc and the subsequent timer execution, not by
processing ingress network traffic.
* **Other Remote Trigger:** **No.**
* **Peripheral Trigger:** **No.**
* **Malicious Filesystem Trigger:** **No.** Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/24 09:44 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/24 09:44 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/a79c4e925ae8c5c64e9b72d754aa2b30922b01ce]
|
| 3/1 |
2026/05/24 09:46 |
action |
kernel-builder |
18m
Results: map[KernelObj:/app/workdir/cache/build/00f6e6600229f8f13e300fdb69b57702fd77ba30]
|
| 4/1 |
2026/05/24 10:04 |
action |
codesearch-prepare |
20m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/24 10:25 |
agent |
expert |
4m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Instruction:
You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by greeping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption or elevated privileges.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completly wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control tranfers, that's also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidetial Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
rcu: Tasks blocked on level-0 rcu_node (CPUs 0-1): P10713/1:b..l
rcu: (detected by 1, t=10502 jiffies, g=58129, q=579 ncpus=2)
task:udevd state:R running task stack:24440 pid:10713 tgid:10713 ppid:4988 task_flags:0x400140 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5388 [inline]
__schedule+0x17b4/0x5680 kernel/sched/core.c:7189
preempt_schedule_notrace+0x57/0x90 kernel/sched/core.c:7463
preempt_schedule_notrace_thunk+0x16/0x30 arch/x86/entry/thunk.S:13
rcu_is_watching+0x7f/0xb0 kernel/rcu/tree.c:753
trace_lock_acquire include/trace/events/lock.h:24 [inline]
lock_acquire+0x5f/0x350 kernel/locking/lockdep.c:5831
rcu_lock_acquire include/linux/rcupdate.h:300 [inline]
rcu_read_lock include/linux/rcupdate.h:838 [inline]
class_rcu_constructor include/linux/rcupdate.h:1181 [inline]
unwind_next_frame+0xc3/0x2550 arch/x86/kernel/unwind_orc.c:495
arch_stack_walk+0x11b/0x150 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0xa9/0x100 kernel/stacktrace.c:122
save_stack+0x122/0x230 mm/page_owner.c:165
__reset_page_owner+0x71/0x1f0 mm/page_owner.c:320
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1402 [inline]
free_unref_folios+0xcec/0x1480 mm/page_alloc.c:3004
folios_put_refs+0x9ff/0xb40 mm/swap.c:1008
folio_batch_release include/linux/folio_batch.h:101 [inline]
shmem_undo_range+0x52c/0x1660 mm/shmem.c:1149
shmem_truncate_range mm/shmem.c:1277 [inline]
shmem_evict_inode+0x289/0xae0 mm/shmem.c:1407
evict+0x61e/0xb10 fs/inode.c:841
__dentry_kill+0x1a2/0x690 fs/dcache.c:718
finish_dput+0xc9/0x480 fs/dcache.c:927
__fput+0x691/0xa60 fs/file_table.c:518
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f970baa7407
RSP: 002b:00007ffc3e6440f0 EFLAGS: 00000202 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 00007f970c1fc880 RCX: 00007f970baa7407
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000008
RBP: 00007f970c1fc6e8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000002
R13: 000055b8b2717190 R14: 0000000000000008 R15: 000055b8b2726f10
</TASK>
rcu: rcu_preempt kthread timer wakeup didn't happen for 10493 jiffies! g58129 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402
rcu: Possible timer handling issue on cpu=0 timer-softirq=37630
rcu: rcu_preempt kthread starved for 10494 jiffies! g58129 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 ->cpu=0
rcu: Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior.
rcu: RCU grace-period kthread stack dump:
task:rcu_preempt state:I stack:28152 pid:16 tgid:16 ppid:2 task_flags:0x208040 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5388 [inline]
__schedule+0x17b4/0x5680 kernel/sched/core.c:7189
__schedule_loop kernel/sched/core.c:7268 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7283
schedule_timeout+0x158/0x2c0 kernel/time/sleep_timeout.c:99
rcu_gp_fqs_loop+0x312/0x11d0 kernel/rcu/tree.c:2095
rcu_gp_kthread+0x9e/0x2b0 kernel/rcu/tree.c:2297
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
rcu: Stack dump where RCU GP kthread last ran:
Sending NMI from CPU 1 to CPUs 0:
NMI backtrace for cpu 0
CPU: 0 UID: 0 PID: 10884 Comm: sed Tainted: G L syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
RIP: 0010:arch_irqs_disabled_flags arch/x86/include/asm/irqflags.h:146 [inline]
RIP: 0010:arch_irqs_disabled arch/x86/include/asm/irqflags.h:153 [inline]
RIP: 0010:lock_is_held_type+0xf3/0x150 kernel/locking/lockdep.c:5942
Code: 0f 94 c3 eb 05 bb 01 00 00 00 48 c7 c7 dd 89 21 8e e8 31 19 00 00 b8 ff ff ff ff 65 0f c1 05 74 fd 90 07 83 f8 01 75 25 9c 58 <a9> 00 02 00 00 75 39 41 f7 c4 00 02 00 00 74 01 fb 89 d8 5b 41 5c
RSP: 0018:ffffc90000007cd8 EFLAGS: 00000046
RAX: 0000000000000046 RBX: 0000000000000001 RCX: 0000000080010001
RDX: ffff88802e869ec0 RSI: ffffffff8e2189dd RDI: ffffffff8c28ac60
RBP: 00000000ffffffff R08: 0000000000000003 R09: 0000000000000004
R10: dffffc0000000000 R11: fffff52000000f90 R12: 0000000000000046
R13: ffff88802e869ec0 R14: ffff8880300572c0 R15: 0000000000000001
FS: 0000000000000000(0000) GS:ffff888125290000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9a8d4f5000 CR3: 000000008f57c000 CR4: 0000000000350ef0
Call Trace:
<IRQ>
lock_is_held include/linux/lockdep.h:249 [inline]
advance_sched+0x1c6/0xc20 net/sched/sch_taprio.c:935
__run_hrtimer kernel/time/hrtimer.c:1930 [inline]
__hrtimer_run_queues+0x3c0/0xa20 kernel/time/hrtimer.c:1994
hrtimer_interrupt+0x44b/0x950 kernel/time/hrtimer.c:2113
local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1050 [inline]
__sysvec_apic_timer_interrupt+0x102/0x430 arch/x86/kernel/apic/apic.c:1067
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1061 [inline]
sysvec_apic_timer_interrupt+0xa1/0xc0 arch/x86/kernel/apic/apic.c:1061
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0010:get_current arch/x86/include/asm/current.h:25 [inline]
RIP: 0010:__sanitizer_cov_trace_pc+0x8/0x70 kernel/kcov.c:216
Code: 8b 3d d4 93 60 0c 48 89 de 5b e9 b3 ea 5f 00 cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 48 8b 04 24 <65> 48 8b 0d b8 43 73 11 65 8b 15 d9 43 73 11 81 e2 00 01 ff 00 74
RSP: 0018:ffffc90004f7f2c0 EFLAGS: 00000246
RAX: ffffffff82215e74 RBX: ffffc90004f7f3a0 RCX: 0000000000000000
RDX: ffff88802e869ec0 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffff88802e869ec0 R09: 0000000000000006
R10: 0000000000000007 R11: 0000000000000000 R12: ffff88803367cc40
R13: 1ffff920009efe74 R14: ffff888020b4cc80 R15: ffff888020b4ccd8
unlink_file_vma_batch_add+0xe4/0x1e0 mm/vma.c:1816
free_pgtables+0x67e/0xb70 mm/memory.c:404
unmap_region+0x29d/0x330 mm/vma.c:490
vms_clear_ptes mm/vma.c:1303 [inline]
vms_clean_up_area mm/vma.c:1315 [inline]
__mmap_setup mm/vma.c:2476 [inline]
__mmap_region mm/vma.c:2753 [inline]
mmap_region+0xc9a/0x22a0 mm/vma.c:2857
do_mmap+0xc39/0x10c0 mm/mmap.c:560
vm_mmap_pgoff+0x2c9/0x4f0 mm/util.c:581
ksys_mmap_pgoff+0x51e/0x760 mm/mmap.c:606
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5c87279242
Code: 08 00 04 00 00 eb e2 90 41 f7 c1 ff 0f 00 00 75 27 55 89 cd 53 48 89 fb 48 85 ff 74 33 41 89 ea 48 89 df b8 09 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 5e 5b 5d c3 0f 1f 00 c7 05 46 40 01 00 16 00
RSP: 002b:00007ffc3ed9d5a8 EFLAGS: 00000206 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f5c86f98000 RCX: 00007f5c87279242
RDX: 0000000000000003 RSI: 0000000000002000 RDI: 00007f5c86f98000
RBP: 0000000000000812 R08: 0000000000000003 R09: 0000000000004000
R10: 0000000000000812 R11: 0000000000000206 R12: 00007ffc3ed9d668
R13: 00007f5c8724e050 R14: 00007ffc3ed9d9e0 R15: 00000fff87db3ab8
</TASK>
Reply: Based on the analysis of the bug report and the kernel source code, here is the assessment of the vulnerability:
### Root Cause Analysis
The bug is an infinite loop / CPU stall in the `advance_sched` hrtimer callback of the `sch_taprio` network scheduler.
When configuring the `taprio` qdisc, the kernel validates the `interval` of schedule entries to ensure it is large enough to transmit a minimum-sized Ethernet frame (`ETH_ZLEN`). This minimum duration is calculated based on the network device's link speed (`picos_per_byte`).
For devices with very high link speedsβsuch as `veth` (which defaults to 10000 Mbps) or `tun` (which can be configured to arbitrary speeds up to `0x7fffffff` via ethtool)βthe calculated `min_duration` can be extremely small, down to just `1 ns` (or `48 ns` for `veth`).
If a user configures the `taprio` qdisc with such a small `interval`, the `advance_sched` timer callback will increment the timer's next expiration time by only `1 ns` (or `48 ns`) and return `HRTIMER_RESTART`. Because the execution time of the `advance_sched` function and the hrtimer subsystem overhead is significantly larger than this tiny interval, the timer's expiration time will never catch up to the current time (`basenow`).
This causes the hrtimer subsystem to repeatedly execute the timer callback in an infinite loop (or an exponentially growing loop) in hardirq context, completely starving the CPU. This leads to the observed RCU stall, soft lockup, and a complete system freeze.
### Security Impact
* **Exploitable:** **No.** The bug is a pure logic error leading to an infinite loop in interrupt context. It does not cause memory corruption, out-of-bounds accesses, or use-after-free conditions. Therefore, it cannot be exploited for arbitrary code execution or privilege escalation.
* **Denial Of Service:** **Yes.** Triggering the bug causes the CPU to be permanently stuck in an interrupt context loop, leading to an RCU stall, soft lockups, and a system crash/freeze.
* **Accessible From Unprivileged Processes:** **No.** Configuring network schedulers (qdiscs) requires `CAP_NET_ADMIN` capabilities, which a standard unprivileged user does not have in the initial network namespace.
* **Accessible From User Namespaces:** **Yes.** An unprivileged user can create a new user namespace and a new network namespace, gaining `CAP_NET_ADMIN` within that namespace. They can then create a `veth` or `tun` device and attach the malicious `taprio` qdisc configuration to it, successfully triggering the Denial of Service on the host.
* **VM Guest Trigger:** **No.** This is a network scheduler bug, not related to virtualization or KVM guest exits.
* **VM Host Trigger in The Confidential Computing Context:** **No.**
* **Ethernet Network Trigger:** **No.** The bug is triggered synchronously during the configuration of the qdisc and the subsequent timer execution, not by processing ingress network traffic.
* **Other Remote Trigger:** **No.**
* **Peripheral Trigger:** **No.**
* **Malicious Filesystem Trigger:** **No.**
|
| 6/2 |
2026/05/24 10:25 |
llm |
expert |
0m
Model:
Tokens:
input: 10137
output: 42
thoughts: 372
Thoughts: **RCU Stall Investigation**
Okay, here's what I'm seeing. We've got an RCU stall report, and it's flagged on CPU 0. Immediately, I'm checking the stack trace on CPU 0 β it's crucial to understand where this is happening. The trace shows we're inside an interrupt (`<IRQ>`), which adds a layer of complexity. From the stack, it looks like we're in `advance_sched` within `net/sched/sch_taprio.c`. Specifically, the code path shows that we are inside `net/sched/sch_taprio.c`, line 935. We also see that we are inside `lock_is_held` which means that a lock is being held. Given that we are inside an interrupt, and the stack contains hrtimer calls, I'm already starting to suspect timer-related contention or a potential lock-ordering issue within the TAPRIO scheduler. My next step is obviously to dive into the `advance_sched` function in `net/sched/sch_taprio.c` and figure out what locks it's dealing with and how it interacts with the hrtimer infrastructure. Let's see what's going on in that code.
|
| 7/2 |
2026/05/24 10:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:advance_sched]
Results: map[SourceCode: 918: static enum hrtimer_restart advance_sched(struct hrtimer *timer)
919: {
920: struct taprio_sched *q = container_of(timer, struct taprio_sched,
921: advance_timer);
922: struct net_device *dev = qdisc_dev(q->root);
923: struct sched_gate_list *oper, *admin;
924: int num_tc = netdev_get_num_tc(dev);
925: struct sched_entry *entry, *next;
926: struct Qdisc *sch = q->root;
927: ktime_t end_time;
928: int tc;
929:
930: spin_lock(&q->current_entry_lock);
931: entry = rcu_dereference_protected(q->current_entry,
932: lockdep_is_held(&q->current_entry_lock));
933: oper = rcu_dereference_protected(q->oper_sched,
934: lockdep_is_held(&q->current_entry_lock));
935: admin = rcu_dereference_protected(q->admin_sched,
936: lockdep_is_held(&q->current_entry_lock));
937:
938: if (!oper)
939: switch_schedules(q, &admin, &oper);
940:
941: /* This can happen in two cases: 1. this is the very first run
942: * of this function (i.e. we weren't running any schedule
943: * previously); 2. The previous schedule just ended. The first
944: * entry of all schedules are pre-calculated during the
945: * schedule initialization.
946: */
947: if (unlikely(!entry || entry->end_time == oper->base_time)) {
948: next = list_first_entry(&oper->entries, struct sched_entry,
949: list);
950: end_time = next->end_time;
951: goto first_run;
952: }
953:
954: if (should_restart_cycle(oper, entry)) {
955: next = list_first_entry(&oper->entries, struct sched_entry,
956: list);
957: oper->cycle_end_time = ktime_add_ns(oper->cycle_end_time,
958: oper->cycle_time);
959: } else {
960: next = list_next_entry(entry, list);
961: }
962:
963: end_time = ktime_add_ns(entry->end_time, next->interval);
964: end_time = min_t(ktime_t, end_time, oper->cycle_end_time);
965:
966: for (tc = 0; tc < num_tc; tc++) {
967: if (next->gate_duration[tc] == oper->cycle_time)
968: next->gate_close_time[tc] = KTIME_MAX;
969: else
970: next->gate_close_time[tc] = ktime_add_ns(entry->end_time,
971: next->gate_duration[tc]);
972: }
973:
974: if (should_change_schedules(admin, oper, end_time)) {
975: switch_schedules(q, &admin, &oper);
976: /* After changing schedules, the next entry is the first one
977: * in the new schedule, with a pre-calculated end_time.
978: */
979: next = list_first_entry(&oper->entries, struct sched_entry, list);
980: end_time = next->end_time;
981: }
982:
983: next->end_time = end_time;
984: taprio_set_budgets(q, oper, next);
985:
986: first_run:
987: rcu_assign_pointer(q->current_entry, next);
988: spin_unlock(&q->current_entry_lock);
989:
990: hrtimer_set_expires(&q->advance_timer, end_time);
991:
992: rcu_read_lock();
993: __netif_schedule(sch);
994: rcu_read_unlock();
995:
996: return HRTIMER_RESTART;
997: }
SourceFile:net/sched/sch_taprio.c]
|
| 8/2 |
2026/05/24 10:25 |
llm |
expert |
0m
Model:
Tokens:
input: 12171
output: 45
thoughts: 193
Thoughts: **RCU Stall Investigation**
Okay, here's the situation. The CPU seems to be hung up in `advance_sched`. Right, that rings a bell β it's an RCU stall. That means this CPU has been either in an RCU read-side critical section or, more likely, with interrupts disabled for an extended period. I need to figure out why.
`advance_sched` is a timer callback, which means itβs running in either hardirq or softirq context. Given that the stack trace points to `hrtimer_interrupt`, I'm dealing with a hardirq context. But, if it's an RCU stall *and* the stack trace is stuck in `advance_sched`, my initial instinct is that `advance_sched` is looping. But, no, it's not. I've been down this road before. `advance_sched` doesn't contain an explicit loop.
Wait a second⦠`advance_sched` *returns* `HRTIMER_RESTART`! If the timer immediately expires again, then `__hrtimer_run_queues` will fire it right back up, creating an *implicit* loop! I've seen that behavior before. Right, I need to verify that `__hrtimer_run_queues` is behaving as I expect it to. Let's dig into that function.
|
| 9/2 |
2026/05/24 10:25 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:__hrtimer_run_queues]
Results: map[SourceCode:1968: static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now,
1969: unsigned long flags, unsigned int active_mask)
1970: {
1971: unsigned int active = cpu_base->active_bases & active_mask;
1972: struct hrtimer_clock_base *base;
1973:
1974: for_each_active_base(base, cpu_base, active) {
1975: ktime_t basenow = ktime_add(now, base->offset);
1976: struct hrtimer *timer;
1977:
1978: while ((timer = clock_base_next_timer(base))) {
1979: /*
1980: * The immediate goal for using the softexpires is
1981: * minimizing wakeups, not running timers at the
1982: * earliest interrupt after their soft expiration.
1983: * This allows us to avoid using a Priority Search
1984: * Tree, which can answer a stabbing query for
1985: * overlapping intervals and instead use the simple
1986: * BST we already have.
1987: * We don't add extra wakeups by delaying timers that
1988: * are right-of a not yet expired timer, because that
1989: * timer will have to trigger a wakeup anyway.
1990: */
1991: if (basenow < hrtimer_get_softexpires(timer))
1992: break;
1993:
1994: __run_hrtimer(cpu_base, base, timer, basenow, flags);
1995: if (active_mask == HRTIMER_ACTIVE_SOFT)
1996: hrtimer_sync_wait_running(cpu_base, flags);
1997: }
1998: }
1999: }
SourceFile:kernel/time/hrtimer.c]
|
| 10/2 |
2026/05/24 10:25 |
llm |
expert |
0m
Model:
Tokens:
input: 13256
output: 42
thoughts: 91
Thoughts: Okay, let's break this down.
**Analyzing Potential Infinite Loop in Kernel Timers**
Right, so I'm looking at this timer logic, specifically how `advance_sched` interacts with the high-resolution timer system. The core concern here is what happens if `advance_sched` sets the next expiration time to a point that's either in the past or practically the present. My immediate thought is, "Will this cause an infinite loop in the kernel?" Specifically, if the expiration time is essentially 'now' or before, will the `__run_hrtimer` function just keep getting called and returning `HRTIMER_RESTART`? If so, `__hrtimer_run_queues` would get stuck in a tight loop. The documentation does say that `__run_hrtimer` re-enqueues the timer when it returns `HRTIMER_RESTART`, which really seems like the key to understand if an infinite loop can occur. I'd better double-check the implementation of `__run_hrtimer` to confirm how it handles these edge cases.
|
| 11/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:__run_hrtimer]
Results: map[SourceCode:1871: /*
1872: * The write_seqcount_barrier()s in __run_hrtimer() split the thing into 3
1873: * distinct sections:
1874: *
1875: * - queued: the timer is queued
1876: * - callback: the timer is being ran
1877: * - post: the timer is inactive or (re)queued
1878: *
1879: * On the read side we ensure we observe timer->is_queued and cpu_base->running
1880: * from the same section, if anything changed while we looked at it, we retry.
1881: * This includes timer->base changing because sequence numbers alone are
1882: * insufficient for that.
1883: *
1884: * The sequence numbers are required because otherwise we could still observe
1885: * a false negative if the read side got smeared over multiple consecutive
1886: * __run_hrtimer() invocations.
1887: */
1888: static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, struct hrtimer_clock_base *base,
1889: struct hrtimer *timer, ktime_t now, unsigned long flags)
1890: __must_hold(&cpu_base->lock)
1891: {
1892: enum hrtimer_restart (*fn)(struct hrtimer *);
1893: bool expires_in_hardirq;
1894: int restart;
1895:
1896: lockdep_assert_held(&cpu_base->lock);
1897:
1898: debug_hrtimer_deactivate(timer);
1899: base->running = timer;
1900:
1901: /*
1902: * Separate the ->running assignment from the ->is_queued assignment.
1903: *
1904: * As with a regular write barrier, this ensures the read side in
1905: * hrtimer_active() cannot observe base->running == NULL &&
1906: * timer->is_queued == INACTIVE.
1907: */
1908: raw_write_seqcount_barrier(&base->seq);
1909:
1910: __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, false);
1911: fn = ACCESS_PRIVATE(timer, function);
1912:
1913: /*
1914: * Clear the 'is relative' flag for the TIME_LOW_RES case. If the
1915: * timer is restarted with a period then it becomes an absolute
1916: * timer. If its not restarted it does not matter.
1917: */
1918: if (IS_ENABLED(CONFIG_TIME_LOW_RES))
1919: timer->is_rel = false;
1920:
1921: /*
1922: * The timer is marked as running in the CPU base, so it is
1923: * protected against migration to a different CPU even if the lock
1924: * is dropped.
1925: */
1926: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1927: trace_hrtimer_expire_entry(timer, now);
1928: expires_in_hardirq = lockdep_hrtimer_enter(timer);
1929:
1930: restart = fn(timer);
1931:
1932: lockdep_hrtimer_exit(expires_in_hardirq);
1933: trace_hrtimer_expire_exit(timer);
1934: raw_spin_lock_irq(&cpu_base->lock);
1935:
1936: /*
1937: * Note: We clear the running state after enqueue_hrtimer and
1938: * we do not reprogram the event hardware. Happens either in
1939: * hrtimer_start_range_ns() or in hrtimer_interrupt()
1940: *
1941: * Note: Because we dropped the cpu_base->lock above,
1942: * hrtimer_start_range_ns() can have popped in and enqueued the timer
1943: * for us already.
1944: */
1945: if (restart == HRTIMER_RESTART && !timer->is_queued)
1946: enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS, false);
1947:
1948: /*
1949: * Separate the ->running assignment from the ->is_queued assignment.
1950: *
1951: * As with a regular write barrier, this ensures the read side in
1952: * hrtimer_active() cannot observe base->running.timer == NULL &&
1953: * timer->is_queued == INACTIVE.
1954: */
1955: raw_write_seqcount_barrier(&base->seq);
1956:
1957: WARN_ON_ONCE(base->running != timer);
1958: base->running = NULL;
1959: }
SourceFile:kernel/time/hrtimer.c]
|
| 12/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 15055
output: 42
thoughts: 471
Thoughts: **Infinite Loop Vulnerability in HRTimer Scheduler**
Okay, so I'm digging into this HRTimer code, and something's not quite right. If `advance_sched` returns `HRTIMER_RESTART`, `__run_hrtimer` re-enqueues the timer, which makes sense. Then `__hrtimer_run_queues` loops through the timers:
```c
while ((timer = clock_base_next_timer(base))) {
if (basenow < hrtimer_get_softexpires(timer))
break;
__run_hrtimer(cpu_base, base, timer, basenow, flags);
```
The issue I see is that if `advance_sched` sets the *next* expiration time to be less than or equal to `basenow`, then `__hrtimer_run_queues` will immediately run it again, right? But... wait a minute, `basenow` isn't updated *inside* the loop! It's calculated once at the beginning: `ktime_t basenow = ktime_add(now, base->offset);` which is outside the `while` loop!
So, if `advance_sched` sets that *next* expiration time to something less than or equal to the initial `basenow`, we've got an infinite loop! We just keep re-running the same timer!
Okay, let's look closer at `advance_sched`...
```c
if (should_restart_cycle(oper, entry)) {
next = list_first_entry(&oper->entries, struct sched_entry,
list);
oper->cycle_end_time = ktime_add_ns(oper->cycle_end_time,
oper->cycle_time);
} else {
next = list_next_entry(entry, list);
}
end_time = ktime_add_ns(entry->end_time, next->interval);
end_time = min_t(ktime_t, end_time, oper->cycle_end_time);
```
Aha! Now I see it. If `next->interval` is zero, `end_time` will simply be `entry->end_time`. And *if* `entry->end_time` is less than or equal to `basenow`, boom: the timer fires immediately, and we're back to that infinite loop. We're re-running it, and re-running it...
Now I'm just curious about that `next->interval`. It's a `u64` or `u32`? Let's check `struct sched_entry` and see what's what. This feels like a classic, hard-to-find bug.
|
| 13/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:sched_entry]
Results: map[SourceCode: 52: struct sched_entry {
53: /* Durations between this GCL entry and the GCL entry where the
54: * respective traffic class gate closes
55: */
56: u64 gate_duration[TC_MAX_QUEUE];
57: atomic_t budget[TC_MAX_QUEUE];
58: /* The qdisc makes some effort so that no packet leaves
59: * after this time
60: */
61: ktime_t gate_close_time[TC_MAX_QUEUE];
62: struct list_head list;
63: /* Used to calculate when to advance the schedule */
64: ktime_t end_time;
65: ktime_t next_txtime;
66: int index;
67: u32 gate_mask;
68: u32 interval;
69: u8 command;
70: };
SourceFile:net/sched/sch_taprio.c]
|
| 14/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 16471
output: 56
thoughts: 30
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this field:
**Analyzing a Potential Zero-Value Interval**
Alright, so `interval` is defined as a `u32`. My immediate concern is whether or not that `u32` can be zero. That's a critical question because a zero interval could lead to all sorts of unexpected behavior, particularly in time-based calculations or iterative processes. It's often a source of bugs, so it warrants immediate investigation. Therefore, I need to understand the constraints and potential origins of this variable, `interval`. Time to trace where this `interval` variable is set; only then can I understand if zero is a valid value, or if some guard clause exists. This is fundamental for robust code.
|
| 15/2 |
2026/05/24 10:26 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeSnippetLines:5 Name:sched_entry::interval SourceTreePrefix:net/sched/]
Results: map[References:[map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:advance_sched SourceFile:net/sched/sch_taprio.c SourceLine:963 SourceSnippet: 958: oper->cycle_time);
959: } else {
960: next = list_next_entry(entry, list);
961: }
962:
963: end_time = ktime_add_ns(entry->end_time, next->interval);
964: end_time = min_t(ktime_t, end_time, oper->cycle_end_time);
965:
966: for (tc = 0; tc < num_tc; tc++) {
967: if (next->gate_duration[tc] == oper->cycle_time)
968: next->gate_close_time[tc] = KTIME_MAX;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:dump_entry SourceFile:net/sched/sch_taprio.c SourceLine:2239 SourceSnippet:2234: if (nla_put_u32(msg, TCA_TAPRIO_SCHED_ENTRY_GATE_MASK,
2235: entry->gate_mask))
2236: goto nla_put_failure;
2237:
2238: if (nla_put_u32(msg, TCA_TAPRIO_SCHED_ENTRY_INTERVAL,
2239: entry->interval))
2240: goto nla_put_failure;
2241:
2242: return nla_nest_end(msg, item);
2243:
2244: nla_put_failure:
] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:fill_sched_entry SourceFile:net/sched/sch_taprio.c SourceLine:1064 SourceSnippet:1059: if (interval < min_duration) {
1060: NL_SET_ERR_MSG(extack, "Invalid interval for schedule entry");
1061: return -EINVAL;
1062: }
1063:
1064: entry->interval = interval;
1065:
1066: return 0;
1067: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:find_entry_to_transmit SourceFile:net/sched/sch_taprio.c SourceLine:364 SourceSnippet: 359:
360: if (ktime_after(curr_intv_start, cycle_end))
361: break;
362:
363: if (!(entry->gate_mask & BIT(tc)) ||
364: packet_transmit_time > entry->interval)
365: continue;
366:
367: txtime = entry->next_txtime;
368:
369: if (ktime_before(txtime, time) || validate_interval) {
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:get_interval_end_time SourceFile:net/sched/sch_taprio.c SourceLine:244 SourceSnippet: 239: {
240: s32 cycle_elapsed = get_cycle_time_elapsed(sched, intv_start);
241: ktime_t intv_end, cycle_ext_end, cycle_end;
242:
243: cycle_end = ktime_add_ns(intv_start, sched->cycle_time - cycle_elapsed);
244: intv_end = ktime_add_ns(intv_start, entry->interval);
245: cycle_ext_end = ktime_add(cycle_end, sched->cycle_time_extension);
246:
247: if (ktime_before(intv_end, cycle_end))
248: return intv_end;
249: else if (admin && admin != sched &&
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:parse_taprio_schedule SourceFile:net/sched/sch_taprio.c SourceLine:1159 SourceSnippet:1154: if (!new->cycle_time) {
1155: struct sched_entry *entry;
1156: ktime_t cycle = 0;
1157:
1158: list_for_each_entry(entry, &new->entries, list)
1159: cycle = ktime_add_ns(cycle, entry->interval);
1160:
1161: if (cycle < 0 || cycle > INT_MAX) {
1162: NL_SET_ERR_MSG(extack, "'cycle_time' is too big");
1163: return -EINVAL;
1164: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:setup_first_end_time SourceFile:net/sched/sch_taprio.c SourceLine:1258 SourceSnippet:1253: cycle = sched->cycle_time;
1254:
1255: /* FIXME: find a better place to do this */
1256: sched->cycle_end_time = ktime_add_ns(base, cycle);
1257:
1258: first->end_time = ktime_add_ns(base, first->interval);
1259: taprio_set_budgets(q, sched, first);
1260:
1261: for (tc = 0; tc < num_tc; tc++) {
1262: if (first->gate_duration[tc] == sched->cycle_time)
1263: first->gate_close_time[tc] = KTIME_MAX;
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:setup_txtime SourceFile:net/sched/sch_taprio.c SourceLine:1372 SourceSnippet:1367: struct sched_entry *entry;
1368: u64 interval = 0;
1369:
1370: list_for_each_entry(entry, &sched->entries, list) {
1371: entry->next_txtime = ktime_add_ns(base, interval);
1372: interval += entry->interval;
1373: }
1374: }
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:taprio_calculate_gate_durations SourceFile:net/sched/sch_taprio.c SourceLine:145 SourceSnippet: 140: for (tc = 0; tc < num_tc; tc++) {
141: if (!(gates_still_open & BIT(tc)))
142: continue;
143:
144: if (cur->gate_mask & BIT(tc))
145: entry->gate_duration[tc] += cur->interval;
146: else
147: gates_still_open &= ~BIT(tc);
148: }
149:
150: cur = list_next_entry_circular(cur, &sched->entries, list);
] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:taprio_sched_to_offload SourceFile:net/sched/sch_taprio.c SourceLine:1474 SourceSnippet:1469:
1470: list_for_each_entry(entry, &sched->entries, list) {
1471: struct tc_taprio_sched_entry *e = &offload->entries[i];
1472:
1473: e->command = entry->command;
1474: e->interval = entry->interval;
1475: if (caps->gate_mask_per_txq)
1476: e->gate_mask = tc_map_to_queue_mask(dev,
1477: entry->gate_mask);
1478: else
1479: e->gate_mask = entry->gate_mask;
]] TruncatedOutput:false]
|
| 16/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 19018
output: 44
thoughts: 84
Thoughts: **Analyzing Schedule Entry Validation**
Okay, so I'm looking at this `fill_sched_entry` function, specifically this section where it's checking the `interval` against `min_duration`. It seems straightforward enough: if the proposed `interval` is shorter than the allowed `min_duration`, we kick back an error. Makes sense β prevent someone from setting an incredibly short, probably pointless or disruptive, schedule entry. But I need to understand what `min_duration` actually represents in the broader context of the scheduler. What are the constraints, and why this minimum duration? I need to know how `min_duration` is defined, what that constant represents and where it's derived. I'm going to track that down now to fully grasp the potential implications of this validation step and the types of schedules it's intended to support or prevent.
|
| 17/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:fill_sched_entry]
Results: map[SourceCode:1037: static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb,
1038: struct sched_entry *entry,
1039: struct netlink_ext_ack *extack)
1040: {
1041: int min_duration = length_to_duration(q, ETH_ZLEN);
1042: u32 interval = 0;
1043:
1044: if (tb[TCA_TAPRIO_SCHED_ENTRY_CMD])
1045: entry->command = nla_get_u8(
1046: tb[TCA_TAPRIO_SCHED_ENTRY_CMD]);
1047:
1048: if (tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK])
1049: entry->gate_mask = nla_get_u32(
1050: tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK]);
1051:
1052: if (tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL])
1053: interval = nla_get_u32(
1054: tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL]);
1055:
1056: /* The interval should allow at least the minimum ethernet
1057: * frame to go out.
1058: */
1059: if (interval < min_duration) {
1060: NL_SET_ERR_MSG(extack, "Invalid interval for schedule entry");
1061: return -EINVAL;
1062: }
1063:
1064: entry->interval = interval;
1065:
1066: return 0;
1067: }
SourceFile:net/sched/sch_taprio.c]
|
| 18/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 19843
output: 44
thoughts: 31
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Diving into Duration Calculations**
Right, let's see, we're calculating `min_duration` here. The context implies it's related to some queuing process (`q`), and we're dealing with Ethernet frames (`ETH_ZLEN` suggests an Ethernet zero-length frame, or something close). So, it's pretty clear we're figuring out the minimum time required for something, likely related to transmission or processing. Now, the key is this `length_to_duration` function. I need to refresh my memory on what that does, specifically in this context. It's crucial because *that* function is where the details of the underlying physical layer, timing constraints, and perhaps even protocol overhead are handled. That's the engine that's turning a frame length into a real-world duration. Let me quickly verify what `length_to_duration` does. Depending on how it's defined in this library, it's either doing the conversion or a call to another function which does. I'll need to know.
|
| 19/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:length_to_duration]
Results: map[SourceCode: 257: static int length_to_duration(struct taprio_sched *q, int len)
258: {
259: return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC);
260: }
SourceFile:net/sched/sch_taprio.c]
|
| 20/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 20273
output: 62
thoughts: 84
Thoughts: **Analyzing a Potential Infinite Loop**
Okay, so I'm digging into this code, and I see a potential problem. If the value of `q->picos_per_byte` is zero, the `length_to_duration` function is going to spit back a zero value. That's a red flag. This means `min_duration` will be zero, and consequently, the `interval` will also be zero. And here's where it gets hairy: if `interval` is zero, the `advance_sched` function is going to get stuck in an infinite loop! I need to trace back and figure out how `q->picos_per_byte` is being set. This is the critical piece of information that will determine if this code is going to choke up. Time to investigate where this value is initialized.
|
| 21/2 |
2026/05/24 10:26 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeSnippetLines:5 Name:taprio_sched::picos_per_byte SourceTreePrefix:net/sched/]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:duration_to_length SourceFile:net/sched/sch_taprio.c SourceLine:264 SourceSnippet: 262: static int duration_to_length(struct taprio_sched *q, u64 duration)
263: {
264: return div_u64(duration * PSEC_PER_NSEC, atomic64_read(&q->picos_per_byte));
265: }
] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:length_to_duration SourceFile:net/sched/sch_taprio.c SourceLine:259 SourceSnippet: 257: static int length_to_duration(struct taprio_sched *q, int len)
258: {
259: return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC);
260: }
] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:taprio_set_budgets SourceFile:net/sched/sch_taprio.c SourceLine:676 SourceSnippet: 671: /* Traffic classes which never close have infinite budget */
672: if (entry->gate_duration[tc] == sched->cycle_time)
673: budget = INT_MAX;
674: else
675: budget = div64_u64((u64)entry->gate_duration[tc] * PSEC_PER_NSEC,
676: atomic64_read(&q->picos_per_byte));
677:
678: atomic_set(&entry->budget[tc], budget);
679: }
680: }
] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:taprio_set_picos_per_byte SourceFile:net/sched/sch_taprio.c SourceLine:1321 SourceSnippet:1316: "Link speed %d is too high. Schedule may be inaccurate.",
1317: speed);
1318: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
1319: }
1320:
1321: atomic64_set(&q->picos_per_byte, picos_per_byte);
1322: netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
1323: dev->name, (long long)atomic64_read(&q->picos_per_byte),
1324: ecmd.base.speed);
1325: }
] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:taprio_set_picos_per_byte SourceFile:net/sched/sch_taprio.c SourceLine:1322 SourceSnippet:1317: speed);
1318: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
1319: }
1320:
1321: atomic64_set(&q->picos_per_byte, picos_per_byte);
1322: netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
1323: dev->name, (long long)atomic64_read(&q->picos_per_byte),
1324: ecmd.base.speed);
1325: }
]] TruncatedOutput:false]
|
| 22/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 21644
output: 50
thoughts: 17
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Digging into `taprio_set_picos_per_byte`**
Right, let's circle back to `taprio_set_picos_per_byte`. I need to re-examine that function and what it's doing. This likely affects the core timing calculations within TAPRIO. My goal is to understand how we're translating our byte-level data into precise time units, down at the picosecond level. I need to make sure this is accurate, efficient, and that it's handling edge cases correctly, especially considering the different hardware targets we're supporting. Is it performing as expected? Are there any potential overflow issues lurking? What's the error bound on those conversions? I should look for the places where this function is called. Are there any inconsistencies I should be concerned about? Perhaps I should see if there are better ways of achieving the same, or even better, results. I need to refresh myself on the math, the implementation, and any potential optimizations that could be made. It's a critical piece of the puzzle, and a thorough check is in order.
|
| 23/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_set_picos_per_byte]
Results: map[SourceCode:1293: static void taprio_set_picos_per_byte(struct net_device *dev,
1294: struct taprio_sched *q,
1295: struct netlink_ext_ack *extack)
1296: {
1297: struct ethtool_link_ksettings ecmd;
1298: int speed = SPEED_10;
1299: int picos_per_byte;
1300: int err;
1301:
1302: err = __ethtool_get_link_ksettings(dev, &ecmd);
1303: if (err < 0)
1304: goto skip;
1305:
1306: if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN)
1307: speed = ecmd.base.speed;
1308:
1309: skip:
1310: picos_per_byte = (USEC_PER_SEC * 8) / speed;
1311: if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
1312: if (!extack)
1313: pr_warn("Link speed %d is too high. Schedule may be inaccurate.\n",
1314: speed);
1315: NL_SET_ERR_MSG_FMT_MOD(extack,
1316: "Link speed %d is too high. Schedule may be inaccurate.",
1317: speed);
1318: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
1319: }
1320:
1321: atomic64_set(&q->picos_per_byte, picos_per_byte);
1322: netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
1323: dev->name, (long long)atomic64_read(&q->picos_per_byte),
1324: ecmd.base.speed);
1325: }
SourceFile:net/sched/sch_taprio.c]
|
| 24/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 22580
output: 50
thoughts: 168
Thoughts: **Analyzing the Byte Timing Calculation**
Okay, let's break this down. My initial thought is about how we're calculating `picos_per_byte`. It looks like we're multiplying the number of microseconds per second, which is `1000000`, by 8 to get a base rate, and then dividing that by the data transfer `speed`. So, `(1000000 * 8) / speed`. Multiplying those constants gives us `8000000`. That's straightforward enough: the time it takes to transmit 8 bits (a byte) given the base microseconds.
However, a potential issue jumps out immediately. If `speed` gets incredibly high, this calculation could result in `picos_per_byte` becoming zero. Obviously that's a problem, we can't have a zero time, so I knew there'd be some kind of check.
Ah, there it is! There's a conditional check:
```c
if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
}
```
Okay, so if the calculated `picos_per_byte` is less than `TAPRIO_PICOS_PER_BYTE_MIN`, then `picos_per_byte` is set to that minimum value. That effectively puts a lower bound on the result. Seems good, we are going to avoid zero.
Now, what is `TAPRIO_PICOS_PER_BYTE_MIN`? That's the next critical question. Is this a system-defined constant? Hardcoded? Is it configurable? The meaning of this constant dictates the effective lower bound of the transmission time, and so how much faster it is actually able to run. I'll need to know what it is to understand the implications fully.
|
| 25/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:TAPRIO_PICOS_PER_BYTE_MIN]
Results: map[SourceCode: SourceFile:]
|
| 26/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 23237
output: 25
thoughts: 18
Thoughts: Here's my thought process, as it just happened:
**Diving into the Codebase**
Okay, so I need to find something, and the name "TAPRIO\_PICOS\_PER\_BYTE\_MIN" just popped into my head. It's probably a constant, defined somewhere in the code. My instinct is to use `grep`. It's quick, dirty, and usually gets the job done. I could use something more sophisticated like `ack` or `ripgrep`, but `grep` is readily available on pretty much any system and I just want to find a definition, so let's start with that. Hopefully, the naming convention is consistent and the variable is defined with a straightforward assignment. Time to get searching!
|
| 27/2 |
2026/05/24 10:26 |
tool |
grepper |
0m
Args: map[Expression:TAPRIO_PICOS_PER_BYTE_MIN]
Results: map[Output:net/sched/sch_taprio.c=37=static struct static_key_false taprio_have_working_mqprio;
--
net/sched/sch_taprio.c-49- */
net/sched/sch_taprio.c:50:#define TAPRIO_PICOS_PER_BYTE_MIN 17
net/sched/sch_taprio.c-51-
--
net/sched/sch_taprio.c=1293=static void taprio_set_picos_per_byte(struct net_device *dev,
--
net/sched/sch_taprio.c-1310- picos_per_byte = (USEC_PER_SEC * 8) / speed;
net/sched/sch_taprio.c:1311: if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
net/sched/sch_taprio.c-1312- if (!extack)
--
net/sched/sch_taprio.c-1317- speed);
net/sched/sch_taprio.c:1318: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
net/sched/sch_taprio.c-1319- }
]
|
| 28/2 |
2026/05/24 10:26 |
llm |
expert |
0m
Model:
Tokens:
input: 23767
output: 45
thoughts: 438
Thoughts: **Analyzing a Potential RCU Stall in Network Scheduling**
Okay, so I'm looking at this scheduling code and I see a potential problem. I'm focusing on how the minimum duration is calculated and how it interacts with the timer logic. Initially, I'm noting that `picos_per_byte` has a minimum value of 17. Following the calculation for `length_to_duration`, which involves `ETH_ZLEN` (which is 60), the product of the length (60 bytes in this case) and the minimum `picos_per_byte` (17) is at least 1020. Since `PSEC_PER_NSEC` is 1000, that 1020 ps value ends up translating to a minimum duration of 1 ns.
Now here's where it gets interesting: If the `min_duration` can be 1, that means the `interval` could also be 1. If the interval is just 1 ns, and `advance_sched` is called to increment the end time, it will increment `entry->end_time` by just one nanosecond. This is where I start getting worried.
In `advance_sched`, the `end_time` is updated by adding `next->interval`. If `next->interval` is just 1 ns, the `end_time` effectively increments by 1 ns each time. If `end_time` is less than or equal to `basenow`, which represents the time the timer queue started processing, the code will loop in `__hrtimer_run_queues`. This makes me think it will take an absurd amount of time to advance the timer.
The problem is that if `advance_sched` increments the `end_time` by just 1 ns each time, it would take a billion iterations to advance just one second. That's a huge potential for an RCU stall! We're talking about an insane amount of looping.
I need to confirm this. I need to make sure I'm following the logic correctly in `__hrtimer_run_queues` to double-check that `basenow` isn't changing during the `while` loop (or, if it is changing, it still poses a problem). If `advance_sched` returns `HRTIMER_RESTART` with only a tiny increment of the `end_time` by one ns, `__hrtimer_run_queues` will see that `basenow` is greater than or equal to `end_time`, and we'll loop again. I need to revisit the `__hrtimer_run_queues` function. This requires further investigation to ensure my conclusions are solid.
|
| 29/2 |
2026/05/24 10:26 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:__hrtimer_run_queues]
Results: map[SourceCode:1968: static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now,
1969: unsigned long flags, unsigned int active_mask)
1970: {
1971: unsigned int active = cpu_base->active_bases & active_mask;
1972: struct hrtimer_clock_base *base;
1973:
1974: for_each_active_base(base, cpu_base, active) {
1975: ktime_t basenow = ktime_add(now, base->offset);
1976: struct hrtimer *timer;
1977:
1978: while ((timer = clock_base_next_timer(base))) {
1979: /*
1980: * The immediate goal for using the softexpires is
1981: * minimizing wakeups, not running timers at the
1982: * earliest interrupt after their soft expiration.
1983: * This allows us to avoid using a Priority Search
1984: * Tree, which can answer a stabbing query for
1985: * overlapping intervals and instead use the simple
1986: * BST we already have.
1987: * We don't add extra wakeups by delaying timers that
1988: * are right-of a not yet expired timer, because that
1989: * timer will have to trigger a wakeup anyway.
1990: */
1991: if (basenow < hrtimer_get_softexpires(timer))
1992: break;
1993:
1994: __run_hrtimer(cpu_base, base, timer, basenow, flags);
1995: if (active_mask == HRTIMER_ACTIVE_SOFT)
1996: hrtimer_sync_wait_running(cpu_base, flags);
1997: }
1998: }
1999: }
SourceFile:kernel/time/hrtimer.c]
|
| 30/2 |
2026/05/24 10:27 |
llm |
expert |
0m
Model:
Tokens:
input: 25387
output: 45
thoughts: 1395
Thoughts: **Analyzing the Timer Loop and Potential Infinite Iterations**
Okay, so I'm focusing on this loop and trying to figure out if it can get stuck. I've confirmed that `basenow` is fixed within the `while` loop, which is important. The core concern is whether `advance_sched` can cause an infinite loop, or just a very long one. My initial thought was that if `advance_sched` increments the timer expiration by a tiny amount (1 ns), and `basenow` is significantly ahead, `advance_sched` might be called a huge number of times in the same loop.
Then I realized that the logic actually calculates how many times `advance_sched` needs to run based on the difference between `basenow` and `end_time`. If `end_time` is initialized to be significantly behind `basenow`, then the timer will catch up a lot of times. The question is, can that lead to an infinite loop? But, `basenow` is fixed, and `end_time` will eventually pass it, so it will break the while loop. That's good, so it's not an infinite loop, just a *potentially* long one.
But then, what if the `interval` is zero? I had to go back to the code, and realized that `min_duration` is, in my test cases, calculated as 1. Is that right? I followed the code and tracked the values: `length_to_duration` returns a value based on `ETH_ZLEN` (which is 60) and `picos_per_byte`. I calculated that if `picos_per_byte` is 16, then `min_duration` would be 0, but `TAPRIO_PICOS_PER_BYTE_MIN` is 17. So `picos_per_byte` will always be 17.
But what if there is a negative value for `picos_per_byte`? I dug into how `picos_per_byte` is determined. It's based on the link settings. Ah, I see! `picos_per_byte` is an `int`. If the link speed is very large, for example, a large unsigned number that becomes negative as an `int`, when computing `picos_per_byte`, I realized that the formula `(USEC_PER_SEC * 8) / speed` could result in a negative `speed`. Then the calculation becomes `8000000 / -2147483648`, which is zero. But, the code checks for values less than `TAPRIO_PICOS_PER_BYTE_MIN`, so the minimum value will be 17, and it can never be zero.
Okay, so even if `min_duration` is effectively 0, that's taken care of.
Now, what if the `interval` is 1? I need to analyze `advance_sched` again, looking for a scenario where `end_time` might *never* catch up to `basenow`. The problem is that `advance_sched` also adds `next->interval` to `end_time`. If the timer needs to catch up to `basenow`, it's going to run, `basenow - end_time` times. But, I looked closer, and `end_time` is capped by `oper->cycle_end_time`.
If `oper->cycle_end_time` is less than or equal to `basenow`, then `end_time` will never exceed it! And, in this case, the while loop will exit. But, wait, if `end_time` reaches `oper->cycle_end_time`, the code checks `should_restart_cycle`. If the cycle is restarted, `oper->cycle_end_time` gets incremented by `oper->cycle_time`. If `oper->cycle_time` is zero, then `oper->cycle_end_time` will never increase! I'm going to have to go and check what can make `oper->cycle_time` zero.
|
| 31/2 |
2026/05/24 10:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:parse_taprio_schedule]
Results: map[SourceCode:1128: static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
1129: struct sched_gate_list *new,
1130: struct netlink_ext_ack *extack)
1131: {
1132: int err = 0;
1133:
1134: if (tb[TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY]) {
1135: NL_SET_ERR_MSG(extack, "Adding a single entry is not supported");
1136: return -ENOTSUPP;
1137: }
1138:
1139: if (tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME])
1140: new->base_time = nla_get_s64(tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]);
1141:
1142: if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION])
1143: new->cycle_time_extension = nla_get_s64(tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION]);
1144:
1145: if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME])
1146: new->cycle_time = nla_get_s64(tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]);
1147:
1148: if (tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST])
1149: err = parse_sched_list(q, tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST],
1150: new, extack);
1151: if (err < 0)
1152: return err;
1153:
1154: if (!new->cycle_time) {
1155: struct sched_entry *entry;
1156: ktime_t cycle = 0;
1157:
1158: list_for_each_entry(entry, &new->entries, list)
1159: cycle = ktime_add_ns(cycle, entry->interval);
1160:
1161: if (cycle < 0 || cycle > INT_MAX) {
1162: NL_SET_ERR_MSG(extack, "'cycle_time' is too big");
1163: return -EINVAL;
1164: }
1165:
1166: new->cycle_time = cycle;
1167: }
1168:
1169: if (new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)) {
1170: NL_SET_ERR_MSG(extack, "'cycle_time' is too small");
1171: return -EINVAL;
1172: }
1173:
1174: taprio_calculate_gate_durations(q, new);
1175:
1176: return 0;
1177: }
SourceFile:net/sched/sch_taprio.c]
|
| 32/2 |
2026/05/24 10:27 |
llm |
expert |
0m
Model:
Tokens:
input: 28602
output: 44
thoughts: 340
Thoughts: **Analyzing the Cycle Time Calculation**
Okay, so I'm digging into this code and trying to understand how `cycle_time` is determined. The first thing that jumps out is that if `new->cycle_time` isn't explicitly provided, it's derived by summing up the `entry->interval` values. Now, I know that `entry->interval` has a lower bound of `min_duration`, which itself is at least 1. This immediately tells me that the calculated `cycle` will always be, at a bare minimum, the number of entries (`new->num_entries`) multiplied by 1. Therefore, `cycle` will be, at a bare minimum, the same as the number of entries.
Then I see this crucial check:
```c
if (new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)) {
NL_SET_ERR_MSG(extack, "'cycle_time' is too small");
return -EINVAL;
}
```
Hold on, I see `length_to_duration(q, ETH_ZLEN)` is really just `min_duration`. So this check is verifying that `new->cycle_time` is *at least* `new->num_entries * min_duration`. Since `min_duration` has a value of at least 1, this means `new->cycle_time` has to be at least as big as `new->num_entries`. From that, it's clear that `cycle_time` can't be zero!
But then I had a thought...what about the edge case where `new->num_entries` is actually *zero*? If `num_entries` is 0, then `cycle_time` *could* be 0. But if `num_entries` is zero, the `list_for_each_entry` loop won't execute and `cycle` will remain at zero. So what if `num_entries` is zero and the loop is skipped? If `num_entries` is 0, then the logic says `new->cycle_time` *could* be 0. So, I need to check if the scenario of `num_entries` being zero is even allowed.
|
| 33/2 |
2026/05/24 10:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:parse_sched_list]
Results: map[SourceCode:1088: static int parse_sched_list(struct taprio_sched *q, struct nlattr *list,
1089: struct sched_gate_list *sched,
1090: struct netlink_ext_ack *extack)
1091: {
1092: struct nlattr *n;
1093: int err, rem;
1094: int i = 0;
1095:
1096: if (!list)
1097: return -EINVAL;
1098:
1099: nla_for_each_nested(n, list, rem) {
1100: struct sched_entry *entry;
1101:
1102: if (nla_type(n) != TCA_TAPRIO_SCHED_ENTRY) {
1103: NL_SET_ERR_MSG(extack, "Attribute is not of type 'entry'");
1104: continue;
1105: }
1106:
1107: entry = kzalloc_obj(*entry);
1108: if (!entry) {
1109: NL_SET_ERR_MSG(extack, "Not enough memory for entry");
1110: return -ENOMEM;
1111: }
1112:
1113: err = parse_sched_entry(q, n, entry, i, extack);
1114: if (err < 0) {
1115: kfree(entry);
1116: return err;
1117: }
1118:
1119: list_add_tail(&entry->list, &sched->entries);
1120: i++;
1121: }
1122:
1123: sched->num_entries = i;
1124:
1125: return i;
1126: }
SourceFile:net/sched/sch_taprio.c]
|
| 34/2 |
2026/05/24 10:27 |
llm |
expert |
0m
Model:
Tokens:
input: 30032
output: 43
thoughts: 366
Thoughts: **Analyzing the Zero-Entry TAPRIO Schedule Scenario**
Okay, so I'm walking through this TAPRIO code, trying to understand what happens with an empty schedule entry list. If `list` is empty, `nla_for_each_nested` won't even run, and the iterator `i` stays at 0. `parse_sched_list` returns 0, indicating success. Now, inside `parse_taprio_schedule`, the check on the `TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST` passes (as `tb` has it and `err` is 0).
Then, `new->cycle_time` gets initialized to 0. The subsequent check, `new->cycle_time < new->num_entries * length_to_duration`, boils down to `0 < 0 * min_duration`, which simplifies to `0 < 0`, evaluates to false. So, the parse *succeeds*, which is interesting. But, if `num_entries` is 0, then `sched->entries` is empty.
Now I'm looking at `advance_sched`. The problematic part is, if `oper->entries` is empty then `list_first_entry` will be passed an empty list. This, as I understand it, would return a pointer that's essentially garbage β specifically the address of `&oper->entries` but offset by the structure member "list" . Attempting to dereference `next->end_time` would cause a crash (probably a page fault or something similar), not an RCU stall.
The question then is, does `taprio_change` itself allow for zero entries in the first place? I need to go back and check the overall structure of that command...
|
| 35/2 |
2026/05/24 10:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_change]
Results: map[SourceCode:1817: static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
1818: struct netlink_ext_ack *extack)
1819: {
1820: struct qdisc_size_table *stab = rtnl_dereference(sch->stab);
1821: struct nlattr *tb[TCA_TAPRIO_ATTR_MAX + 1] = { };
1822: struct sched_gate_list *oper, *admin, *new_admin;
1823: struct taprio_sched *q = qdisc_priv(sch);
1824: struct net_device *dev = qdisc_dev(sch);
1825: struct tc_mqprio_qopt *mqprio = NULL;
1826: unsigned long flags;
1827: u32 taprio_flags;
1828: ktime_t start;
1829: int i, err;
1830:
1831: err = nla_parse_nested_deprecated(tb, TCA_TAPRIO_ATTR_MAX, opt,
1832: taprio_policy, extack);
1833: if (err < 0)
1834: return err;
1835:
1836: if (tb[TCA_TAPRIO_ATTR_PRIOMAP])
1837: mqprio = nla_data(tb[TCA_TAPRIO_ATTR_PRIOMAP]);
1838:
1839: /* The semantics of the 'flags' argument in relation to 'change()'
1840: * requests, are interpreted following two rules (which are applied in
1841: * this order): (1) an omitted 'flags' argument is interpreted as
1842: * zero; (2) the 'flags' of a "running" taprio instance cannot be
1843: * changed.
1844: */
1845: taprio_flags = nla_get_u32_default(tb[TCA_TAPRIO_ATTR_FLAGS], 0);
1846:
1847: /* txtime-assist and full offload are mutually exclusive */
1848: if ((taprio_flags & TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST) &&
1849: (taprio_flags & TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD)) {
1850: NL_SET_ERR_MSG_ATTR(extack, tb[TCA_TAPRIO_ATTR_FLAGS],
1851: "TXTIME_ASSIST and FULL_OFFLOAD are mutually exclusive");
1852: return -EINVAL;
1853: }
1854:
1855: if (q->flags != TAPRIO_FLAGS_INVALID && q->flags != taprio_flags) {
1856: NL_SET_ERR_MSG_MOD(extack,
1857: "Changing 'flags' of a running schedule is not supported");
1858: return -EOPNOTSUPP;
1859: }
1860: q->flags = taprio_flags;
1861:
1862: /* Needed for length_to_duration() during netlink attribute parsing */
1863: taprio_set_picos_per_byte(dev, q, extack);
1864:
1865: err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags);
1866: if (err < 0)
1867: return err;
1868:
1869: err = taprio_parse_tc_entries(sch, opt, extack);
1870: if (err)
1871: return err;
1872:
1873: new_admin = kzalloc_obj(*new_admin);
1874: if (!new_admin) {
1875: NL_SET_ERR_MSG(extack, "Not enough memory for a new schedule");
1876: return -ENOMEM;
1877: }
1878: INIT_LIST_HEAD(&new_admin->entries);
1879:
1880: oper = rtnl_dereference(q->oper_sched);
1881: admin = rtnl_dereference(q->admin_sched);
1882:
1883: /* no changes - no new mqprio settings */
1884: if (!taprio_mqprio_cmp(dev, mqprio))
1885: mqprio = NULL;
1886:
1887: if (mqprio && (oper || admin)) {
1888: NL_SET_ERR_MSG(extack, "Changing the traffic mapping of a running schedule is not supported");
1889: err = -ENOTSUPP;
1890: goto free_sched;
1891: }
1892:
1893: if (mqprio) {
1894: err = netdev_set_num_tc(dev, mqprio->num_tc);
1895: if (err)
1896: goto free_sched;
1897: for (i = 0; i < mqprio->num_tc; i++) {
1898: netdev_set_tc_queue(dev, i,
1899: mqprio->count[i],
1900: mqprio->offset[i]);
1901: q->cur_txq[i] = mqprio->offset[i];
1902: }
1903:
1904: /* Always use supplied priority mappings */
1905: for (i = 0; i <= TC_BITMASK; i++)
1906: netdev_set_prio_tc_map(dev, i,
1907: mqprio->prio_tc_map[i]);
1908: }
1909:
1910: err = parse_taprio_schedule(q, tb, new_admin, extack);
1911: if (err < 0)
1912: goto free_sched;
1913:
1914: if (new_admin->num_entries == 0) {
1915: NL_SET_ERR_MSG(extack, "There should be at least one entry in the schedule");
1916: err = -EINVAL;
1917: goto free_sched;
1918: }
1919:
1920: err = taprio_parse_clockid(sch, tb, extack);
1921: if (err < 0)
1922: goto free_sched;
1923:
1924: taprio_update_queue_max_sdu(q, new_admin, stab);
1925:
1926: if (FULL_OFFLOAD_IS_ENABLED(q->flags))
1927: err = taprio_enable_offload(dev, q, new_admin, extack);
1928: else
1929: err = taprio_disable_offload(dev, q, extack);
1930: if (err)
1931: goto free_sched;
1932:
1933: /* Protects against enqueue()/dequeue() */
1934: spin_lock_bh(qdisc_lock(sch));
1935:
1936: if (tb[TCA_TAPRIO_ATTR_TXTIME_DELAY]) {
1937: if (!TXTIME_ASSIST_IS_ENABLED(q->flags)) {
1938: NL_SET_ERR_MSG_MOD(extack, "txtime-delay can only be set when txtime-assist mode is enabled");
1939: err = -EINVAL;
1940: goto unlock;
1941: }
1942:
1943: q->txtime_delay = nla_get_u32(tb[TCA_TAPRIO_ATTR_TXTIME_DELAY]);
1944: }
1945:
1946: if (!TXTIME_ASSIST_IS_ENABLED(q->flags) &&
1947: !FULL_OFFLOAD_IS_ENABLED(q->flags) &&
1948: !hrtimer_active(&q->advance_timer)) {
1949: hrtimer_setup(&q->advance_timer, advance_sched, q->clockid, HRTIMER_MODE_ABS);
1950: }
1951:
1952: err = taprio_get_start_time(sch, new_admin, &start);
1953: if (err < 0) {
1954: NL_SET_ERR_MSG(extack, "Internal error: failed get start time");
1955: goto unlock;
1956: }
1957:
1958: setup_txtime(q, new_admin, start);
1959:
1960: if (TXTIME_ASSIST_IS_ENABLED(q->flags)) {
1961: if (!oper) {
1962: rcu_assign_pointer(q->oper_sched, new_admin);
1963: err = 0;
1964: new_admin = NULL;
1965: goto unlock;
1966: }
1967:
1968: /* Not going to race against advance_sched(), but still */
1969: admin = rcu_replace_pointer(q->admin_sched, new_admin,
1970: lockdep_rtnl_is_held());
1971: if (admin)
1972: call_rcu(&admin->rcu, taprio_free_sched_cb);
1973: } else {
1974: setup_first_end_time(q, new_admin, start);
1975:
1976: /* Protects against advance_sched() */
1977: spin_lock_irqsave(&q->current_entry_lock, flags);
1978:
1979: taprio_start_sched(sch, start, new_admin);
1980:
1981: admin = rcu_replace_pointer(q->admin_sched, new_admin,
1982: lockdep_rtnl_is_held());
1983: if (admin)
1984: call_rcu(&admin->rcu, taprio_free_sched_cb);
1985:
1986: spin_unlock_irqrestore(&q->current_entry_lock, flags);
1987:
1988: if (FULL_OFFLOAD_IS_ENABLED(q->flags))
1989: taprio_offload_config_changed(q);
1990: }
1991:
1992: new_admin = NULL;
1993: err = 0;
1994:
1995: if (!stab)
1996: NL_SET_ERR_MSG_MOD(extack,
1997: "Size table not specified, frame length estimations may be inaccurate");
1998:
1999: unlock:
2000: spin_unlock_bh(qdisc_lock(sch));
2001:
2002: free_sched:
2003: if (new_admin)
2004: call_rcu(&new_admin->rcu, taprio_free_sched_cb);
2005:
2006: return err;
2007: }
SourceFile:net/sched/sch_taprio.c]
|
| 36/2 |
2026/05/24 10:27 |
llm |
expert |
0m
Model:
Tokens:
input: 33962
output: 47
thoughts: 526
Thoughts: **Analyzing TAPRIO Scheduler Cycle Time and Potential RCU Stall**
Okay, let's break down this `taprio_change` function. First, I see a check that `num_entries` in the schedule can't be zero. Makes sense; you need at least one entry. Then, there's an implicit constraint on `cycle_time`: it can't be zero either, because of the following check.
I see that `cycle_time` is a signed 64-bit integer (`s64`), and its value comes from user input. The code parses it with `nla_get_s64`. Okay, so far so good. Then, there's a crucial validation: `new->cycle_time` must be greater than or equal to `new->num_entries * length_to_duration(q, ETH_ZLEN)`. Since `length_to_duration` will return something greater than 0, then the minimum `cycle_time` is dictated by the number of entries. So, again, `cycle_time` cannot be 0.
But here's where my expert senses tingle. If `cycle_time` is very large, say, `0x7fffffffffffffff`, that's going to cause problems down the line. That will result in a very large `oper->cycle_end_time`. If the interval is small, say 1, the `advance_sched` function increments `end_time` by 1 nanosecond each time it's called. If `basenow` is only one second ahead of `end_time`, `advance_sched` will be called a billion times! That's a huge potential for an RCU stall.
I need to understand how `basenow` can be significantly ahead of `end_time`. It looks like it's set by `taprio_start_sched` which calls `taprio_get_start_time`. I need to review that function to see how the initial `start` time is determined. I suspect it's crucial for understanding how the gap between `basenow` and `end_time` can be established. Time to dive deeper into `taprio_get_start_time` and the timing logic of the TAPRIO scheduler.
|
| 37/2 |
2026/05/24 10:27 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_get_start_time]
Results: map[SourceCode:1207: static int taprio_get_start_time(struct Qdisc *sch,
1208: struct sched_gate_list *sched,
1209: ktime_t *start)
1210: {
1211: struct taprio_sched *q = qdisc_priv(sch);
1212: ktime_t now, base, cycle;
1213: s64 n;
1214:
1215: base = sched_base_time(sched);
1216: now = taprio_get_time(q);
1217:
1218: if (ktime_after(base, now)) {
1219: *start = base;
1220: return 0;
1221: }
1222:
1223: cycle = sched->cycle_time;
1224:
1225: /* The qdisc is expected to have at least one sched_entry. Moreover,
1226: * any entry must have 'interval' > 0. Thus if the cycle time is zero,
1227: * something went really wrong. In that case, we should warn about this
1228: * inconsistent state and return error.
1229: */
1230: if (WARN_ON(!cycle))
1231: return -EFAULT;
1232:
1233: /* Schedule the start time for the beginning of the next
1234: * cycle.
1235: */
1236: n = div64_s64(ktime_sub_ns(now, base), cycle);
1237: *start = ktime_add_ns(base, (n + 1) * cycle);
1238: return 0;
1239: }
SourceFile:net/sched/sch_taprio.c]
|
| 38/2 |
2026/05/24 10:27 |
llm |
expert |
0m
Model:
Tokens:
input: 35540
output: 24
thoughts: 1096
Thoughts: **Analyzing Potential RCU Stall in TAPRIO Scheduler**
Okay, let's break this down. My initial thought is focused on how the `start` time for a timer is calculated, and what happens when the timer expires. The system calculates `start` as `base + (n + 1) * cycle`, which puts it in the future, at most one `cycle` ahead of `now`. If `cycle` is small, `start` is close to the current time. The opposite is also true.
I see that when a timer expires and the timer runs, `basenow` becomes roughly `start`. Then `advance_sched` increments `end_time` by `interval`, and if `interval` is 1, `end_time` becomes `start + 1`.
The crucial bit is that when `advance_sched` returns, the timer is re-enqueued with `start + 1`. Now, because `basenow` is close to `start`, there's a possibility that `start + 1` is *still* less than or equal to `basenow`!
This means the timer could trigger again immediately, and it will run `basenow - start` times. I realize `basenow - start` is effectively the timer latency. If the timer is late by a typical 10 microseconds, then the calculations could run 10,000 times! Even worse, if it's late by a millisecond, we are looking at 1,000,000 executions and that is getting close to RCU issues. Latency by 10 milliseconds, and we have 10,000,000 executions! This is a potential RCU stall scenario, no question.
Okay, let's figure out how this `interval` can become 1. I know that `interval` can be 1, if `min_duration` is 1. `min_duration` being 1 relies on `picos_per_byte` being 17. And `picos_per_byte` is 17 if the `speed` is large.
Now, where does this `speed` value come from? It's from `__ethtool_get_link_ksettings`. I know that network device properties are not typically controlled by unprivileged users, but could the scheduler settings be exposed somehow? That's what I am starting to suspect.
Then I remind myself that `taprio` is a qdisc. Unprivileged users can't directly configure qdiscs... or can they? What about user namespaces? If a user has `CAP_NET_ADMIN` within a user namespace, they can create dummy or veth devices and configure qdiscs on them. This is the crucial point! I then realized that `taprio` is a network scheduler that uses netlink (`rtnetlink`) and can be configured with `RTM_NEWQDISC`, which is permissible if the user has `CAP_NET_ADMIN` in the namespace.
So, yes, it seems this is accessible from user namespaces! Now, how can we make sure `interval` is small in such a scenario?
Okay, could the interval be zero? I see that it might happen if `speed` is very large. But a check prevents it: a minimum value for `picos_per_byte` is enforced.
Ok, so `picos_per_byte` can't be smaller than 17. Then the smallest duration is 1.
One more thing. What if `speed` is set to `SPEED_UNKNOWN` (-1)? It remains `SPEED_10` (10), then `picos_per_byte` is a large number. Then `min_duration` becomes very large.
Now, consider a dummy device. What is its speed? The speed is usually `SPEED_UNKNOWN`, so the large number is valid. But what about a veth device? Its speed is `SPEED_10000` (10 Gbps). Now, I need to check the veth device's speed setting.
|
| 39/2 |
2026/05/24 10:28 |
tool |
grepper |
0m
Error:
Args: map[Expression:SPEED_10000.*veth]
Results:
|
| 40/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 37559
output: 21
thoughts: 17
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing veth.c for Performance Bottlenecks**
Okay, time to dig in. My gut tells me there might be some low-hanging fruit in `drivers/net/veth.c` when it comes to performance. That's the first place I'd check for a virtual Ethernet device. I'm wondering if a recent patch or a subtle change in the datapath has introduced some unexpected overhead. I'll need to focus on the core packet processing functions β the transmit and receive paths are always good starting points for understanding the flow. I'll be looking for any unnecessary copies, excessive locking, or suboptimal buffer management. My goal is to quickly identify potential areas where packet throughput could be improved. I'll probably start by grepping for common performance-sensitive functions like `skb_pull`, `skb_push`, `netif_rx`, and anything related to queueing or workqueues. Then, I'll review those sections carefully, paying close attention to any changes in the context of recent commits. Let's see what we can find.
|
| 41/2 |
2026/05/24 10:28 |
tool |
grepper |
0m
Error:
Args: map[Expression:SPEED_.*veth.c]
Results:
|
| 42/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 37854
output: 45
thoughts: 22
Thoughts: Here's a summary of my thought process, as if I were considering this myself:
**Investigating the veth Driver's Ethtool Operations**
Okay, so I need to understand how the `veth` driver handles its ethtool operations. I know `ethtool_ops` is the likely place to start, as it's the standard structure for defining ethtool functionality within a network driver. Let's dive straight into the source code for the `veth` driver. Specifically, I'll examine `drivers/net/veth.c`. My aim is to look for the implementation details, the specifics of how they have handled and defined these `ethtool_ops`. I need to see how they've implemented functions for things like getting link speed, duplex, statistics, and any other relevant ethtool features. I'm going to quickly scan for the `ethtool_ops` struct definition and then trace how those function pointers are assigned and, if possible, how they're used. This should give me a good handle on its implementation.
|
| 43/2 |
2026/05/24 10:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/veth.c IncludeLines:true Name:veth_ethtool_ops]
Results: map[SourceCode: 264: static const struct ethtool_ops veth_ethtool_ops = {
265: .get_drvinfo = veth_get_drvinfo,
266: .get_link = ethtool_op_get_link,
267: .get_strings = veth_get_strings,
268: .get_sset_count = veth_get_sset_count,
269: .get_ethtool_stats = veth_get_ethtool_stats,
270: .get_link_ksettings = veth_get_link_ksettings,
271: .get_ts_info = ethtool_op_get_ts_info,
272: .get_channels = veth_get_channels,
273: .set_channels = veth_set_channels,
274: };
SourceFile:drivers/net/veth.c]
|
| 44/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 38423
output: 46
thoughts: 15
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing `veth_get_link_ksettings`**
Okay, let's dive into `veth_get_link_ksettings`. I need to understand exactly what's being extracted here. Given the name, it's obviously about retrieving kernel-side link settings for a virtual ethernet pair. I'm immediately thinking about what "link settings" actually encompasses in the context of veth β is it speed, duplex, MTU, maybe some more specialized flags or QoS parameters? My initial hunch is this likely covers the basic network interface characteristics, the same settings I'd get from `ethtool` but from the kernel's perspective. It's probably being used as an internal utility function, possibly for displaying configuration information, setting up configurations, or maybe even being used when propagating settings between the veth endpoints. It is important to know the context this code runs in, to understand if this is used in the context of a new veth interface. Or perhaps, this is called as part of a more extensive configuration management process. Need to trace its calls in the surrounding code to determine how this is being used. And, as always, I'm thinking about edge cases β what happens if the veth pair isn't fully initialized, or if there's an error retrieving the settings? The error handling in this function will be crucial. I'm anticipating some sort of `netlink` interaction, but the details are still fuzzy. Let's dig in and see the implementation.
|
| 45/2 |
2026/05/24 10:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/veth.c IncludeLines:true Name:veth_get_link_ksettings]
Results: map[SourceCode: 128: static int veth_get_link_ksettings(struct net_device *dev,
129: struct ethtool_link_ksettings *cmd)
130: {
131: cmd->base.speed = SPEED_10000;
132: cmd->base.duplex = DUPLEX_FULL;
133: cmd->base.port = PORT_TP;
134: cmd->base.autoneg = AUTONEG_DISABLE;
135: return 0;
136: }
SourceFile:drivers/net/veth.c]
|
| 46/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 39001
output: 20
thoughts: 451
Thoughts: **Analyzing Potential Timer Overruns and RCU Stalls**
Okay, let's break this down. My initial observation is that the `veth` interface reports a speed of `SPEED_10000`. Based on that, I can calculate `picos_per_byte` as 8,000,000,000 / 10,000 = 800. This in turn leads to a `min_duration` (which translates to the `interval` size) of 60 * 800 / 1000 = 48.
Now, if this timer is slightly late β say, by 1 millisecond (1,000,000 ns) β the `advance_sched` function could be called 1,000,000 / 48 = 20,833 times. Even if it's late by 10 milliseconds, that's still "only" 208,333 calls. While that's a significant number of calls, I don't see that as a direct route to an RCU stall, which, from memory, is typically around 21 seconds.
Ah, right, 21 seconds is 21,000,000,000 ns. But the key is: the timer itself is not late by 21 seconds; the issue is how many times the loop runs within a given time.
Let's assume `advance_sched` takes 100 ns to execute, and it's called 200,000 times. That's a total time of 20 ms. Still not enough to cause an RCU stall. Therefore, to trigger such a stall, `interval` would have to be 1 or `advance_sched` needs to loop infinitely.
Wait, can `interval` even be 0? I need to check the conditions. I also need to rule out a couple of related variables: `ETH_ZLEN` - that's 60. What about `picos_per_byte` being 0? No, from my earlier calculations it is at least 17, so that doesn't make sense.
Okay, what if the `speed` is extremely large? Could a user craft a network device with an artificially inflated speed? Yes, I see that this is a possibility with a `tun` device. I need to check the actual speed reported by a `tun` device. That might be the key to reproducing the issue.
|
| 47/2 |
2026/05/24 10:28 |
tool |
grepper |
0m
Error:
Args: map[Expression:SPEED_.*tun.c]
Results:
|
| 48/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 40040
output: 43
thoughts: 21
Thoughts: Here's my thought process, as if I were considering this code:
**Analyzing the tun.c Module**
Okay, so I need to understand how `ethtool_ops` are handled within the networking context of this driver. My immediate instinct is to dive into `drivers/net/tun.c`. That's where I'd expect to find the core implementation for the TUN/TAP interface, which should include the ethtool operations. I'll focus on that file to start, as it's the most likely location for the relevant function hooks.
|
| 49/2 |
2026/05/24 10:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/tun.c IncludeLines:true Name:tun_ethtool_ops]
Results: map[SourceCode:3588: static const struct ethtool_ops tun_ethtool_ops = {
3589: .supported_coalesce_params = ETHTOOL_COALESCE_RX_MAX_FRAMES,
3590: .get_drvinfo = tun_get_drvinfo,
3591: .get_msglevel = tun_get_msglevel,
3592: .set_msglevel = tun_set_msglevel,
3593: .get_link = ethtool_op_get_link,
3594: .get_channels = tun_get_channels,
3595: .get_ts_info = ethtool_op_get_ts_info,
3596: .get_coalesce = tun_get_coalesce,
3597: .set_coalesce = tun_set_coalesce,
3598: .get_link_ksettings = tun_get_link_ksettings,
3599: .set_link_ksettings = tun_set_link_ksettings,
3600: };
SourceFile:drivers/net/tun.c]
|
| 50/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 40543
output: 44
thoughts: 14
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Investigating `tun_get_link_ksettings`**
Right, let's dive into this. The initial thought, of course, is to check `tun_get_link_ksettings`. It's a natural starting point when dealing with tun/tap interface settings, as I'm sure you know. This function is critical for understanding the current configuration of the link, and before making any adjustments, a thorough read of those settings is essential. Gotta figure out what we're starting with before making any changes, right? Makes perfect sense.
|
| 51/2 |
2026/05/24 10:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/tun.c IncludeLines:true Name:tun_get_link_ksettings]
Results: map[SourceCode:3503: static int tun_get_link_ksettings(struct net_device *dev,
3504: struct ethtool_link_ksettings *cmd)
3505: {
3506: struct tun_struct *tun = netdev_priv(dev);
3507:
3508: memcpy(cmd, &tun->link_ksettings, sizeof(*cmd));
3509: return 0;
3510: }
SourceFile:drivers/net/tun.c]
|
| 52/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 40897
output: 44
thoughts: 14
Thoughts: Okay, here's my summarized thought process, presented as if I'm the one thinking it:
**Examining `tun_set_link_ksettings`**
Right, let's dive into this. I need to take a look at `tun_set_link_ksettings`. It's crucial for understanding how we're configuring the TUN interface at the kernel level. This function likely handles the low-level settings that impact how the interface interacts with the network stack. I'll need to remember to pay close attention to the parameter passing and any potential side effects. I'm especially interested in how it interacts with other kernel modules and what specific aspects of the link it's modifying. I'll also try to trace the call paths to get a comprehensive view of its functionality.
|
| 53/2 |
2026/05/24 10:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/tun.c IncludeLines:true Name:tun_set_link_ksettings]
Results: map[SourceCode:3512: static int tun_set_link_ksettings(struct net_device *dev,
3513: const struct ethtool_link_ksettings *cmd)
3514: {
3515: struct tun_struct *tun = netdev_priv(dev);
3516:
3517: memcpy(&tun->link_ksettings, cmd, sizeof(*cmd));
3518: return 0;
3519: }
SourceFile:drivers/net/tun.c]
|
| 54/2 |
2026/05/24 10:28 |
llm |
expert |
0m
Model:
Tokens:
input: 41275
output: 44
thoughts: 3774
Thoughts: **Vulnerability Assessment: taprio, tun, and Exponential Timer Blowup**
Okay, here's the breakdown of what I've discovered: I see a potential for an RCU stall within the `taprio` qdisc implementation, specifically when combined with the `tun` device. The core issue revolves around the interaction of the scheduled timer, its execution latency, and the calculation of the `end_time` variable that determines when the next timer event is due.
The scenario unfolds like this: A user can manipulate the "speed" setting of a `tun` device using `ETHTOOL_SLINKSETTINGS`. If they set the speed to an extremely large value (e.g., `0x7fffffff`), the internal calculations lead to a minimum duration (`min_duration`) of 1 nanosecond for each scheduled entry. This is a critical factor.
The vulnerability stems from the `interval` parameter of a taprio scheduling entry. If `interval` is set to this minimal value (1 ns), the code adds it to the `end_time` calculation. The problem is that the actual execution time of the `advance_sched` function, which handles these scheduling entries, is likely much larger than 1 ns. This leads to an exponential blowup of the timer events.
Here's how it happens: The system is using the `hrtimer` framework. Let's say, after the timer fires, its `end_time` is the real time minus a small latency, e.g. 10 us, while the clock has advanced by an execution latency `E` (e.g. 100 ns). The next time the timer is programmed to run is the *previous end_time* plus 1 ns. Thus, the next timer event will be in the past! Each timer iteration increments `end_time` by 1 ns, and we need to schedule `L/interval = L` many timer events before `end_time` catches up with `basenow`, *while* the real clock (and thus the `basenow`) is advancing by `E`. This creates an exponential effect: the more the loop runs, the bigger the difference between `end_time` and `basenow`, and thus, the more iterations it takes! The execution latency accumulates. For example, after the first run, the clock has advanced by `L*E`, so there will be an accumulated latency. The loop starts again, at a much higher `basenow` - `end_time`, which will be again several orders of magnitude higher.
I've determined that an unprivileged user can create a `tun` device in a user namespace and control its speed, which leads to this vulnerability. It is also possible, with the right veth setup and configuration, even without a `tun` device, to trigger this issue by setting the speed of the veth device to, say, `10000`, in which case, even `interval=48` can lead to an exponential blowup, with the same principle described.
The use of `__netif_schedule` doesn't mitigate the problem, because it only sets a bit and returns; the heavy lifting is done elsewhere, and this scheduling is fast. The major bottlenecks are the spinlock, rcu operations, and the overall function call overhead of `advance_sched`, which may add up to the required execution latency. The important part is that if an execution latency exists, this bug triggers.
The implications are serious: this exponential timer blowup leads to an RCU stall, effectively a denial-of-service condition. This can be triggered by an unprivileged user within a user namespace, which drastically increases the risk. The exponential behavior may take a while to happen, but it does cause a stall once it starts!
|
| 55/2 |
2026/05/24 10:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/tun.c IncludeLines:true Name:tun_set_link_ksettings]
Results: map[SourceCode:3512: static int tun_set_link_ksettings(struct net_device *dev,
3513: const struct ethtool_link_ksettings *cmd)
3514: {
3515: struct tun_struct *tun = netdev_priv(dev);
3516:
3517: memcpy(&tun->link_ksettings, cmd, sizeof(*cmd));
3518: return 0;
3519: }
SourceFile:drivers/net/tun.c]
|
| 56/2 |
2026/05/24 10:29 |
llm |
expert |
0m
Model:
Tokens:
input: 46046
output: 43
thoughts: 1116
Thoughts: **Analyzing the TAPRIO Qdisc Bug**
Okay, so I've got this TAPRIO qdisc issue to dissect. It's immediately clear β the code just copies the struct without validation on the `speed` field, which is a major red flag. This means `speed` can be set to `0x7fffffff` β the maximum signed integer. Now, let's see where that leads.
If `speed` is that large, `picos_per_byte` becomes `8000000 / 2147483647`, which evaluates to zero. But then, `picos_per_byte` is clamped to `TAPRIO_PICOS_PER_BYTE_MIN` (17). So then `min_duration` will be `60 * 17 / 1000 = 1`. This allows the `interval` to also be 1. Bingo! That's a solid, straightforward path to trigger the bug.
Now, let's look at the actual bug report. The stack trace shows the CPU is stuck in `advance_sched` within `hrtimer_interrupt`, which fully aligns with the analysis: The timer is firing continuously or is in an infinite loop.
Okay, let's explore if there are other ways to trigger this, to make sure this is the only path.
What about a large `interval` but a small `cycle_time`? Ah, but the code checks `cycle_time` to be greater or equal to `num_entries * min_duration`, so that will be checked, and in the case `num_entries` is `1` that would mean that `cycle_time` could be `min_duration`. If `min_duration` is 1, `cycle_time` can be 1. So then `interval` could be 1.
Then `oper->cycle_end_time` would increase by 1, and the `end_time` would also increase by 1. That's a nanosecond, and it all checks out to be the same analysis.
Any other gotchas? What if `interval` is large and `next->interval` is 0? But no, `interval` gets checked against `min_duration`, which we've established can be 1, so it won't be zero. It's at least 1, but again, 1 ns is so small that it would cause the infinite loop.
So the bug: it's an infinite loop inside a timer interrupt. This leads to an RCU stall and a soft lockup. It does not corrupt memory. It does not leak memory. No arbitrary code execution. So, it's a straightforward Denial of Service (DoS) vulnerability.
Can an unprivileged user exploit this? Yep, with user namespaces enabled. An unprivileged user creates a user namespace, then a network namespace. They get `CAP_NET_ADMIN` in the network namespace. They can set up a `tun` or `veth` device, configure the `taprio` qdisc, and set that `interval` ridiculously small. The timer will loop, crash, or hang the system.
So the summary: This is not exploitable (except for DoS), it *is* a Denial of Service, it's not accessible from unprivileged processes because it needs `CAP_NET_ADMIN`. And it *is* accessible from user namespaces because `CAP_NET_ADMIN` in userns is sufficient.
Just to be absolutely sure, let's confirm that configuring `taprio` in a user namespace is allowed. Yes, `tc qdisc add` uses `rtnetlink`. `rtnetlink` checks for `ns_capable(net->user_ns, CAP_NET_ADMIN)`, so it's good. And `taprio` doesn't need any special physical device. I should double check `taprio_change` or `taprio_init` for any `capable(CAP_NET_ADMIN)` checks, but so far so good.
|
| 57/2 |
2026/05/24 10:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_init]
Results: map[SourceCode:2063: static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
2064: struct netlink_ext_ack *extack)
2065: {
2066: struct taprio_sched *q = qdisc_priv(sch);
2067: struct net_device *dev = qdisc_dev(sch);
2068: int i, tc;
2069:
2070: spin_lock_init(&q->current_entry_lock);
2071:
2072: hrtimer_setup(&q->advance_timer, advance_sched, CLOCK_TAI, HRTIMER_MODE_ABS);
2073:
2074: q->root = sch;
2075:
2076: /* We only support static clockids. Use an invalid value as default
2077: * and get the valid one on taprio_change().
2078: */
2079: q->clockid = -1;
2080: q->flags = TAPRIO_FLAGS_INVALID;
2081:
2082: list_add(&q->taprio_list, &taprio_list);
2083:
2084: if (sch->parent != TC_H_ROOT) {
2085: NL_SET_ERR_MSG_MOD(extack, "Can only be attached as root qdisc");
2086: return -EOPNOTSUPP;
2087: }
2088:
2089: if (!netif_is_multiqueue(dev)) {
2090: NL_SET_ERR_MSG_MOD(extack, "Multi-queue device is required");
2091: return -EOPNOTSUPP;
2092: }
2093:
2094: q->qdiscs = kzalloc_objs(q->qdiscs[0], dev->num_tx_queues);
2095: if (!q->qdiscs)
2096: return -ENOMEM;
2097:
2098: if (!opt)
2099: return -EINVAL;
2100:
2101: for (i = 0; i < dev->num_tx_queues; i++) {
2102: struct netdev_queue *dev_queue;
2103: struct Qdisc *qdisc;
2104:
2105: dev_queue = netdev_get_tx_queue(dev, i);
2106: qdisc = qdisc_create_dflt(dev_queue,
2107: &pfifo_qdisc_ops,
2108: TC_H_MAKE(TC_H_MAJ(sch->handle),
2109: TC_H_MIN(i + 1)),
2110: extack);
2111: if (!qdisc)
2112: return -ENOMEM;
2113:
2114: if (i < dev->real_num_tx_queues)
2115: qdisc_hash_add(qdisc, false);
2116:
2117: q->qdiscs[i] = qdisc;
2118: }
2119:
2120: for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++)
2121: q->fp[tc] = TC_FP_EXPRESS;
2122:
2123: taprio_detect_broken_mqprio(q);
2124:
2125: return taprio_change(sch, opt, extack);
2126: }
SourceFile:net/sched/sch_taprio.c]
|
| 58/2 |
2026/05/24 10:29 |
llm |
expert |
0m
Model:
Tokens:
input: 49095
output: 66
thoughts: 2245
Thoughts: **My Analysis of the `taprio` Qdisc Bug**
Okay, so I've been digging into this `taprio` qdisc code, and here's what I'm thinking: first, no immediate red flags in `taprio_init`. Good. Ah, but wait, `taprio` needs a multi-queue device. Let me check... the code specifically enforces that:
```c
if (!netif_is_multiqueue(dev)) {
NL_SET_ERR_MSG_MOD(extack, "Multi-queue device is required");
return -EOPNOTSUPP;
}
```
Is `veth` multi-queue? Yes! We can create it with multiple queues: `ip link add type veth numtxqueues 4 numrxqueues 4`. Good, that requirement is satisfied. How about `tun`? Yep, `tun` supports `IFF_MULTI_QUEUE`, and same goes for `dummy`. So that's easily handled inside a user namespace.
Let's see if there are other roadblocks. Okay, this check seems standard:
```c
if (sch->parent != TC_H_ROOT) {
NL_SET_ERR_MSG_MOD(extack, "Can only be attached as root qdisc");
return -EOPNOTSUPP;
}
```
No problem; we *can* attach it as root.
Time to revisit `taprio_change`. I don't need full offload, so I'm not enabling `TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD`. The code uses a software timer in the absence of full offload.
```c
if (!TXTIME_ASSIST_IS_ENABLED(q->flags) &&
!FULL_OFFLOAD_IS_ENABLED(q->flags) &&
!hrtimer_active(&q->advance_timer)) {
hrtimer_setup(&q->advance_timer, advance_sched, q->clockid, HRTIMER_MODE_ABS);
}
```
This sets up the `hrtimer`.
So, it looks like this is fully reachable from a user namespace. The impact? Denial of Service β RCU stall, soft lockup, system freeze. Okay, let's explore some dimensions.
- VM Guest Trigger: Nope, not relevant.
- VM Host Trigger: No.
- Ethernet Network Trigger: Nope. It's about configuring the qdisc, not packet arrival.
- Other Remote Trigger: No.
- Peripheral Trigger: No.
- Malicious Filesystem Trigger: No.
Hold on... could network traffic *contribute*? If the qdisc is configured with a small interval, could receiving or sending packets make it worse? No, the timer runs independently. The timer's started during configuration. It's the configuration itself that triggers it.
Let's be *absolutely* sure there's no memory corruption. The timer loop increments `end_time` and re-enqueues the timer. Is it accessing freed memory? No, the qdisc is active, the timer is part of it. If the qdisc is destroyed, the timer is canceled:
```c
static void taprio_destroy(struct Qdisc *sch)
{
struct taprio_sched *q = qdisc_priv(sch);
...
hrtimer_cancel(&q->advance_timer);
...
}
```
So, no use-after-free. Just an infinite loop or exponential blowup in the timer interrupt.
Okay, let's nail down the core of the bug. In `sch_taprio`, the `advance_sched` timer callback calculates the next expiration time by adding `entry->interval` to the current `end_time`. The `interval` is validated to be at least `min_duration`, which is calculated based on the device's link speed. Here's where it gets interesting: if the device has a very high link speed (like a `tun` device with the speed set to the maximum possible value, or a `veth` device which defaults to a high speed), `min_duration` can be tiny (1 ns or 48 ns!). This allows a user to configure a *ridiculously* small `interval`. When the timer fires, `advance_sched` increments the expiration time by this minimal `interval` and returns `HRTIMER_RESTART`. Because the increment is so small, the new expiration time may still be in the past relative to the current time. The hrtimer subsystem then repeatedly executes the timer callback in a loop to catch up. Since the callback's execution time is *larger
|
| 59/2 |
2026/05/24 10:30 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 60/2 |
2026/05/24 10:30 |
llm |
expert |
0m
Model:
Tokens:
input: 52495
output: 714
thoughts: 247
Thoughts: **Final Response Formulation**
Okay, the data is locked down, and I'm ready to craft the final response. My analysis of the bug indicates a pretty nasty denial-of-service vulnerability in the `sch_taprio` qdisc implementation. Here's what's happening, as I understand it:
Essentially, the root of the problem lies in how `sch_taprio` determines the minimum allowable `interval` for a scheduling entry. For high-speed virtual devices like `veth` and `tun`, it calculates a minimum interval that is shockingly small, like 1 nanosecond.
The trigger is straightforward: a user deliberately, or perhaps accidentally through misconfiguration, sets the `taprio` qdisc with an extremely low `interval` value, such as 1 nanosecond. This seems like a reasonable thing for someone to do who is configuring network quality of service.
The consequence is dire. The `advance_sched` hrtimer callback, which is responsible for managing the schedule, increments the timer's expiration by this ridiculously tiny `interval` and restarts the timer. The key flaw is that the time it takes to execute that callback is significantly *larger* than the very small `interval`. Because of this, the timer's expiration never catches up to the current time, leading to an infinite loop within the hrtimer subsystem. The cascading effect is an RCU stall and ultimately a soft lockup.
The impact is clearly a Denial of Service. In a worst-case scenario, this means the system becomes unresponsive.
Perhaps even more concerning is the attack vector. An unprivileged user can exploit this vulnerability with minimal effort by creating a user namespace and a network namespace, creating a `veth` or `tun` device, and configuring the `taprio` qdisc. This is pretty low-hanging fruit for a bad actor.
|
| 61/1 |
2026/05/24 10:30 |
action |
format-explanation |
0m
Results: map[Explanation:Based on the analysis of the bug report and the kernel source code, here is the
assessment of the vulnerability:
### Root Cause Analysis
The bug is an infinite loop / CPU stall in the `advance_sched` hrtimer callback
of the `sch_taprio` network scheduler.
When configuring the `taprio` qdisc, the kernel validates the `interval` of
schedule entries to ensure it is large enough to transmit a minimum-sized
Ethernet frame (`ETH_ZLEN`). This minimum duration is calculated based on the
network device's link speed (`picos_per_byte`).
For devices with very high link speedsβsuch as `veth` (which defaults to 10000
Mbps) or `tun` (which can be configured to arbitrary speeds up to `0x7fffffff`
via ethtool)βthe calculated `min_duration` can be extremely small, down to just
`1 ns` (or `48 ns` for `veth`).
If a user configures the `taprio` qdisc with such a small `interval`, the
`advance_sched` timer callback will increment the timer's next expiration time
by only `1 ns` (or `48 ns`) and return `HRTIMER_RESTART`. Because the execution
time of the `advance_sched` function and the hrtimer subsystem overhead is
significantly larger than this tiny interval, the timer's expiration time will
never catch up to the current time (`basenow`).
This causes the hrtimer subsystem to repeatedly execute the timer callback in an
infinite loop (or an exponentially growing loop) in hardirq context, completely
starving the CPU. This leads to the observed RCU stall, soft lockup, and a
complete system freeze.
### Security Impact
* **Exploitable:** **No.** The bug is a pure logic error leading to an infinite
loop in interrupt context. It does not cause memory corruption, out-of-bounds
accesses, or use-after-free conditions. Therefore, it cannot be exploited for
arbitrary code execution or privilege escalation.
* **Denial Of Service:** **Yes.** Triggering the bug causes the CPU to be
permanently stuck in an interrupt context loop, leading to an RCU stall, soft
lockups, and a system crash/freeze.
* **Accessible From Unprivileged Processes:** **No.** Configuring network
schedulers (qdiscs) requires `CAP_NET_ADMIN` capabilities, which a standard
unprivileged user does not have in the initial network namespace.
* **Accessible From User Namespaces:** **Yes.** An unprivileged user can create
a new user namespace and a new network namespace, gaining `CAP_NET_ADMIN` within
that namespace. They can then create a `veth` or `tun` device and attach the
malicious `taprio` qdisc configuration to it, successfully triggering the Denial
of Service on the host.
* **VM Guest Trigger:** **No.** This is a network scheduler bug, not related to
virtualization or KVM guest exits.
* **VM Host Trigger in The Confidential Computing Context:** **No.**
* **Ethernet Network Trigger:** **No.** The bug is triggered synchronously
during the configuration of the qdisc and the subsequent timer execution, not by
processing ingress network traffic.
* **Other Remote Trigger:** **No.**
* **Peripheral Trigger:** **No.**
* **Malicious Filesystem Trigger:** **No.**]
|