Skip to contentSkip to conversation

net/sched: defer qdisc freeing after failed creation

PATCH In review David Lee 3 participants 8 messages Aug 5 – Aug 19

Subsystems (3)
lore
Share & tools
lore

David Lee

author
#0 lore raw

PATCH 1/1 net/sched: defer qdisc freeing after failed creation

From: Kyle Zeng <[email protected]>

A qdisc's init callback can publish state to RCU readers before qdisc_create() completes. In particular, clsact_init() binds a populated shared ingress block and installs an embedded mini_Qdisc in dev->tcx_ingress. If subsequent rate estimator setup fails, the unwind removes that pointer but qdisc_free() immediately releases the qdisc and its per-CPU statistics. A reader that obtained the miniq before removal can then access freed memory.

Add qdisc_free_rcu() and use it for the creation error path, matching normal qdisc destruction. This keeps the embedded miniq and the per-CPU statistics alive until pre-existing readers complete.

Fixes 51ab2994c387 ("net: sched: allow ingress and clsact qdiscs to share filter blocks")
Assisted-by Codex:gpt-5.6-sol Codex:gpt-5.5-cyber

---
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.

Trail of Bits has a reproducer for this bug that triggers a KASAN use-after-free and can share if needed.

 include/net/sch_generic.h | 1 +
 net/sched/sch_api.c       | 2 +-
 net/sched/sch_generic.c   | 7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
include/net/sch_generic.h +1 -0
index 45a1e8c782..d45442c926 100644
@@ -793,6 +793,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
 			  const struct Qdisc_ops *ops,
 			  struct netlink_ext_ack *extack);
 void qdisc_free(struct Qdisc *qdisc);
+void qdisc_free_rcu(struct Qdisc *qdisc);
 struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
 				const struct Qdisc_ops *ops, u32 parentid,
 				struct netlink_ext_ack *extack);
net/sched/sch_api.c +1 -1
index 668bcd60d1..041bd60072 100644
@@ -1373,7 +1373,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
 err_out3:
 	qdisc_lock_uninit(sch, ops);
 	netdev_put(dev, &sch->dev_tracker);
-	qdisc_free(sch);
+	qdisc_free_rcu(sch);
 err_out2:
 	bpf_module_put(ops, ops->owner);
 err_out:
net/sched/sch_generic.c +6 -1
index ef2b4bf515..86d551fbab 100644
@@ -1103,6 +1103,11 @@ static void qdisc_free_cb(struct rcu_head *head)
 	qdisc_free(q);
 }
 
+void qdisc_free_rcu(struct Qdisc *qdisc)
+{
+	call_rcu(&qdisc->rcu, qdisc_free_cb);
+}
+
 static void __qdisc_destroy(struct Qdisc *qdisc)
 {
 	const struct Qdisc_ops  *ops = qdisc->ops;
@@ -1127,7 +1132,7 @@ static void __qdisc_destroy(struct Qdisc *qdisc)
 
 	trace_qdisc_destroy(qdisc);
 
-	call_rcu(&qdisc->rcu, qdisc_free_cb);
+	qdisc_free_rcu(qdisc);
 }
 
 void qdisc_destroy(struct Qdisc *qdisc)
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 11 lines · David Lee

From: Kyle Zeng <[email protected]>

A qdisc's init callback can publish state to RCU readers before qdisc_create() completes. In particular, clsact_init() binds a populated shared ingress block and installs an embedded mini_Qdisc in dev->tcx_ingress. If subsequent rate estimator setup fails, the unwind removes that pointer but qdisc_free() immediately releases the qdisc and its per-CPU statistics. A reader that obtained the miniq before removal can then access freed memory.

Quoted 8 lines

Add qdisc_free_rcu() and use it for the creation error path, matching normal qdisc destruction. This keeps the embedded miniq and the per-CPU statistics alive until pre-existing readers complete.

Fixes 51ab2994c387 ("net: sched: allow ingress and clsact qdiscs to share filter blocks")
Assisted-by Codex:gpt-5.6-sol Codex:gpt-5.5-cyber

Thanks for finding the issue. But you should know the deal by now, send the poc - you can send it in private. Same goes for your other patch.

cheers,
jamal

Quoted 64 lines

---
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.

Trail of Bits has a reproducer for this bug that triggers a KASAN use-after-free and can share if needed.

 include/net/sch_generic.h | 1 +
 net/sched/sch_api.c       | 2 +-
 net/sched/sch_generic.c   | 7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
include/net/sch_generic.h +1 -0
index 45a1e8c782..d45442c926 100644
@@ -793,6 +793,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
                          const struct Qdisc_ops *ops,
                          struct netlink_ext_ack *extack);
 void qdisc_free(struct Qdisc *qdisc);
+void qdisc_free_rcu(struct Qdisc *qdisc);
 struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
                                const struct Qdisc_ops *ops, u32 parentid,
                                struct netlink_ext_ack *extack);
net/sched/sch_api.c +1 -1
index 668bcd60d1..041bd60072 100644
@@ -1373,7 +1373,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
 err_out3:
        qdisc_lock_uninit(sch, ops);
        netdev_put(dev, &sch->dev_tracker);
-       qdisc_free(sch);
+       qdisc_free_rcu(sch);
 err_out2:
        bpf_module_put(ops, ops->owner);
 err_out:
