Skip to content

Commit 6ea14cc

Browse files
committed
netfilter: flowtable: validate vlan header
Ensure there is sufficient room to access the protocol field of the VLAN header, validate it once before the flowtable lookup. ===================================================== BUG: KMSAN: uninit-value in nf_flow_offload_inet_hook+0x45a/0x5f0 net/netfilter/nf_flow_table_inet.c:32 nf_flow_offload_inet_hook+0x45a/0x5f0 net/netfilter/nf_flow_table_inet.c:32 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook_ingress include/linux/netfilter_netdev.h:34 [inline] nf_ingress net/core/dev.c:5440 [inline] Fixes: 4cd91f7 ("netfilter: flowtable: add vlan support") Reported-by: [email protected] Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent a0b39e2 commit 6ea14cc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

net/netfilter/nf_flow_table_inet.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ nf_flow_offload_inet_hook(void *priv, struct sk_buff *skb,
1717

1818
switch (skb->protocol) {
1919
case htons(ETH_P_8021Q):
20+
if (!pskb_may_pull(skb, skb_mac_offset(skb) + sizeof(*veth)))
21+
return NF_ACCEPT;
22+
2023
veth = (struct vlan_ethhdr *)skb_mac_header(skb);
2124
proto = veth->h_vlan_encapsulated_proto;
2225
break;

net/netfilter/nf_flow_table_ip.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ static bool nf_flow_skb_encap_protocol(struct sk_buff *skb, __be16 proto,
281281

282282
switch (skb->protocol) {
283283
case htons(ETH_P_8021Q):
284+
if (!pskb_may_pull(skb, skb_mac_offset(skb) + sizeof(*veth)))
285+
return false;
286+
284287
veth = (struct vlan_ethhdr *)skb_mac_header(skb);
285288
if (veth->h_vlan_encapsulated_proto == proto) {
286289
*offset += VLAN_HLEN;

0 commit comments

Comments
 (0)