• Eric Dumazet's avatar
    wireguard: use DEV_STATS_INC() · 93da8d75
    Eric Dumazet authored
    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: e7096c13 ("net: WireGuard secure network tunnel")
    Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Cc: Jason A. Donenfeld <Jason@zx2c4.com>
    Cc: Hangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: default avatarHangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    93da8d75
device.c 13.2 KB