mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net/sched: sch_choke: fix skb leak on packet ring wrap
@ 2026-11-26 14:11 Junyoung Jang
  0 siblings, 0 replies; only message in thread
From: Junyoung Jang @ 2026-11-26 14:11 UTC (permalink / raw)
  To: Jamal Hadi Salim, Jiri Pirko
  Cc: Junyoung Jang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Willem de Bruijn, Simon Horman, Gwanhyun Lee,
	netdev, linux-kernel

CHOKe represents an empty ring with q->head == q->tail. When
choke_drop_by_idx() drops a matched packet from the middle of the ring,
it clears q->tab[idx] and decrements sch->q.qlen without reducing
choke_len(q).

Repeated interior drops allow choke_len(q) to reach q->tab_mask while
sch->q.qlen is still below q->limit. Enqueuing another packet then
advances q->tail onto q->head with live skbs still in q->tab.

Once wrapped, choke_dequeue() and choke_reset() see an empty ring,
stalling dequeue and leaking all queued skbs on qdisc reset or deletion.
If sch->q.qlen is still below q->limit after the wrap, subsequent
choke_enqueue() calls also overwrite live q->tab entries in place,
leaking skbs during normal packet processing.

Check choke_len(q) < q->tab_mask in choke_enqueue() to preserve an empty
slot and prevent the ring from wrapping.

An in-house LLM-based analysis tool developed by the authors
assisted in surfacing this bug candidate and drafting the initial notes.
Root-cause analysis, patch code, and reproducer results were manually
reviewed and independently verified by the authors.

Fixes: 45e144339ac5 ("sched: CHOKe flow scheduler")
Co-developed-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Junyoung Jang <graypanda.inzag@gmail.com>
---
Tested on net/main in QEMU with a C reproducer that fills a 4,095-packet
CHOKe ring (tab_mask = 4095), triggers one interior matched drop, and
sends one more packet:
  - Before: q->tail wrapped onto q->head, and deleting the qdisc freed
    none of the 4,095 queued skbs (traced via kfree_skb).
  - After: the extra packet hit pdrops, and deleting the qdisc freed all
    4,094 remaining skbs.

 net/sched/sch_choke.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index 73d3e673dc7b..92d4f29acf57 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -268,7 +268,7 @@ static int choke_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	}
 
 	/* Admit new packet */
-	if (sch->q.qlen < q->limit) {
+	if (sch->q.qlen < q->limit && choke_len(q) < q->tab_mask) {
 		q->tab[q->tail] = skb;
 		q->tail = (q->tail + 1) & q->tab_mask;
 		qdisc_qlen_inc(sch);

base-commit: ae8e5ef9fa9eeaf4ee0a9a9bde0fc63023d9b154
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26 14:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 14:11 [PATCH net] net/sched: sch_choke: fix skb leak on packet ring wrap Junyoung Jang

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®