android_kernel_sony_sdm845/net/ipv6
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Taehee Yoo 743475d915 ip6_gre: fix use-after-free in ip6gre_tunnel_lookup()
[ Upstream commit dafabb6590cb15f300b77c095d50312e2c7c8e0f ]

In the datapath, the ip6gre_tunnel_lookup() is used and it internally uses
fallback tunnel device pointer, which is fb_tunnel_dev.
This pointer variable should be set to NULL when a fb interface is deleted.
But there is no routine to set fb_tunnel_dev pointer to NULL.
So, this pointer will be still used after interface is deleted and
it eventually results in the use-after-free problem.

Test commands:
    ip netns add A
    ip netns add B
    ip link add eth0 type veth peer name eth1
    ip link set eth0 netns A
    ip link set eth1 netns B

    ip netns exec A ip link set lo up
    ip netns exec A ip link set eth0 up
    ip netns exec A ip link add ip6gre1 type ip6gre local fc:0::1 \
	    remote fc:0::2
    ip netns exec A ip -6 a a fc💯:1/64 dev ip6gre1
    ip netns exec A ip link set ip6gre1 up
    ip netns exec A ip -6 a a fc:0::1/64 dev eth0
    ip netns exec A ip link set ip6gre0 up

    ip netns exec B ip link set lo up
    ip netns exec B ip link set eth1 up
    ip netns exec B ip link add ip6gre1 type ip6gre local fc:0::2 \
	    remote fc:0::1
    ip netns exec B ip -6 a a fc💯:2/64 dev ip6gre1
    ip netns exec B ip link set ip6gre1 up
    ip netns exec B ip -6 a a fc:0::2/64 dev eth1
    ip netns exec B ip link set ip6gre0 up
    ip netns exec A ping fc💯:2 -s 60000 &
    ip netns del B

