Kuniyuki Iwashima
1c488f4e95
af_unix: Fix data races around sk->sk_shutdown.
...
[ Upstream commit e1d09c2c2f5793474556b60f83900e088d0d366d ]
KCSAN found a data race around sk->sk_shutdown where unix_release_sock()
and unix_shutdown() update it under unix_state_lock(), OTOH unix_poll()
and unix_dgram_poll() read it locklessly.
We need to annotate the writes and reads with WRITE_ONCE() and READ_ONCE().
BUG: KCSAN: data-race in unix_poll / unix_release_sock
write to 0xffff88800d0f8aec of 1 bytes by task 264 on cpu 0:
unix_release_sock+0x75c/0x910 net/unix/af_unix.c:631
unix_release+0x59/0x80 net/unix/af_unix.c:1042
__sock_release+0x7d/0x170 net/socket.c:653
sock_close+0x19/0x30 net/socket.c:1397
__fput+0x179/0x5e0 fs/file_table.c:321
____fput+0x15/0x20 fs/file_table.c:349
task_work_run+0x116/0x1a0 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x174/0x180 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x1a/0x30 kernel/entry/common.c:297
do_syscall_64+0x4b/0x90 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x72/0xdc
read to 0xffff88800d0f8aec of 1 bytes by task 222 on cpu 1:
unix_poll+0xa3/0x2a0 net/unix/af_unix.c:3170
sock_poll+0xcf/0x2b0 net/socket.c:1385
vfs_poll include/linux/poll.h:88 [inline]
ep_item_poll.isra.0+0x78/0xc0 fs/eventpoll.c:855
ep_send_events fs/eventpoll.c:1694 [inline]
ep_poll fs/eventpoll.c:1823 [inline]
do_epoll_wait+0x6c4/0xea0 fs/eventpoll.c:2258
__do_sys_epoll_wait fs/eventpoll.c:2270 [inline]
__se_sys_epoll_wait fs/eventpoll.c:2265 [inline]
__x64_sys_epoll_wait+0xcc/0x190 fs/eventpoll.c:2265
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x72/0xdc
value changed: 0x00 -> 0x03
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 222 Comm: dbus-broker Not tainted 6.3.0-rc7-02330-gca6270c12e20 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
Fixes: 3c73419c09a5 ("af_unix: fix 'poll for write'/ connected DGRAM sockets")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-30 12:42:08 +01:00
..
2020-01-27 14:50:41 +01:00
2023-04-20 12:04:40 +02:00
2023-01-18 11:30:36 +01:00
2023-05-17 11:13:11 +02:00
2021-04-07 12:48:49 +02:00
2022-11-03 23:52:26 +09:00
2022-04-27 13:39:46 +02:00
2022-05-18 09:42:47 +02:00
2023-05-17 11:13:05 +02:00
2022-11-25 17:40:29 +01:00
2020-01-27 14:50:51 +01:00
2022-09-28 11:02:56 +02:00
2023-03-17 08:31:44 +01:00
2023-04-05 11:15:40 +02:00
2020-11-05 11:08:53 +01:00
2023-05-30 12:42:08 +01:00
2022-03-08 19:04:10 +01:00
2023-04-26 11:21:53 +02:00
2021-07-28 11:13:48 +02:00
2020-04-23 10:30:24 +02:00
2022-03-23 09:10:44 +01:00
2020-01-09 10:19:09 +01:00
2022-12-08 11:18:33 +01:00
2022-11-03 23:52:30 +09:00
2023-05-30 12:42:08 +01:00
2023-05-17 11:13:23 +02:00
2023-03-22 13:27:10 +01:00
2022-11-25 17:40:29 +01:00
2022-12-08 11:18:29 +01:00
2023-04-26 11:21:53 +02:00
2021-02-10 09:21:06 +01:00
2022-03-28 08:41:44 +02:00
2023-04-20 12:04:38 +02:00
2022-12-14 11:28:28 +01:00
2023-02-22 12:47:21 +01:00
2021-04-14 08:22:35 +02:00
2023-05-17 11:13:22 +02:00
2021-09-22 11:48:09 +02:00
2023-05-30 12:42:07 +01:00
2023-02-22 12:47:12 +01:00
2023-03-17 08:31:42 +01:00
2023-02-22 12:47:12 +01:00
2023-05-17 11:13:24 +02:00
2022-01-11 13:58:50 +01:00
2019-12-05 09:21:30 +01:00
2021-09-03 09:58:00 +02:00
2023-03-11 16:31:37 +01:00
2020-01-12 12:17:17 +01:00
2023-02-22 12:47:19 +01:00
2023-05-17 11:13:24 +02:00
2023-05-17 11:13:24 +02:00
2023-04-26 11:21:53 +02:00
2022-09-15 12:17:03 +02:00
2023-05-17 11:13:19 +02:00
2023-03-17 08:31:44 +01:00
2022-07-29 17:10:32 +02:00
2023-05-30 12:42:08 +01:00
2023-01-18 11:30:18 +01:00
2023-03-13 10:17:15 +01:00
2023-02-22 12:47:12 +01:00
2021-05-22 10:59:48 +02:00
2022-10-26 13:19:37 +02:00
2021-06-30 08:48:13 -04:00
2021-07-31 08:22:37 +02:00
2023-05-30 12:42:07 +01:00