Eric Dumazet
68b7234958
packet: fix data-race in fanout_flow_is_huge()
...
[ Upstream commit b756ad928d98e5ef0b74af7546a6a31a8dadde00 ]
KCSAN reported the following data-race [1]
Adding a couple of READ_ONCE()/WRITE_ONCE() should silence it.
Since the report hinted about multiple cpus using the history
concurrently, I added a test avoiding writing on it if the
victim slot already contains the desired value.
[1]
BUG: KCSAN: data-race in fanout_demux_rollover / fanout_demux_rollover
read to 0xffff8880b01786cc of 4 bytes by task 18921 on cpu 1:
fanout_flow_is_huge net/packet/af_packet.c:1303 [inline]
fanout_demux_rollover+0x33e/0x3f0 net/packet/af_packet.c:1353
packet_rcv_fanout+0x34e/0x490 net/packet/af_packet.c:1453
deliver_skb net/core/dev.c:1888 [inline]
dev_queue_xmit_nit+0x15b/0x540 net/core/dev.c:1958
xmit_one net/core/dev.c:3195 [inline]
dev_hard_start_xmit+0x3f5/0x430 net/core/dev.c:3215
__dev_queue_xmit+0x14ab/0x1b40 net/core/dev.c:3792
dev_queue_xmit+0x21/0x30 net/core/dev.c:3825
neigh_direct_output+0x1f/0x30 net/core/neighbour.c:1530
neigh_output include/net/neighbour.h:511 [inline]
ip6_finish_output2+0x7a2/0xec0 net/ipv6/ip6_output.c:116
__ip6_finish_output net/ipv6/ip6_output.c:142 [inline]
__ip6_finish_output+0x2d7/0x330 net/ipv6/ip6_output.c:127
ip6_finish_output+0x41/0x160 net/ipv6/ip6_output.c:152
NF_HOOK_COND include/linux/netfilter.h:294 [inline]
ip6_output+0xf2/0x280 net/ipv6/ip6_output.c:175
dst_output include/net/dst.h:436 [inline]
ip6_local_out+0x74/0x90 net/ipv6/output_core.c:179
ip6_send_skb+0x53/0x110 net/ipv6/ip6_output.c:1795
udp_v6_send_skb.isra.0+0x3ec/0xa70 net/ipv6/udp.c:1173
udpv6_sendmsg+0x1906/0x1c20 net/ipv6/udp.c:1471
inet6_sendmsg+0x6d/0x90 net/ipv6/af_inet6.c:576
sock_sendmsg_nosec net/socket.c:637 [inline]
sock_sendmsg+0x9f/0xc0 net/socket.c:657
___sys_sendmsg+0x2b7/0x5d0 net/socket.c:2311
__sys_sendmmsg+0x123/0x350 net/socket.c:2413
__do_sys_sendmmsg net/socket.c:2442 [inline]
__se_sys_sendmmsg net/socket.c:2439 [inline]
__x64_sys_sendmmsg+0x64/0x80 net/socket.c:2439
do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9
write to 0xffff8880b01786cc of 4 bytes by task 18922 on cpu 0:
fanout_flow_is_huge net/packet/af_packet.c:1306 [inline]
fanout_demux_rollover+0x3a4/0x3f0 net/packet/af_packet.c:1353
packet_rcv_fanout+0x34e/0x490 net/packet/af_packet.c:1453
deliver_skb net/core/dev.c:1888 [inline]
dev_queue_xmit_nit+0x15b/0x540 net/core/dev.c:1958
xmit_one net/core/dev.c:3195 [inline]
dev_hard_start_xmit+0x3f5/0x430 net/core/dev.c:3215
__dev_queue_xmit+0x14ab/0x1b40 net/core/dev.c:3792
dev_queue_xmit+0x21/0x30 net/core/dev.c:3825
neigh_direct_output+0x1f/0x30 net/core/neighbour.c:1530
neigh_output include/net/neighbour.h:511 [inline]
ip6_finish_output2+0x7a2/0xec0 net/ipv6/ip6_output.c:116
__ip6_finish_output net/ipv6/ip6_output.c:142 [inline]
__ip6_finish_output+0x2d7/0x330 net/ipv6/ip6_output.c:127
ip6_finish_output+0x41/0x160 net/ipv6/ip6_output.c:152
NF_HOOK_COND include/linux/netfilter.h:294 [inline]
ip6_output+0xf2/0x280 net/ipv6/ip6_output.c:175
dst_output include/net/dst.h:436 [inline]
ip6_local_out+0x74/0x90 net/ipv6/output_core.c:179
ip6_send_skb+0x53/0x110 net/ipv6/ip6_output.c:1795
udp_v6_send_skb.isra.0+0x3ec/0xa70 net/ipv6/udp.c:1173
udpv6_sendmsg+0x1906/0x1c20 net/ipv6/udp.c:1471
inet6_sendmsg+0x6d/0x90 net/ipv6/af_inet6.c:576
sock_sendmsg_nosec net/socket.c:637 [inline]
sock_sendmsg+0x9f/0xc0 net/socket.c:657
___sys_sendmsg+0x2b7/0x5d0 net/socket.c:2311
__sys_sendmmsg+0x123/0x350 net/socket.c:2413
__do_sys_sendmmsg net/socket.c:2442 [inline]
__se_sys_sendmmsg net/socket.c:2439 [inline]
__x64_sys_sendmmsg+0x64/0x80 net/socket.c:2439
do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 18922 Comm: syz-executor.3 Not tainted 5.4.0-rc6+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Fixes: 3b3a5b0aab5b ("packet: rollover huge flows before small flows")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-27 14:46:51 +01:00
..
2020-01-27 14:46:30 +01:00
2019-07-31 07:28:39 +02:00
2017-11-02 11:10:55 +01:00
2020-01-12 12:12:09 +01:00
2019-12-17 20:38:59 +01:00
2019-11-10 11:25:34 +01:00
2019-10-05 12:47:43 +02:00
2020-01-23 08:20:34 +01:00
2020-01-09 10:17:57 +01:00
2020-01-27 14:46:34 +01:00
2019-11-10 11:25:34 +01:00
2019-07-21 09:04:22 +02:00
2019-08-29 08:26:42 +02:00
2020-01-27 14:46:51 +01:00
2018-09-19 22:43:43 +02:00
2020-01-17 19:45:43 +01:00
2020-01-04 14:00:14 +01:00
2018-07-22 14:28:49 +02:00
2020-01-23 08:20:34 +01:00
2020-01-09 10:17:59 +01:00
2020-01-17 19:45:45 +01:00
2020-01-27 14:46:36 +01:00
2018-04-29 11:33:13 +02:00
2020-01-27 14:46:50 +01:00
2020-01-27 14:46:36 +01:00
2017-11-02 11:10:55 +01:00
2020-01-27 14:46:38 +01:00
2019-04-17 08:37:45 +02:00
2019-09-16 08:20:44 +02:00
2020-01-27 14:46:33 +01:00
2019-06-22 08:16:14 +02:00
2020-01-27 14:46:49 +01:00
2020-01-27 14:46:49 +01:00
2018-09-09 19:55:52 +02:00
2020-01-27 14:46:37 +01:00
2017-10-21 01:56:38 +01:00
2020-01-27 14:46:23 +01:00
2019-03-13 14:03:08 -07:00
2019-04-03 06:25:08 +02:00
2019-07-31 07:28:46 +02:00
2019-12-31 12:36:41 +01:00
2018-07-22 14:28:49 +02:00
2019-12-21 10:47:34 +01:00
2020-01-27 14:46:51 +01:00
2019-11-10 11:25:34 +01:00
2019-12-05 15:38:15 +01:00
2019-10-05 12:47:40 +02:00
2020-01-27 14:46:47 +01:00
2020-01-12 12:11:57 +01:00
2019-05-02 09:40:34 +02:00
2020-01-27 14:46:39 +01:00
2020-01-27 14:46:50 +01:00
2020-01-12 12:12:07 +01:00
2019-12-17 20:38:01 +01:00
2018-07-22 14:28:47 +02:00
2020-01-17 19:45:47 +01:00
2017-08-07 14:48:48 -07:00
2020-01-27 14:46:41 +01:00
2018-12-05 19:41:11 +01:00
2020-01-17 19:45:49 +01:00
2019-12-05 15:37:24 +01:00
2017-11-02 11:10:55 +01:00
2020-01-23 08:20:35 +01:00
2019-12-17 20:38:25 +01:00
2019-12-17 20:37:28 +01:00
2019-01-09 17:14:46 +01:00
2017-09-04 13:25:20 +02:00
2017-11-02 11:10:55 +01:00
2020-01-17 19:45:49 +01:00