net/sched/sch_generic.c +6 -2
index ef2b4bf515..86d551fbab 100644
@@ -1103,6 +1103,11 @@ static void qdisc_free_cb(struct rcu_head *head)
        qdisc_free(q);
 }
 
+void qdisc_free_rcu(struct Qdisc *qdisc)
+{
+       call_rcu(&qdisc->rcu, qdisc_free_cb);
+}
+
 static void __qdisc_destroy(struct Qdisc *qdisc)
 {
        const struct Qdisc_ops  *ops = qdisc->ops;
@@ -1127,7 +1132,7 @@ static void __qdisc_destroy(struct Qdisc *qdisc)
 
        trace_qdisc_destroy(qdisc);
 
-       call_rcu(&qdisc->rcu, qdisc_free_cb);
+       qdisc_free_rcu(qdisc);
 }
 
 void qdisc_destroy(struct Qdisc *qdisc)
--

2.53.0

author
#2 lore raw

Hi Jamal,

I have attached the reproducer and satnizer logs here:

---

[  230.057740] ipip: IPv4 and MPLS over IPv4 tunneling driver
[  231.667279]
==================================================================
[  231.667738] BUG: KASAN: stack-out-of-bounds in
__ip_options_echo+0xdf7/0x1860
[  231.667738] Write of size 255 at addr ffffc9000029f008 by task
ksoftirqd/3/37
[  231.667738]
[  231.667738] CPU: 3 UID: 0 PID: 37 Comm: ksoftirqd/3 Not tainted
7.2.0-rc3-kasan #1 PREEMPT(lazy)
[  231.667738] Hardware name: QEMU Ubuntu 26.04 PC (i440FX + PIIX, 1996),
BIOS 1.17.0-debian-1.17.0-1ubuntu1 04/01/2014
[  231.667738] Call Trace:
[  231.667738]  <TASK>
[  231.667738]  dump_stack_lvl+0x5f/0x90
[  231.667738]  print_report+0x15b/0x4ec
[  231.667738]  ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[  231.667738]  ? kasan_addr_to_slab+0xd/0x80
[  231.667738]  kasan_report+0xf2/0x130
[  231.667738]  ? __ip_options_echo+0xdf7/0x1860
[  231.667738]  ? __ip_options_echo+0xdf7/0x1860
[  231.667738]  kasan_check_range+0x13a/0x230
[  231.667738]  __asan_memcpy+0x3b/0x80
[  231.667738]  __ip_options_echo+0xdf7/0x1860
[  231.667738]  ? __pfx___ip_options_echo+0x10/0x10
[  231.667738]  __icmp_send+0x8c5/0x26e0
[  231.667738]  ? __pfx___icmp_send+0x10/0x10
[  231.667738]  ? sysvec_apic_timer_interrupt+0x54/0xd0
[  231.667738]  ? __pfx_nf_reject_fill_skb_dst+0x10/0x10 [nf_reject_ipv4]
[  231.667738]  ? _raw_spin_lock+0x82/0xf0
[  231.667738]  ? irqentry_exit+0x1cd/0x7b0
[  231.667738]  nf_send_unreach+0x303/0x810 [nf_reject_ipv4]
[  231.667738]  ? __pfx_nf_send_unreach+0x10/0x10 [nf_reject_ipv4]
[  231.667738]  nft_reject_inet_eval+0x4cd/0x8a0 [nft_reject_inet]
[  231.667738]  ? nft_do_chain+0x45a/0x1ae0 [nf_tables]
[  231.667738]  nft_do_chain+0x25a/0x1ae0 [nf_tables]
[  231.667738]  ? __pfx_tcp_v4_rcv+0x10/0x10
[  231.667738]  ? raw_local_deliver+0x3b9/0xc80
[  231.667738]  ? __pfx_nft_do_chain+0x10/0x10 [nf_tables]
[  231.667738]  ? update_stack_state+0x26e/0x6a0
[  231.667738]  ? fib_validate_source+0x455/0x770
[  231.667738]  ? update_stack_state+0x26e/0x6a0
[  231.667738]  nft_do_chain_inet_ingress+0x44f/0x1420 [nf_tables]
[  231.667738]  ? __pfx_nft_do_chain_inet_ingress+0x10/0x10 [nf_tables]
[  231.667738]  ? unwind_next_frame+0x18a/0xac0
[  231.667738]  nf_hook_slow+0xaa/0x1f0
[  231.667738]  __netif_receive_skb_core.constprop.0+0x19b6/0x31e0
[  231.667738]  ? __pfx_read_hpet+0x10/0x10
[  231.667738]  ? ret_from_fork_asm+0x1a/0x30
[  231.667738]  ? __pfx___netif_receive_skb_core.constprop.0+0x10/0x10
[  231.667738]  ? clockevents_program_event+0x2bd/0x750
[  231.667738]  ? run_ksoftirqd+0x3a/0x60
[  231.667738]  ? kasan_save_stack+0x4e/0x70
[  231.667738]  ? __kasan_check_write+0x14/0x30
[  231.667738]  ? _raw_spin_lock+0x82/0xf0
[  231.667738]  ? __hrtimer_rearm_deferred+0x18a/0x520
[  231.667738]  __netif_receive_skb_list_core+0x314/0xb10
[  231.667738]  ? sysvec_apic_timer_interrupt+0x54/0xd0
[  231.667738]  ? __pfx___netif_receive_skb_list_core+0x10/0x10
[  231.667738]  ? kasan_save_track+0x27/0x70
[  231.667738]  netif_receive_skb_list_internal+0x5eb/0xde0
[  231.667738]  ? __kasan_check_write+0x14/0x30
[  231.667738]  ? __pfx_netif_receive_skb_list_internal+0x10/0x10
[  231.667738]  ? __pfx_napi_complete_done+0x10/0x10
[  231.667738]  ? __pfx_dql_completed+0x10/0x10
[  231.667738]  ? __kasan_check_read+0x11/0x20
[  231.667738]  ? dev_gro_receive+0x20d/0x3060
[  231.667738]  napi_complete_done+0x1b6/0x830
[  231.667738]  ? pick_eevdf+0x19b/0x7e0
[  231.667738]  ? __pfx_napi_complete_done+0x10/0x10
[  231.667738]  ? gro_receive_skb+0x292/0xa90
[  231.667738]  gro_cell_poll+0x120/0x1f0
[  231.667738]  __napi_poll+0xa3/0x4c0
[  231.667738]  net_rx_action+0x4c1/0xfb0
[  231.667738]  ? __pfx_net_rx_action+0x10/0x10
[  231.667738]  ? finish_task_switch.isra.0+0x1f1/0xc10
[  231.667738]  ? __switch_to+0x8d7/0xd40
[  231.667738]  handle_softirqs+0x1ae/0x670
[  231.667738]  ? __pfx_handle_softirqs+0x10/0x10
[  231.667738]  run_ksoftirqd+0x3a/0x60
[  231.667738]  smpboot_thread_fn+0x29d/0x6e0
[  231.667738]  ? __pfx_smpboot_thread_fn+0x10/0x10
[  231.667738]  kthread+0x333/0x420
[  231.667738]  ? calculate_sigpending+0x78/0xb0
[  231.667738]  ? __pfx_kthread+0x10/0x10
[  231.667738]  ret_from_fork+0x426/0x7c0
[  231.667738]  ? __pfx_ret_from_fork+0x10/0x10
[  231.667738]  ? native_load_gs_index+0x3f/0x60
[  231.667738]  ? __switch_to+0x8d7/0xd40
[  231.667738]  ? __switch_to_asm+0x39/0x70
[  231.667738]  ? __pfx_kthread+0x10/0x10
[  231.667738]  ret_from_fork_asm+0x1a/0x30
[  231.667738]  </TASK>
[  231.667738]
[  231.667738] The buggy address belongs to stack of task ksoftirqd/3/37
[  231.667738]  and is located at offset 376 in frame:
[  231.667738]  __icmp_send+0x0/0x26e0
[  231.667738]
[  231.667738] This frame has 7 objects:
[  231.667738]  [32, 33) 'apply_ratelimit'
[  231.667738]  [48, 49) '_inner_type'
[  231.667738]  [64, 68) 'data'
[  231.667738]  [80, 88) 'rt'
[  231.667738]  [112, 168) 'ipc'
[  231.667738]  [208, 264) 'fl4'
[  231.667738]  [304, 416) 'icmp_param_u'
[  231.667738]
[  231.667738] The buggy address belongs to a vmalloc virtual mapping
[  231.667738] The buggy address belongs to the physical page:
[  231.667738] page: refcount:1 mapcount:0 mapping:0000000000000000
index:0x0 pfn:0x100c1f
[  231.667738] flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff)
[  231.667738] raw: 0017ffffc0000000 ffffea00040307c8 ffffea00040307c8
0000000000000000
[  231.667738] raw: 0000000000000000 0000000000000000 00000001ffffffff
0000000000000000
[  231.667738] page dumped because: kasan: bad access detected
[  231.667738]
[  231.667738] Memory state around the buggy address:
[  231.667738]  ffffc9000029ef00: 00 00 00 00 00 00 00 f2 f2 f2 f2 f2 00 00
00 00
[  231.667738]  ffffc9000029ef80: 00 00 00 f2 f2 f2 f2 f2 00 00 00 00 00 00
00 00
[  231.667738] >ffffc9000029f000: 00 00 00 00 00 00 f3 f3 f3 f3 00 00 00 00
00 00
[  231.667738]                                      ^
[  231.667738]  ffffc9000029f080: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
00 f3
[  231.667738]  ffffc9000029f100: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
00 00
[  231.667738]
==================================================================
[  231.746888] Disabling lock debugging due to kernel taint

