From: Dickson Wu <dick…@certik.com>
In txtime-assist mode, find_entry_to_transmit() compares a packet's
transmission time with the configured entry interval. A cycle can end
an entry earlier, leaving a window shorter than the packet. The
function still selects that entry, and get_packet_txtime() retries
one cycle at a time while holding the qdisc lock. It never finds a
window that fits.
The search also considers an entry starting exactly at the cycle end,
even though the schedule restarts at its first entry there. Stop the
search at the cycle boundary and compare against the usable window.
A packet that fits no active entry then takes the existing drop path.
An unprivileged user can trigger the lockup in a user and network
namespace with one packet. A peer can trigger it by eliciting a large
reply when the host has such a schedule configured.
A reproducer is available on request.
Fixes: 4cfd5779bd6e ("taprio: Add support for txtime-assist mode")
Signed-off-by: Dickson Wu <dick…@certik.com>
---
Tested on net e9d78fc6741a in KVM (x86_64), as an unprivileged user in
a user namespace:
- one taprio entry cut short by the cycle time, txtime-assist mode, one
1400-byte send: base stalls in find_entry_to_transmit() with an RCU
stall report; patched drops the packet and the guest stays responsive.
- two-entry schedule, large ping from a peer: base stalls; patched
answers a small ping and drops the large reply.
- equal-cycle controls transmit normally on both kernels.
- tdc taprio tests: same results on both kernels (10 pass, 2 fail
because CBS is unavailable in the guest, 2 skip).
- W=1 build of sch_taprio.o, no warnings.
A dropped GSO segment is still counted twice in the qdisc drop stats:
taprio_enqueue_segmented() adds a drop after qdisc_drop() already
counted it. That predates this patch (it happens for segments over
max_sdu or longer than every entry) and is left for a separate fix.
This was found and the fix prepared with AI coding tools (OpenAI Codex
agents, with review by Claude). I went over the analysis and the patch
before signing off.
net/sched/sch_taprio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 4f69ef3d847a..ee8a8a7022f8 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -364,11 +364,11 @@ static struct sched_entry *find_entry_to_transmit(struct sk_buff *skb,
curr_intv_end = get_interval_end_time(sched, admin, entry,
curr_intv_start);
- if (ktime_after(curr_intv_start, cycle_end))
+ if (!ktime_before(curr_intv_start, cycle_end))
break;
if (!(entry->gate_mask & BIT(tc)) ||
- packet_transmit_time > entry->interval)
+ packet_transmit_time > ktime_sub(curr_intv_end, curr_intv_start))
continue;
txtime = entry->next_txtime;
--
2.43.0