Splat looks like:
[   73.087285][    C1] BUG: KASAN: use-after-free in ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
[   73.088361][    C1] Read of size 4 at addr ffff888040559218 by task ping/1429
[   73.089317][    C1]
[   73.089638][    C1] CPU: 1 PID: 1429 Comm: ping Not tainted 5.7.0+ #602
[   73.090531][    C1] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[   73.091725][    C1] Call Trace:
[   73.092160][    C1]  <IRQ>
[   73.092556][    C1]  dump_stack+0x96/0xdb
[   73.093122][    C1]  print_address_description.constprop.6+0x2cc/0x450
[   73.094016][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
[   73.094894][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
[   73.095767][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
[   73.096619][    C1]  kasan_report+0x154/0x190
[   73.097209][    C1]  ? ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
[   73.097989][    C1]  ip6gre_tunnel_lookup+0x1064/0x13f0 [ip6_gre]
[   73.098750][    C1]  ? gre_del_protocol+0x60/0x60 [gre]
[   73.099500][    C1]  gre_rcv+0x1c5/0x1450 [ip6_gre]
[   73.100199][    C1]  ? ip6gre_header+0xf00/0xf00 [ip6_gre]
[   73.100985][    C1]  ? rcu_read_lock_sched_held+0xc0/0xc0
[   73.101830][    C1]  ? ip6_input_finish+0x5/0xf0
[   73.102483][    C1]  ip6_protocol_deliver_rcu+0xcbb/0x1510
[   73.103296][    C1]  ip6_input_finish+0x5b/0xf0
[   73.103920][    C1]  ip6_input+0xcd/0x2c0
[   73.104473][    C1]  ? ip6_input_finish+0xf0/0xf0
[   73.105115][    C1]  ? rcu_read_lock_held+0x90/0xa0
[   73.105783][    C1]  ? rcu_read_lock_sched_held+0xc0/0xc0
[   73.106548][    C1]  ipv6_rcv+0x1f1/0x300
[ ... ]

Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Fixes: c12b395a46 ("gre: Support GRE over IPv6")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-06-30 15:38:39 -04:00
..
ila ila_xlat: add missing hash secret initialization 2017-06-24 07:11:12 +02:00
netfilter netfilter: ipv6: nf_defrag: accept duplicate fragments again 2019-07-21 09:05:53 +02:00
addrconf.c ipv6/addrconf: call ipv6_mc_up() for non-Ethernet interface 2020-03-20 09:07:38 +01:00
addrconf_core.c net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup 2020-05-20 08:15:30 +02:00
addrlabel.c ipv6/addrlabel: fix ip6addrlbl_get() 2015-12-22 15:57:54 -05:00
af_inet6.c net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup 2020-05-20 08:15:30 +02:00
ah6.c ipsec: check return value of skb_to_sgvec always 2018-04-13 19:48:31 +02:00
anycast.c
calipso.c netlabel: cope with NULL catmap 2020-05-20 08:15:39 +02:00
datagram.c net: ipv6: add net argument to ip6_dst_lookup_flow 2020-05-20 08:15:30 +02:00
esp6.c esp6: fix memleak on error path in esp6_input 2020-06-11 09:22:18 +02:00
exthdrs.c ipv6: make ipv6_renew_options() interrupt/kernel safe 2018-08-24 13:12:36 +02:00
exthdrs_core.c ipv6: constify the skb pointer of ipv6_find_tlv(). 2016-06-27 15:06:15 -04:00
exthdrs_offload.c
fib6_rules.c ipv6: Do not leak throw route references 2017-07-05 14:40:16 +02:00
fou6.c fou: add Kconfig options for IPv6 support 2016-05-29 22:24:21 -07:00
icmp.c net: handle no dst on skb in icmp6_send 2016-11-28 16:13:01 -05:00
inet6_connection_sock.c net: ipv6: add net argument to ip6_dst_lookup_flow 2020-05-20 08:15:30 +02:00
inet6_hashtables.c tcp/dccp: fix possible race __inet_lookup_established() 2020-01-04 13:41:12 +01:00
ip6_checksum.c net: udp: fix handling of CHECKSUM_COMPLETE packets 2018-11-10 07:42:58 -08:00
ip6_fib.c ipv6: Fix route replacement with dev-only route 2020-03-11 07:53:05 +01:00
ip6_flowlabel.c ipv6: flowlabel: fl6_sock_lookup() must use atomic_inc_not_zero 2019-06-22 08:17:21 +02:00
ip6_gre.c ip6_gre: fix use-after-free in ip6gre_tunnel_lookup() 2020-06-30 15:38:39 -04:00
ip6_icmp.c ipv6: icmp: add a force_saddr param to icmp6_send() 2016-06-18 22:11:38 -07:00
ip6_input.c ipv6: drop incoming packets having a v4mapped source address 2019-10-07 18:53:20 +02:00
ip6_offload.c gso_segment: Reset skb->mac_len after modifying network header 2018-09-29 03:07:32 -07:00
ip6_offload.h udp: Add GRO functions to UDP socket 2016-04-07 16:53:29 -04:00
ip6_output.c net: ipv6: add net argument to ip6_dst_lookup_flow 2020-05-20 08:15:30 +02:00
ip6_tunnel.c net, ip6_tunnel: fix namespaces move 2020-01-29 10:24:37 +01:00
ip6_udp_tunnel.c ipv6: explicitly initialize udp6_addr in udp_sock_create6() 2019-01-09 16:16:40 +01:00
ip6_vti.c vti6: Fix memory leak of skb if input policy check fails 2020-04-02 17:20:35 +02:00
ip6mr.c ipv6: check sk sk_type and protocol early in ip_mroute_set/getsockopt 2019-08-04 09:33:43 +02:00
ipcomp6.c
ipv6_sockglue.c ipv6: fix IPV6_ADDRFORM operation logic 2020-06-20 10:24:07 +02:00
Kconfig fou: fix IPv6 Kconfig options 2016-05-31 14:07:49 -07:00
Makefile Merge branch 'stable-4.8' of git://git.infradead.org/users/pcmoore/selinux into next 2016-07-07 10:15:34 +10:00
mcast.c mld: fix memory leak in ipv6_mc_destroy_dev() 2020-06-30 15:38:38 -04:00
mcast_snoop.c
mip6.c
ndisc.c ipv6/ndisc: Preserve IPv6 control buffer if protocol error handlers are called 2018-11-10 07:42:57 -08:00
netfilter.c
output_core.c inet: switch IP ID generator to siphash 2019-08-25 10:51:42 +02:00
ping.c ipv6: Fix the link time qualifier of 'ping_v6_proc_exit_net()' 2019-09-21 07:14:01 +02:00
proc.c inet: frags: break the 2GB limit for frags storage 2018-10-18 09:13:24 +02:00
protocol.c
raw.c net: ipv6: add net argument to ip6_dst_lookup_flow 2020-05-20 08:15:30 +02:00
reassembly.c inet: frags: call inet_frags_fini() after unregister_pernet_subsys() 2020-01-29 10:24:25 +01:00
route.c Revert "ipv6: add mtu lock check in __ip6_rt_update_pmtu" 2020-05-20 08:15:39 +02:00
sit.c Revert "net: sit: fix memory leak in sit_init_net()" 2019-10-29 09:15:26 +01:00
syncookies.c net: ipv6: add net argument to ip6_dst_lookup_flow 2020-05-20 08:15:30 +02:00
sysctl_net_ipv6.c calipso: Add a label cache. 2016-06-27 15:06:17 -04:00
tcp_ipv6.c net: ipv6: add net argument to ip6_dst_lookup_flow 2020-05-20 08:15:30 +02:00
tcpv6_offload.c gso: validate gso_type in GSO handlers 2018-01-31 12:55:55 +01:00
tunnel6.c ipv6: fix tunnel error handling 2015-11-03 10:52:13 -05:00
udp.c bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err 2019-07-10 09:55:42 +02:00
udp_impl.h udplite: call proper backlog handlers 2016-11-24 15:32:14 -05:00
udp_offload.c gso: validate gso_type in GSO handlers 2018-01-31 12:55:55 +01:00
udplite.c udplite: call proper backlog handlers 2016-11-24 15:32:14 -05:00
xfrm6_input.c vti6: fix input path 2016-09-21 10:09:14 +02:00
xfrm6_mode_beet.c
xfrm6_mode_ro.c ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt() 2017-06-14 15:05:51 +02:00
xfrm6_mode_transport.c ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt() 2017-06-14 15:05:51 +02:00
xfrm6_mode_tunnel.c ipv6: update skb->csum when CE mark is propagated 2016-01-15 15:07:23 -05:00
xfrm6_output.c xfrm: Always set XFRM_TRANSFORMED in xfrm{4,6}_output_finish 2020-05-02 17:23:09 +02:00
xfrm6_policy.c xfrm6: avoid potential infinite loop in _decode_session6() 2018-06-26 08:08:05 +08:00
xfrm6_protocol.c
xfrm6_state.c
xfrm6_tunnel.c xfrm6_tunnel: Fix potential panic when unloading xfrm6_tunnel module 2019-05-25 18:26:54 +02:00