[moderation] [perf?] KCSAN: data-race in event_sched_out / perf_poll

0 views
Skip to first unread message

syzbot

unread,
7:06 PM (1 hour ago) 7:06 PM
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 666539eecdf4 Merge tag 'assoc-array-fixes-v2'
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15e87bed580000
kernel config: https://syzkaller.appspot.com/x/.config?x=b949a9d3c1d44ceb
dashboard link: https://syzkaller.appspot.com/bug?extid=d2f5271536cfba9f371d
compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
CC: [ac...@kernel.org adrian...@intel.com alexander...@linux.intel.com iro...@google.com james...@linaro.org jo...@kernel.org linux-...@vger.kernel.org linux-pe...@vger.kernel.org mark.r...@arm.com mi...@redhat.com namh...@kernel.org pet...@infradead.org]

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a943b9915869/disk-666539ee.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/9bfd839d7ea5/vmlinux-666539ee.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0f20b9720a71/bzImage-666539ee.xz

AI-generated root cause summary:
`perf_poll()` in `kernel/events/core.c` performs unmarked reads of
`event->state` (at lines 6322 and 6327, as well as in `is_event_hup()` at line
6260) without holding the event context lock `ctx->lock`. Concurrently—or when
preempted during `perf_poll()`, as shown in the KCSAN report—the scheduler's
`perf_event_task_sched_out()` -> `event_sched_out()` path calls
`perf_event_set_state()`, which updates `event->state` using
`WRITE_ONCE(event->state, state)` under `ctx->lock`. This mismatch between the
marked write in `perf_event_set_state()` and the unmarked reads in `perf_poll()`
triggers the KCSAN data-race report, whereas line 6333 of `perf_poll()` already
uses `READ_ONCE(event->state)`.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=d2f5271536cfba9f371d

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d2f527...@syzkaller.appspotmail.com

==================================================================
BUG: KCSAN: data-race in event_sched_out / perf_poll

write (marked) to 0xffff88811b78a4a8 of 4 bytes by task 5259 on cpu 1:
perf_event_set_state kernel/events/core.c:790 [inline]
event_sched_out+0x534/0x740 kernel/events/core.c:2506
group_sched_out kernel/events/core.c:2530 [inline]
__pmu_ctx_sched_out+0x3e7/0x530 kernel/events/core.c:3582
ctx_sched_out+0x273/0x2d0 kernel/events/core.c:3673
task_ctx_sched_out+0x4d/0x70 kernel/events/core.c:2982
perf_event_context_sched_out kernel/events/core.c:3883 [inline]
__perf_event_task_sched_out+0x441/0x710 kernel/events/core.c:3985
perf_event_task_sched_out include/linux/perf_event.h:1668 [inline]
prepare_task_switch kernel/sched/core.c:5366 [inline]
context_switch kernel/sched/core.c:5529 [inline]
__schedule+0xd04/0xd30 kernel/sched/core.c:7386
preempt_schedule_common+0x12/0x40 kernel/sched/core.c:7565
preempt_schedule_thunk+0x16/0x40 arch/x86/entry/thunk.S:12
delay_tsc+0x64/0xa0 arch/x86/lib/delay.c:75
udelay include/asm-generic/delay.h:64 [inline]
delay_access kernel/kcsan/core.c:332 [inline]
kcsan_setup_watchpoint+0x255/0x3f0 kernel/kcsan/core.c:622
perf_poll+0x36/0x200 kernel/events/core.c:6322
vfs_poll include/linux/poll.h:82 [inline]
io_file_supports_nowait io_uring/rw.c:48 [inline]
__io_read+0x30b/0xbd0 io_uring/rw.c:924
io_read+0x4a/0x1b0 io_uring/rw.c:1017
__io_issue_sqe+0xfd/0x2e0 io_uring/io_uring.c:1514
io_issue_sqe+0x1e7/0xd20 io_uring/io_uring.c:1537
io_queue_sqe io_uring/io_uring.c:1794 [inline]
io_req_task_submit+0x46/0xa0 io_uring/io_uring.c:1143
tctx_task_work_run+0x3cd/0x550 io_uring/tw.c:96
tctx_task_work+0x3f/0x60 io_uring/tw.c:133
task_work_run+0x145/0x1a0 kernel/task_work.c:233
get_signal+0xc12/0xd30 kernel/signal.c:2885
arch_do_signal_or_restart+0x96/0x480 arch/x86/kernel/signal.c:337
__exit_to_user_mode_loop kernel/entry/common.c:66 [inline]
exit_to_user_mode_loop+0x161/0x940 kernel/entry/common.c:101
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:343 [inline]
do_syscall_64+0x23b/0x3a0 arch/x86/entry/syscall_64.c:107
entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff88811b78a4a8 of 4 bytes by task 5259 on cpu 1:
perf_poll+0x36/0x200 kernel/events/core.c:6322
vfs_poll include/linux/poll.h:82 [inline]
io_file_supports_nowait io_uring/rw.c:48 [inline]
__io_read+0x30b/0xbd0 io_uring/rw.c:924
io_read+0x4a/0x1b0 io_uring/rw.c:1017
__io_issue_sqe+0xfd/0x2e0 io_uring/io_uring.c:1514
io_issue_sqe+0x1e7/0xd20 io_uring/io_uring.c:1537
io_queue_sqe io_uring/io_uring.c:1794 [inline]
io_req_task_submit+0x46/0xa0 io_uring/io_uring.c:1143
tctx_task_work_run+0x3cd/0x550 io_uring/tw.c:96
tctx_task_work+0x3f/0x60 io_uring/tw.c:133
task_work_run+0x145/0x1a0 kernel/task_work.c:233
get_signal+0xc12/0xd30 kernel/signal.c:2885
arch_do_signal_or_restart+0x96/0x480 arch/x86/kernel/signal.c:337
__exit_to_user_mode_loop kernel/entry/common.c:66 [inline]
exit_to_user_mode_loop+0x161/0x940 kernel/entry/common.c:101
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:230 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:343 [inline]
do_syscall_64+0x23b/0x3a0 arch/x86/entry/syscall_64.c:107
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 5259 Comm: syz.6.503 Not tainted syzkaller #0 PREEMPT(lazy)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================


---
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 syzk...@googlegroups.com.

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

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages