linux-imx/net
Al Viro 4fa1d0ff4f missing barriers in some of unix_sock ->addr and ->path accesses
[ Upstream commit ae3b564179 ]

Several u->addr and u->path users are not holding any locks in
common with unix_bind().  unix_state_lock() is useless for those
purposes.

u->addr is assign-once and *(u->addr) is fully set up by the time
we set u->addr (all under unix_table_lock).  u->path is also
set in the same critical area, also before setting u->addr, and
any unix_sock with ->path filled will have non-NULL ->addr.

So setting ->addr with smp_store_release() is all we need for those
"lockless" users - just have them fetch ->addr with smp_load_acquire()
and don't even bother looking at ->path if they see NULL ->addr.

Users of ->addr and ->path fall into several classes now:
    1) ones that do smp_load_acquire(u->addr) and access *(u->addr)
and u->path only if smp_load_acquire() has returned non-NULL.
    2) places holding unix_table_lock.  These are guaranteed that
*(u->addr) is seen fully initialized.  If unix_sock is in one of the
"bound" chains, so's ->path.
    3) unix_sock_destructor() using ->addr is safe.  All places
that set u->addr are guaranteed to have seen all stores *(u->addr)
while holding a reference to u and unix_sock_destructor() is called
when (atomic) refcount hits zero.
    4) unix_release_sock() using ->path is safe.  unix_bind()
is serialized wrt unix_release() (normally - by struct file
refcount), and for the instances that had ->path set by unix_bind()
unix_release_sock() comes from unix_release(), so they are fine.
Instances that had it set in unix_stream_connect() either end up
attached to a socket (in unix_accept()), in which case the call
chain to unix_release_sock() and serialization are the same as in
the previous case, or they never get accept'ed and unix_release_sock()
is called when the listener is shut down and its queue gets purged.
In that case the listener's queue lock provides the barriers needed -
unix_stream_connect() shoves our unix_sock into listener's queue
under that lock right after having set ->path and eventual
unix_release_sock() caller picks them from that queue under the
same lock right before calling unix_release_sock().
    5) unix_find_other() use of ->path is pointless, but safe -
it happens with successful lookup by (abstract) name, so ->path.dentry
is guaranteed to be NULL there.

