android_kernel_oneplus_msm8998/net
Jonathan Basseri faa82dcc9d BACKPORT: xfrm: Clear sk_dst_cache when applying per-socket policy.
If a socket has a valid dst cache, then xfrm_lookup_route will get
skipped. However, the cache is not invalidated when applying policy to a
socket (i.e. IPV6_XFRM_POLICY). The result is that new policies are
sometimes ignored on those sockets. (Note: This was broken for IPv4 and
IPv6 at different times.)

This can be demonstrated like so,
1. Create UDP socket.
2. connect() the socket.
3. Apply an outbound XFRM policy to the socket. (setsockopt)
4. send() data on the socket.

Packets will continue to be sent in the clear instead of matching an
xfrm or returning a no-match error (EAGAIN). This affects calls to
send() and not sendto().

Invalidating the sk_dst_cache is necessary to correctly apply xfrm
policies. Since we do this in xfrm_user_policy(), the sk_lock was
already acquired in either do_ip_setsockopt() or do_ipv6_setsockopt(),
and we may call __sk_dst_reset().

Performance impact should be negligible, since this code is only called
when changing xfrm policy, and only affects the socket in question.

Change-Id: I54b4ec422aa5f4e31652a8c6913696f0a5610a51
Fixes: 00bc0ef5880d ("ipv6: Skip XFRM lookup if dst_entry in socket cache is valid")
Tested: https://android-review.googlesource.com/517555
Tested: https://android-review.googlesource.com/418659
Signed-off-by: Jonathan Basseri <misterikkit@google.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
(cherry picked from commit 2b06cdf3e688b98fcc9945873b5d42792bd4eee0)
2017-11-08 02:09:52 +00:00
..
6lowpan
9p
802
8021q vlan: Propagate MAC address to VLANs 2017-08-06 19:19:43 -07:00
appletalk
atm
ax25
batman-adv
bluetooth This is the 4.4.88 stable release 2017-09-14 09:48:29 -07:00
bridge This is the 4.4.91 stable release 2017-10-08 10:41:52 +02:00
caif
can
ceph
core This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
dcb
dccp dccp: defer ccid_hc_tx_delete() at dismantle time 2017-08-30 10:19:18 +02:00
decnet
dns_resolver KEYS: Fix race between updating and finding a negative key 2017-10-27 10:23:18 +02:00
dsa net: dsa: Check return value of phy_connect_direct() 2017-07-05 14:37:19 +02:00
ethernet
hsr
ieee802154 Revert "net: fix percpu memory leaks" 2017-09-27 11:00:11 +02:00
ipv4 This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
ipv6 This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
ipx
irda irda: do not leak initialized list.dev to userspace 2017-08-30 10:19:21 +02:00
iucv
key af_key: do not use GFP_KERNEL in atomic contexts 2017-08-30 10:19:18 +02:00
l2tp This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
l3mdev
lapb
llc
mac80211 This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
mac802154
mpls
netfilter This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
netlabel
netlink
netrom
nfc ANDROID: NFC: Fix possible memory corruption when handling SHDLC I-Frame commands 2017-08-21 08:45:10 -07:00
openvswitch openvswitch: fix potential out of bound access in parse_ct 2017-08-11 09:08:53 -07:00
packet packet: only test po->has_vnet_hdr once in packet_snd 2017-10-21 17:09:03 +02:00
phonet
rds rds: ib: add error handle 2017-10-08 10:14:19 +02:00
rfkill
rose
rxrpc
sched net: sched: fix NULL pointer dereference when action calls some targets 2017-08-30 10:19:21 +02:00
sctp sctp: fully initialize the IPv6 address in sctp_v6_to_addr() 2017-08-30 10:19:19 +02:00
sunrpc
switchdev
tipc tipc: use only positive error codes in messages 2017-10-21 17:09:03 +02:00
unix
vmw_vsock
wimax
wireless This is the 4.4.93 stable release 2017-10-19 10:08:29 -07:00
x25
xfrm BACKPORT: xfrm: Clear sk_dst_cache when applying per-socket policy. 2017-11-08 02:09:52 +00:00
compat.c audit: log 32-bit socketcalls 2017-10-08 10:14:18 +02:00
Kconfig
Makefile
socket.c
sysctl_net.c