net/sched: act_gate RCU schedule update fixes
Get series with b4
b4 am [email protected]Versions newest first
- v3 Latest7 patches 18 repliesIn review
Changes in v3 from the cover letter
* 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
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | net/sched: act_gate: zero-initialize netlink dump structnet/ | +5 | 7 replies | |
| 2/7 | net/sched: act_gate: add RCU support for parameter updateinclude/ net/ | +69 | 2 replies | |
| 3/7 | net/sched: act_gate: build schedule and RCU-swapnet/ | +140 | 1 reply | |
| 4/7 | net/sched: act_gate: read schedule via RCUinclude/ net/ | +40 | 1 reply | |
| 5/7 | net/sched: act_gate: cancel timer outside tcf_locknet/ | +24 | 0 replies | |
| 6/7 | net/sched: act_gate: reject empty schedule listnet/ | +6 | 6 replies | |
| 7/7 | net/sched: act_gate: guard NULL params in accessorsinclude/ net/ | +32 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH net v3 0/7] net/sched: act_gate RCU schedule update fixes
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(-)
Signature · 1 line
2.52.GIT