From: Ranganath V N <vnranganath.20@gmail.com>
To: johannes@sipsolutions.net, dave.taht@bufferbloat.net,
linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
khalid@kernel.org, Ranganath V N <vnranganath.20@gmail.com>,
syzbot+878ddc3962f792e9af59@syzkaller.appspotmail.com
Subject: [PATCH v3] wifi: cfg80211: Fix uninitialized header access in cfg80211_classify8021d
Date: Tue, 18 Nov 2025 20:35:24 +0530 [thread overview]
Message-ID: <20251118150524.7973-1-vnranganath.20@gmail.com> (raw)
Fix an issue detected by syzbot with KMSAN
BUG: KMSAN: uninit-value in cfg80211_classify8021d+0x99d/0x12b0
net/wireless/util.c:1027
The function accessed DSCP fields from IP and IPv6 headers without first
verifying that sufficient header data was present in the skb. When a
packet reaches this path, the header dereference could access
uninitialized memory, as reported by KMSAN under fuzzing with syzkaller.
Add explicit skb_header_pointer() checks for both IPv4 and IPv6 headers to
ensure that the required header data is available before extracting the
DSCP field. This prevents uninitialized memory reads while preserving
existing behavior for valid packets
This fix has been tested and validated by syzbot. This patch closes the
bug reported at the following syzkaller link.Fixes the uninitialized
header access.
Reported-by: syzbot+878ddc3962f792e9af59@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com./bug?extid=878ddc3962f792e9af59
Tested-by: syzbot+878ddc3962f792e9af59@syzkaller.appspotmail.com
Fixes: b156579b1404 ("wireless: Treat IPv6 diffserv the same as IPv4 for 802.11e")
Signed-off-by: Ranganath V N <vnranganath.20@gmail.com>
---
validate header before DSCP read in cfg80211_classify8021d().
skb_header_pointer() checks before accessing header structures to ensure
safe and fully initialized data access.
Changes in v3:
- Corrected the code by using the correct offset past the header.
similar to the existing MPLs handling logic.
- Link to v2:https://lore.kernel.org/all/20251108-fifth-v2-1-405da01c6684@gmail.com
Changes in v2:
- Corrected the commit subject and Fixes tag.
- Link to v1: https://lore.kernel.org/r/20251103-fifth-v1-1-4a221737ddfe@gmail.com
---
net/wireless/util.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 56724b33af04..f2a6644d854e 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -963,9 +963,23 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
switch (skb->protocol) {
case htons(ETH_P_IP):
+ struct iphdr iph, *ip;
+
+ ip = skb_header_pointer(skb, sizeof(struct ethhdr),
+ sizeof(*ip), &iph);
+ if (!ip)
+ return 0;
+
dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;
break;
case htons(ETH_P_IPV6):
+ struct ipv6hdr ip6h, *ip6;
+
+ ip6 = skb_header_pointer(skb, sizeof(struct ethhdr),
+ sizeof(*ip6), &ip6h);
+ if (!ip6)
+ return 0;
+
dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & 0xfc;
break;
case htons(ETH_P_MPLS_UC):
--
2.43.0
next reply other threads:[~2025-11-18 15:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 15:05 Ranganath V N [this message]
2025-11-19 9:09 ` [PATCH v3] wifi: cfg80211: Fix uninitialized header access in cfg80211_classify8021d Johannes Berg
2025-11-19 14:49 ` kernel test robot
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=20251118150524.7973-1-vnranganath.20@gmail.com \
--to=vnranganath.20@gmail.com \
--cc=dave.taht@bufferbloat.net \
--cc=david.hunter.linux@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=khalid@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+878ddc3962f792e9af59@syzkaller.appspotmail.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 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.