Kuniyuki Iwashima
610fd07c13
af_unix: Fix a data race of sk->sk_receive_queue->qlen.
...
[ Upstream commit 679ed006d416ea0cecfe24a99d365d1dea69c683 ]
KCSAN found a data race of sk->sk_receive_queue->qlen where recvmsg()
updates qlen under the queue lock and sendmsg() checks qlen under
unix_state_sock(), not the queue lock, so the reader side needs
READ_ONCE().
BUG: KCSAN: data-race in __skb_try_recv_from_queue / unix_wait_for_peer
write (marked) to 0xffff888019fe7c68 of 4 bytes by task 49792 on cpu 0:
__skb_unlink include/linux/skbuff.h:2347 [inline]
__skb_try_recv_from_queue+0x3de/0x470 net/core/datagram.c:197
__skb_try_recv_datagram+0xf7/0x390 net/core/datagram.c:263
__unix_dgram_recvmsg+0x109/0x8a0 net/unix/af_unix.c:2452
unix_dgram_recvmsg+0x94/0xa0 net/unix/af_unix.c:2549
sock_recvmsg_nosec net/socket.c:1019 [inline]
____sys_recvmsg+0x3a3/0x3b0 net/socket.c:2720
___sys_recvmsg+0xc8/0x150 net/socket.c:2764
do_recvmmsg+0x182/0x560 net/socket.c:2858
__sys_recvmmsg net/socket.c:2937 [inline]
__do_sys_recvmmsg net/socket.c:2960 [inline]
__se_sys_recvmmsg net/socket.c:2953 [inline]
__x64_sys_recvmmsg+0x153/0x170 net/socket.c:2953
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 0xffff888019fe7c68 of 4 bytes by task 49793 on cpu 1:
skb_queue_len include/linux/skbuff.h:2127 [inline]
unix_recvq_full net/unix/af_unix.c:229 [inline]
unix_wait_for_peer+0x154/0x1a0 net/unix/af_unix.c:1445
unix_dgram_sendmsg+0x13bc/0x14b0 net/unix/af_unix.c:2048
sock_sendmsg_nosec net/socket.c:724 [inline]
sock_sendmsg+0x148/0x160 net/socket.c:747
____sys_sendmsg+0x20e/0x620 net/socket.c:2503
___sys_sendmsg+0xc6/0x140 net/socket.c:2557
__sys_sendmmsg+0x11d/0x370 net/socket.c:2643
__do_sys_sendmmsg net/socket.c:2672 [inline]
__se_sys_sendmmsg net/socket.c:2669 [inline]
__x64_sys_sendmmsg+0x58/0x70 net/socket.c:2669
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: 0x0000000b -> 0x00000001
Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 49793 Comm: syz-executor.0 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: 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-24 17:36:42 +01:00
..
2023-04-20 12:13:53 +02:00
2022-12-31 13:14:42 +01:00
2023-05-11 23:00:26 +09:00
2022-10-29 10:12:55 +02:00
2022-06-22 14:22:01 +02:00
2022-07-29 17:25:07 +02:00
2023-05-01 08:23:23 +09:00
2022-12-31 13:14:11 +01:00
2023-05-24 17:36:42 +01:00
2023-03-17 08:48:54 +01:00
2023-04-13 16:48:25 +02:00
2022-05-25 09:57:28 +02:00
2023-05-24 17:36:42 +01:00
2022-03-08 19:12:52 +01:00
2023-04-26 13:51:54 +02:00
2022-08-03 12:03:51 +02:00
2023-03-30 12:47:48 +02:00
2021-08-03 13:05:26 +01:00
2023-05-17 11:50:18 +02:00
2023-04-05 11:25:02 +02:00
2022-11-03 23:59:14 +09:00
2023-05-24 17:36:42 +01:00
2023-05-17 11:50:16 +02:00
2023-03-22 13:31:28 +01:00
2022-11-26 09:24:50 +01:00
2022-12-02 17:41:06 +01:00
2023-04-26 13:51:54 +02:00
2022-04-27 14:38:53 +02:00
2023-05-24 17:36:42 +01:00
2023-04-13 16:48:17 +02:00
2022-12-14 11:37:25 +01:00
2023-02-06 07:59:02 +01:00
2023-02-22 12:57:09 +01:00
2023-04-26 13:51:54 +02:00
2023-05-17 11:50:16 +02:00
2023-05-24 17:36:41 +01:00
2022-04-13 20:59:10 +02:00
2023-05-24 17:36:42 +01:00
2023-02-09 11:26:36 +01:00
2023-03-17 08:48:49 +01:00
2023-02-22 12:57:09 +01:00
2023-05-24 17:36:42 +01:00
2022-01-11 15:35:16 +01:00
2023-04-20 12:13:53 +02:00
2023-03-10 09:39:16 +01:00
2022-04-08 14:23:00 +02:00
2023-02-22 12:57:02 +01:00
2023-05-17 11:50:17 +02:00
2023-05-17 11:50:17 +02:00
2023-04-26 13:51:54 +02:00
2023-05-24 17:36:42 +01:00
2021-11-18 19:17:11 +01:00
2023-05-11 23:00:37 +09:00
2021-08-04 12:35:07 +01:00
2023-05-24 17:36:42 +01:00
2023-05-24 17:36:42 +01:00
2023-05-24 17:36:42 +01:00
2022-12-31 13:14:18 +01:00
2023-03-13 10:20:37 +01:00
2023-02-09 11:26:40 +01:00
2023-05-11 23:00:27 +09:00
2023-04-05 11:24:52 +02:00
2023-05-24 17:36:42 +01:00