KCSAN: data-race in netlink_recvmsg / netlink_recvmsg

From: syzbot
Date: Thu Nov 07 2019 - 13:55:16 EST


Hello,

syzbot found the following crash on:

HEAD commit: 94c00660 x86, kcsan: Enable KCSAN for x86
git tree: https://github.com/google/ktsan.git kcsan
console output: https://syzkaller.appspot.com/x/log.txt?x=14426768e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=51a7c7d2972c87e5
dashboard link: https://syzkaller.appspot.com/bug?extid=6dedf50d68e5713a1f65
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+6dedf50d68e5713a1f65@xxxxxxxxxxxxxxxxxxxxxxxxx

==================================================================
BUG: KCSAN: data-race in netlink_recvmsg / netlink_recvmsg

write to 0xffff8880b588efb2 of 2 bytes by task 19788 on cpu 0:
skb_reset_transport_header include/linux/skbuff.h:2463 [inline]
netlink_recvmsg+0x196/0x910 net/netlink/af_netlink.c:1974
sock_recvmsg_nosec+0x5c/0x70 net/socket.c:871
___sys_recvmsg+0x1a0/0x3e0 net/socket.c:2480
do_recvmmsg+0x19a/0x5c0 net/socket.c:2601
__sys_recvmmsg+0x1ef/0x200 net/socket.c:2680
__do_sys_recvmmsg net/socket.c:2703 [inline]
__se_sys_recvmmsg net/socket.c:2696 [inline]
__x64_sys_recvmmsg+0x89/0xb0 net/socket.c:2696
do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9

write to 0xffff8880b588efb2 of 2 bytes by task 19789 on cpu 1:
skb_reset_transport_header include/linux/skbuff.h:2463 [inline]
netlink_recvmsg+0x196/0x910 net/netlink/af_netlink.c:1974
sock_recvmsg_nosec net/socket.c:871 [inline]
sock_recvmsg net/socket.c:889 [inline]
sock_recvmsg+0x92/0xb0 net/socket.c:885
__sys_recvfrom+0x1ae/0x2d0 net/socket.c:2009
__do_sys_recvfrom net/socket.c:2027 [inline]
__se_sys_recvfrom net/socket.c:2023 [inline]
__x64_sys_recvfrom+0x89/0xb0 net/socket.c:2023
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: 1 PID: 19789 Comm: syz-executor.0 Not tainted 5.4.0-rc6+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
==================================================================
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 19789 Comm: syz-executor.0 Not tainted 5.4.0-rc6+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xf5/0x159 lib/dump_stack.c:113
panic+0x210/0x640 kernel/panic.c:221
kcsan_report.cold+0xc/0xe kernel/kcsan/report.c:302
kcsan_setup_watchpoint+0x3fe/0x410 kernel/kcsan/core.c:357
check_access kernel/kcsan/core.c:409 [inline]
__tsan_unaligned_write2+0x143/0x1f0 kernel/kcsan/core.c:528
skb_reset_transport_header include/linux/skbuff.h:2463 [inline]
netlink_recvmsg+0x196/0x910 net/netlink/af_netlink.c:1974
sock_recvmsg_nosec net/socket.c:871 [inline]
sock_recvmsg net/socket.c:889 [inline]
sock_recvmsg+0x92/0xb0 net/socket.c:885
__sys_recvfrom+0x1ae/0x2d0 net/socket.c:2009
__do_sys_recvfrom net/socket.c:2027 [inline]
__se_sys_recvfrom net/socket.c:2023 [inline]
__x64_sys_recvfrom+0x89/0xb0 net/socket.c:2023
do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45a219
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f580a978c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002d
RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 000000000045a219
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000005
RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f580a9796d4
R13: 00000000004c7c59 R14: 00000000004ddd80 R15: 00000000ffffffff
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.