Skip to content

Commit

Permalink
net/packet: annotate data race in packet_sendmsg()
Browse files Browse the repository at this point in the history
There is a known race in packet_sendmsg(), addressed
in commit 32d3182 ("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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Jun 10, 2021
1 parent b71eaed commit d1b5bee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit d1b5bee

Please sign in to comment.