Subject: [syzbot] KCSAN: data-race in dev_get_tstats64 / wg_packet_rx_poll (3)

From: syzbot <[email-masked]>
Date: Tue, 08 Feb 2022 01:13:22 -0800

Hello,

syzbot found the following issue on:

HEAD commit:    79e06c4c4950 Merge tag 'for-linus' of git://git.kernel.org..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1642e837b00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d443ab22c440893a
dashboard link: https://syzkaller.appspot.com/bug?extid=5d8276c437d9827c1fbf
compiler:       Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email-masked]

==================================================================
BUG: KCSAN: data-race in dev_get_tstats64 / wg_packet_rx_poll

write to 0xffffe8ffffc39fe0 of 8 bytes by interrupt on cpu 0:
 update_rx_stats drivers/net/wireguard/receive.c:26 [inline]
 wg_packet_consume_data_done drivers/net/wireguard/receive.c:365 [inline]
 wg_packet_rx_poll+0xf37/0x11f0 drivers/net/wireguard/receive.c:481
 __napi_poll+0x65/0x3f0 net/core/dev.c:6365
 napi_poll net/core/dev.c:6432 [inline]
 net_rx_action+0x29e/0x650 net/core/dev.c:6519
 __do_softirq+0x158/0x2de kernel/softirq.c:558
 do_softirq+0xb1/0xf0 kernel/softirq.c:459
 __local_bh_enable_ip+0x68/0x70 kernel/softirq.c:383
 __raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline]
 _raw_spin_unlock_bh+0x33/0x40 kernel/locking/spinlock.c:210
 spin_unlock_bh include/linux/spinlock.h:394 [inline]
 ptr_ring_consume_bh include/linux/ptr_ring.h:367 [inline]
 wg_packet_decrypt_worker+0x73c/0x780 drivers/net/wireguard/receive.c:506
 process_one_work+0x3f6/0x960 kernel/workqueue.c:2307
 worker_thread+0x616/0xa70 kernel/workqueue.c:2454
 kthread+0x2c7/0x2e0 kernel/kthread.c:327
 ret_from_fork+0x1f/0x30

read to 0xffffe8ffffc39fe0 of 8 bytes by task 7601 on cpu 1:
 dev_fetch_sw_netstats net/core/dev.c:10050 [inline]
 dev_get_tstats64+0x117/0x1e0 net/core/dev.c:10075
 dev_get_stats+0x65/0x180 net/core/dev.c:10017
 rtnl_fill_stats+0x45/0x320 net/core/rtnetlink.c:1203
 rtnl_fill_ifinfo+0xf16/0x25b0 net/core/rtnetlink.c:1776
 rtmsg_ifinfo_build_skb+0xa8/0x130 net/core/rtnetlink.c:3833
 rtmsg_ifinfo_event net/core/rtnetlink.c:3865 [inline]
 rtmsg_ifinfo+0x58/0xc0 net/core/rtnetlink.c:3874
 __dev_notify_flags+0x63/0x3b0 net/core/dev.c:8173
 dev_change_flags+0xa2/0xc0 net/core/dev.c:8215
 do_setlink+0x820/0x2500 net/core/rtnetlink.c:2729
 __rtnl_newlink net/core/rtnetlink.c:3412 [inline]
 rtnl_newlink+0xfad/0x13b0 net/core/rtnetlink.c:3527
 rtnetlink_rcv_msg+0x745/0x7e0 net/core/rtnetlink.c:5592
 netlink_rcv_skb+0x14e/0x250 net/netlink/af_netlink.c:2494
 rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:5610
 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
 netlink_unicast+0x602/0x6d0 net/netlink/af_netlink.c:1343
 netlink_sendmsg+0x728/0x850 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg net/socket.c:725 [inline]
 __sys_sendto+0x21e/0x2c0 net/socket.c:2040
 __do_sys_sendto net/socket.c:2052 [inline]
 __se_sys_sendto net/socket.c:2048 [inline]
 __x64_sys_sendto+0x74/0x90 net/socket.c:2048
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

value changed: 0x0000000000000001 -> 0x0000000000000002

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 7601 Comm: syz-executor.0 Not tainted 5.16.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
==================================================================

---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email-masked].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.