From: sashiko-bot@kernel.org
To: "Daniel Borkmann" <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 2/3] net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains
Date: Wed, 01 Jul 2026 12:33:40 +0000 [thread overview]
Message-ID: <20260701123340.D29A71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630123331.186840-3-daniel@iogearbox.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Missing handling of TC_ACT_CONSUMED in qdisc filter chains leads to Use-After-Free.
--
commit 84137b5068cebac45a2a901c08e1d2f5e6d71111
Author: Jamal Hadi Salim <jhs@mojatatu.com>
net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains
When a TC filter attached to a qdisc filter chain returns TC_ACT_REDIRECT,
the redirect was silently lost and the packet fell through to the switch.
This patch adds a tcf_classify_qdisc wrapper to convert TC_ACT_REDIRECT to
TC_ACT_SHOT, preventing the packet from silently continuing.
> diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
> --- a/include/net/pkt_cls.h
> +++ b/include/net/pkt_cls.h
[ ... ]
> @@ -156,8 +156,20 @@ static inline int tcf_classify(struct sk_buff *skb,
> {
> return TC_ACT_UNSPEC;
> }
> -
> #endif
> +static inline int tcf_classify_qdisc(struct sk_buff *skb,
> + const struct tcf_proto *tp,
> + struct tcf_result *res, bool compat_mode)
> +{
> + int ret = tcf_classify(skb, NULL, tp, res, compat_mode);
> +
> + /* TC_ACT_REDIRECT from qdisc filter chains is not supported.
> + * Use BPF via tcx or mirred redirect instead.
> + */
> + if (unlikely(ret == TC_ACT_REDIRECT))
> + ret = TC_ACT_SHOT;
> + return ret;
> +}
[Severity: Critical]
This is a pre-existing issue, but missing handling of TC_ACT_CONSUMED in
this helper can lead to a use-after-free.
The tcf_classify_qdisc() wrapper intentionally intercepts TC_ACT_REDIRECT
to prevent it from falling through to the qdiscs. However, it fails to
intercept TC_ACT_CONSUMED, which suffers from the exact same fall-through
vulnerability.
If a user configures a qdisc filter with an action that returns
TC_ACT_CONSUMED (such as act_ct queueing an IPv4 fragment for defrag), the
action takes ownership of the skb.
Because TC_ACT_CONSUMED bypasses the switch statements in qdisc classify
functions like cake_classify(), the qdisc treats it as a successful match
and enqueues the already consumed skb into its internal queues.
Should TC_ACT_CONSUMED also be intercepted and handled here in
tcf_classify_qdisc() to prevent this use-after-free scenario?
> diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
> --- a/net/sched/sch_cake.c
> +++ b/net/sched/sch_cake.c
[ ... ]
> @@ -1730,7 +1730,7 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t,
> goto hash;
>
> *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
> - result = tcf_classify(skb, NULL, filter, &res, false);
> + result = tcf_classify_qdisc(skb, filter, &res, false);
>
> if (result >= 0) {
> #ifdef CONFIG_NET_CLS_ACT
[Severity: Critical]
This is a pre-existing issue, but TC_ACT_CONSUMED bypasses the switch
statement that immediately follows this result check.
When tcf_classify_qdisc() returns TC_ACT_CONSUMED, it satisfies the
result >= 0 check but falls through the switch handling TC_ACT_STOLEN,
TC_ACT_QUEUED, and TC_ACT_TRAP. The qdisc then treats the consumed packet
as a successful match and enqueues it.
Could this be resolved by either adding TC_ACT_CONSUMED to the switch
cases here and in other qdiscs, or by having tcf_classify_qdisc() intercept
it alongside TC_ACT_REDIRECT?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630123331.186840-1-daniel@iogearbox.net?part=2
next prev parent reply other threads:[~2026-07-01 12:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 12:33 [PATCH net 0/3] Fix broken TC_ACT_REDIRECT from qdiscs Daniel Borkmann
2026-06-30 12:33 ` [PATCH net 1/3] bpf: Reject redirect helpers without a bpf_net_context Daniel Borkmann
2026-06-30 12:33 ` [PATCH net 2/3] net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains Daniel Borkmann
2026-06-30 15:16 ` Jamal Hadi Salim
2026-06-30 15:23 ` Daniel Borkmann
2026-07-01 15:35 ` Jamal Hadi Salim
2026-07-05 7:26 ` Paolo Abeni
2026-07-05 14:03 ` Jamal Hadi Salim
2026-07-01 12:33 ` sashiko-bot [this message]
2026-07-01 13:07 ` Daniel Borkmann
2026-07-06 9:01 ` Paolo Abeni
2026-06-30 12:33 ` [PATCH net 3/3] selftests/bpf: Add test for redirect from qdisc qevent block Daniel Borkmann
2026-07-01 12:33 ` sashiko-bot
2026-07-01 13:20 ` Daniel Borkmann
2026-06-30 14:37 ` [PATCH net 0/3] Fix broken TC_ACT_REDIRECT from qdiscs Sebastian Andrzej Siewior
2026-06-30 15:09 ` Daniel Borkmann
-- strict thread matches above, loose matches on Subject: below --
2026-06-26 16:51 [PATCH net 0/3] Fix broken TC_ACT_REDIRECT Jamal Hadi Salim
2026-06-26 16:51 ` [PATCH net 2/3] net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains Jamal Hadi Salim
2026-06-27 16:52 ` sashiko-bot
2026-06-28 12:28 ` Jamal Hadi Salim
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=20260701123340.D29A71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.