android_kernel_motorola_sm6225/net
Eric Dumazet 44ba281510 net/af_unix: fix a data-race in unix_dgram_poll
commit 04f08eb44b5011493d77b602fdec29ff0f5c6cd5 upstream.

syzbot reported another data-race in af_unix [1]

Lets change __skb_insert() to use WRITE_ONCE() when changing
skb head qlen.

Also, change unix_dgram_poll() to use lockless version
of unix_recvq_full()

It is verry possible we can switch all/most unix_recvq_full()
to the lockless version, this will be done in a future kernel version.

[1] HEAD commit: 8596e589b787732c8346f0482919e83cc9362db1

BUG: KCSAN: data-race in skb_queue_tail / unix_dgram_poll

write to 0xffff88814eeb24e0 of 4 bytes by task 25815 on cpu 0:
 __skb_insert include/linux/skbuff.h:1938 [inline]
 __skb_queue_before include/linux/skbuff.h:2043 [inline]
 __skb_queue_tail include/linux/skbuff.h:2076 [inline]
 skb_queue_tail+0x80/0xa0 net/core/skbuff.c:3264
 unix_dgram_sendmsg+0xff2/0x1600 net/unix/af_unix.c:1850
 sock_sendmsg_nosec net/socket.c:703 [inline]
 sock_sendmsg net/socket.c:723 [inline]
 ____sys_sendmsg+0x360/0x4d0 net/socket.c:2392
 ___sys_sendmsg net/socket.c:2446 [inline]
 __sys_sendmmsg+0x315/0x4b0 net/socket.c:2532
 __do_sys_sendmmsg net/socket.c:2561 [inline]
 __se_sys_sendmmsg net/socket.c:2558 [inline]
 __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2558
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

read to 0xffff88814eeb24e0 of 4 bytes by task 25834 on cpu 1:
 skb_queue_len include/linux/skbuff.h:1869 [inline]
 unix_recvq_full net/unix/af_unix.c:194 [inline]
 unix_dgram_poll+0x2bc/0x3e0 net/unix/af_unix.c:2777
 sock_poll+0x23e/0x260 net/socket.c:1288
 vfs_poll include/linux/poll.h:90 [inline]
 ep_item_poll fs/eventpoll.c:846 [inline]
 ep_send_events fs/eventpoll.c:1683 [inline]
 ep_poll fs/eventpoll.c:1798 [inline]
 do_epoll_wait+0x6ad/0xf00 fs/eventpoll.c:2226
 __do_sys_epoll_wait fs/eventpoll.c:2238 [inline]
 __se_sys_epoll_wait fs/eventpoll.c:2233 [inline]
 __x64_sys_epoll_wait+0xf6/0x120 fs/eventpoll.c:2233
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

value changed: 0x0000001b -> 0x00000001

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 25834 Comm: syz-executor.1 Tainted: G        W         5.14.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011

