Eric Dumazet
61217d8f63
virtio_net: use u64_stats_t infra to avoid data-races
syzbot reported a data-race in virtnet_poll / virtnet_stats [1]
u64_stats_t infra has very nice accessors that must be used
to avoid potential load-store tearing.
[1]
BUG: KCSAN: data-race in virtnet_poll / virtnet_stats
read-write to 0xffff88810271b1a0 of 8 bytes by interrupt on cpu 0:
virtnet_receive drivers/net/virtio_net.c:2102 [inline]
virtnet_poll+0x6c8/0xb40 drivers/net/virtio_net.c:2148
__napi_poll+0x60/0x3b0 net/core/dev.c:6527
napi_poll net/core/dev.c:6594 [inline]
net_rx_action+0x32b/0x750 net/core/dev.c:6727
__do_softirq+0xc1/0x265 kernel/softirq.c:553
invoke_softirq kernel/softirq.c:427 [inline]
__irq_exit_rcu kernel/softirq.c:632 [inline]
irq_exit_rcu+0x3b/0x90 kernel/softirq.c:644
common_interrupt+0x7f/0x90 arch/x86/kernel/irq.c:247
asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:636
__sanitizer_cov_trace_const_cmp8+0x0/0x80 kernel/kcov.c:306
jbd2_write_access_granted fs/jbd2/transaction.c:1174 [inline]
jbd2_journal_get_write_access+0x94/0x1c0 fs/jbd2/transaction.c:1239
__ext4_journal_get_write_access+0x154/0x3f0 fs/ext4/ext4_jbd2.c:241
ext4_reserve_inode_write+0x14e/0x200 fs/ext4/inode.c:5745
__ext4_mark_inode_dirty+0x8e/0x440 fs/ext4/inode.c:5919
ext4_evict_inode+0xaf0/0xdc0 fs/ext4/inode.c:299
evict+0x1aa/0x410 fs/inode.c:664
iput_final fs/inode.c:1775 [inline]
iput+0x42c/0x5b0 fs/inode.c:1801
do_unlinkat+0x2b9/0x4f0 fs/namei.c:4405
__do_sys_unlink fs/namei.c:4446 [inline]
__se_sys_unlink fs/namei.c:4444 [inline]
__x64_sys_unlink+0x30/0x40 fs/namei.c:4444
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
read to 0xffff88810271b1a0 of 8 bytes by task 2814 on cpu 1:
virtnet_stats+0x1b3/0x340 drivers/net/virtio_net.c:2564
dev_get_stats+0x6d/0x860 net/core/dev.c:10511
rtnl_fill_stats+0x45/0x320 net/core/rtnetlink.c:1261
rtnl_fill_ifinfo+0xd0e/0x1120 net/core/rtnetlink.c:1867
rtnl_dump_ifinfo+0x7f9/0xc20 net/core/rtnetlink.c:2240
netlink_dump+0x390/0x720 net/netlink/af_netlink.c:2266
netlink_recvmsg+0x425/0x780 net/netlink/af_netlink.c:1992
sock_recvmsg_nosec net/socket.c:1027 [inline]
sock_recvmsg net/socket.c:1049 [inline]
____sys_recvmsg+0x156/0x310 net/socket.c:2760
___sys_recvmsg net/socket.c:2802 [inline]
__sys_recvmsg+0x1ea/0x270 net/socket.c:2832
__do_sys_recvmsg net/socket.c:2842 [inline]
__se_sys_recvmsg net/socket.c:2839 [inline]
__x64_sys_recvmsg+0x46/0x50 net/socket.c:2839
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
value changed: 0x000000000045c334 -> 0x000000000045c376
Fixes: 3fa2a1df90 ("virtio-net: per cpu 64 bit stats (v2)")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-10-27 10:58:15 +01:00
..
2023-10-19 08:01:20 +02:00
2023-08-11 21:12:45 +02:00
2023-10-22 12:47:43 +02:00
2023-08-22 15:50:57 +02:00
2023-10-05 12:48:08 +02:00
2023-10-10 14:42:22 +09:00
2023-10-10 12:41:17 +02:00
2023-08-30 13:34:34 -07:00
2023-10-18 09:30:03 -07:00
2023-10-06 15:43:19 -07:00
2023-10-23 11:04:51 -07:00
2023-09-13 10:24:53 +03:00
2023-09-01 09:08:59 -07:00
2023-08-04 16:21:20 +02:00
2023-09-13 11:44:20 -07:00
2023-09-12 10:56:05 -07:00
2023-09-04 13:15:57 -07:00
2023-09-12 15:49:20 +02:00
2023-10-24 10:53:45 +02:00
2023-10-02 13:13:15 +02:00
2023-08-29 20:51:40 +02:00
2023-08-31 12:43:10 -07:00
2023-10-18 11:30:06 -04:00
2023-09-22 14:31:04 -07:00
2023-08-24 16:20:30 -07:00
2023-08-10 22:48:16 +09:00
2023-10-13 08:52:57 -07:00
2023-10-05 11:05:58 +02:00
2023-10-15 16:08:25 +01:00
2023-08-30 19:23:00 -07:00
2023-07-27 10:04:42 -07:00
2023-08-05 15:42:15 +09:00
2023-09-28 21:23:00 +09:00
2023-10-22 07:05:28 -10:00
2023-08-11 23:04:21 +08:00
2023-08-22 15:51:33 +02:00
2023-10-20 11:24:16 +02:00
2023-10-20 14:24:35 +10:00
2023-10-06 16:09:14 +02:00
2023-07-31 23:17:57 +02:00
2023-08-28 13:31:06 -05:00
2023-09-04 11:26:29 -07:00
2023-09-18 11:52:18 -07:00
2023-09-20 10:46:30 +01:00
2023-09-27 21:32:06 +02:00
2023-10-17 12:45:03 +02:00
2023-08-28 16:35:01 -07:00
2023-10-05 18:06:46 +01:00
2023-10-13 09:35:34 -07:00
2023-10-13 23:19:16 -07:00
2023-08-30 19:53:39 -07:00
2023-09-25 16:10:36 +02:00
2023-08-11 21:12:46 +02:00
2023-10-10 11:14:07 -07:00
2023-10-23 09:39:46 +01:00
2023-09-19 15:16:23 +01:00
2023-08-31 12:43:10 -07:00
2023-09-05 10:11:01 -05:00
2023-10-05 09:50:14 +02:00
2023-10-10 10:47:35 -07:00
2023-10-11 15:26:16 +02:00
2023-08-05 09:01:31 +02:00
2023-10-05 11:03:20 -07:00
2023-09-25 10:48:19 +02:00
2023-09-27 12:17:04 +02:00
2023-10-20 13:12:34 -07:00
2023-08-28 13:36:24 -05:00
2023-10-27 10:58:15 +01:00
2023-08-30 18:32:24 -07:00
2023-08-22 12:38:19 -04:00
2023-08-30 20:52:08 -07:00
2023-10-18 14:08:39 -07:00
2023-08-23 16:34:02 +02:00
2023-10-02 11:34:23 -05:00
2023-08-18 10:55:49 +05:30
2023-08-31 21:42:42 +02:00
2023-09-01 09:38:00 -07:00
2023-10-06 09:11:13 -07:00
2023-08-04 15:39:44 +02:00
2023-08-08 10:53:30 +02:00
2023-10-13 09:17:48 -07:00
2023-10-22 07:11:10 -10:00
2023-10-19 10:12:48 +02:00
2023-10-18 15:38:09 +02:00
2023-10-05 00:28:52 +02:00
2023-08-17 19:38:35 +02:00
2023-09-30 21:00:20 +02:00
2023-09-06 22:21:22 +02:00
2023-10-19 15:51:52 -07:00
2023-09-07 18:05:58 -07:00
2023-09-26 17:26:08 +02:00
2023-09-04 15:12:26 -07:00
2023-08-30 19:53:39 -07:00
2023-09-04 15:08:52 -07:00
2023-09-07 16:07:35 -07:00
2023-10-26 13:46:28 -07:00
2023-08-28 13:36:24 -05:00
2023-10-20 13:24:50 -07:00
2023-10-12 11:52:23 -07:00
2023-09-21 11:31:33 +02:00
2023-10-02 15:03:19 +01:00
2023-10-19 10:26:26 +03:00
2023-10-20 11:34:50 +01:00
2023-09-27 10:55:29 -04:00
2023-10-12 11:52:23 -07:00
2023-09-18 13:13:05 +02:00
2023-10-17 19:25:42 +02:00
2023-10-07 11:23:47 +02:00
2023-10-09 21:33:30 -04:00
2023-08-22 13:41:55 +02:00
2023-10-20 07:52:44 +02:00
2023-10-18 11:29:41 -04:00
2023-09-22 12:48:04 -06:00
2023-10-26 13:46:28 -07:00
2023-10-17 17:14:22 -07:00
2023-08-24 16:20:18 -07:00
2023-10-18 11:30:12 -04:00
2023-09-13 10:48:42 +02:00
2023-09-06 09:19:12 -07:00
2023-10-09 09:21:16 +02:00
2023-08-21 13:27:44 +02:00
2023-09-17 11:50:20 +01:00
2023-09-17 11:50:20 +01:00