Kuniyuki Iwashima
e1d09c2c2f
af_unix: Fix data races around sk->sk_shutdown.
...
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>
2023-05-10 19:06:53 -07:00
..
2023-03-29 08:22:52 +01:00
2023-05-05 19:12:01 -07:00
2022-12-25 13:38:09 -08:00
2023-04-21 08:22:14 +01:00
2023-04-26 16:07:23 -07:00
2022-11-16 13:31:03 +00:00
2023-04-23 14:16:44 +01:00
2023-04-27 11:53:57 -07:00
2023-04-21 11:34:50 -07:00
2023-05-10 10:25:55 +01:00
2023-03-02 22:22:07 -08:00
2023-04-06 12:01:20 -07:00
2023-02-21 18:24:12 -08:00
2023-05-10 19:06:49 -07:00
2023-01-20 09:33:22 +00:00
2023-03-22 21:50:23 +01:00
2023-02-20 11:38:35 +00:00
2023-04-23 14:16:45 +01:00
2022-12-07 20:02:44 -08:00
2023-05-03 09:13:20 +01:00
2023-04-21 20:24:57 -07:00
2023-03-16 21:11:03 -07:00
2023-03-17 09:13:53 +01:00
2023-05-10 10:27:31 +01:00
2023-04-28 09:53:43 +01:00
2023-03-16 17:34:40 -07:00
2023-01-23 11:26:50 +00:00
2023-02-13 09:30:14 +00:00
2023-03-31 09:25:12 +01:00
2023-05-10 10:03:32 +01:00
2023-04-21 07:35:51 -07:00
2023-04-05 13:48:04 +00:00
2023-03-09 23:06:21 -08:00
2023-02-15 10:26:37 +00:00
2023-04-20 16:29:51 -07:00
2023-04-28 09:35:33 +01:00
2023-05-05 19:12:01 -07:00
2023-05-10 09:28:38 +01:00
2023-01-30 07:30:47 +00:00
2023-03-07 13:37:05 -08:00
2023-04-07 19:42:53 -07:00
2023-05-10 10:25:55 +01:00
2023-01-23 11:26:50 +00:00
2023-04-13 09:35:30 +02:00
2023-02-13 09:33:39 +00:00
2023-04-06 20:36:27 +02:00
2023-01-28 00:19:57 -08:00
2023-05-05 19:12:01 -07:00
2023-05-05 10:01:31 +01:00
2023-04-21 08:19:30 +01:00
2023-05-10 10:03:32 +01:00
2023-04-29 11:04:14 -07:00
2023-05-10 10:03:32 +01:00
2023-05-10 10:03:32 +01:00
2023-05-10 19:06:53 -07:00
2023-04-14 11:04:04 +01:00
2023-04-27 11:53:57 -07:00
2023-01-25 09:51:04 +00:00
2023-04-13 16:43:38 -07:00
2023-04-19 18:46:17 -07:00
2023-04-14 11:09:27 +01:00
2023-04-19 18:48:48 -07:00
2023-04-19 18:48:48 -07:00
2023-05-10 09:58:29 +01:00