net/packet: annotate data race in packet_sendmsg()
Subsystems (3)
PATCH 1/1 net/packet: annotate data race in packet_sendmsg()
From: Eric Dumazet <[email protected]>
There is a known race in packet_sendmsg(), addressed in commit 32d3182cd2cd ("net/packet: fix race in tpacket_snd()")
Now we have data_race(), we can use it to avoid a future KCSAN warning, as syzbot loves stressing af_packet sockets :)
--- net/packet/af_packet.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/packet/af_packet.c +6 -3
@@ -3034,10 +3034,13 @@ static int packet_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)struct sock *sk = sock->sk;struct packet_sock *po =pkt_sk (sk); -if (po->tx_ring.pg_vec) +/* Reading tx_ring.pg_vec without holding pg_vec_lock is racy. +* tpacket_snd() will redo the check safely. +*/ +if (data_race (po->tx_ring.pg_vec))return tpacket_snd (po, msg); -else -return packet_snd (sock, msg, len); + +return packet_snd (sock, msg, len); }/*
Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 9 lines · On Thu, 10 Jun 2021 09:00:12 -0700 you wrote:
From: Eric Dumazet <[email protected]>
There is a known race in
packet_sendmsg(), addressed in commit32d3182cd2cd("net/packet: fix race intpacket_snd()")Now we have
data_race(), we can use it to avoid a future KCSAN warning, as syzbot loves stressingaf_packetsockets :)[...]
Here is the summary with links:
- [net] net/packet: annotate data race in packet_sendmsg()
https://git.kernel.org/netdev/net/c/d1b5bee4c8be
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html