---
======== Affected Versions =======
Confirmed Version:
* 6f5156d7a31a8c3b0f34af4675c9299c8f877cbe (post-v7.2-rc3) Required Configs for the Vulnerability:
* CONFIG_INET
* CONFIG_NETFILTER
* CONFIG_NETFILTER_INGRESS
* CONFIG_NF_TABLES
* CONFIG_NF_TABLES_INET
* CONFIG_NFT_REJECT
* CONFIG_NFT_REJECT_INET
* CONFIG_NF_REJECT_IPV4

Additional Configs for the Proof of Concept:
* CONFIG_NET_IPIP
* CONFIG_VETH
* CONFIG_PACKET
* CONFIG_USER_NS
* CONFIG_NET_NS

========== Reproduction ==========
Step 1: Build kernel commit 6f5156d7a31a8c3b0f34af4675c9299c8f877cbe with KASAN and the configuration options listed above.

Step 2: Build the attached poc.c:

~
gcc -static -O2 -Wall -Wextra -o poc poc.c
~

Step 3: Ensure the nft_reject_inet, nf_reject_ipv4, ipip, and veth modules are available or built into the kernel. Run ./poc as an ordinary local user on a system that permits unprivileged user namespaces. The ip utility must be installed.

The program creates its own user and network namespace, configures a veth pair and IPIP device, installs an inet-ingress ICMPX reject rule, and transmits the triggering packet. KASAN reports the stack-out-of-bounds write.

