Skip to content

Commit b078556

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: ipv6: fix use-after-free Write in nf_nat_ipv6_manip_pkt
l4proto->manip_pkt() can cause reallocation of skb head so pointer to the ipv6 header must be reloaded. Reported-and-tested-by: <[email protected]> Fixes: 58a317f ("netfilter: ipv6: add IPv6 NAT support") Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 1a9da59 commit b078556

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/ipv6/netfilter/nf_nat_l3proto_ipv6.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ static bool nf_nat_ipv6_manip_pkt(struct sk_buff *skb,
9999
!l4proto->manip_pkt(skb, &nf_nat_l3proto_ipv6, iphdroff, hdroff,
100100
target, maniptype))
101101
return false;
102+
103+
/* must reload, offset might have changed */
104+
ipv6h = (void *)skb->data + iphdroff;
105+
102106
manip_addr:
103107
if (maniptype == NF_NAT_MANIP_SRC)
104108
ipv6h->saddr = target->src.u3.in6;

0 commit comments

Comments
 (0)