diff options
author | Eric Dumazet <edumazet@google.com> | 2021-06-10 19:00:12 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-11 00:12:54 +0300 |
commit | d1b5bee4c8be01585033be9b3a8878789285285f (patch) | |
tree | ab9212ee4357ee19d60508de497524d1ec18b485 /net/packet/af_packet.c | |
parent | b71eaed8c04f72a919a9c44e83e4ee254e69e7f3 (diff) | |
download | linux-d1b5bee4c8be01585033be9b3a8878789285285f.tar.xz |
net/packet: annotate data race in packet_sendmsg()
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 :)
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ae906eb4b269..74e6e45a8e84 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); } /* |