2023-04-24 07:22:48

by syzbot

[permalink] [raw]
Subject: [syzbot] [block?] KCSAN: data-race in __get_task_ioprio / set_task_ioprio

Hello,

syzbot found the following issue on:

HEAD commit: 44149752e998 Merge tag 'cgroup-for-6.3-rc6-fixes' of git:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=147afc8fc80000
kernel config: https://syzkaller.appspot.com/x/.config?x=710057cbb8def08c
dashboard link: https://syzkaller.appspot.com/bug?extid=28ed267c18c614a9376f
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/7bfa303f05cc/disk-44149752.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/4e8ea8730409/vmlinux-44149752.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e584bce13ba7/bzImage-44149752.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

==================================================================
BUG: KCSAN: data-race in __get_task_ioprio / set_task_ioprio

write to 0xffff888108c83888 of 8 bytes by task 15748 on cpu 0:
set_task_ioprio+0x23b/0x260 block/blk-ioc.c:291
__do_sys_ioprio_set block/ioprio.c:124 [inline]
__se_sys_ioprio_set+0x272/0x5a0 block/ioprio.c:68
__x64_sys_ioprio_set+0x43/0x50 block/ioprio.c:68
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 0xffff888108c83888 of 8 bytes by task 15749 on cpu 1:
__get_task_ioprio+0x1c/0x110 block/ioprio.c:150
get_current_ioprio include/linux/ioprio.h:60 [inline]
init_sync_kiocb include/linux/fs.h:2003 [inline]
__kernel_write_iter+0xe2/0x380 fs/read_write.c:515
dump_emit_page fs/coredump.c:885 [inline]
dump_user_range+0x258/0x480 fs/coredump.c:912
elf_core_dump+0x1a73/0x1b90 fs/binfmt_elf.c:2142
do_coredump+0xfeb/0x1840 fs/coredump.c:762
get_signal+0xd65/0xff0 kernel/signal.c:2845
arch_do_signal_or_restart+0x89/0x2a0 arch/x86/kernel/signal.c:306
exit_to_user_mode_loop+0x6f/0xe0 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x6c/0xb0 kernel/entry/common.c:204
irqentry_exit_to_user_mode+0x9/0x20 kernel/entry/common.c:310
irqentry_exit+0x12/0x40 kernel/entry/common.c:413
exc_general_protection+0x339/0x4c0 arch/x86/kernel/traps.c:728
asm_exc_general_protection+0x26/0x30 arch/x86/include/asm/idtentry.h:564

value changed: 0x0000000000000000 -> 0xffff8881049b5c90

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 15749 Comm: syz-executor.5 Tainted: G W 6.3.0-rc6-syzkaller-00138-g44149752e998 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/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 [email protected].

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


2023-04-24 07:55:39

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: [syzbot] [block?] KCSAN: data-race in __get_task_ioprio / set_task_ioprio

On Mon, 24 Apr 2023 at 09:20, syzbot
<[email protected]> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 44149752e998 Merge tag 'cgroup-for-6.3-rc6-fixes' of git:/..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=147afc8fc80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=710057cbb8def08c
> dashboard link: https://syzkaller.appspot.com/bug?extid=28ed267c18c614a9376f
> 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/7bfa303f05cc/disk-44149752.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/4e8ea8730409/vmlinux-44149752.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/e584bce13ba7/bzImage-44149752.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]

It looks like it can lead to reading wrong/uninit ioprio in __get_task_ioprio.
I think set_task_ioprio() should init ioprio before publishing and
publish with a release store, __get_task_ioprio needs to use load
acquire to ensure proper ordering.

> ==================================================================
> BUG: KCSAN: data-race in __get_task_ioprio / set_task_ioprio
>
> write to 0xffff888108c83888 of 8 bytes by task 15748 on cpu 0:
> set_task_ioprio+0x23b/0x260 block/blk-ioc.c:291
> __do_sys_ioprio_set block/ioprio.c:124 [inline]
> __se_sys_ioprio_set+0x272/0x5a0 block/ioprio.c:68
> __x64_sys_ioprio_set+0x43/0x50 block/ioprio.c:68
> 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 0xffff888108c83888 of 8 bytes by task 15749 on cpu 1:
> __get_task_ioprio+0x1c/0x110 block/ioprio.c:150
> get_current_ioprio include/linux/ioprio.h:60 [inline]
> init_sync_kiocb include/linux/fs.h:2003 [inline]
> __kernel_write_iter+0xe2/0x380 fs/read_write.c:515
> dump_emit_page fs/coredump.c:885 [inline]
> dump_user_range+0x258/0x480 fs/coredump.c:912
> elf_core_dump+0x1a73/0x1b90 fs/binfmt_elf.c:2142
> do_coredump+0xfeb/0x1840 fs/coredump.c:762
> get_signal+0xd65/0xff0 kernel/signal.c:2845
> arch_do_signal_or_restart+0x89/0x2a0 arch/x86/kernel/signal.c:306
> exit_to_user_mode_loop+0x6f/0xe0 kernel/entry/common.c:168
> exit_to_user_mode_prepare+0x6c/0xb0 kernel/entry/common.c:204
> irqentry_exit_to_user_mode+0x9/0x20 kernel/entry/common.c:310
> irqentry_exit+0x12/0x40 kernel/entry/common.c:413
> exc_general_protection+0x339/0x4c0 arch/x86/kernel/traps.c:728
> asm_exc_general_protection+0x26/0x30 arch/x86/include/asm/idtentry.h:564
>
> value changed: 0x0000000000000000 -> 0xffff8881049b5c90
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 1 PID: 15749 Comm: syz-executor.5 Tainted: G W 6.3.0-rc6-syzkaller-00138-g44149752e998 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/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 [email protected].
>
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/00000000000071af7a05fa0fd8dc%40google.com.