mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Junyoung Jang <graypanda.inzag@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>, Jiri Pirko <jiri@resnulli.us>
Cc: Junyoung Jang <graypanda.inzag@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Gwanhyun Lee <gwanhyunlee@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net] net/sched: sch_choke: fix skb leak on packet ring wrap
Date: Thu, 26 Nov 2026 23:11:36 +0900	[thread overview]
Message-ID: <20261126141137.1261866-1-graypanda.inzag@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-26 14:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126141137.1261866-1-graypanda.inzag@gmail.com \
    --to=graypanda.inzag@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gwanhyunlee@gmail.com \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®