Netdev List
 help / color / mirror / Atom feed
* [PATCH] net/sched: sch_qfq: prevent aggregate self-replacement
@ 2026-07-31 14:05 David Lee
  2026-07-31 16:32 ` Jamal Hadi Salim
  2026-08-02  8:41 ` Sven Eckelmann
  0 siblings, 2 replies; 3+ messages in thread
From: David Lee @ 2026-07-31 14:05 UTC (permalink / raw)
  To: jhs, jiri, davem, edumazet, kuba, pabeni
  Cc: David Lee, Kyle Zeng, Dominik 'Disconnect3d' Czarnota,
	horms, netdev, linux-kernel

qfq_change_class() snapshots the current aggregate settings while
holding the qdisc tree lock, but drops the lock before selecting the
destination aggregate. During that gap, qfq_enqueue() can move the
class to an aggregate matching the requested settings.

When qfq_change_class() resumes, qfq_find_agg() then returns cl->agg.
If it is a singleton, qfq_deact_rm_from_agg() frees the aggregate
before qfq_add_to_agg() immediately accesses the same pointer, causing
a use-after-free.

While holding the tree lock, skip the replacement when the destination
is already the current aggregate. Any estimator replacement has already
completed, so the class change can finish normally.

Fixes: 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
Bug found and triaged by OpenAI Security Research and 
validated by Trail of Bits.

Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
Signed-off-by: Kyle Zeng <kylebot@openai.com>
---
Trail of Bits has a reproducer for this bug that triggers a
KASAN use-after-free and can share if needed.

 net/sched/sch_qfq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index 6f3b7273c..e900890e9 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -517,11 +517,14 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 		sch_tree_lock(sch);
 		qfq_init_agg(q, new_agg, lmax, weight);
 	}
+	if (existing && new_agg == cl->agg)
+		goto unlock;
 	if (existing)
 		qfq_deact_rm_from_agg(q, cl);
 	else
 		qdisc_class_hash_insert(&q->clhash, &cl->common);
 	qfq_add_to_agg(q, new_agg, cl);
+unlock:
 	sch_tree_unlock(sch);
 	qdisc_class_hash_grow(sch, &q->clhash);
 
-- 
2.53.0

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

* Re: [PATCH] net/sched: sch_qfq: prevent aggregate self-replacement
  2026-07-31 14:05 [PATCH] net/sched: sch_qfq: prevent aggregate self-replacement David Lee
@ 2026-07-31 16:32 ` Jamal Hadi Salim
  2026-08-02  8:41 ` Sven Eckelmann
  1 sibling, 0 replies; 3+ messages in thread
From: Jamal Hadi Salim @ 2026-07-31 16:32 UTC (permalink / raw)
  To: David Lee
  Cc: jiri, davem, edumazet, kuba, pabeni, Kyle Zeng,
	Dominik 'Disconnect3d' Czarnota, horms, netdev,
	linux-kernel

On Fri, Jul 31, 2026 at 10:05 AM David Lee <david.lee@trailofbits.com> wrote:
>
> qfq_change_class() snapshots the current aggregate settings while
> holding the qdisc tree lock, but drops the lock before selecting the
> destination aggregate. During that gap, qfq_enqueue() can move the
> class to an aggregate matching the requested settings.
>
> When qfq_change_class() resumes, qfq_find_agg() then returns cl->agg.
> If it is a singleton, qfq_deact_rm_from_agg() frees the aggregate
> before qfq_add_to_agg() immediately accesses the same pointer, causing
> a use-after-free.
>
> While holding the tree lock, skip the replacement when the destination
> is already the current aggregate. Any estimator replacement has already
> completed, so the class change can finish normally.
>
> Fixes: 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
> Bug found and triaged by OpenAI Security Research and
> validated by Trail of Bits.
>

Please always send a reproducer - either as a tdc test case or if it
is sensitive send it privately to me and Cc the other maintainers.
As trivial as this looks I will not look at it without a repro.

cheers,
jamal

> Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
> Signed-off-by: Kyle Zeng <kylebot@openai.com>
> ---
> Trail of Bits has a reproducer for this bug that triggers a
> KASAN use-after-free and can share if needed.
>
>  net/sched/sch_qfq.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
> index 6f3b7273c..e900890e9 100644
> --- a/net/sched/sch_qfq.c
> +++ b/net/sched/sch_qfq.c
> @@ -517,11 +517,14 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
>                 sch_tree_lock(sch);
>                 qfq_init_agg(q, new_agg, lmax, weight);
>         }
> +       if (existing && new_agg == cl->agg)
> +               goto unlock;
>         if (existing)
>                 qfq_deact_rm_from_agg(q, cl);
>         else
>                 qdisc_class_hash_insert(&q->clhash, &cl->common);
>         qfq_add_to_agg(q, new_agg, cl);
> +unlock:
>         sch_tree_unlock(sch);
>         qdisc_class_hash_grow(sch, &q->clhash);
>
> --
> 2.53.0

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

* Re: [PATCH] net/sched: sch_qfq: prevent aggregate self-replacement
  2026-07-31 14:05 [PATCH] net/sched: sch_qfq: prevent aggregate self-replacement David Lee
  2026-07-31 16:32 ` Jamal Hadi Salim
@ 2026-08-02  8:41 ` Sven Eckelmann
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2026-08-02  8:41 UTC (permalink / raw)
  To: jhs, jiri, davem, edumazet, kuba, pabeni, David Lee, Kyle Zeng
  Cc: Dominik 'Disconnect3d' Czarnota, horms, netdev,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1036 bytes --]

On Friday, 31 July 2026 16:05:32 CEST David Lee wrote:
> Fixes: 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
> Bug found and triaged by OpenAI Security Research and 
> validated by Trail of Bits.
> 
> Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
> Signed-off-by: Kyle Zeng <kylebot@openai.com>

1. weird text (advertisement) + newlines in the tags section which shouldn't be there
   https://docs.kernel.org/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
   (and all these tag/format related sections below)

2. author didn't sign off the patch (see below)

3. odd unrelated Signed-off-by without any obvious connection to 
   the patch

   - I actually would guess that Kyle Zeng <kylebot@openai.com> is the author 
     and David Lee removed its authorship (From: ) before sending the patch.
     But in its current form, David is claiming to be the author. And even
     when it is the case, David must still add the the non-Author SoB at the
     end.

Regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2026-08-02  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 14:05 [PATCH] net/sched: sch_qfq: prevent aggregate self-replacement David Lee
2026-07-31 16:32 ` Jamal Hadi Salim
2026-08-02  8:41 ` Sven Eckelmann

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