Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: geneve: check skb is large enough for IPv4/IPv6 header

Check within geneve_xmit_skb/geneve6_xmit_skb that sk_buff structure
is large enough to include IPv4 or IPv6 header, and reject if not. The
geneve_xmit_skb portion and overall idea was contributed by Eric Dumazet.
Fixes a KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=abe95dc3e3e9667fc23b8d81f29ecad95c6f106f

Suggested-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot+2e406a9ac75bb71d4b7a@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Phillip Potter and committed by
David S. Miller
6628ddfe 31457db3

+6
+6
drivers/net/geneve.c
··· 891 891 __be16 sport; 892 892 int err; 893 893 894 + if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) 895 + return -EINVAL; 896 + 894 897 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 895 898 rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info, 896 899 geneve->cfg.info.key.tp_dst, sport); ··· 987 984 __u8 prio, ttl; 988 985 __be16 sport; 989 986 int err; 987 + 988 + if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) 989 + return -EINVAL; 990 990 991 991 sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); 992 992 dst = geneve_get_v6_dst(skb, dev, gs6, &fl6, info,