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
  2026-12-04 11:19 ` Paolo Abeni
  0 siblings, 1 reply; 3+ messages 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] 3+ messages in thread

* Re: [PATCH net] net/sched: sch_choke: fix skb leak on packet ring wrap
  2026-11-26 14:11 [PATCH net] net/sched: sch_choke: fix skb leak on packet ring wrap Junyoung Jang
@ 2026-12-04 11:19 ` Paolo Abeni
  2026-12-05  3:55   ` Junyoung Jang
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Abeni @ 2026-12-04 11:19 UTC (permalink / raw)
  To: Junyoung Jang, Jamal Hadi Salim, Jiri Pirko
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Willem de Bruijn,
	Simon Horman, Gwanhyun Lee, netdev, linux-kernel

On 11/26/26 15:11, Junyoung Jang wrote:
> 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) {

Sashiko noted the above causes a behavior change:

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126141137.1261866-1-graypanda.inzag@gmail.com

and I think we should avoid it.

/P

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

* Re: [PATCH net] net/sched: sch_choke: fix skb leak on packet ring wrap
  2026-12-04 11:19 ` Paolo Abeni
@ 2026-12-05  3:55   ` Junyoung Jang
  0 siblings, 0 replies; 3+ messages in thread
From: Junyoung Jang @ 2026-12-05  3:55 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Jamal Hadi Salim, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Willem de Bruijn, Simon Horman, Gwanhyun Lee,
	netdev, linux-kernel

On 11/26/26 20:19, Paolo Abeni wrote:
> On 11/26/26 15:11, Junyoung Jang wrote:
...
> Sashiko noted the above causes a behavior change:
>
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126141137.1261866-1-graypanda.inzag@gmail.com
>
> and I think we should avoid it.

Thanks for pointing this out. I just sent v2, which sizes the ring for
holes and compacts live entries before wrap so admissions below
q->limit are preserved:

https://lore.kernel.org/netdev/20261205035232.2243251-1-graypanda.inzag@gmail.com/

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

end of thread, other threads:[~2026-12-05  3:55 UTC | newest]

Thread overview: 3+ messages (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
2026-12-04 11:19 ` Paolo Abeni
2026-12-05  3:55   ` 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®