mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v3 0/7] net/sched: act_gate RCU schedule update fixes
@ 2026-01-21 13:20 Paul Moses
  2026-01-21 13:20 ` [PATCH net v3 1/7] net/sched: act_gate: zero-initialize netlink dump struct Paul Moses
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Paul Moses @ 2026-01-21 13:20 UTC (permalink / raw)
  To: netdev
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	linux-kernel, Paul Moses

This series fixes a schedule lifetime race in `act_gate` between the
control-plane replace path and the running hrtimer callback (gate_timer_func).

Before this series, a gate action could be replaced via
`RTM_NEWACTION | NLM_F_REPLACE` while its hrtimer was armed or executing.
The replace path frees the existing schedule entries immediately, but
the timer callback may concurrently dereference and walk the old entry
list to compute the next expiry. This allows the timer to observe freed
memory, leading to UAF or NULL dereference depending on timing and reuse.

The fix publishes gate configuration updates using an RCU snapshot
pattern. A new parameter set (including the schedule list) is fully
constructed first and then swapped in atomically via an RCU-protected
pointer. Readers (timer, dump, and accessors) only dereference the
current snapshot under RCU, and the old snapshot is reclaimed via
`call_rcu()` after the swap. This ensures the timer never observes freed
or partially invalid schedules during a replace.

Additional hardening included in this series:

* Zero-initialize the netlink dump struct to avoid leaking stack padding
* Reject empty schedule lists, which result in undefined runtime behavior
* Guard against NULL parameters in accessors during teardown
* Cancel the hrtimer outside `tcf_lock` to avoid lock inversion with the
  timer callback; cancellation is limited to clockid changes to avoid
  unnecessary blocking

Stable relevance:

* Fixes UAF / NULL deref hazards when a gate action is replaced while the
  timer, dump, or accessors are active
* Fixes a potential deadlock when canceling the hrtimer under `tcf_lock`
* Fixes a padding information leak in netlink dumps
* Dependency chain: patches 2–7 build on patch 1 and on each other

Changes since v2:
* Split patch into logical steps
* Split hardening into explicit empty-schedule rejection and NULL
  accessor guards
* Align `tcf_gate_init()` initialization with net/sched conventions
* Cancel the hrtimer only when the clockid changes on replace
* Allow basetime to advance correctly on REPLACE
* Make `tcf_gate_copy_entries()` leave cleanup to the caller on failure
* Initialize `parse_gate_list()` error handling defensively

Paul Moses (7):
  net/sched: act_gate: zero-initialize netlink dump struct
  net/sched: act_gate: add RCU support for parameter update
  net/sched: act_gate: build schedule and RCU-swap
  net/sched: act_gate: read schedule via RCU
  net/sched: act_gate: cancel timer outside tcf_lock
  net/sched: act_gate: reject empty schedule list
  net/sched: act_gate: guard NULL params in accessors

 include/net/tc_act/tc_gate.h |  65 ++++++--
 net/sched/act_gate.c         | 295 ++++++++++++++++++++++++++---------
 2 files changed, 268 insertions(+), 92 deletions(-)

-- 
2.52.GIT


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

end of thread, other threads:[~2026-02-02 12:44 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 13:20 [PATCH net v3 0/7] net/sched: act_gate RCU schedule update fixes Paul Moses
2026-01-21 13:20 ` [PATCH net v3 1/7] net/sched: act_gate: zero-initialize netlink dump struct Paul Moses
2026-01-21 13:25   ` Eric Dumazet
2026-01-21 13:39     ` Paul Moses
2026-01-21 13:48       ` Eric Dumazet
2026-01-21 14:01         ` Paul Moses
2026-01-21 14:03           ` Eric Dumazet
2026-01-21 15:26             ` Paul Moses
2026-01-21 15:46               ` Eric Dumazet
2026-01-21 13:20 ` [PATCH net v3 2/7] net/sched: act_gate: add RCU support for parameter update Paul Moses
2026-01-21 19:42   ` Victor Nogueira
2026-01-22 15:51     ` Paul Moses
2026-01-21 13:20 ` [PATCH net v3 3/7] net/sched: act_gate: build schedule and RCU-swap Paul Moses
2026-01-21 19:43   ` Victor Nogueira
2026-01-21 13:20 ` [PATCH net v3 4/7] net/sched: act_gate: read schedule via RCU Paul Moses
2026-01-21 19:44   ` Victor Nogueira
2026-01-21 13:20 ` [PATCH net v3 5/7] net/sched: act_gate: cancel timer outside tcf_lock Paul Moses
2026-01-21 13:20 ` [PATCH net v3 6/7] net/sched: act_gate: reject empty schedule list Paul Moses
2026-01-21 19:44   ` Victor Nogueira
2026-01-21 21:48     ` Victor Nogueira
2026-01-26  8:53       ` Paul Moses
2026-01-26 12:05         ` Victor Nogueira
2026-01-31 15:00           ` Paul Moses
2026-02-02 12:44             ` Victor Nogueira
2026-01-21 13:21 ` [PATCH net v3 7/7] net/sched: act_gate: guard NULL params in accessors Paul Moses
2026-01-21 19:47   ` Victor Nogueira

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

all inboxes | Powered by JetHome®