Commit d1b5bee4 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net/packet: annotate data race in packet_sendmsg()



There is a known race in packet_sendmsg(), addressed
in commit 32d3182c ("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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b71eaed8
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -3034,9 +3034,12 @@ 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);
}