Skip to content

net/packet: KCSAN awareness

Eric Dumazet netdev 1 version Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 4 repliesApplied 9/9

Patches in v1 All 9 applied

#Subject and filesSizeRepliesApplied
1/9net/packet: annotate accesses to po->xmitnet/packet/af_packet.c+8 -43 repliesApplied
2/9net/packet: convert po->origdev to an atomic flagnet/packet/af_packet.c net/packet/diag.c net/packet/internal.h+26 -80 repliesApplied
3/9net/packet: convert po->auxdata to an atomic flagnet/packet/af_packet.c net/packet/diag.c net/packet/internal.h+6 -80 repliesApplied
4/9net/packet: annotate accesses to po->tp_tstampnet/packet/af_packet.c net/packet/diag.c+6 -50 repliesApplied
5/9net/packet: convert po->tp_tx_has_off to an atomic flagnet/packet/af_packet.c net/packet/internal.h+5 -50 repliesApplied
6/9net/packet: convert po->tp_loss to an atomic flagnet/packet/af_packet.c net/packet/diag.c net/packet/internal.h+6 -60 repliesApplied
7/9net/packet: convert po->has_vnet_hdr to an atomic flagnet/packet/af_packet.c net/packet/diag.c net/packet/internal.h+12 -110 repliesApplied
8/9net/packet: convert po->running to an atomic flagnet/packet/af_packet.c net/packet/diag.c net/packet/internal.h+12 -120 repliesApplied
9/9net/packet: convert po->pressure to an atomic flagnet/packet/af_packet.c net/packet/internal.h+9 -70 repliesApplied

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchWillem de Bruijn
SeriesR-b
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH net-next 0/9] net/packet: KCSAN awareness

This series is based on one syzbot report [1]

Seven 'flags/booleans' are converted to atomic bit variant.

po->xmit and po->tp_tstamp accesses get annotations.

[1]

BUG: KCSAN: data-race in packet_rcv / packet_setsockopt

read-write to 0xffff88813dbe84e4 of 1 bytes by task 12312 on cpu 0:

packet_setsockopt+0xb77/0xe60 net/packet/af_packet.c:3900
__sys_setsockopt+0x212/0x2b0 net/socket.c:2252
__do_sys_setsockopt net/socket.c:2263 [inline]
__se_sys_setsockopt net/socket.c:2260 [inline]
__x64_sys_setsockopt+0x62/0x70 net/socket.c:2260
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

read to 0xffff88813dbe84e4 of 1 bytes by task 1911 on cpu 1:

packet_rcv+0x4b1/0xa40 net/packet/af_packet.c:2187
deliver_skb net/core/dev.c:2189 [inline]
dev_queue_xmit_nit+0x3a9/0x620 net/core/dev.c:2259
xmit_one+0x71/0x2a0 net/core/dev.c:3586
dev_hard_start_xmit+0x72/0x120 net/core/dev.c:3606
__dev_queue_xmit+0x91c/0x11c0 net/core/dev.c:4256
dev_queue_xmit include/linux/netdevice.h:3008 [inline]
neigh_hh_output include/net/neighbour.h:530 [inline]
neigh_output include/net/neighbour.h:544 [inline]
ip6_finish_output2+0x9e9/0xc30 net/ipv6/ip6_output.c:134
__ip6_finish_output net/ipv6/ip6_output.c:195 [inline]
ip6_finish_output+0x395/0x4f0 net/ipv6/ip6_output.c:206
NF_HOOK_COND include/linux/netfilter.h:291 [inline]
ip6_output+0x10e/0x210 net/ipv6/ip6_output.c:227
dst_output include/net/dst.h:445 [inline]
ip6_local_out+0x60/0x80 net/ipv6/output_core.c:161
ip6tunnel_xmit include/net/ip6_tunnel.h:161 [inline]
udp_tunnel6_xmit_skb+0x321/0x4a0 net/ipv6/ip6_udp_tunnel.c:109
send6+0x2ed/0x3b0 drivers/net/wireguard/socket.c:152
wg_socket_send_skb_to_peer+0xbb/0x120 drivers/net/wireguard/socket.c:178
wg_packet_create_data_done drivers/net/wireguard/send.c:251 [inline]
wg_packet_tx_worker+0x142/0x360 drivers/net/wireguard/send.c:276
process_one_work+0x3d3/0x720 kernel/workqueue.c:2289
worker_thread+0x618/0xa70 kernel/workqueue.c:2436
kthread+0x1a9/0x1e0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

value changed: 0x00 -> 0x01

Reported by Kernel Concurrency Sanitizer on:

CPU: 1 PID: 1911 Comm: kworker/1:3 Not tainted 6.1.0-rc8-syzkaller-00164-g4cee37b3a4e6-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Workqueue: wg-crypt-wg0 wg_packet_tx_worker

Eric Dumazet (9):
net/packet: annotate accesses to po->xmit net/packet: convert po->origdev to an atomic flag net/packet: convert po->auxdata to an atomic flag net/packet: annotate accesses to po->tp_tstamp net/packet: convert po->tp_tx_has_off to an atomic flag net/packet: convert po->tp_loss to an atomic flag net/packet: convert po->has_vnet_hdr to an atomic flag net/packet: convert po->running to an atomic flag net/packet: convert po->pressure to an atomic flag

 net/packet/af_packet.c | 104 +++++++++++++++++++++--------------------
 net/packet/diag.c      |  12 ++---
 net/packet/internal.h  |  34 +++++++++++---
 3 files changed, 87 insertions(+), 63 deletions(-)
Signature · 1 line
2.40.0.rc2.332.ga46443480c-goog