From: Yun Zhou <yun.zhou@windriver.com>
To: <edumazet@google.com>, <davem@davemloft.net>,
<jiayuan.chen@linux.dev>, <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yun.zhou@windriver.com>
Subject: [PATCH] net/sched: cls_flower: reject ETH_ADDRS match on devices without L2 header
Date: Wed, 3 Jun 2026 18:11:35 +0800 [thread overview]
Message-ID: <20260603101135.1954370-1-yun.zhou@windriver.com> (raw)
Reject loading flower filters that match on Ethernet addresses
(eth_dst/eth_src) when the underlying device does not have an Ethernet
header (hard_header_len < sizeof(flow_dissector_key_eth_addrs)).
When such a filter is installed on a device like TUN (IFF_TUN mode,
hard_header_len=0), the flow dissector will attempt to read 12 bytes
from skb mac_header during classification. Since TUN is an L3 device
with no link-layer header, this reads uninitialized skb memory, causing
KMSAN to report uninit-value in __fl_lookup via rhashtable_lookup_fast.
Fix this at the source by preventing nonsensical filter configurations
rather than adding bounds checks in the hot classification path.
Reported-by: syzbot+fa2f5b1fb06147be5e16@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fa2f5b1fb06147be5e16
Fixes: 77b9900ef53a ("tc: introduce Flower classifier")
Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
Suggested-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
net/sched/cls_flower.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 88f8a32fab2b..187cb6a60309 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -2465,6 +2465,18 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
if (err)
goto unbind_filter;
+ if (FL_KEY_IS_MASKED(&mask->key, eth)) {
+ struct Qdisc *q = tp->chain->block->q;
+
+ if (q && qdisc_dev(q)->hard_header_len <
+ sizeof(struct flow_dissector_key_eth_addrs)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Device does not have an Ethernet header");
+ err = -EINVAL;
+ goto unbind_filter;
+ }
+ }
+
fl_mask_update_range(mask);
fl_set_masked_key(&fnew->mkey, &fnew->key, mask);
--
2.43.0
next reply other threads:[~2026-06-03 10:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 10:11 Yun Zhou [this message]
2026-06-06 1:52 ` Jakub Kicinski
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=20260603101135.1954370-1-yun.zhou@windriver.com \
--to=yun.zhou@windriver.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®