From: Samuel Moelius <sam.moelius@trailofbits.com>
To: "Toke Høiland-Jørgensen" <toke@toke.dk>
Cc: Samuel Moelius <sam.moelius@trailofbits.com>,
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>,
cake@lists.bufferbloat.net (moderated list:CAKE QDISC),
netdev@vger.kernel.org (open list:TC subsystem),
linux-kernel@vger.kernel.org (open list)
Subject: [Cake] [PATCH] net/sched: cake: reject overhead values that underflow length
Date: Tue, 9 Jun 2026 00:00:59 +0000 [thread overview]
Message-ID: <20260609000059.1234072.bc8844db0200.cake-overhead-underflow@trailofbits.com> (raw)
CAKE accepts overhead values that can make adjusted packet length
arithmetic underflow. A negative effective length can wrap through
unsigned arithmetic and become a large value.
Such configurations make rate accounting depend on integer wraparound
rather than on the packet size userspace intended to model.
Validate overhead settings before using them in adjusted length
calculations.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
net/sched/sch_cake.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index 5862933be8d7..03972e5525b5 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -2308,12 +2308,18 @@ static void cake_reset(struct Qdisc *sch)
cake_clear_tin(sch, c);
}
+static const struct netlink_range_validation_signed cake_overhead_range = {
+ .min = -64,
+ .max = 256,
+};
+
static const struct nla_policy cake_policy[TCA_CAKE_MAX + 1] = {
[TCA_CAKE_BASE_RATE64] = { .type = NLA_U64 },
[TCA_CAKE_DIFFSERV_MODE] = { .type = NLA_U32 },
[TCA_CAKE_ATM] = { .type = NLA_U32 },
[TCA_CAKE_FLOW_MODE] = { .type = NLA_U32 },
- [TCA_CAKE_OVERHEAD] = { .type = NLA_S32 },
+ [TCA_CAKE_OVERHEAD] =
+ NLA_POLICY_FULL_RANGE_SIGNED(NLA_S32, &cake_overhead_range),
[TCA_CAKE_RTT] = { .type = NLA_U32 },
[TCA_CAKE_TARGET] = { .type = NLA_U32 },
[TCA_CAKE_AUTORATE] = { .type = NLA_U32 },
--
2.43.0
next reply other threads:[~2026-06-09 0:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 0:00 Samuel Moelius [this message]
2026-06-09 1:07 ` [Cake] Re: [PATCH] net/sched: cake: reject overhead values that underflow length Eric Dumazet
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
List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609000059.1234072.bc8844db0200.cake-overhead-underflow@trailofbits.com \
--to=sam.moelius@trailofbits.com \
--cc=cake@lists.bufferbloat.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.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=toke@toke.dk \
/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