Netdev List
 help / color / mirror / Atom feed
* [PATCH net v4 0/3] net/sched: act_gate: bound the cycle time and refuse schedule entries shorter than 10 us
@ 2026-11-24 14:12 Jamal Hadi Salim
  2026-11-24 14:12 ` [PATCH net v4 1/3] net/sched: act_gate: bound the cycle time and start time arithmetic Jamal Hadi Salim
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jamal Hadi Salim @ 2026-11-24 14:12 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Jiri Pirko, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Alexei Starovoitov, linux-rt-devel, Victor Nogueira,
	Edward Adam Davis, Po Liu, Shuah Khan, linux-kselftest, stable,
	syzbot+0054fed3dc9085390f51, shaos, sashiko-bot

An act_gate schedule is armed from TCA_GATE_BASE_TIME and
TCA_GATE_CYCLE_TIME, both unchecked u64 attributes that are read into a
signed ktime_t.  A cycle time above S64_MAX turns negative on that read
and the cycle arithmetic that follows wraps.

That arms the timer in the past.  Every expiry then recomputes the same
past time, so the timer softirq never finishes and the task that
installed the action spins until the watchdog reports a soft lockup.

A schedule entry of a few nanoseconds reaches the same state from the
other direction: the entry interval is the period the hrtimer runs at, so
the handler is always behind its own next expiry and the action holds a
core for as long as it exists.

  1/3  cap base_time and cycle_time at KTIME_MAX, and make every
       start-time computation saturate instead of wrapping.
  2/3  require at least 10 us per schedule entry.
  3/3  cover the refusals, the largest accepted base time and cycle time,
       and both sides of the interval boundary in the tdc action tests.

Edward Adam Davis posted a v3 that capped cycle_time at S64_MAX and moved
the attribute to NLA_S64.  That refuses the reported value but leaves the
invariant to the wrap: base_time is read the same way into the same
arithmetic and stays unbounded, so an accepted pair can still compute a
start the timer was never meant to take.  The type change is also
unnecessary; S64_MAX is a fine range for NLA_U64.

Alexei Starovoitov traced the stall to this action on the syzbot thread
and sketched the saturating arithmetic used here:
https://lore.kernel.org/netdev/DN37NBGPJJG9.2DSVDCKS3UYTV@gmail.com/

This series keeps NLA_U64 for both attributes and bounds the computed
start time rather than one input's value.  cycle_time = 0 stays accepted:
it means "derive the cycle from the entry intervals".

The 10 us entry floor comes from the measured cost of one expiry rather
than a device's frame time, and 2/3 states the margin it leaves.  The
100 us floor proposed for taprio was withdrawn for narrowing working uAPI
and for a margin it never explained; this floor answers both.

Changes in v4:
- Reworked as a three-patch series on the current net tree.
- Bound base_time and cycle_time at KTIME_MAX, keeping NLA_U64.
- Saturating start-time arithmetic, shared with the catch-up path.
- Minimum entry interval, with its measured cost and its tdc coverage.

v1 -> v2: reject an out-of-range cycletime instead of clamping it.
v2 -> v3: move the range check into the netlink policy.

Jamal Hadi Salim (3):
  net/sched: act_gate: bound the cycle time and start time arithmetic
  net/sched: act_gate: refuse schedule entries shorter than 10 us
  selftests: tc-testing: act_gate: cover the new cycle time and interval
    limits

 net/sched/act_gate.c                          |  45 +++--
 .../tc-testing/tc-tests/actions/gate.json     | 189 ++++++++++++++++++
 2 files changed, 217 insertions(+), 17 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-24 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 14:12 [PATCH net v4 0/3] net/sched: act_gate: bound the cycle time and refuse schedule entries shorter than 10 us Jamal Hadi Salim
2026-11-24 14:12 ` [PATCH net v4 1/3] net/sched: act_gate: bound the cycle time and start time arithmetic Jamal Hadi Salim
2026-11-24 14:12 ` [PATCH net v4 2/3] net/sched: act_gate: refuse schedule entries shorter than 10 us Jamal Hadi Salim
2026-11-24 14:12 ` [PATCH net v4 3/3] selftests: tc-testing: act_gate: cover the new cycle time and interval limits Jamal Hadi Salim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox