Skip to content

net/sched: defer qdisc freeing after failed creation

Weiming Shi lkml netdev 1 version Applied

Status from this message: This patch was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest1 patch 0 repliesApplied 1/1

Changes in v2 from the cover letter

- inline qdisc_free() into qdisc_free_cb()
- use qdisc_free_rcu() for normal and failed-construction teardown
- retain Fixes: 51ab2994c387 as requested
- credit the earlier security-list reporter

[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/CAC_etQFk%[email protected]/

Patches in v2 All 1 applied

#Subject and filesSizeRepliesApplied
1/1net/sched: defer qdisc freeing after failed creationinclude/net/sch_generic.h net/sched/sch_api.c net/sched/sch_generic.c+12 -120 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH net v2 0/1] net/sched: defer qdisc freeing after failed creation

This is v2 of the qdisc failed-creation lifetime fix posted by Kyle Zeng and David Lee [1]. The public reproducer is available in a follow-up message [2].

When clsact binds a populated shared ingress block, ->init() can publish an embedded mini_Qdisc before qdisc_create() completes. A later invalid TCA_RATE makes estimator setup fail. The unwind removes the published pointer but frees the containing qdisc synchronously while tc_run() can still hold it.

The fix itself is unchanged: failed qdiscs are retired through RCU.

With the public reproducer from [2], the vulnerable kernel reports a KASAN UAF in tc_run(), with the free in qdisc_create(). The same test completes without a KASAN report on v2.

Changes in v2:
- inline qdisc_free() into qdisc_free_cb()
- use qdisc_free_rcu() for normal and failed-construction teardown
- retain Fixes: 51ab2994c387 as requested
- credit the earlier security-list reporter

[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/CAC_etQFk%[email protected]/

Weiming Shi (1):
net/sched: defer qdisc freeing after failed creation

 include/net/sch_generic.h |  2 +-
 net/sched/sch_api.c       |  2 +-
 net/sched/sch_generic.c   | 20 ++++++++++----------
 3 files changed, 12 insertions(+), 12 deletions(-)