af_unix: Fix four data-races.
Subsystems (4)
cover af_unix: Fix four data-races.
While running syzkaller, KCSAN reported 3 data-races with systemd-coredump using AF_UNIX sockets.
This series fixes the three and another one inspiered by one of the reports.
Kuniyuki Iwashima (4):
af_unix: Fix data-races around user->unix_inflight.
af_unix: Fix data-race around unix_tot_inflight.
af_unix: Fix data-races around sk->sk_shutdown.
af_unix: Fix data race around sk->sk_err.
net/core/sock.c | 6 +++--- net/unix/af_unix.c | 2 +- net/unix/scm.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/4 af_unix: Fix data-races around user->unix_inflight.
user->unix_inflight is changed under spin_lock(unix_gc_lock), but too_many_unix_fds() reads it locklessly.
Let's annotate the write/read accesses to user->unix_inflight.
BUG: KCSAN: data-race in unix_attach_fds / unix_inflight
write to 0xffffffff8546f2d0 of 8 bytes by task 44798 on cpu 1:
unix_inflight+0x157/0x180 net/unix/scm.c:66 unix_attach_fds+0x147/0x1e0 net/unix/scm.c:123 unix_scm_to_skb net/unix/af_unix.c:1827 [inline] unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1950 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8
read to 0xffffffff8546f2d0 of 8 bytes by task 44814 on cpu 0:
too_many_unix_fds net/unix/scm.c:101 [inline] unix_attach_fds+0x54/0x1e0 net/unix/scm.c:110 unix_scm_to_skb net/unix/af_unix.c:1827 [inline] unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1950 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8
value changed: 0x000000000000000c -> 0x000000000000000d
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 44814 Comm: systemd-coredum Not tainted 6.4.0-11989-g6843306689af #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
---
Cc: Willy Tarreau <[email protected]>
--- net/unix/scm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/unix/scm.c +3 -3
@@ -64,7 +64,7 @@ void unix_inflight(struct user_struct *user, struct file *fp)/* Paired with READ_ONCE() in wait_for_unix_gc() */ WRITE_ONCE (unix_tot_inflight, unix_tot_inflight +1 ); } - user->unix_inflight++; +WRITE_ONCE (user->unix_inflight, user->unix_inflight +1 );spin_unlock (&unix_gc_lock); }
@@ -85,7 +85,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp)/* Paired with READ_ONCE() in wait_for_unix_gc() */ WRITE_ONCE (unix_tot_inflight, unix_tot_inflight -1 ); } - user->unix_inflight--; +WRITE_ONCE (user->unix_inflight, user->unix_inflight -1 );spin_unlock (&unix_gc_lock); }
@@ -99,7 +99,7 @@ static inline bool too_many_unix_fds(struct task_struct *p) {struct user_struct *user =current_user (); -if (unlikely (user->unix_inflight >task_rlimit (p,RLIMIT_NOFILE ))) +if (unlikely (READ_ONCE (user->unix_inflight) >task_rlimit (p,RLIMIT_NOFILE )))return !capable (CAP_SYS_RESOURCE ) && !capable (CAP_SYS_ADMIN );return false; }
Signature · 1 line
2.30.2
Re: [PATCH v1 net 1/4] af_unix: Fix data-races around user->unix_inflight.
Hi,
Quoted 83 lines · Kuniyuki Iwashima
user->unix_inflightis changed underspin_lock(unix_gc_lock), buttoo_many_unix_fds()reads it locklessly.Let's annotate the write/read accesses to
user->unix_inflight.BUG: KCSAN: data-race in unix_attach_fds / unix_inflightwrite to
0xffffffff8546f2d0of 8 bytes by task 44798 on cpu 1:unix_inflight+0x157/0x180 net/unix/scm.c:66 unix_attach_fds+0x147/0x1e0 net/unix/scm.c:123 unix_scm_to_skb net/unix/af_unix.c:1827 [inline] unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1950 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8read to
0xffffffff8546f2d0of 8 bytes by task 44814 on cpu 0:too_many_unix_fds net/unix/scm.c:101 [inline] unix_attach_fds+0x54/0x1e0 net/unix/scm.c:110 unix_scm_to_skb net/unix/af_unix.c:1827 [inline] unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1950 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8value changed:
0x000000000000000c->0x000000000000000dReported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 44814 Comm: systemd-coredum Not tainted 6.4.0-11989-g6843306689af #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014Fixes 712f4aad406b ("unix: properly account for FDs passed over unix sockets")Reported-by syzkaller <[email protected]>Signed-off-by Kuniyuki Iwashima <[email protected]>---
Cc: Willy Tarreau <[email protected]>--- net/unix/scm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)net/unix/scm.c +2
-2@@ -64,7 +64,7 @@ void unix_inflight(struct user_struct *user, struct file *fp)/* Paired with READ_ONCE() in wait_for_unix_gc() */ WRITE_ONCE (unix_tot_inflight, unix_tot_inflight +1 ); } - user->unix_inflight++; +WRITE_ONCE (user->unix_inflight, user->unix_inflight +1 );spin_unlock (&unix_gc_lock); }@@ -85,7 +85,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp)/* Paired with READ_ONCE() in wait_for_unix_gc() */ WRITE_ONCE (unix_tot_inflight, unix_tot_inflight -1 ); } - user->unix_inflight--; +WRITE_ONCE (user->unix_inflight, user->unix_inflight -1 );spin_unlock (&unix_gc_lock); }
net/unix/scm.c static inline bool too_many_unix_fds(struct task_struct *p) · line 105
Quoted 8 lines
net/unix/scm.c +1
-1@@ -99,7 +99,7 @@ static inline bool too_many_unix_fds(struct task_struct *p) {struct user_struct *user =current_user (); -if (unlikely (user->unix_inflight >task_rlimit (p,RLIMIT_NOFILE ))) +if (unlikely (READ_ONCE (user->unix_inflight) >task_rlimit (p,RLIMIT_NOFILE )))return !capable (CAP_SYS_RESOURCE ) && !capable (CAP_SYS_ADMIN );return false; }
Looks good to me, thanks!
Willy
Re: [PATCH v1 net 1/4] af_unix: Fix data-races around user->unix_inflight.
In reply to Kuniyuki IwashimaQuoted 48 lines · Kuniyuki Iwashima
user->unix_inflightis changed underspin_lock(unix_gc_lock), buttoo_many_unix_fds()reads it locklessly.Let's annotate the write/read accesses to
user->unix_inflight.BUG: KCSAN: data-race in unix_attach_fds / unix_inflightwrite to
0xffffffff8546f2d0of 8 bytes by task 44798 on cpu 1:unix_inflight+0x157/0x180 net/unix/scm.c:66 unix_attach_fds+0x147/0x1e0 net/unix/scm.c:123 unix_scm_to_skb net/unix/af_unix.c:1827 [inline] unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1950 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8read to
0xffffffff8546f2d0of 8 bytes by task 44814 on cpu 0:too_many_unix_fds net/unix/scm.c:101 [inline] unix_attach_fds+0x54/0x1e0 net/unix/scm.c:110 unix_scm_to_skb net/unix/af_unix.c:1827 [inline] unix_dgram_sendmsg+0x46a/0x14f0 net/unix/af_unix.c:1950 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8value changed:
0x000000000000000c->0x000000000000000d
Quoted 7 lines
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 44814 Comm: systemd-coredum Not tainted 6.4.0-11989-g6843306689af #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014Fixes 712f4aad406b ("unix: properly account for FDs passed over unix sockets")Reported-by syzkaller <[email protected]>Signed-off-by Kuniyuki Iwashima <[email protected]>
PATCH 2/4 af_unix: Fix data-race around unix_tot_inflight.
In reply to Kuniyuki Iwashimaunix_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
---
Cc: Pavel Emelyanov <[email protected]>
--- net/unix/af_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -1
@@ -680,7 +680,7 @@ static void unix_release_sock(struct sock *sk, int embrion)* What the above comment does talk about? --ANK(980817) */ -if (unix_tot_inflight) +if (READ_ONCE (unix_tot_inflight))unix_gc ();/* Garbage collect fds */ }
Signature · 1 line
2.30.2
Re: [PATCH v1 net 2/4] af_unix: Fix data-race around unix_tot_inflight.
Quoted 6 lines · Kuniyuki Iwashima
unix_tot_inflightis changed underspin_lock(unix_gc_lock), butunix_release_sock()reads it locklessly.Let's use
READ_ONCE()forunix_tot_inflight.
Quoted 8 lines
Note that the writer side was marked by commit
9d6d7f1cb67c("af_unix:
annote lockless accesses tounix_tot_inflight&gc_in_progress")Fixes 9305cfa4443d ("[AF_UNIX]: Make unix_tot_inflight counter non-atomic")Reported-by syzkaller <[email protected]>Signed-off-by Kuniyuki Iwashima <[email protected]>---
PATCH 3/4 af_unix: Fix data-races around sk->sk_shutdown.
In reply to Kuniyuki Iwashimask->sk_shutdown is changed under unix_state_lock(sk), but unix_dgram_sendmsg() calls two functions to read sk_shutdown locklessly.
sock_alloc_send_pskb
`- sock_wait_for_wmem
Let's use READ_ONCE() there.
Note that the writer side was marked by commit e1d09c2c2f57 ("af_unix:
Fix data races around sk->sk_shutdown.").
BUG: KCSAN: data-race in sock_alloc_send_pskb / unix_release_sock
write (marked) to 0xffff8880069af12c of 1 bytes by task 1 on cpu 1:
unix_release_sock+0x75c/0x910 net/unix/af_unix.c:631 unix_release+0x59/0x80 net/unix/af_unix.c:1053 __sock_release+0x7d/0x170 net/socket.c:654 sock_close+0x19/0x30 net/socket.c:1386 __fput+0x2a3/0x680 fs/file_table.c:384 ____fput+0x15/0x20 fs/file_table.c:412 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+0x6e/0xd8
read to 0xffff8880069af12c of 1 bytes by task 28650 on cpu 0:
sock_alloc_send_pskb+0xd2/0x620 net/core/sock.c:2767 unix_dgram_sendmsg+0x2f8/0x14f0 net/unix/af_unix.c:1944 unix_seqpacket_sendmsg net/unix/af_unix.c:2308 [inline] unix_seqpacket_sendmsg+0xba/0x130 net/unix/af_unix.c:2292 sock_sendmsg_nosec net/socket.c:725 [inline] sock_sendmsg+0x148/0x160 net/socket.c:748 ____sys_sendmsg+0x4e4/0x610 net/socket.c:2494 ___sys_sendmsg+0xc6/0x140 net/socket.c:2548 __sys_sendmsg+0x94/0x140 net/socket.c:2577 __do_sys_sendmsg net/socket.c:2586 [inline] __se_sys_sendmsg net/socket.c:2584 [inline] __x64_sys_sendmsg+0x45/0x50 net/socket.c:2584 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+0x6e/0xd8
value changed: 0x00 -> 0x03
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 28650 Comm: systemd-coredum Not tainted 6.4.0-11989-g6843306689af #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
--- net/core/sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/sock.c +2 -2
@@ -2747,7 +2747,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)prepare_to_wait (sk_sleep (sk), &wait,TASK_INTERRUPTIBLE );if (refcount_read (&sk->sk_wmem_alloc) <READ_ONCE (sk->sk_sndbuf))break ; -if (sk->sk_shutdown &SEND_SHUTDOWN ) +if (READ_ONCE (sk->sk_shutdown) &SEND_SHUTDOWN )break ;if (sk->sk_err)break ;
@@ -2777,7 +2777,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len, goto failure; err = -EPIPE ; -if (sk->sk_shutdown &SEND_SHUTDOWN ) +if (READ_ONCE (sk->sk_shutdown) &SEND_SHUTDOWN ) goto failure;if (sk_wmem_alloc_get (sk) <READ_ONCE (sk->sk_sndbuf))
Signature · 1 line
2.30.2
Re: [PATCH v1 net 3/4] af_unix: Fix data-races around sk->sk_shutdown.
Quoted 12 lines · Kuniyuki Iwashima
sk->sk_shutdownis changed underunix_state_lock(sk), butunix_dgram_sendmsg()calls two functions to readsk_shutdownlocklessly.
sock_alloc_send_pskb
`-sock_wait_for_wmemLet's use
READ_ONCE()there.Note that the writer side was marked by commit
e1d09c2c2f57("af_unix:
Fix data races aroundsk->sk_shutdown.").
Quoted 6 lines
BUG: KCSAN: data-race in sock_alloc_send_pskb / unix_release_sockFixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by syzkaller <[email protected]>Signed-off-by Kuniyuki Iwashima <[email protected]>
PATCH 4/4 af_unix: Fix data race around sk->sk_err.
In reply to Kuniyuki IwashimaAs with sk->sk_shutdown shown in the previous patch, sk->sk_err can be read locklessly by unix_dgram_sendmsg().
Let's use READ_ONCE() for sk_err as well.
Note that the writer side is marked by commit cc04410af7de ("af_unix:
annotate lockless accesses to sk->sk_err").
--- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/sock.c +1 -1
@@ -2749,7 +2749,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)break ;if (READ_ONCE (sk->sk_shutdown) &SEND_SHUTDOWN )break ; -if (sk->sk_err) +if (READ_ONCE (sk->sk_err))break ; timeo =schedule_timeout (timeo); }
Signature · 1 line
2.30.2
Re: [PATCH v1 net 4/4] af_unix: Fix data race around sk->sk_err.
Quoted 4 lines · Kuniyuki Iwashima
As with
sk->sk_shutdownshown in the previous patch,sk->sk_errcan be read locklessly byunix_dgram_sendmsg().
Quoted 8 lines
Let's use
READ_ONCE()forsk_erras well.Note that the writer side is marked by commit
cc04410af7de("af_unix:
annotate lockless accesses tosk->sk_err").Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Kuniyuki Iwashima <[email protected]>---
Title is slightly off, since this is a generic net: change, but this is fine really ;)
Thanks.
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Fri, 1 Sep 2023 17:27:04 -0700 you wrote:
While running syzkaller, KCSAN reported 3 data-races with systemd-coredump using
AF_UNIXsockets.This series fixes the three and another one inspiered by one of the reports.
[...]
Here is the summary with links:
- [v1,net,1/4] af_unix: Fix data-races around user->unix_inflight.
https://git.kernel.org/netdev/net/c/0bc36c0650b2 - [v1,net,2/4] af_unix: Fix data-race around unix_tot_inflight. https://git.kernel.org/netdev/net/c/ade32bd8a738 - [v1,net,3/4] af_unix: Fix data-races around sk->sk_shutdown. https://git.kernel.org/netdev/net/c/afe8764f7634 - [v1,net,4/4] af_unix: Fix data race around sk->sk_err. https://git.kernel.org/netdev/net/c/b192812905e4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html