Message ID | 20210610160012.1452531-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d1b5bee4c8be01585033be9b3a8878789285285f |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net/packet: annotate data race in packet_sendmsg() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | fail | Series targets non-next tree, but doesn't contain any Fixes tags |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 6 maintainers not CCed: john.ogness@linutronix.de willemb@google.com wanghai38@huawei.com eyal.birger@gmail.com tannerlove@google.com xie.he.0141@gmail.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 16 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/header_inline | success | Link |
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Thu, 10 Jun 2021 09:00:12 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > 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 :) > > [...] 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
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ae906eb4b269e858434828a383491e8d4c33c422..74e6e45a8e8435a556ce813c410a1f4146dd05b6 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -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); } /*