From: Jamal Hadi Salim <jhs@mojatatu.com>
To: netdev@vger.kernel.org
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
"Mohit P. Tahiliani" <tahiliani@nitk.edu.in>,
"Sachin D . Patil" <sdp.sachin@gmail.com>,
"V. Saicharan" <vsaicharan1998@gmail.com>,
Mohit Bhasi <mohitbhasi1998@gmail.com>,
Leslie Monis <lesliemonis@gmail.com>,
Gautam Ramakrishnan <gautamramk@gmail.com>,
Terry Lam <vtlam@google.com>,
stable@vger.kernel.org, vega@nebusec.ai,
Victor Nogueira <victor@mojatatu.com>
Subject: [PATCH net v3 0/6] net: sched: fix quantum/mtu overflow in fq, fq_codel, sch_codel, fq_pie, hhf, sfq
Date: Sat, 22 Aug 2026 15:55:03 -0400 [thread overview]
Message-ID: <20260822195509.112717-1-jhs@mojatatu.com> (raw)
Several qdiscs derive their per-flow quantum or CoDel mtu from
psched_mtu() without an overflow or zero clamp, which can drive the
dequeue/credit-refill loop into a soft lockup or silently disable the
AQM. vega@nebusec.ai provided reports and PoCs for the following qdiscs:
sch_fq, sch_fq_codel, sch_fq_pie, sch_hhf, and sch_sfq.
sch_codel was found by inspection for the same pattern. It's TheLinuxWay
(i.e cutnpaste code from somewhere for your new feature) and the AIs
are having a lot of fun finding patterns. We must overcome!
Clamp the quantum (and, for the codel family, the cparams/params mtu)
to a sane range at init/change time so the dequeue loops terminate and
the AQM stays armed. The clamps live in the init/change paths, not the
per-packet fast path, so no hot-path cost is added for a configuration
issue.
This series depends on "net/sched: bound qdisc_pkt_len to prevent qdisc
soft lockup", which caps qdisc_pkt_len() at GSO_MAX_SIZE in
__qdisc_calculate_pkt_len(). That cap closes the fq_codel TCA_STAB
backlog-wrap vector (qdisc_pkt_len inflated to ~1 GiB wrapping the u32
per-flow backlog to 0 and NULL-derefing in fq_codel_drop()); with it
upstream this series no longer needs the fq_codel_drop() hardening hunk
that the earlier respin carried. The five quantum/mtu fixes here are
psched_mtu()-driven and orthogonal to the qdisc_pkt_len() cap.
Q: Why not bound the MTU at the source instead? dummy's max_mtu == 0 is
intentional (dev_validate_mtu() treats 0 as unbounded), other drivers
can legitimately advertise large MTUs, and qdiscs must not trust
psched_mtu() regardless.
Conditions to recreate the bug: a device whose MTU (plus
hard_header_len) wraps 2 * psched_mtu() or psched_mtu() into the sign
bit (e.g. a dummy device with max_mtu == 0 accepting a huge MTU).
Requires CAP_NET_ADMIN in a user namespace.
---
v2 to v3
General: Feeback from Eric and Sashiko and one addtional qdisc from
inspection.
1. Split into one patch per file (Eric Dumazet).
2. Clamp to a range [256, FQ_CODEL_QUANTUM_MAX], not just a lower
bound, in fq_codel/fq_pie init (Sashiko).
3. Clamp psched_mtu() before multiplying in fq_init() (Sashiko).
4. Move hhf clamp before hhf_change() (Sashiko).
5. Fold fq_codel cparams.mtu clamp: same unclamped psched_mtu() six
lines below q->quantum disables codel; hoist one clamped mtu.
6. New patch 3: add sch_codel -- same params.mtu issue.
7. Drop the fq_codel_drop() hardening hunk: the qdisc_pkt_len() cap
in the posted "bound qdisc_pkt_len" dependency closes the TCA_STAB
backlog wrap at the source, making the empty-flow fallback unreachable.
8. Switch sfq to clamp_t(..., 256, 1 << 20) - all patches now
have same pattern.
9. Drop the stale TCA_FQ_INITIAL_QUANTUM narrowing: .max = INT_MAX was
set deliberately by 7041101ff6c3 and already guarantees f->credit
stays non-negative; lowering it would reject working configs.
v1 to v2
Changes based on feedback from Eric and Sashikos on V1.
1. Drop the fast-path changes in fq_dequeue() (Eric).
2. Clamp to a range, not just a lower bound (Eric); upper bound 1M
matches fq_change()'s TCA_FQ_QUANTUM cap, not Eric's 16M.
3. Dropped the TCA_FQ_INITIAL_QUANTUM policy narrowing (see v2 to v3
note 9 for why).
4. Fold fq_codel_init() quantum clamp (Sashiko).
5. Fold fq_pie_init()/fq_pie_change() quantum clamp (Sashiko).
6. Reword the hhf/sfq comments (Sashiko).
Sashiko links:
https://sashiko.dev/#/patchset/20260818101130.16203-1-jhs@mojatatu.com
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260818101130.16203-1-jhs@mojatatu.com
https://sashiko.dev/#/patchset/20260819143136.57350-1-jhs@mojatatu.com
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260819143136.57350-1-jhs@mojatatu.com
---
Jamal Hadi Salim (6):
net/sched: fq: add overflow bounds to quantum and initial quantum
net/sched: fq_codel: clamp default quantum and mtu
net/sched: sch_codel: clamp default mtu to avoid disabling CoDel
net/sched: fq_pie: clamp default quantum to avoid signed overflow
net/sched: hhf: clamp quantum before hhf_change() to avoid overflow
net/sched: sfq: clamp quantum to avoid signed overflow soft lockup
net/sched/sch_codel.c | 2 +-
net/sched/sch_fq.c | 6 ++++--
net/sched/sch_fq_codel.c | 6 ++++--
net/sched/sch_fq_pie.c | 3 ++-
net/sched/sch_hhf.c | 4 ++++
net/sched/sch_sfq.c | 3 ++-
6 files changed, 17 insertions(+), 7 deletions(-)
--
2.43.0
next reply other threads:[~2026-08-22 19:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 19:55 Jamal Hadi Salim [this message]
2026-08-22 19:55 ` [PATCH net v3 1/6] net/sched: fq: add overflow bounds to quantum and initial quantum Jamal Hadi Salim
2026-08-25 10:03 ` Eric Dumazet
2026-08-25 10:43 ` Jamal Hadi Salim
2026-08-25 11:02 ` Jamal Hadi Salim
2026-08-22 19:55 ` [PATCH net v3 2/6] net/sched: fq_codel: clamp default quantum and mtu Jamal Hadi Salim
2026-08-22 19:55 ` [PATCH net v3 3/6] net/sched: sch_codel: clamp default mtu to avoid disabling CoDel Jamal Hadi Salim
2026-08-22 19:55 ` [PATCH net v3 4/6] net/sched: fq_pie: clamp default quantum to avoid signed overflow Jamal Hadi Salim
2026-08-25 8:33 ` Paolo Abeni
2026-08-25 9:16 ` Jamal Hadi Salim
2026-08-25 9:43 ` Paolo Abeni
2026-08-25 9:48 ` Jamal Hadi Salim
2026-08-22 19:55 ` [PATCH net v3 5/6] net/sched: hhf: clamp quantum before hhf_change() to avoid overflow Jamal Hadi Salim
2026-08-22 19:55 ` [PATCH net v3 6/6] net/sched: sfq: clamp quantum to avoid signed overflow soft lockup Jamal Hadi Salim
2026-08-25 11:30 ` [PATCH net v3 0/6] net: sched: fix quantum/mtu overflow in fq, fq_codel, sch_codel, fq_pie, hhf, sfq patchwork-bot+netdevbpf
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=20260822195509.112717-1-jhs@mojatatu.com \
--to=jhs@mojatatu.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gautamramk@gmail.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=lesliemonis@gmail.com \
--cc=mohitbhasi1998@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdp.sachin@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tahiliani@nitk.edu.in \
--cc=vega@nebusec.ai \
--cc=victor@mojatatu.com \
--cc=vsaicharan1998@gmail.com \
--cc=vtlam@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