earlier-variant-reviewed-by: "Paul E. McKenney" <paulmck@linux.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-19 13:11:55 +01:00
..
6lowpan 6lowpan: iphc: reset mac_header after decompress to fix panic 2018-07-06 12:32:12 +02:00
9p 9p/net: put a lower bound on msize 2019-01-13 09:24:07 +01:00
802
8021q netpoll: allow cleanup to be synchronous 2018-10-19 17:01:43 -07:00
appletalk
atm Revert "net: simplify sock_poll_wait" 2018-10-23 10:57:06 -07:00
ax25 ax25: fix possible use-after-free 2019-02-23 09:08:07 +01:00
batman-adv batman-adv: release station info tidstats 2019-03-13 14:04:11 -07:00
bluetooth Bluetooth: Fix locking in bt_accept_enqueue() for BH context 2019-03-10 07:10:16 +01:00
bpf bpf: refactor bpf_test_run() to separate own failures and test program result 2018-12-01 12:33:58 -08:00
bpfilter net: bpfilter: Set user mode helper's command line 2018-10-22 19:37:36 -07:00
bridge netfilter: ebtables: compat: un-break 32bit setsockopt when no rules are present 2019-03-13 14:04:04 -07:00
caif Revert "net: simplify sock_poll_wait" 2018-10-23 10:57:06 -07:00
can can: bcm: check timer values before ktime conversion 2019-01-31 08:15:43 +01:00
ceph libceph: handle an empty authorize reply 2019-02-27 10:09:41 +01:00
core gro_cells: make sure device is up in gro_cells_receive() 2019-03-19 13:11:52 +01:00
dcb net: dcb: Add priority-to-DSCP map getters 2018-07-27 13:17:50 -07:00
dccp dccp: fool proof ccid_hc_[rt]x_parse_options() 2019-02-12 20:02:32 +01:00
decnet decnet: Remove unnecessary check for dev->name 2018-09-21 19:48:36 -07:00
dns_resolver dns: Allow the dns resolver to retrieve a server set 2018-10-04 09:40:52 -07:00
dsa net: dsa: Fix NPD checking for br_vlan_enabled() 2019-02-27 10:09:53 +01:00
ethernet
hsr net/hsr: fix possible crash in add_timer() 2019-03-19 13:11:52 +01:00
ieee802154 ieee802154: lowpan_header_create check must check daddr 2019-01-09 17:45:50 +01:00
ife
ipv4 tcp: repaired skbs must init their tso_segs 2019-03-19 13:11:54 +01:00
ipv6 ipv6: route: enforce RCU protection in ip6_route_check_nh_onlink() 2019-03-19 13:11:55 +01:00
iucv Revert "net: simplify sock_poll_wait" 2018-10-23 10:57:06 -07:00
kcm Revert "kcm: remove any offset before parsing messages" 2018-09-17 18:43:42 -07:00
key Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next 2018-07-27 09:33:37 -07:00
l2tp l2tp: fix infoleak in l2tp_ip6_recvmsg() 2019-03-19 13:11:52 +01:00
l3mdev
lapb
llc llc: do not use sk_eat_skb() 2018-10-22 19:59:20 -07:00
mac80211 mac80211: Add attribute aligned(2) to struct 'action' 2019-03-05 17:59:42 +01:00
mac802154 mac802154: Remove VLA usage of skcipher 2018-09-28 12:46:07 +08:00
mpls mpls: Return error for RTA_GATEWAY attribute 2019-03-10 07:10:14 +01:00
ncsi net/ncsi: Add NCSI Broadcom OEM command 2018-10-17 22:14:54 -07:00
netfilter netfilter: nft_compat: don't use refcount_inc on newly allocated entry 2019-03-13 14:04:17 -07:00
netlabel netlabel: fix out-of-bounds memory accesses 2019-03-10 07:10:12 +01:00
netlink net: netlink: rename NETLINK_DUMP_STRICT_CHK -> NETLINK_GET_STRICT_CHK 2018-12-14 11:44:31 -08:00
netrom netrom: switch to sock timer API 2019-02-06 17:27:36 +01:00
nfc net: nfc: Fix NULL dereference on nfc_llcp_build_tlv fails 2019-03-10 07:10:12 +01:00
nsh nsh: set mac len based on inner packet 2018-07-12 16:55:29 -07:00
openvswitch openvswitch: Avoid OOB read when parsing flow nlattrs 2019-01-31 08:15:33 +01:00
packet net/packet: fix 4gb buffer limit due to overflow check 2019-02-27 10:09:52 +01:00
phonet
psample
qrtr net: qrtr: Reset the node and port ID of broadcast messages 2018-07-05 20:20:03 +09:00
rds rds: fix refcount bug in rds_sock_addref 2019-02-12 20:02:33 +01:00
rfkill Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2018-09-04 21:33:03 -07:00
rose net/rose: fix NULL ax25_cb kernel panic 2019-02-06 17:27:36 +01:00
rxrpc rxrpc: Fix client call queueing, waiting for channel 2019-03-19 13:11:53 +01:00
sched net: sched: flower: insert new filter to idr after setting its mask 2019-03-19 13:11:54 +01:00
sctp sctp: remove sched init from sctp_stream_init 2019-03-19 13:11:53 +01:00
smc net/smc: fix smc_poll in SMC_INIT state 2019-03-19 13:11:55 +01:00
strparser bpf, sockmap: convert to generic sk_msg interface 2018-10-15 12:23:19 -07:00
sunrpc SUNRPC: Ensure we respect the RPCSEC_GSS sequence number limit 2019-02-27 10:09:49 +01:00
switchdev
tipc tipc: fix race condition causing hung sendto 2019-03-10 07:10:13 +01:00
tls net: tls: Save iv in tls_rec for async crypto requests 2019-02-06 17:27:38 +01:00
unix missing barriers in some of unix_sock ->addr and ->path accesses 2019-03-19 13:11:55 +01:00
vmw_vsock vsock/virtio: reset connected sockets on device removal 2019-03-13 14:04:14 -07:00
wimax wimax: remove blank lines at EOF 2018-07-24 14:10:42 -07:00
wireless cfg80211: extend range deviation for DMG 2019-03-05 17:59:42 +01:00
x25 net/x25: fix a race in x25_bind() 2019-03-19 13:11:54 +01:00
xdp xsk: Check if a queue exists during umem setup 2019-02-27 10:09:49 +01:00
xfrm xfrm: refine validation of template and selector families 2019-02-15 08:11:07 +01:00
compat.c sock: Make sock->sk_stamp thread-safe 2019-01-09 17:45:51 +01:00
Kconfig bpf, sockmap: convert to generic sk_msg interface 2018-10-15 12:23:19 -07:00
Makefile
socket.c net: socket: set sock->sk to NULL after calling proto_ops::release() 2019-03-10 07:10:13 +01:00
sysctl_net.c