Re: [syzbot] [kernel?] KCSAN: data-race in complete_signal / do_group_exit (7)

From: Dmitry Vyukov
Date: Fri Apr 21 2023 - 10:46:27 EST


On Fri, 21 Apr 2023 at 16:33, syzbot
<syzbot+0864692611e2ae4cc85f@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 3a93e40326c8 Merge tag 'for-linus' of git://git.kernel.org..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1769d1dec80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=f7350c77b8056a38
> dashboard link: https://syzkaller.appspot.com/bug?extid=0864692611e2ae4cc85f
> compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/2122926bc9fe/disk-3a93e403.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/8392992358bc/vmlinux-3a93e403.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/6398a2d19a7e/bzImage-3a93e403.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+0864692611e2ae4cc85f@xxxxxxxxxxxxxxxxxxxxxxxxx

Here this:

signal->flags = SIGNAL_GROUP_EXIT;
signal->group_exit_code = sig;

runs concurrently with:

if (sig->flags & SIGNAL_GROUP_EXIT)
exit_code = sig->group_exit_code;

If I am reading this correctly, do_group_exit() can use a wrong/uninit
exit code as the result.





> ==================================================================
> BUG: KCSAN: data-race in complete_signal / do_group_exit
>
> write to 0xffff88810491e534 of 4 bytes by task 13425 on cpu 0:
> complete_signal+0x541/0x6d0 kernel/signal.c:1053
> __send_signal_locked+0x5cc/0x700 kernel/signal.c:1190
> send_signal_locked+0x28d/0x3a0 kernel/signal.c:1253
> do_send_sig_info+0x9f/0xf0 kernel/signal.c:1296
> send_sig_info kernel/signal.c:1636 [inline]
> send_sig+0x53/0x60 kernel/signal.c:1646
> pipe_write+0x8b1/0xd70 fs/pipe.c:482
> call_write_iter include/linux/fs.h:1851 [inline]
> new_sync_write fs/read_write.c:491 [inline]
> vfs_write+0x45a/0x750 fs/read_write.c:584
> ksys_write+0xeb/0x1a0 fs/read_write.c:637
> __do_sys_write fs/read_write.c:649 [inline]
> __se_sys_write fs/read_write.c:646 [inline]
> __x64_sys_write+0x42/0x50 fs/read_write.c:646
> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
> read to 0xffff88810491e534 of 4 bytes by task 13410 on cpu 1:
> do_group_exit+0x3e/0x150 kernel/exit.c:998
> __do_sys_exit_group kernel/exit.c:1030 [inline]
> __se_sys_exit_group kernel/exit.c:1028 [inline]
> __x64_sys_exit_group+0x1f/0x20 kernel/exit.c:1028
> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
> value changed: 0x00000002 -> 0x00000004
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 1 PID: 13410 Comm: syz-executor.0 Not tainted 6.3.0-rc4-syzkaller-00025-g3a93e40326c8 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
> ==================================================================
>
>
> ---
> This report 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@xxxxxxxxxxxxxxxx.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@xxxxxxxxxxxxxxxx.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000be9fa205f9d98b5b%40google.com.