UPSTREAM: ipv6: add complete rcu protection around np->opt 48/154948/1
authorEric Dumazet <edumazet@google.com>
Mon, 30 Nov 2015 03:37:57 +0000 (19:37 -0800)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 11 Oct 2017 12:17:54 +0000 (21:17 +0900)
commit644ccb48eebb1c736f5cd314b094057fbdb0d6ee
tree51610187f75476656ff47320eac4c552c181b872
parent0b7ec1475828801019fdf5e218b6074c9df02e39
UPSTREAM: ipv6: add complete rcu protection around np->opt

[ Upstream commit 45f6fad84cc305103b28d73482b344d7f5b76f39 ]

This patch addresses multiple problems :

UDP/RAW sendmsg() need to get a stable struct ipv6_txoptions
while socket is not locked : Other threads can change np->opt
concurrently. Dmitry posted a syzkaller
(http://github.com/google/syzkaller) program desmonstrating
use-after-free.

Starting with TCP/DCCP lockless listeners, tcp_v6_syn_recv_sock()
and dccp_v6_request_recv_sock() also need to use RCU protection
to dereference np->opt once (before calling ipv6_dup_options())

This patch adds full RCU protection to np->opt

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[sw0312.kim: cherry-pick mainline backported patch to fix CVE-2016-3841
 - from android-3.10.y in https://android.googlesource.com/kernel/common]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Ia0ad9b75da9c86cfaee15e103784f9a500ae3768
13 files changed:
include/linux/ipv6.h
include/net/ipv6.h
net/dccp/ipv6.c
net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/exthdrs.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ipv6_sockglue.c
net/ipv6/raw.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/l2tp/l2tp_ip6.c