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 p9_client_readdir() fix 2017-05-02 21:19:55 -07:00
802
8021q vlan: Propagate MAC address to VLANs 2017-08-06 19:19:43 -07:00
appletalk
atm
ax25 ax25: Fix segfault after sock connection timeout 2017-02-04 09:45:09 +01:00
batman-adv batman-adv: Check for alloc errors when preparing TT local data 2016-12-15 08:49:23 -08:00
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 net: caif: Fix a sleep-in-atomic bug in cfpkt_create_pfx 2017-07-05 14:37:14 +02:00
can can: Fix kernel panic at security_sock_rcv_skb 2017-02-18 16:39:26 +01:00
ceph libceph: force GFP_NOIO for socket allocations 2017-04-08 09:53:30 +02:00
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 decnet: always not take dst->__refcnt when inserting dst into hash table 2017-07-05 14:37:14 +02:00
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 net: introduce device min_header_len 2017-02-18 16:39:27 +01:00
hsr net/hsr: fix a warning message 2015-11-23 14:56:15 -05:00
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 ipx: call ipxitf_put() in ioctl error path 2017-05-25 14:30:13 +02:00
irda irda: do not leak initialized list.dev to userspace 2017-08-30 10:19:21 +02:00
iucv af_iucv: Validate socket address length in iucv_sock_bind() 2016-03-03 15:07:03 -08:00
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 net/llc: avoid BUG_ON() in skb_orphan() 2017-02-26 11:07:49 +01:00
mac80211 This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
mac802154
mpls mpls: Send route delete notifications when router module is unloaded 2017-03-22 12:04:16 +01:00
netfilter This is the 4.4.94 stable release 2017-10-22 08:09:11 +02:00
netlabel netlabel: add address family checks to netlbl_{sock,req}_delattr() 2016-08-20 18:09:22 +02:00
netlink netlink: Allow direct reclaim for fallback allocation 2017-05-08 07:46:02 +02:00
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 phonet: properly unshare skbs in phonet_rcv() 2016-01-31 11:29:00 -08:00
rds rds: ib: add error handle 2017-10-08 10:14:19 +02:00
rfkill ANDROID: rfkill: fix unused function warning 2017-05-12 14:36:34 +02:00
rose
rxrpc rxrpc: Fix several cases where a padded len isn't checked in ticket decode 2017-06-29 12:48:52 +02:00
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 SUNRPC: fix refcounting problems with auth_gss messages. 2017-04-21 09:30:08 +02:00
switchdev switchdev: pass pointer to fib_info instead of copy 2016-06-24 10:18:16 -07:00
tipc tipc: use only positive error codes in messages 2017-10-21 17:09:03 +02:00
unix af_unix: Add sockaddr length checks before accessing sa_family in bind and connect handlers 2017-07-05 14:37:13 +02:00
vmw_vsock VSOCK: Detach QP check should filter out non matching QPs. 2017-04-27 09:09:32 +02:00
wimax
wireless This is the 4.4.93 stable release 2017-10-19 10:08:29 -07:00
x25 net: fix a kernel infoleak in x25 module 2016-05-18 17:06:43 -07:00
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 Revert "net: activity_stats: Add statistics for network transmission activity" 2016-04-25 22:19:46 +05:30
Makefile Revert "net: activity_stats: Add statistics for network transmission activity" 2016-04-25 22:19:46 +05:30
socket.c UPSTREAM: net: socket: Make unnecessarily global sockfs_setattr() static 2017-04-14 19:00:48 +05:30
sysctl_net.c net: Use ns_capable_noaudit() when determining net sysctl permissions 2016-09-15 08:27:50 +02:00