From: Qi Tang <tpluszz77@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>, Jiri Pirko <jiri@resnulli.us>
Cc: "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>,
netdev@vger.kernel.org, Qi Tang <tpluszz77@gmail.com>
Subject: [PATCH] net/sched: cls_flow: reject baseclass resolution on shared blocks
Date: Mon, 30 Mar 2026 00:53:49 +0800 [thread overview]
Message-ID: <20260329165349.241123-1-tpluszz77@gmail.com> (raw)
flow_change() calls tcf_block_q() and immediately dereferences the
returned qdisc pointer to resolve a zero-major baseclass handle.
On shared blocks, tcf_block_q() returns NULL because no qdisc owns
the block, causing a NULL pointer dereference.
Check for NULL before dereferencing and return -EOPNOTSUPP, since
shared blocks have no qdisc handle to derive the major number from.
Triggered by creating a cls_flow filter on a shared block without
a non-zero-major TCA_FLOW_BASECLASS:
Kernel panic - not syncing: kernel: panic_on_warn set ...
Call Trace:
<TASK>
check_panic_on_warn+0x5d/0x80
__warn+0xe7/0x300
flow_change+0x1422/0x1900
report_bug+0x9a/0x1e0
handle_bug+0x14c/0x360
exc_invalid_op+0x13/0x40
asm_exc_invalid_op+0x16/0x20
RIP: 0010:flow_change+0x1422/0x1900
tc_new_tfilter+0x92b/0x2060
rtnetlink_rcv_msg+0x758/0xab0
netlink_rcv_skb+0x120/0x350
netlink_unicast+0x755/0xaa0
netlink_sendmsg+0x787/0xc30
____sys_sendmsg+0x8b6/0xb00
___sys_sendmsg+0xed/0x170
__sys_sendmsg+0x107/0x1a0
do_syscall_64+0xe0/0x1290
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fixes: 1abf272022cf ("net: sched: tcindex, fw, flow: use tcf_block_q helper to get struct Qdisc")
Signed-off-by: Qi Tang <tpluszz77@gmail.com>
---
net/sched/cls_flow.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 339c664beff6..ad8b4c375d1c 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -505,6 +505,10 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
if (TC_H_MAJ(baseclass) == 0) {
struct Qdisc *q = tcf_block_q(tp->chain->block);
+ if (!q) {
+ err = -EOPNOTSUPP;
+ goto err2;
+ }
baseclass = TC_H_MAKE(q->handle, baseclass);
}
if (TC_H_MIN(baseclass) == 0)
--
2.43.0
reply other threads:[~2026-03-29 16:53 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=20260329165349.241123-1-tpluszz77@gmail.com \
--to=tpluszz77@gmail.com \
--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=netdev@vger.kernel.org \
--cc=pabeni@redhat.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