public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: xeb@mail.ru, netdev@vger.kernel.org
Subject: Re: gre: Support GRE over IPv6
Date: Wed, 26 Sep 2012 13:39:20 +0200	[thread overview]
Message-ID: <1348659560.5093.337.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120926110258.GP13767@mwanda>

From: Eric Dumazet <edumazet@google.com>

On Wed, 2012-09-26 at 14:02 +0300, Dan Carpenter wrote:
> Hi Dmitry,
> 
> I never heard back on this whether it was memory corruption bug or
> not?
> 
> regards,
> dan carpenter
> 
> On Thu, Sep 13, 2012 at 07:01:05PM +0300, Dan Carpenter wrote:
> > 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?


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.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 net/ipv6/ip6_gre.c |    8 --------
 1 file changed, 8 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 424d11a..796f5d5 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -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 = {

  reply	other threads:[~2012-09-26 11:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 16:01 gre: Support GRE over IPv6 Dan Carpenter
2012-09-26 11:02 ` Dan Carpenter
2012-09-26 11:39   ` Eric Dumazet [this message]
2012-09-27 23:07     ` David Miller
     [not found] <20121002205219.7C3BD340556@ra.kernel.org>
2013-04-24 12:23 ` Geert Uytterhoeven
2013-04-24 15:14   ` Eric Dumazet

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=1348659560.5093.337.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=xeb@mail.ru \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox