Re: [syzbot] [mm?] WARNING in try_to_migrate_one (3)

Lorenzo Stoakes
2025-08-11T05:12:16Z

On Sat, Aug 09, 2025 at 01:36:38PM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 0227b49b5027 Merge tag 'gpio-updates-for-v6.17-rc1-part2' ..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=1422d434580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=2ae1da3a7f4a6ba4
> dashboard link: https://syzkaller.appspot.com/bug?extid=63859a31071a369082b1
> compiler: Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=117c72f0580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17ab7ea2580000

This seems to be racey so as is often the case the repro doesn't repro for me...

Upstream hasn't yet got [0] which is is very likely the cause of this.

[0]:https://lore.kernel.org/all/20250806145611.3962-1-dev.jain@arm.com/

Let's have syzbot test it:

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-hotfixes-unstable

>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/d0d0622733f6/disk-0227b49b.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/6a993871f113/vmlinux-0227b49b.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/0f07823c6782/bzImage-0227b49b.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+63859a31071a369082b1@syzkaller.appspotmail.com
>
> do_initcall_level+0x104/0x190 init/main.c:1331
> do_initcalls+0x59/0xa0 init/main.c:1347
> kernel_init_freeable+0x334/0x4b0 init/main.c:1579
> kernel_init+0x1d/0x1d0 init/main.c:1469
> ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 5866 at mm/rmap.c:2452 try_to_migrate_one+0xf27/0x34d0 mm/rmap.c:2451

Presumably:

VM_WARN_ON_FOLIO(writable && folio_test_anon(folio) &&
!anon_exclusive, folio);

Likely the anon exclusive flag has not been propagated correctly because of
the bug in commit cac1db8c3aad (" mm: optimize mprotect() by PTE
batching"), which means if the PTE range doesn't include the 0th page of
the folio we accidentily consider it and pages offset by it in
page_anon_exclusive_sub_batch(), which really does point to this being the bug.

This is fixed by [0].

> Modules linked in:
> CPU: 0 UID: 0 PID: 5866 Comm: syz-executor265 Not tainted 6.16.0-syzkaller-12187-g0227b49b5027 #0 PREEMPT(full)
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
> RIP: 0010:try_to_migrate_one+0xf27/0x34d0 mm/rmap.c:2451
> Code: fb 00 00 00 f4 0f 84 35 0e 00 00 e8 f3 41 ae ff e9 73 f8 ff ff e8 e9 41 ae ff 4c 89 e7 48 c7 c6 00 79 96 8b e8 0a 92 16 ff 90 <0f> 0b 90 e9 60 ff ff ff e8 cc 41 ae ff 49 ff cf e9 3e fb ff ff e8
> RSP: 0000:ffffc9000401f120 EFLAGS: 00010246
> RAX: c3d51769d0dbd500 RBX: 0400000000000000 RCX: c3d51769d0dbd500
> RDX: 0000000000000003 RSI: ffffffff8dba5e25 RDI: ffff8880115dda00
> RBP: ffffc9000401f370 R08: ffff8880b8624253 R09: 1ffff110170c484a
> R10: dffffc0000000000 R11: ffffed10170c484b R12: ffffea0001cd8000
> R13: 0000000073603867 R14: dffffc0000000000 R15: ffffea0001cd8018
> FS: 0000555590a54380(0000) GS:ffff888125c1c000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000000045ad50 CR3: 00000000743ea000 CR4: 00000000003526f0
> Call Trace:
> <TASK>
> rmap_walk_anon+0x550/0x730 mm/rmap.c:2842
> rmap_walk_locked mm/rmap.c:2958 [inline]
> try_to_migrate+0x3f5/0x670 mm/rmap.c:2619
> unmap_folio+0x191/0x1f0 mm/huge_memory.c:3137
> __folio_split+0x90d/0x1c60 mm/huge_memory.c:3711
> try_split_folio+0x13f/0x310 mm/migrate.c:1550
> migrate_pages_batch+0x653/0x3620 mm/migrate.c:1819
> migrate_pages_sync mm/migrate.c:1974 [inline]
> migrate_pages+0x1bcc/0x2930 mm/migrate.c:2083
> do_mbind mm/mempolicy.c:1539 [inline]
> kernel_mbind mm/mempolicy.c:1682 [inline]
> __do_sys_mbind mm/mempolicy.c:1756 [inline]
> __se_sys_mbind+0xa3e/0xc30 mm/mempolicy.c:1752
> do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7fb95004e539
> Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
> RSP: 002b:00007fffa7b144d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ed
> RAX: ffffffffffffffda RBX: 0000200000000000 RCX: 00007fb95004e539
> RDX: 0000000000000001 RSI: 0000000000600000 RDI: 0000200000000000
> RBP: 00007fb9500c15f0 R08: 0000000000000000 R09: 0000000000000002
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
> R13: 431bde82d7b634db R14: 0000000000000001 R15: 0000000000000001
> </TASK>
>
>
> ---
> 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@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 syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
>
> 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