Best regards,
David

Quoted 98 lines · Jamal Hadi Salim
Quoted 11 lines · David Lee

From: Kyle Zeng <[email protected]>

A qdisc's init callback can publish state to RCU readers before qdisc_create() completes. In particular, clsact_init() binds a populated shared ingress block and installs an embedded mini_Qdisc in dev->tcx_ingress. If subsequent rate estimator setup fails, the unwind removes that pointer but qdisc_free() immediately releases the qdisc and its per-CPU statistics. A reader that obtained the miniq before removal can then access freed memory.

Quoted 5 lines

Add qdisc_free_rcu() and use it for the creation error path, matching normal qdisc destruction. This keeps the embedded miniq and the per-CPU statistics alive until pre-existing readers complete.

Fixes 51ab2994c387 ("net: sched: allow ingress and clsact qdiscs to

share filter blocks")

Quoted 3 lines
Assisted-by Codex:gpt-5.6-sol Codex:gpt-5.5-cyber

Thanks for finding the issue. But you should know the deal by now, send the poc - you can send it in private. Same goes for your other patch.

cheers,
jamal

include/net/sch_generic.h struct Qdisc *qdisc_alloc(struct netdev_queue

Quoted 17 lines

---
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.

Trail of Bits has a reproducer for this bug that triggers a KASAN use-after-free and can share if needed.

 include/net/sch_generic.h | 1 +
 net/sched/sch_api.c       | 2 +-
 net/sched/sch_generic.c   | 7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
include/net/sch_generic.h +0 -0
index 45a1e8c782..d45442c926 100644
@@ -793,6 +793,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue

*dev_queue,

include/net/sch_generic.h struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,

Quoted 6 lines
include/net/sch_generic.h +1 -0
                          const struct Qdisc_ops *ops,
                          struct netlink_ext_ack *extack);
 void qdisc_free(struct Qdisc *qdisc);
+void qdisc_free_rcu(struct Qdisc *qdisc);
 struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
                                const struct Qdisc_ops *ops, u32

parentid,

net/sched/sch_api.c static struct Qdisc *qdisc_create(struct

Quoted 6 lines
include/net/sch_generic.h +0 -0
                                struct netlink_ext_ack *extack);
net/sched/sch_api.c +0 -0
index 668bcd60d1..041bd60072 100644
@@ -1373,7 +1373,7 @@ static struct Qdisc *qdisc_create(struct

net_device *dev,

Quoted 35 lines
net/sched/sch_api.c +1 -1
 err_out3:
        qdisc_lock_uninit(sch, ops);
        netdev_put(dev, &sch->dev_tracker);
-       qdisc_free(sch);
+       qdisc_free_rcu(sch);
 err_out2:
        bpf_module_put(ops, ops->owner);
 err_out:
net/sched/sch_generic.c +6 -2
index ef2b4bf515..86d551fbab 100644
@@ -1103,6 +1103,11 @@ static void qdisc_free_cb(struct rcu_head *head)
        qdisc_free(q);
 }
 
+void qdisc_free_rcu(struct Qdisc *qdisc)
+{
+       call_rcu(&qdisc->rcu, qdisc_free_cb);
+}
+
 static void __qdisc_destroy(struct Qdisc *qdisc)
 {
        const struct Qdisc_ops  *ops = qdisc->ops;
@@ -1127,7 +1132,7 @@ static void __qdisc_destroy(struct Qdisc *qdisc)
 
        trace_qdisc_destroy(qdisc);
 
-       call_rcu(&qdisc->rcu, qdisc_free_cb);
+       qdisc_free_rcu(qdisc);
 }
 
 void qdisc_destroy(struct Qdisc *qdisc)
--

2.53.0

maintainer
#3 lore raw
Quoted 5 lines · On Tue, 11 Aug 2026 00:58:27 +0900 David Lee wrote:
[  230.057740] ipip: IPv4 and MPLS over IPv4 tunneling driver
[  231.667279]
==================================================================
[  231.667738] BUG: KASAN: stack-out-of-bounds in

__ip_options_echo+0xdf7/0x1860

I'm struggling to see how this is a repro for the qdisc lifecycle bug

In any case -- if the fix is really correct and there's some real repro shared off list - I think you're deleting the last caller of qdisc_free() so you should inline it into qdisc_free_cb()

So patch as is needs to be refactored. But please don't repost just to refactor, we need a convincing repro first.

author
#4 lore raw

Hi Jakub,

Apologies for the confusion. I've reattached the correct reproducer.

======== Affected Versions =======
Runtime reproduction: Linux 7.2.0-rc3-kasan
Confirmed vulnerable revision:
f5098b6bae761e346ebcd9da7f95622c04733cff (Linux 7.2-rc5) Latest inspected vulnerable revisions:
* 62cc90241548d5570ee68e01aaba6506964e9811 (Torvalds master)
* 9d8da8e0a9bce4a340af60dd0446bc7eb8d07587 (net main) Introduced by:
51ab2994c387c80b45caf8b8067b3f3b97771d25
("net: sched: allow ingress and clsact qdiscs to share filter blocks")
https://github.com/torvalds/linux/commit/51ab2994c387c80b45caf8b8067b3f3b97771d25

Required Configs for the Vulnerability:
* CONFIG_NET_SCHED
* CONFIG_NET_SCH_INGRESS
* CONFIG_NET_CLS_ACT

Additional Configs used by the Proof-of-Concept:
* CONFIG_NET_CLS_BPF
* CONFIG_TUN
* CONFIG_USER_NS
* CONFIG_NET_NS
* CONFIG_KASAN

========== Reproduction ==========
Step 1: Build and boot a KASAN-enabled kernel with the configurations listed above.

Step 2: Statically compile the attached poc.c:

~
gcc -static -O2 -Wall -Wextra -pthread -o poc poc.c ~

Step 3: Run ./poc as a regular local user. The program creates an owned user and network namespace, two TUN interfaces, and a populated shared ingress block. It sends ingress traffic while repeatedly requesting a clsact qdisc with the shared block and the invalid rate estimator.

Step 4: Because this is a race, triggering time varies. The validated run reported:

~

BUG: KASAN: slab-use-after-free in tc_run+0x5e3/0x620
Read of size 8 ... by task poc/...

Freed by task ...:
  kfree
  qdisc_free
  qdisc_create
  tc_modify_qdisc

~

The complete KASAN report is attached as splash.txt.

Best regards,
David

Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Tue, 11 Aug 2026 00:58:27 +0900 David Lee wrote:
[  230.057740] ipip: IPv4 and MPLS over IPv4 tunneling driver
[  231.667279]
==================================================================
[  231.667738] BUG: KASAN: stack-out-of-bounds in

__ip_options_echo+0xdf7/0x1860

Quoted 9 lines

I'm struggling to see how this is a repro for the qdisc lifecycle bug

In any case -- if the fix is really correct and there's some real repro shared off list - I think you're deleting the last caller of qdisc_free() so you should inline it into qdisc_free_cb()

So patch as is needs to be refactored. But please don't repost just to refactor, we need a convincing repro first.

[  232.894671] ==================================================================
[  232.894793] BUG: KASAN: slab-use-after-free in tc_run+0x5e3/0x620
[  232.894793] Read of size 8 at addr ffff8881032c51e8 by task poc/1272
[  232.894793] 
[  232.894793] CPU: 3 UID: 1000 PID: 1272 Comm: poc Not tainted 7.2.0-rc3-kasan #1 PREEMPT(lazy) 
[  232.894793] Hardware name: QEMU Ubuntu 26.04 PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1ubuntu1 04/01/2014
[  232.894793] Call Trace:
[  232.894793]  <TASK>
[  232.894793]  dump_stack_lvl+0x5f/0x90
[  232.894793]  print_report+0x15b/0x4ec
[  232.894793]  ? __pfx__raw_spin_lock_irqsave+0x10/0x10
[  232.894793]  ? kasan_complete_mode_report_info+0x88/0x230
[  232.894793]  kasan_report+0xf2/0x130
[  232.894793]  ? tc_run+0x5e3/0x620
[  232.894793]  ? tc_run+0x5e3/0x620
[  232.894793]  __asan_report_load8_noabort+0x14/0x30
[  232.894793]  tc_run+0x5e3/0x620
[  232.894793]  ? __pfx_tc_run+0x10/0x10
[  232.894793]  __netif_receive_skb_core.constprop.0+0x9cc/0x31e0
[  232.894793]  ? __pfx___skb_flow_dissect+0x10/0x10
[  232.894793]  ? __pfx___netif_receive_skb_core.constprop.0+0x10/0x10
[  232.894793]  ? lapic_next_event+0x15/0x30
[  232.894793]  ? clockevents_program_event+0x2bd/0x750
[  232.894793]  ? ktime_get+0x100/0x190
[  232.894793]  ? __alloc_skb+0x34c/0xa10
[  232.894793]  ? lapic_next_event+0x15/0x30
[  232.894793]  ? __pfx_clockevents_program_event+0x10/0x10
[  232.894793]  ? __kasan_check_write+0x14/0x30
[  232.894793]  ? _raw_spin_lock+0x82/0xf0
[  232.894793]  __netif_receive_skb_one_core+0xa5/0x1d0
[  232.894793]  ? tick_program_event+0x69/0x130
[  232.894793]  ? __pfx___netif_receive_skb_one_core+0x10/0x10
[  232.894793]  ? __hrtimer_rearm_deferred+0x18a/0x520
[  232.894793]  ? sysvec_apic_timer_interrupt+0x54/0xd0
[  232.894793]  ? irqentry_exit+0x1cd/0x7b0
[  232.894793]  __netif_receive_skb+0x1c/0x160
[  232.894793]  netif_receive_skb+0x2f3/0x420
[  232.894793]  ? asm_sysvec_apic_timer_interrupt+0x1b/0x20
[  232.894793]  ? __pfx_netif_receive_skb+0x10/0x10
[  232.894793]  tun_get_user+0x2208/0x3c40
[  232.894793]  ? aa_file_perm+0x544/0xf20
[  232.894793]  ? __pfx_tun_get_user+0x10/0x10
[  232.894793]  ? rcu_sched_clock_irq+0xf08/0x2310
[  232.894793]  ? apparmor_file_permission+0x14d/0x500
[  232.894793]  ? __pfx_apparmor_file_permission+0x10/0x10
[  232.894793]  ? update_cfs_group+0x218/0x380
[  232.894793]  tun_chr_write_iter+0x176/0x2a0
[  232.894793]  ? tun_chr_write_iter+0x176/0x2a0
[  232.894793]  ? __pfx_run_posix_cpu_timers+0x10/0x10
[  232.894793]  vfs_write+0x580/0xf70
[  232.894793]  ? perf_event_task_tick+0x92/0x1d0
[  232.894793]  ? __pfx_vfs_write+0x10/0x10
[  232.894793]  ? __kasan_check_write+0x14/0x30
[  232.894793]  ? __kasan_check_write+0x14/0x30
[  232.894793]  ? fdget_pos+0x420/0x600
[  232.894793]  ksys_write+0x104/0x240
[  232.894793]  ? __pfx_ksys_write+0x10/0x10
[  232.894793]  ? lapic_next_event+0x15/0x30
[  232.894793]  ? clockevents_program_event+0x2bd/0x750
[  232.894793]  __x64_sys_write+0x72/0xd0
[  232.894793]  ? ktime_get_update_offsets_now+0x1d5/0x400
[  232.894793]  x64_sys_call+0x22f/0x2390
[  232.894793]  do_syscall_64+0xdd/0x640
[  232.894793]  ? __kasan_check_write+0x14/0x30
[  232.894793]  ? _raw_spin_lock+0x82/0xf0
[  232.894793]  ? __pfx__raw_spin_lock+0x10/0x10
[  232.894793]  ? tick_program_event+0x69/0x130
[  232.894793]  ? __kasan_check_read+0x11/0x20
[  232.894793]  ? fpregs_assert_state_consistent+0x5c/0x100
[  232.894793]  ? irqentry_exit+0x3f/0x7b0
[  232.894793]  ? __irq_exit_rcu+0x45/0x250
[  232.894793]  ? __sysvec_apic_timer_interrupt+0x91/0x320
[  232.894793]  ? do_syscall_64+0x94/0x640
[  232.894793]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[  232.894793] RIP: 0033:0x440692
[  232.910990] Code: 08 0f 85 f1 de ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 55 48 89 e5
[  232.911028] RSP: 002b:000070c4801be188 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[  232.911028] RAX: ffffffffffffffda RBX: 00007ffdcdd87380 RCX: 0000000000440692
[  232.911028] RDX: 0000000000000040 RSI: 00000000004a8500 RDI: 0000000000000004
[  232.911028] RBP: 000070c4801be1b0 R08: 0000000000000000 R09: 0000000000000000
[  232.911028] R10: 0000000000000000 R11: 0000000000000246 R12: 000070c4801be6c0
[  232.911028] R13: 00007ffdcdd87170 R14: 000070c4801bece4 R15: 00007ffdcdd87267
[  232.911028]  </TASK>
[  232.911028] 
[  232.934520] Allocated by task 1267 on cpu 0 at 232.847363s:
[  232.934520]  kasan_save_stack+0x3a/0x70
[  232.934520]  kasan_save_track+0x18/0x70
[  232.934520]  kasan_save_alloc_info+0x39/0x60
[  232.934520]  __kasan_kmalloc+0xa9/0xd0
[  232.934520]  __kmalloc_node_noprof+0x208/0x630
[  232.934520]  qdisc_alloc+0xba/0x7a0
[  232.934520]  qdisc_create+0x6e/0xc80
[  232.934520]  tc_modify_qdisc+0xab5/0x1ff0
[  232.934520]  rtnetlink_rcv_msg+0x34f/0xb00
[  232.934520]  netlink_rcv_skb+0x147/0x400
[  232.934520]  rtnetlink_rcv+0x15/0x30
[  232.934520]  netlink_unicast+0x796/0xb30
[  232.934520]  netlink_sendmsg+0x770/0xc70
[  232.934520]  ____sys_sendmsg+0x95d/0xc50
[  232.934520]  ___sys_sendmsg+0x101/0x1a0
[  232.934520]  __sys_sendmsg+0x127/0x1e0
[  232.934520]  __x64_sys_sendmsg+0x77/0xd0
[  232.934520]  x64_sys_call+0x20d2/0x2390
[  232.934520]  do_syscall_64+0xdd/0x640
[  232.934520]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[  232.934520] 
[  232.934520] Freed by task 1267 on cpu 0 at 232.854692s:
[  232.934520]  kasan_save_stack+0x3a/0x70
[  232.934520]  kasan_save_track+0x18/0x70
[  232.934520]  kasan_save_free_info+0x3b/0x70
[  232.934520]  __kasan_slab_free+0x7a/0xb0
[  232.934520]  kfree+0x1bd/0x510
[  232.934520]  qdisc_free+0x9c/0xd0
[  232.934520]  qdisc_create+0x5b0/0xc80
[  232.934520]  tc_modify_qdisc+0xab5/0x1ff0
[  232.934520]  rtnetlink_rcv_msg+0x34f/0xb00
[  232.934520]  netlink_rcv_skb+0x147/0x400
[  232.934520]  rtnetlink_rcv+0x15/0x30
[  232.934520]  netlink_unicast+0x796/0xb30
[  232.934520]  netlink_sendmsg+0x770/0xc70
[  232.934520]  ____sys_sendmsg+0x95d/0xc50
[  232.934520]  ___sys_sendmsg+0x101/0x1a0
[  232.934520]  __sys_sendmsg+0x127/0x1e0
[  232.934520]  __x64_sys_sendmsg+0x77/0xd0
[  232.934520]  x64_sys_call+0x20d2/0x2390
[  232.934520]  do_syscall_64+0xdd/0x640
[  232.934520]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[  232.934520] 
[  232.934520] The buggy address belongs to the object at ffff8881032c5000
[  232.934520]  which belongs to the cache kmalloc-part-02-1k of size 1024
[  232.934520] The buggy address is located 488 bytes inside of
[  232.934520]  freed 1024-byte region [ffff8881032c5000, ffff8881032c5400)
[  232.934520] 
[  232.934520] The buggy address belongs to the physical page:
[  232.934520] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8881032c6800 pfn:0x1032c0
[  232.934520] head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
[  232.934520] flags: 0x17ffffc0000240(workingset|head|node=0|zone=2|lastcpupid=0x1fffff)
[  232.934520] page_type: f5(slab)
[  232.934520] raw: 0017ffffc0000240 ffff888100048f00 ffff888100041290 ffffea0004071610
[  232.934520] raw: ffff8881032c6800 000000080010000e 00000000f5000000 0000000000000000
[  232.934520] head: 0017ffffc0000240 ffff888100048f00 ffff888100041290 ffffea0004071610
[  232.934520] head: ffff8881032c6800 000000080010000e 00000000f5000000 0000000000000000
[  232.934520] head: 0017ffffc0000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
[  232.934520] head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
[  232.934520] page dumped because: kasan: bad access detected
[  232.934520] 
[  232.934520] Memory state around the buggy address:
[  232.934520]  ffff8881032c5080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  232.934520]  ffff8881032c5100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  232.934520] >ffff8881032c5180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  232.934520]                                                           ^
[  232.934520]  ffff8881032c5200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  232.934520]  ffff8881032c5280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[  232.934520] ==================================================================
[  233.001266] Disabling lock debugging due to kernel taint
maintainer
#5 lore raw
Quoted 1 line · On Mon, 17 Aug 2026 05:06:01 -0400 David Lee wrote:

