syzbot


KCSAN: data-race in folios_put_refs / need_mlock_drain

Status: moderation: reported on 2024/06/18 12:36
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+7f97e2bd338da740913e@syzkaller.appspotmail.com
First crash: 24d, last: 1d09h

Sample crash report:
EXT4-fs (loop3): unmounting filesystem 00000000-0000-0000-0000-000000000000.
==================================================================
BUG: KCSAN: data-race in folios_put_refs / need_mlock_drain

write to 0xffff888237c2b410 of 1 bytes by task 6006 on cpu 0:
 folio_batch_reinit include/linux/pagevec.h:50 [inline]
 folios_put_refs+0x266/0x2b0 mm/swap.c:1018
 folios_put include/linux/mm.h:1572 [inline]
 mlock_folio_batch+0x31af/0x31e0 mm/mlock.c:209
 mlock_folio+0x1b7/0x210 mm/mlock.c:259
 mlock_vma_folio mm/internal.h:862 [inline]
 __folio_add_file_rmap mm/rmap.c:1452 [inline]
 folio_add_file_rmap_ptes+0x1a6/0x1b0 mm/rmap.c:1469
 set_pte_range+0x201/0x430 mm/memory.c:4705
 filemap_map_order0_folio mm/filemap.c:3594 [inline]
 filemap_map_pages+0x643/0x9f0 mm/filemap.c:3644
 do_fault_around mm/memory.c:4879 [inline]
 do_read_fault mm/memory.c:4912 [inline]
 do_fault mm/memory.c:5051 [inline]
 do_pte_missing mm/memory.c:3897 [inline]
 handle_pte_fault mm/memory.c:5381 [inline]
 __handle_mm_fault mm/memory.c:5524 [inline]
 handle_mm_fault+0x1141/0x2ac0 mm/memory.c:5689
 faultin_page mm/gup.c:1305 [inline]
 __get_user_pages+0x499/0x10d0 mm/gup.c:1604
 populate_vma_page_range mm/gup.c:2043 [inline]
 __mm_populate+0x25b/0x3b0 mm/gup.c:2146
 mm_populate include/linux/mm.h:3469 [inline]
 __do_sys_mlockall mm/mlock.c:777 [inline]
 __se_sys_mlockall+0x2c5/0x370 mm/mlock.c:753
 __x64_sys_mlockall+0x1f/0x30 mm/mlock.c:753
 x64_sys_call+0x2a79/0x2d70 arch/x86/include/generated/asm/syscalls_64.h:152
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xc9/0x1c0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff888237c2b410 of 1 bytes by task 5312 on cpu 1:
 folio_batch_count include/linux/pagevec.h:56 [inline]
 need_mlock_drain+0x30/0x50 mm/mlock.c:235
 cpu_needs_drain mm/swap.c:806 [inline]
 __lru_add_drain_all+0x235/0x410 mm/swap.c:894
 lru_add_drain_all+0x10/0x20 mm/swap.c:910
 invalidate_bdev+0x47/0x70 block/bdev.c:100
 ext4_put_super+0x51b/0x7e0 fs/ext4/super.c:1345
 generic_shutdown_super+0xde/0x210 fs/super.c:642
 kill_block_super+0x2a/0x70 fs/super.c:1685
 ext4_kill_sb+0x44/0x80 fs/ext4/super.c:7301
 deactivate_locked_super+0x7d/0x1c0 fs/super.c:473
 deactivate_super+0x9f/0xb0 fs/super.c:506
 cleanup_mnt+0x268/0x2e0 fs/namespace.c:1267
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1274
 task_work_run+0x13a/0x1a0 kernel/task_work.c:180
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0xbe/0x130 kernel/entry/common.c:218
 do_syscall_64+0xd6/0x1c0 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

value changed: 0x1f -> 0x01

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 PID: 5312 Comm: syz-executor Not tainted 6.10.0-rc7-syzkaller-00139-g8a18fda0febb #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/12 01:34 upstream 8a18fda0febb eaeb5c15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in folios_put_refs / need_mlock_drain
2024/06/23 01:46 upstream 563a50672d8a edc5149a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in folios_put_refs / need_mlock_drain
2024/06/20 17:45 upstream e5b3efbe1ab1 dac2aa43 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in folios_put_refs / need_mlock_drain
2024/06/18 12:35 upstream 14d7c92f8df9 639d6cdf .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in folios_put_refs / need_mlock_drain
* Struck through repros no longer work on HEAD.