KCSAN: data-race in __trace_trigger_soft_disabled / apply_subsystem_event_filter
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: d0f871bfb831 Merge tag 'arm64-fixes' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=12708a03580000 kernel config: https://syzkaller.appspot.com/x/.config?x=886d2ddd2d6b664e dashboard link: https://syzkaller.appspot.com/bug?extid=1faa12be48036b80e416 compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/018edb90159d/disk-d0f871bf.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b27112368dea/vmlinux-d0f871bf.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1f2c7b502c76/bzImage-d0f871bf.xz
AI-generated root cause summary:filter_disable() (and its counterpart event_set_filtered_flag()) in kernel/trace/trace_events_filter.c updates struct trace_event_file::flags using non-atomic read-modify-write operations (file->flags &= ~EVENT_FILE_FL_FILTERED) instead of atomic bit operations (test_and_clear_bit()/test_and_set_bit()). Meanwhile, tracepoint handlers such as trace_trigger_soft_disabled() and __trace_trigger_soft_disabled() read file->flags locklessly without READ_ONCE(). Writing a failing subsystem filter via subsystem_filter_write() triggers filter_disable() while sched_switch concurrently executes __trace_trigger_soft_disabled() on another CPU, causing a KCSAN data race on file->flags.
full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=1faa12be48036b80e416
IMPORTANT: if you fix the issue, please add the following tag to the commit:
==================================================================
BUG: KCSAN: data-race in __trace_trigger_soft_disabled / apply_subsystem_event_filter
write to 0xffff888100172888 of 8 bytes by task 5433 on cpu 0:
filter_disable kernel/trace/trace_events_filter.c:1325 [inline] process_system_preds kernel/trace/trace_events_filter.c:2331 [inline] create_system_filter kernel/trace/trace_events_filter.c:2486 [inline] apply_subsystem_event_filter+0x28f/0xcd0 kernel/trace/trace_events_filter.c:2574 subsystem_filter_write+0x79/0xd0 kernel/trace/trace_events.c:2523 vfs_write+0x24f/0x9b0 fs/read_write.c:665 ksys_write+0xdc/0x1a0 fs/read_write.c:719 __do_sys_write fs/read_write.c:730 [inline] __se_sys_write fs/read_write.c:727 [inline] __x64_sys_write+0x40/0x50 fs/read_write.c:727 x64_sys_call+0x154e/0x2550 arch/x86/include/generated/asm/syscalls_64.h:2 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89 entry_SYSCALL_64_after_hwframe+0x77/0x7f
read to 0xffff888100172888 of 8 bytes by task 5440 on cpu 1:
__trace_trigger_soft_disabled+0x20/0x1a0 kernel/trace/trace_events_trigger.c:217 trace_trigger_soft_disabled include/linux/trace_events.h:777 [inline] do_trace_event_raw_event_sched_switch include/trace/events/sched.h:220 [inline] trace_event_raw_event_sched_switch+0x186/0x1a0 include/trace/events/sched.h:220 __traceiter_sched_switch+0x3f/0x60 include/trace/events/sched.h:220 __do_trace_sched_switch include/trace/events/sched.h:220 [inline] trace_sched_switch include/trace/events/sched.h:220 [inline] __schedule+0xc3d/0xd30 kernel/sched/core.c:7383 preempt_schedule_common+0x12/0x40 kernel/sched/core.c:7565 preempt_schedule_thunk+0x16/0x40 arch/x86/entry/thunk.S:12 __raw_spin_unlock include/linux/spinlock_api_smp.h:201 [inline] _raw_spin_unlock+0x1e/0x30 kernel/locking/spinlock.c:213 spin_unlock include/linux/spinlock.h:401 [inline] zap_pte_range mm/memory.c:2076 [inline] zap_pmd_range mm/memory.c:2134 [inline] zap_pud_range mm/memory.c:2162 [inline] zap_p4d_range mm/memory.c:2183 [inline] __zap_vma_range+0x273e/0x2ed0 mm/memory.c:2223 unmap_vmas+0x216/0x310 mm/memory.c:2292 exit_mmap+0x1a2/0x650 mm/mmap.c:1315 __mmput+0x28/0x1f0 kernel/fork.c:1192 mmput+0x51/0x60 kernel/fork.c:1215 exit_mm+0x12d/0x1d0 kernel/exit.c:586 do_exit+0x44a/0x1530 kernel/exit.c:967 do_group_exit+0xfe/0x140 kernel/exit.c:1123 get_signal+0xc49/0xd30 kernel/signal.c:3113 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: 5440 Comm: syz.1.454 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 [email protected].
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
Masami Hiramatsu (Google)
maintainerQuoted 18 lines · syzbot
Hello,
syzbot found the following issue on:
HEAD commit: d0f871bfb831 Merge tag 'arm64-fixes' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=12708a03580000 kernel config: https://syzkaller.appspot.com/x/.config?x=886d2ddd2d6b664e dashboard link: https://syzkaller.appspot.com/bug?extid=1faa12be48036b80e416 compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/018edb90159d/disk-d0f871bf.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b27112368dea/vmlinux-d0f871bf.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1f2c7b502c76/bzImage-d0f871bf.xz
Quoted 11 lines
AI-generated root cause summary:
filter_disable()(and its counterpartevent_set_filtered_flag()) inkernel/trace/trace_events_filter.cupdatesstruct trace_event_file::flagsusing non-atomic read-modify-write operations (file->flags &= ~EVENT_FILE_FL_FILTERED) instead of atomic bit operations (test_and_clear_bit()/test_and_set_bit()). Meanwhile, tracepoint handlers such astrace_trigger_soft_disabled()and__trace_trigger_soft_disabled()readfile->flagslocklessly withoutREAD_ONCE(). Writing a failing subsystem filter viasubsystem_filter_write()triggersfilter_disable()whilesched_switchconcurrently executes__trace_trigger_soft_disabled()on another CPU, causing a KCSAN data race onfile->flags.
Hmm, this means we need to update all code which accessing file->flags. The point about using READ_ONCE() is correct, as the trigger must be able to operate in parallel without acquiring a lock.
Thanks,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>