Re: [syzbot] [mm?] KCSAN: data-race in try_to_migrate_one / vms_clear_ptes (2)

From: Lorenzo Stoakes
Date: Wed Mar 26 2025 - 10:00:02 EST


On Tue, Mar 25, 2025 at 04:15:24PM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 3ba7dfb8da62 Merge tag 'rcu-next-v6.15' of git://git.kerne..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=14254198580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=79f1cf4142160c34
> dashboard link: https://syzkaller.appspot.com/bug?extid=93107467480b9f9ed726
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/dd40b872cca9/disk-3ba7dfb8.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/86a3a241fb7d/vmlinux-3ba7dfb8.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/1ce46917915c/bzImage-3ba7dfb8.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+93107467480b9f9ed726@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> ==================================================================
> BUG: KCSAN: data-race in try_to_migrate_one / vms_clear_ptes
>

This is another classic rmap lock vs. mmap/vma lock scenario, but it seems
pretty benign.

try_to_migrate_one() is under rmap lock, vms_clear_ptes() under mmap/vma.

It's an unfortunate race, but we'd probably prefer not to slow down this
code. We might want to tag it data_race() though?

> write to 0xffff88810005d8f8 of 8 bytes by task 8860 on cpu 1:
> update_hiwater_rss include/linux/mm.h:2675 [inline]

This is:

static inline void update_hiwater_rss(struct mm_struct *mm)
{
unsigned long _rss = get_mm_rss(mm);

if ((mm)->hiwater_rss < _rss)
(mm)->hiwater_rss = _rss; <---- here.
}

> vms_clear_ptes+0x1a2/0x300 mm/vma.c:1136
> vms_complete_munmap_vmas+0x17b/0x480 mm/vma.c:1186
> do_vmi_align_munmap+0x344/0x390 mm/vma.c:1445
> do_vmi_munmap+0x1eb/0x230 mm/vma.c:1493
> __vm_munmap+0x19a/0x280 mm/vma.c:2956
> __do_sys_munmap mm/mmap.c:1084 [inline]
> __se_sys_munmap mm/mmap.c:1081 [inline]
> __x64_sys_munmap+0x36/0x40 mm/mmap.c:1081
> x64_sys_call+0xe1b/0x2e10 arch/x86/include/generated/asm/syscalls_64.h:12
> 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 0xffff88810005d8f8 of 8 bytes by task 8858 on cpu 0:
> update_hiwater_rss include/linux/mm.h:2674 [inline]
> try_to_migrate_one+0x775/0x12e0 mm/rmap.c:2183
> rmap_walk_anon+0x28f/0x440 mm/rmap.c:2646
> try_to_migrate+0x11f/0x150
> migrate_folio_unmap mm/migrate.c:1318 [inline]
> migrate_pages_batch+0x786/0x1930 mm/migrate.c:1864
> migrate_pages_sync mm/migrate.c:1987 [inline]
> migrate_pages+0xf02/0x1840 mm/migrate.c:2096
> do_mbind mm/mempolicy.c:1425 [inline]
> kernel_mbind mm/mempolicy.c:1568 [inline]
> __do_sys_mbind mm/mempolicy.c:1642 [inline]
> __se_sys_mbind+0xfd1/0x11c0 mm/mempolicy.c:1638
> __x64_sys_mbind+0x78/0x90 mm/mempolicy.c:1638
> x64_sys_call+0x13be/0x2e10 arch/x86/include/generated/asm/syscalls_64.h:238
> 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
>
> value changed: 0x0000000000001f8f -> 0x000000000000262f
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 0 UID: 0 PID: 8858 Comm: syz.2.1483 Tainted: G W 6.14.0-syzkaller-00685-g3ba7dfb8da62 #0
> Tainted: [W]=WARN
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
> ==================================================================
>
>
> ---
> 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.
>
> 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