Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch carries `Closes:` for the syzbot bug titled "data-
race in unix_release_sock / unix_write_space", but one of the access…
--
net: use RCU_INIT_POINTER() to clear sk->sk_wq in sock_orphan()
This patch changes the plain store that clears sk->sk_wq in sock_orphan()
to RCU_INIT_POINTER(), so the store is done with WRITE_ONCE(). The goal is
to silence a KCSAN data-race report between unix_release_sock() and
unix_write_space() that syzbot found.
Closes: https://syzkaller.appspot.com/bug?extid=c2e012bd497ee37068b0
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 5a203809218aa..9d22ccd91838d 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2168,7 +2168,7 @@ static inline void sock_orphan(struct sock *sk)
> write_lock_bh(&sk->sk_callback_lock);
> sock_set_flag(sk, SOCK_DEAD);
[Severity: Medium]
Will the syzbot bug in the Closes: tag still be reported after this patch?
sock_set_flag() is a plain non-atomic read-modify-write of the whole
sk_flags word:
include/net/sock.h:sock_set_flag() {
__set_bit(flag, &sk->sk_flags);
}
On the peer side, the skb free path reads the same word without holding
sk_callback_lock:
unix_release_sock()->kfree_skb_reason()->unix_wfree()->sock_wfree()
->unix_write_space()->sk_wake_async_rcu()
include/net/sock.h:sk_wake_async_rcu() {
if (unlikely(sock_flag(sk, SOCK_FASYNC)))
sock_wake_async(rcu_dereference(sk->sk_wq), how, band);
}
unix_write_space() only holds rcu_read_lock(), so no lock is shared with
sock_orphan(). KCSAN can still report this pair under the same title,
"data-race in unix_release_sock / unix_write_space".
The notes below the changelog say this pair shows up in 3 of the 35 syzbot
crashes and in 3 of 5 local runs with the patch applied. Once this is
merged, syzbot would close the bug and then report it again from the same
reproducer.
Should the sk_flags access be handled too? One option is an atomic
set_bit() for SOCK_DEAD in sock_orphan(). Another is data_race() on the
reader side. If that is out of scope, could the Closes: tag be changed so
it does not claim the whole syzbot report is fixed?
> sk_set_socket(sk, NULL);
> - sk->sk_wq = NULL;
> + RCU_INIT_POINTER(sk->sk_wq, NULL);
> write_unlock_bh(&sk->sk_callback_lock);
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com