Fixes: 86b18aaa2b5b ("skbuff: fix a data race in skb_queue_len()")
Cc: Qian Cai <cai@lca.pw>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-22 11:48:11 +02:00
..
6lowpan 6lowpan: Off by one handling ->nexthdr 2020-01-27 14:50:41 +01:00
9p 9p/xen: Fix end of loop tests for list_for_each_entry 2021-09-22 11:47:57 +02:00
802 net/802/garp: fix memleak in garp_request_join() 2021-07-31 08:22:37 +02:00
8021q net: vlan: avoid leaks on register_vlan_dev() failures 2021-01-17 14:04:19 +01:00
appletalk appletalk: Fix skb allocation size in loopback case 2021-04-07 12:48:49 +02:00
atm atm: fix a memory leak of vcc->user_back 2020-10-01 13:14:43 +02:00
ax25 AX.25: Prevent integer overflows in connect and sendmsg 2020-07-31 18:37:48 +02:00
batman-adv batman-adv: Avoid WARN_ON timing related checks 2021-06-30 08:48:15 -04:00
bluetooth Bluetooth: Fix handling of LE Enhanced Connection Complete 2021-09-22 11:48:07 +02:00
bpf
bpfilter signal/bpfilter: Fix bpfilter_kernl to use send_sig not force_sig 2020-01-27 14:50:51 +01:00
bridge net: bridge: fix memleak in br_add_if() 2021-08-26 08:36:38 -04:00
caif net-caif: avoid user-triggerable WARN_ON(1) 2021-09-22 11:48:11 +02:00
can can: raw: raw_setsockopt(): fix raw_rcv panic for sock UAF 2021-08-04 12:23:45 +02:00
ceph libceph: clear con->out_msg on Policy::stateful_server faults 2020-11-05 11:08:53 +01:00
core flow_dissector: Fix out-of-bounds warnings 2021-09-22 11:48:04 +02:00
dcb net: dcb: Accept RTM_GETDCB messages carrying set-like DCB commands 2021-01-23 15:49:56 +01:00
dccp dccp: don't duplicate ccid when cloning dccp sock 2021-09-22 11:48:11 +02:00
decnet net: decnet: Fix sleeping inside in af_decnet 2021-07-28 11:13:48 +02:00
dns_resolver KEYS: Don't write out to userspace while holding key semaphore 2020-04-23 10:30:24 +02:00
dsa net: dsa: fix error code getting shifted with 4 in dsa_slave_get_sset_count 2021-06-03 08:38:11 +02:00
ethernet
hsr hsr: use netdev_err() instead of WARN_ONCE() 2021-05-22 10:59:24 +02:00
ieee802154 net: Fix memory leak in ieee802154_raw_deliver 2021-08-26 08:36:38 -04:00
ife
ipv4 tcp: enable data-less, empty-cookie SYN with TFO_SERVER_COOKIE_NOT_REQD 2021-09-22 11:48:07 +02:00
ipv6 ipv6: fix 'disable_policy' for fwd packets 2021-07-28 11:13:47 +02:00
iucv net/af_iucv: set correct sk_protocol for child sockets 2020-12-08 10:18:52 +01:00
kcm
key af_key: relax availability checks for skb size calculation 2021-02-13 13:51:14 +01:00
l2tp net/l2tp: Fix reference count leak in l2tp_udp_recv_core 2021-09-22 11:48:11 +02:00
l3mdev
lapb net: lapb: Copy the skb before sending a packet 2021-02-10 09:21:06 +01:00
llc net: llc: fix skb_over_panic 2021-08-04 12:23:46 +02:00
mac80211 mac80211: Fix insufficient headroom issue for AMSDU 2021-09-22 11:47:54 +02:00
mac802154 net: mac802154: Fix general protection fault 2021-04-14 08:22:36 +02:00
mpls net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 2021-03-17 16:43:43 +01:00
ncsi net/ncsi: Avoid channel_monitor hrtimer deadlock 2021-04-14 08:22:35 +02:00
netfilter netfilter: conntrack: collect all entries in one cycle 2021-09-03 09:58:00 +02:00
netlabel net: fix NULL pointer reference in cipso_v4_doi_free 2021-09-22 11:48:09 +02:00
netlink netlink: Deal with ESRCH error in nlmsg_notify() 2021-09-22 11:48:03 +02:00
netrom netrom: Decrease sock refcount when sock timers expire 2021-07-28 11:13:48 +02:00
nfc net/nfc/rawsock.c: fix a permission check bug 2021-06-16 11:54:56 +02:00
nsh
openvswitch openvswitch: meter: fix race when getting now_ms. 2021-06-03 08:38:11 +02:00
packet net/packet: annotate accesses to po->ifindex 2021-06-30 08:48:31 -04:00
phonet
psample
qrtr net: qrtr: fix another OOB Read in qrtr_endpoint_post 2021-09-03 09:58:00 +02:00
rds net/rds: dma_map_sg is entitled to merge entries 2021-09-03 09:58:02 +02:00
rfkill
rose rose: Fix Null pointer dereference in rose_send_frame() 2020-12-08 10:18:52 +01:00
rxrpc rxrpc: Fix deadlock around release of dst cached on udp tunnel 2021-02-10 09:21:06 +01:00
sched net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed 2021-09-22 11:47:55 +02:00
sctp sctp: move the active_key update after sh_keys is added 2021-08-12 13:19:39 +02:00
smc smc: disallow TCP_ULP in smc_setsockopt() 2021-05-22 10:59:44 +02:00
strparser
sunrpc rpc: fix gss_svc_init cleanup on failure 2021-09-22 11:48:07 +02:00
switchdev
tipc tipc: increase timeout in tipc_sk_enqueue() 2021-09-22 11:48:11 +02:00
tls net/tls: Protect from calling tls_dev_del for TLS RX twice 2020-12-08 10:18:52 +01:00
unix net/af_unix: fix a data-race in unix_dgram_poll 2021-09-22 11:48:11 +02:00
vmw_vsock vsock/virtio: avoid potential deadlock when vsock device remove 2021-08-26 08:36:39 -04:00
wimax
wireless cfg80211: Fix possible memory leak in function cfg80211_bss_update 2021-08-04 12:23:45 +02:00
x25 net/x25: Return the correct errno code 2021-06-30 08:48:13 -04:00
xdp xsk: Simplify detection of empty and full rings 2021-05-22 10:59:48 +02:00
xfrm xfrm: Fix error reporting in xfrm_state_construct. 2021-07-20 16:16:01 +02:00
compat.c net: Return the correct errno code 2021-06-30 08:48:13 -04:00
Kconfig
Makefile net: split out functions related to registering inflight socket files 2021-07-31 08:22:37 +02:00
socket.c net: don't unconditionally copy_from_user a struct ifreq for socket ioctls 2021-09-03 09:58:03 +02:00
sysctl_net.c