Kuniyuki Iwashima
5d91b7891f
af_unix: Fix data-race around unix_tot_inflight.
...
[ Upstream commit ade32bd8a738d7497ffe9743c46728db26740f78 ]
unix_tot_inflight is changed under spin_lock(unix_gc_lock), but
unix_release_sock() reads it locklessly.
Let's use READ_ONCE() for unix_tot_inflight.
Note that the writer side was marked by commit 9d6d7f1cb67c ("af_unix:
annote lockless accesses to unix_tot_inflight & gc_in_progress")
BUG: KCSAN: data-race in unix_inflight / unix_release_sock
write (marked) to 0xffffffff871852b8 of 4 bytes by task 123 on cpu 1:
unix_inflight+0x130/0x180 net/unix/scm.c:64
unix_attach_fds+0x137/0x1b0 net/unix/scm.c:123
unix_scm_to_skb net/unix/af_unix.c:1832 [inline]
unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1955
sock_sendmsg_nosec net/socket.c:724 [inline]
sock_sendmsg+0x148/0x160 net/socket.c:747
____sys_sendmsg+0x4e4/0x610 net/socket.c:2493
___sys_sendmsg+0xc6/0x140 net/socket.c:2547
__sys_sendmsg+0x94/0x140 net/socket.c:2576
__do_sys_sendmsg net/socket.c:2585 [inline]
__se_sys_sendmsg net/socket.c:2583 [inline]
__x64_sys_sendmsg+0x45/0x50 net/socket.c:2583
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
read to 0xffffffff871852b8 of 4 bytes by task 4891 on cpu 0:
unix_release_sock+0x608/0x910 net/unix/af_unix.c:671
unix_release+0x59/0x80 net/unix/af_unix.c:1058
__sock_release+0x7d/0x170 net/socket.c:653
sock_close+0x19/0x30 net/socket.c:1385
__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
value changed: 0x00000000 -> 0x00000001
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 4891 Comm: systemd-coredum Not tainted 6.4.0-rc5-01219-gfa0e21fa4443 #5
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
Fixes: 9305cfa4443d ("[AF_UNIX]: Make unix_tot_inflight counter non-atomic")
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-23 10:59:58 +02:00
..
2021-09-15 09:47:31 +02:00
2023-09-23 10:59:37 +02:00
2023-01-18 11:41:37 +01:00
2023-05-30 12:44:06 +01:00
2021-04-07 14:47:41 +02:00
2023-06-09 10:28:59 +02:00
2022-04-20 09:19:40 +02:00
2023-08-30 16:27:25 +02:00
2023-08-30 16:27:11 +02:00
2023-01-18 11:41:04 +01:00
2021-07-14 16:53:33 +02:00
2023-07-27 08:37:23 +02:00
2023-03-17 08:32:51 +01:00
2023-07-27 08:37:40 +02:00
2023-08-11 11:53:58 +02:00
2023-09-23 10:59:58 +02:00
2023-08-11 11:53:57 +02:00
2023-09-23 10:59:55 +02:00
2023-06-21 15:44:10 +02:00
2023-07-27 08:37:24 +02:00
2023-01-18 11:41:09 +01:00
2022-11-03 23:56:54 +09:00
2023-09-23 10:59:58 +02:00
2023-09-23 10:59:58 +02:00
2023-04-20 12:07:32 +02:00
2022-11-25 17:42:21 +01:00
2023-08-30 16:27:16 +02:00
2023-04-26 11:24:05 +02:00
2022-04-27 13:50:47 +02:00
2021-02-10 09:25:28 +01:00
2023-07-27 08:37:44 +02:00
2023-04-20 12:07:33 +02:00
2022-12-14 11:30:45 +01:00
2023-02-22 12:50:41 +01:00
2023-08-30 16:27:14 +02:00
2023-09-23 10:59:54 +02:00
2023-09-23 10:59:39 +02:00
2023-07-27 08:37:12 +02:00
2023-09-23 10:59:43 +02:00
2023-07-27 08:37:11 +02:00
2023-05-30 12:44:05 +01:00
2023-02-22 12:50:25 +01:00
2023-08-16 18:19:23 +02:00
2022-01-11 15:23:33 +01:00
2021-09-03 10:08:12 +02:00
2023-03-11 16:43:41 +01:00
2020-11-24 13:29:05 +01:00
2023-02-22 12:50:34 +01:00
2023-05-17 11:35:59 +02:00
2023-09-23 10:59:43 +02:00
2023-09-23 10:59:58 +02:00
2023-03-17 08:32:51 +01:00
2021-11-17 09:48:48 +01:00
2023-07-27 08:37:35 +02:00
2021-10-27 09:54:24 +02:00
2023-06-21 15:44:12 +02:00
2023-06-09 10:29:01 +02:00
2023-09-23 10:59:58 +02:00
2023-05-30 12:44:05 +01:00
2023-07-27 08:37:42 +02:00
2023-02-22 12:50:26 +01:00
2023-07-27 08:37:23 +02:00
2023-08-30 16:27:20 +02:00
2021-06-18 09:59:00 +02:00
2023-06-21 15:44:10 +02:00
2023-06-21 15:44:10 +02:00
2023-09-23 10:59:39 +02:00