summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2018-02-19 08:10:17 +0100
committerBen Hutchings <ben@decadent.org.uk>2018-06-16 22:22:24 +0100
commit9a98d66730b71387c2611c28bf9ceaed17dc2621 (patch)
tree65e06536ac43bb36e7dc250d48072e735719440c
parenta315ffb96ea3355dc1188768d8adea367d9f3d94 (diff)
downloadlinux-stable-9a98d66730b71387c2611c28bf9ceaed17dc2621.tar.gz
linux-stable-9a98d66730b71387c2611c28bf9ceaed17dc2621.tar.bz2
linux-stable-9a98d66730b71387c2611c28bf9ceaed17dc2621.zip
netfilter: ipv6: fix use-after-free Write in nf_nat_ipv6_manip_pkt
commit b078556aecd791b0e5cb3a59f4c3a14273b52121 upstream. l4proto->manip_pkt() can cause reallocation of skb head so pointer to the ipv6 header must be reloaded. Reported-and-tested-by: <syzbot+10005f4292fc9cc89de7@syzkaller.appspotmail.com> Fixes: 58a317f1061c89 ("netfilter: ipv6: add IPv6 NAT support") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--net/ipv6/netfilter/nf_nat_l3proto_ipv6.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
index abfe75a2e316..fada816bd0f2 100644
--- a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
@@ -99,6 +99,10 @@ static bool nf_nat_ipv6_manip_pkt(struct sk_buff *skb,
!l4proto->manip_pkt(skb, &nf_nat_l3proto_ipv6, iphdroff, hdroff,
target, maniptype))
return false;
+
+ /* must reload, offset might have changed */
+ ipv6h = (void *)skb->data + iphdroff;
+
manip_addr:
if (maniptype == NF_NAT_MANIP_SRC)
ipv6h->saddr = target->src.u3.in6;