Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: use skb_to_full_sk in ip6_route_me_harder

For some reason, Florian forgot to apply to ip6_route_me_harder
the fix that went in commit 29e09229d9f2 ("netfilter: use
skb_to_full_sk in ip_route_me_harder")

Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener") 
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Eric Dumazet and committed by
Pablo Neira Ayuso
7d98386d 47b7e7f8

+5 -4
+5 -4
net/ipv6/netfilter.c
··· 21 21 int ip6_route_me_harder(struct net *net, struct sk_buff *skb) 22 22 { 23 23 const struct ipv6hdr *iph = ipv6_hdr(skb); 24 + struct sock *sk = sk_to_full_sk(skb->sk); 24 25 unsigned int hh_len; 25 26 struct dst_entry *dst; 26 27 struct flowi6 fl6 = { 27 - .flowi6_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0, 28 + .flowi6_oif = sk ? sk->sk_bound_dev_if : 0, 28 29 .flowi6_mark = skb->mark, 29 - .flowi6_uid = sock_net_uid(net, skb->sk), 30 + .flowi6_uid = sock_net_uid(net, sk), 30 31 .daddr = iph->daddr, 31 32 .saddr = iph->saddr, 32 33 }; 33 34 int err; 34 35 35 - dst = ip6_route_output(net, skb->sk, &fl6); 36 + dst = ip6_route_output(net, sk, &fl6); 36 37 err = dst->error; 37 38 if (err) { 38 39 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); ··· 51 50 if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && 52 51 xfrm_decode_session(skb, flowi6_to_flowi(&fl6), AF_INET6) == 0) { 53 52 skb_dst_set(skb, NULL); 54 - dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), skb->sk, 0); 53 + dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), sk, 0); 55 54 if (IS_ERR(dst)) 56 55 return PTR_ERR(dst); 57 56 skb_dst_set(skb, dst);