]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ip6_gre: fix ip6gre_err() invalid reads
authorEric Dumazet <edumazet@google.com>
Sun, 5 Feb 2017 07:18:55 +0000 (23:18 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 26 Feb 2017 20:01:50 +0000 (20:01 +0000)
commit3a997b28bbc69f7637ccd62c5a37379dec34f36b
tree6361ade5921033182e7f40a2e5e06348bf9993e9
parentb35e1587153b27e12747137ce7a0df0eb921cd85
ip6_gre: fix ip6gre_err() invalid reads

commit 7892032cfe67f4bde6fc2ee967e45a8fbaf33756 upstream.

Andrey Konovalov reported out of bound accesses in ip6gre_err()

If GRE flags contains GRE_KEY, the following expression
*(((__be32 *)p) + (grehlen / 4) - 1)

accesses data ~40 bytes after the expected point, since
grehlen includes the size of IPv6 headers.

Let's use a "struct gre_base_hdr *greh" pointer to make this
code more readable.

p[1] becomes greh->protocol.
grhlen is the GRE header length.

Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16:
 - Add #include <net/gre.h>, added earlier upstream
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv6/ip6_gre.c