linux/drivers/net/wireguard
Eric Dumazet be41c0c4a6 wireguard: use DEV_STATS_INC()
[ Upstream commit 93da8d75a6 ]

wg_xmit() can be called concurrently, KCSAN reported [1]
some device stats updates can be lost.

Use DEV_STATS_INC() for this unlikely case.

[1]
BUG: KCSAN: data-race in wg_xmit / wg_xmit

read-write to 0xffff888104239160 of 8 bytes by task 1375 on cpu 0:
wg_xmit+0x60f/0x680 drivers/net/wireguard/device.c:231
__netdev_start_xmit include/linux/netdevice.h:4918 [inline]
netdev_start_xmit include/linux/netdevice.h:4932 [inline]
xmit_one net/core/dev.c:3543 [inline]
dev_hard_start_xmit+0x11b/0x3f0 net/core/dev.c:3559
...

read-write to 0xffff888104239160 of 8 bytes by task 1378 on cpu 1:
wg_xmit+0x60f/0x680 drivers/net/wireguard/device.c:231
__netdev_start_xmit include/linux/netdevice.h:4918 [inline]
netdev_start_xmit include/linux/netdevice.h:4932 [inline]
xmit_one net/core/dev.c:3543 [inline]
dev_hard_start_xmit+0x11b/0x3f0 net/core/dev.c:3559
...

v2: also change wg_packet_consume_data_done() (Hangbin Liu)
    and wg_packet_purge_staged_packets()

Fixes: e7096c131e ("net: WireGuard secure network tunnel")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-12-03 07:31:21 +01:00
..
selftest wireguard: allowedips: expand maximum node depth 2023-08-16 18:21:57 +02:00
allowedips.c wireguard: allowedips: expand maximum node depth 2023-08-16 18:21:57 +02:00
allowedips.h
cookie.c
cookie.h
device.c wireguard: use DEV_STATS_INC() 2023-12-03 07:31:21 +01:00
device.h
main.c
Makefile
messages.h
netlink.c wireguard: netlink: send staged packets when setting initial private key 2023-07-23 13:47:37 +02:00
netlink.h
noise.c
noise.h
peer.c
peer.h
peerlookup.c
peerlookup.h
queueing.c wireguard: queueing: use saner cpu selection wrapping 2023-07-23 13:47:37 +02:00
queueing.h wireguard: queueing: use saner cpu selection wrapping 2023-07-23 13:47:37 +02:00
ratelimiter.c
ratelimiter.h
receive.c wireguard: use DEV_STATS_INC() 2023-12-03 07:31:21 +01:00
send.c wireguard: use DEV_STATS_INC() 2023-12-03 07:31:21 +01:00
socket.c
socket.h
timers.c
timers.h
version.h