Re: [PATCH net] wireguard: mark racy persistent_keepalive_interval accesses
From: Jason A. Donenfeld
Date: Tue Nov 10 2026 - 12:30:19 EST
On Sun, Oct 11, 2026 at 05:23:22PM +0700, Nguyen Ngoc Thang wrote:
> wg_set_device_doit() updates peer->persistent_keepalive_interval under
> device_update_lock, while the RX/TX paths read it locklessly in
> wg_timers_any_authenticated_packet_traversal() and in the persistent
> keepalive timer. KCSAN reports the race:
>
> BUG: KCSAN: data-race in set_peer / wg_timers_any_authenticated_packet_traversal
>
> write to ... by task 3648 on cpu 1:
> set_peer+0x... drivers/net/wireguard/netlink.c:457
> wg_set_device_doit+0x...
> read to ... by task 3652 on cpu 0:
> wg_timers_any_authenticated_packet_traversal+0x... timers.c:217
> wg_packet_consume_data_done+0x...
> wg_packet_rx_poll+0x...
>
> The race is benign, but the reader also loads the field twice, so the
> zero check and the timer expiry computation can see different values.
> Load it once with READ_ONCE() and mark the writer and the other
> lockless reader accordingly.
Applied, thank you!