Apologies for the confusion. I've reattached the correct reproducer.

please see my feedback on the change itself (if you haven't)

maintainer
#6 lore raw
In reply to David Lee
Quoted 5 lines · David Lee

Hi Jakub,

Apologies for the confusion. I've reattached the correct reproducer.

Thanks for reattaching the correct reproducer. I have run it and the KASAN use-after-free in now matches the bug exactly. The earlier log showed a different issue, please ensure logs match the bug and the repro in the future to reduce review time. We run every test - and we will vet your claim; so sending the wrong log consumes our time for no good reason.

The fix itself is sound, but it requires a v2:
Per request from both Jakub and Sashiko: Inline qdisc_free() into qdisc_free_cb() (or make it static) since your patch removes its last external caller, so the standalone symbol is dead weight. Attaching a C poc to the patch is not something i have seen; make it separate. So mext steps: you are going to send 0/1 with the attached poc and a good description of what changes you made since v1. Then 1/1 is the refactored patch.

Keep Fixes: 51ab2994c387 since the that's the commit that made clsact bind a shared block before creation completes.

cheers,
jamal

Quoted 76 lines

======== Affected Versions =======
Runtime reproduction: Linux 7.2.0-rc3-kasan
Confirmed vulnerable revision:
f5098b6bae761e346ebcd9da7f95622c04733cff (Linux 7.2-rc5) Latest inspected vulnerable revisions:
* 62cc90241548d5570ee68e01aaba6506964e9811 (Torvalds master)
* 9d8da8e0a9bce4a340af60dd0446bc7eb8d07587 (net main) Introduced by:
51ab2994c387c80b45caf8b8067b3f3b97771d25
("net: sched: allow ingress and clsact qdiscs to share filter blocks")
https://github.com/torvalds/linux/commit/51ab2994c387c80b45caf8b8067b3f3b97771d25

Required Configs for the Vulnerability:
* CONFIG_NET_SCHED
* CONFIG_NET_SCH_INGRESS
* CONFIG_NET_CLS_ACT

Additional Configs used by the Proof-of-Concept:
* CONFIG_NET_CLS_BPF
* CONFIG_TUN
* CONFIG_USER_NS
* CONFIG_NET_NS
* CONFIG_KASAN

========== Reproduction ==========
Step 1: Build and boot a KASAN-enabled kernel with the configurations listed above.

Step 2: Statically compile the attached poc.c:

~
gcc -static -O2 -Wall -Wextra -pthread -o poc poc.c ~

Step 3: Run ./poc as a regular local user. The program creates an owned user and network namespace, two TUN interfaces, and a populated shared ingress block. It sends ingress traffic while repeatedly requesting a clsact qdisc with the shared block and the invalid rate estimator.

Step 4: Because this is a race, triggering time varies. The validated run reported:

~

BUG: KASAN: slab-use-after-free in tc_run+0x5e3/0x620
Read of size 8 ... by task poc/...

Freed by task ...:
  kfree
  qdisc_free
  qdisc_create
  tc_modify_qdisc

~

The complete KASAN report is attached as splash.txt.

Best regards,
David

Quoted 16 lines · Jakub Kicinski
Quoted 5 lines · On Tue, 11 Aug 2026 00:58:27 +0900 David Lee wrote:
[  230.057740] ipip: IPv4 and MPLS over IPv4 tunneling driver
[  231.667279]
==================================================================
[  231.667738] BUG: KASAN: stack-out-of-bounds in

__ip_options_echo+0xdf7/0x1860

I'm struggling to see how this is a repro for the qdisc lifecycle bug

In any case -- if the fix is really correct and there's some real repro shared off list - I think you're deleting the last caller of qdisc_free() so you should inline it into qdisc_free_cb()

So patch as is needs to be refactored. But please don't repost just to refactor, we need a convincing repro first.

maintainer
#7 lore raw
Quoted 24 lines · Jamal Hadi Salim
Quoted 5 lines · David Lee

Hi Jakub,

Apologies for the confusion. I've reattached the correct reproducer.

Thanks for reattaching the correct reproducer. I have run it and the KASAN use-after-free in now matches the bug exactly. The earlier log showed a different issue, please ensure logs match the bug and the repro in the future to reduce review time. We run every test - and we will vet your claim; so sending the wrong log consumes our time for no good reason.

The fix itself is sound, but it requires a v2:
Per request from both Jakub and Sashiko: Inline qdisc_free() into qdisc_free_cb() (or make it static) since your patch removes its last external caller, so the standalone symbol is dead weight. Attaching a C poc to the patch is not something i have seen; make it separate. So mext steps: you are going to send 0/1 with the attached poc and a good description of what changes you made since v1. Then 1/1 is the refactored patch.

Quoted 3 lines

Keep Fixes: 51ab2994c387 since the that's the commit that made clsact bind a shared block before creation completes.

Reviewing your patch triggered my memory so i looked around... This _same exact bug_ (with the same KASAN signature) was reported by [email protected](on Cc) on the security list on Jul 20. They promised to send a patch to the list (which was the same as yours!) but they never did.
Two main differences i will note:
1. Their repro was different than yours (ask them to send it to you if you are curious)
2. They quoted Fixes as 3a7d0d07a3867 (in a way that is defensible as well)

So please, when you send a v2 give them some credit in reported-by

cheers,
jamal

Quoted 79 lines

cheers,
jamal

Quoted 76 lines

======== Affected Versions =======
Runtime reproduction: Linux 7.2.0-rc3-kasan
Confirmed vulnerable revision:
f5098b6bae761e346ebcd9da7f95622c04733cff (Linux 7.2-rc5) Latest inspected vulnerable revisions:
* 62cc90241548d5570ee68e01aaba6506964e9811 (Torvalds master)
* 9d8da8e0a9bce4a340af60dd0446bc7eb8d07587 (net main) Introduced by:
51ab2994c387c80b45caf8b8067b3f3b97771d25
("net: sched: allow ingress and clsact qdiscs to share filter blocks")
https://github.com/torvalds/linux/commit/51ab2994c387c80b45caf8b8067b3f3b97771d25

Required Configs for the Vulnerability:
* CONFIG_NET_SCHED
* CONFIG_NET_SCH_INGRESS
* CONFIG_NET_CLS_ACT

Additional Configs used by the Proof-of-Concept:
* CONFIG_NET_CLS_BPF
* CONFIG_TUN
* CONFIG_USER_NS
* CONFIG_NET_NS
* CONFIG_KASAN

========== Reproduction ==========
Step 1: Build and boot a KASAN-enabled kernel with the configurations listed above.

Step 2: Statically compile the attached poc.c:

~
gcc -static -O2 -Wall -Wextra -pthread -o poc poc.c ~

Step 3: Run ./poc as a regular local user. The program creates an owned user and network namespace, two TUN interfaces, and a populated shared ingress block. It sends ingress traffic while repeatedly requesting a clsact qdisc with the shared block and the invalid rate estimator.

Step 4: Because this is a race, triggering time varies. The validated run reported:

~

BUG: KASAN: slab-use-after-free in tc_run+0x5e3/0x620
Read of size 8 ... by task poc/...

Freed by task ...:
  kfree
  qdisc_free
  qdisc_create
  tc_modify_qdisc

~

The complete KASAN report is attached as splash.txt.

Best regards,
David

Quoted 16 lines · Jakub Kicinski
Quoted 5 lines · On Tue, 11 Aug 2026 00:58:27 +0900 David Lee wrote:
[  230.057740] ipip: IPv4 and MPLS over IPv4 tunneling driver
[  231.667279]
==================================================================
[  231.667738] BUG: KASAN: stack-out-of-bounds in

__ip_options_echo+0xdf7/0x1860

I'm struggling to see how this is a repro for the qdisc lifecycle bug

In any case -- if the fix is really correct and there's some real repro shared off list - I think you're deleting the last caller of qdisc_free() so you should inline it into qdisc_free_cb()

So patch as is needs to be refactored. But please don't repost just to refactor, we need a convincing repro first.