Skip to contentSkip to conversation

wifi: cfg80211: Fix uninitialized header access in cfg80211_classify8021d

PATCH Superseded Ranganath V N 2 participants 3 messages Nov 7, 2025 – Nov 11, 2025 802.11 (including cfg80211/NL80211)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: cfg80211: Fix uninitialized header access in cfg80211_classify8021d

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 pskb_may_pull() 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 [email protected]
Fixes b156579b1404 ("wireless: Treat IPv6 diffserv the same as IPv4 for 802.11e")

---
validate header before DSCP read in cfg80211_classify8021d(). pskb_may_pull() checks before accessing header structures to ensure safe and fully initialized data access.
---
Changes in v2:
- Corrected the commit subject and Fixes tag.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 net/wireless/util.c | 4 ++++
 1 file changed, 4 insertions(+)
net/wireless/util.c +4 -0
index 56724b33af04..23bca5e687c1 100644
@@ -963,9 +963,13 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
 
 	switch (skb->protocol) {
 	case htons(ETH_P_IP):
+		if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+			return 0;
 		dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;
 		break;
 	case htons(ETH_P_IPV6):
+		if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
+			return 0;
 		dscp = ipv6_get_dsfield(ipv6_hdr(skb)) & 0xfc;
 		break;
 	case htons(ETH_P_MPLS_UC):

---
base-commit: ba36dd5ee6fd4643ebbf6ee6eefcecf0b07e35c7
change-id: 20251101-fifth-84c599edf594

Best regards,

Signature · 1 line
Ranganath V N <[email protected]>
maintainer
#1 lore raw

net/wireless/util.c unsigned int cfg80211_classify8021d(struct sk_buff *skb, · line 969

Quoted 10 lines · Ranganath V N

+++ b/net/wireless/util.c

net/wireless/util.c +2 -0
@@ -963,9 +963,13 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb,
 
 	switch (skb->protocol) {
 	case htons(ETH_P_IP):
+		if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+			return 0;
 		dscp = ipv4_get_dsfield(ip_hdr(skb)) & 0xfc;
 		break;

That doesn't seem correct to me, passing only the IP header length to pskb_may_pull() call assumes that ip_hdr(skb) == sbk->data, which is almost certainly not true?

MPLS seems to not have this problem.

And maybe there's a similar issue for the VLAN tag?

johannes

#2 lore raw
Quoted 1 line

MPLS seems to not have this problem.

MPLS avoids this issue beacuse skb_header_pointer() is used with the proper
offset.

Quoted 1 line

And maybe there's a similar issue for the VLAN tag?

yes we may need to consider this(header+vlan)

I'll update the fix by using the skb_header_pointer simillar to MPLS. Thanks for the feedback.
--ranganath