• Eric Dumazet's avatar
    net/packet: annotate accesses to po->ifindex · e032f7c9
    Eric Dumazet authored
    Like prior patch, we need to annotate lockless accesses to po->ifindex
    For instance, packet_getname() is reading po->ifindex (twice) while
    another thread is able to change po->ifindex.
    
    KCSAN reported:
    
    BUG: KCSAN: data-race in packet_do_bind / packet_getname
    
    write to 0xffff888143ce3cbc of 4 bytes by task 25573 on cpu 1:
     packet_do_bind+0x420/0x7e0 net/packet/af_packet.c:3191
     packet_bind+0xc3/0xd0 net/packet/af_packet.c:3255
     __sys_bind+0x200/0x290 net/socket.c:1637
     __do_sys_bind net/socket.c:1648 [inline]
     __se_sys_bind net/socket.c:1646 [inline]
     __x64_sys_bind+0x3d/0x50 net/socket.c:1646
     do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    read to 0xffff888143ce3cbc of 4 bytes by task 25578 on cpu 0:
     packet_getname+0x5b/0x1a0 net/packet/af_packet.c:3525
     __sys_getsockname+0x10e/0x1a0 net/socket.c:1887
     __do_sys_getsockname net/socket.c:1902 [inline]
     __se_sys_getsockname net/socket.c:1899 [inline]
     __x64_sys_getsockname+0x3e/0x50 net/socket.c:1899
     do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    value changed: 0x00000000 -> 0x00000001
    
    Reported by Kernel Concurrency Sanitizer on:
    CPU: 0 PID: 25578 Comm: syz-executor.5 Not tainted 5.13.0-rc6-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    e032f7c9
af_packet.c 110 KB