gre: Support GRE over IPv6
Subsystems (3)
Hello Dmitry Kozlov,
The patch c12b395a4664: "gre: Support GRE over IPv6" from Aug 10, 2012, leads to the following warning:net/ipv6/ip6_gre.c:1299 ip6gre_header_parse()
error: memcpy() 'haddr' too small (8 vs 16)
net/ipv6/ip6_gre.c
1296 static int ip6gre_header_parse(const struct sk_buff *skb, unsigned char *haddr) 1297 {
1298 const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb_mac_header(skb);
1299 memcpy(haddr, &ipv6h->saddr, sizeof(struct in6_addr));
^^^^^Smatch thinks this buffer is only 8 characters sometimes.
1300 return sizeof(struct in6_addr); 1301 }
One call tree where this would happen would be the (struct sockaddr_ll *)sll->sll_addr[] in packet_rcv().
-> packet_rcv()
-> dev_parse_header()
-> ip6gre_header_parse()
I don't know the code well enough to say if this is a bug or not. Could you take a look?
regards,
dan carpenter
Hi Dmitry,
I never heard back on this whether it was memory corruption bug or not?
regards,
dan carpenter
Quoted 30 lines · Dan Carpenter
Hello Dmitry Kozlov,
The patch
c12b395a4664: "gre: Support GRE over IPv6" from Aug 10, 2012, leads to the following warning:net/ipv6/ip6_gre.c:1299ip6gre_header_parse()
error:memcpy()'haddr' too small (8 vs 16)
net/ipv6/ip6_gre.c
1296 static intip6gre_header_parse(const struct sk_buff *skb, unsigned char *haddr)1297 {
1298 const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb_mac_header(skb);1299 memcpy(haddr, &ipv6h->saddr, sizeof(struct in6_addr)); ^^^^^Smatch thinks this buffer is only 8 characters sometimes.
1300 return sizeof(struct in6_addr); 1301 }One call tree where this would happen would be the (struct
sockaddr_ll*)sll->sll_addr[] inpacket_rcv().->
packet_rcv()
->dev_parse_header()-> ip6gre_header_parse()I don't know the code well enough to say if this is a bug or not. Could you take a look?
regards,
dan carpenter
From: Eric Dumazet <[email protected]>
Quoted 36 lines · Dan Carpenter
Hi Dmitry,
I never heard back on this whether it was memory corruption bug or not?
regards,
dan carpenterQuoted 27 lines · Dan Carpenter
Hello Dmitry Kozlov,
The patch
c12b395a4664: "gre: Support GRE over IPv6" from Aug 10, 2012, leads to the following warning:net/ipv6/ip6_gre.c:1299ip6gre_header_parse()
error:memcpy()'haddr' too small (8 vs 16)
net/ipv6/ip6_gre.c
1296 static intip6gre_header_parse(const struct sk_buff *skb, unsigned char *haddr)1297 {
1298 const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb_mac_header(skb);1299 memcpy(haddr, &ipv6h->saddr, sizeof(struct in6_addr)); ^^^^^Smatch thinks this buffer is only 8 characters sometimes.
1300 return sizeof(struct in6_addr); 1301 }One call tree where this would happen would be the (struct
sockaddr_ll*)sll->sll_addr[] inpacket_rcv().->
packet_rcv()
->dev_parse_header()-> ip6gre_header_parse()I don't know the code well enough to say if this is a bug or not. Could you take a look?
All dev_parse_header() callers provide 8 bytes of storage.
By the way net/netfilter/nfnetlink_log.c and net/netfilter/nfnetlink_queue_core.c leaks the _pad field to userspace, I will send a separate patch to netfilter guys.
I would just remove this stuff, as it was copied/pasted from ipv4/ip_gre.c without thinking of its use.
Thanks
[PATCH net-next] ipv6: gre: remove ip6gre_header_parse()
dev_parse_header() callers provide 8 bytes of storage, so it's not possible to store an IPv6 address.
--- net/ipv6/ip6_gre.c | 8 -------- 1 file changed, 8 deletions(-)
net/ipv6/ip6_gre.c +0 -8
@@ -1293,16 +1293,8 @@ static int ip6gre_header(struct sk_buff *skb, struct net_device *dev,return -t->hlen; } -static int ip6gre_header_parse (const struct sk_buff *skb,unsigned char *haddr) -{ -const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb_mac_header (skb); -memcpy (haddr, &ipv6h->saddr,sizeof (struct in6_addr )); -return sizeof (struct in6_addr ); -} -static const struct header_ops ip6gre_header_ops = { .create = ip6gre_header, - .parse = ip6gre_header_parse, };static const struct net_device_ops ip6gre_netdev_ops = {
From: Eric Dumazet <[email protected]>
Date: Wed, 26 Sep 2012 13:39:20 +0200
Quoted 1 line
From: Eric Dumazet <[email protected]>
...
Quoted 7 lines
[PATCH net-next] ipv6: gre: remove
ip6gre_header_parse()
dev_parse_header()callers provide 8 bytes of storage, so it's not possible to store an IPv6 address.Signed-off-by Eric Dumazet <[email protected]>Reported-by Dan Carpenter <[email protected]>
Applied, thanks Eric.