Message ID | 20210909000029.1751608-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 04f08eb44b5011493d77b602fdec29ff0f5c6cd5 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net/af_unix: fix a data-race in unix_dgram_poll | expand |
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Wed, 8 Sep 2021 17:00:29 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > syzbot reported another data-race in af_unix [1] > > Lets change __skb_insert() to use WRITE_ONCE() when changing > skb head qlen. > > [...] Here is the summary with links: - [net] net/af_unix: fix a data-race in unix_dgram_poll https://git.kernel.org/netdev/net/c/04f08eb44b50 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 6bdb0db3e8258ad2745705a9b046eb1c93e05840..841e2f0f5240ba9e210bb9a3fc1cbedc2162b2a8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1940,7 +1940,7 @@ static inline void __skb_insert(struct sk_buff *newsk, WRITE_ONCE(newsk->prev, prev); WRITE_ONCE(next->prev, newsk); WRITE_ONCE(prev->next, newsk); - list->qlen++; + WRITE_ONCE(list->qlen, list->qlen + 1); } static inline void __skb_queue_splice(const struct sk_buff_head *list, diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index eb47b9de23809ac9216aae46c2fb1eae4543c890..92345c9bb60cc3b469e7cf50effe122b81c7bb89 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -3073,7 +3073,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock, other = unix_peer(sk); if (other && unix_peer(other) != sk && - unix_recvq_full(other) && + unix_recvq_full_lockless(other) && unix_dgram_peer_wake_me(sk, other)) writable = 0;