On 18.09.23 05:57, syzbot wrote:
Hello,
syzbot found the following issue on:
HEAD commit: 98897dc735cf Add linux-next specific files for 20230914
git tree: linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1214a152680000
kernel config: https://syzkaller.appspot.com/x/.config?x=1502c503717ada5c
dashboard link: https://syzkaller.appspot.com/bug?extid=6e4f59235036c3c2e296
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15869ea0680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15f1b952680000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/00e4c0af5a8a/disk-98897dc7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/7b54a00eee56/vmlinux-98897dc7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/100094353b8e/bzImage-98897dc7.xz
The issue was bisected to:
commit b8575fa4abaa1dee1a61f1f27a86a02757310a7e
Author: David Hildenbrand <david@xxxxxxxxxx>
Date: Wed Sep 13 12:51:12 2023 +0000
mm/rmap: simplify PageAnonExclusive sanity checks when adding anon rmap
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=140e9ea0680000
final oops: https://syzkaller.appspot.com/x/report.txt?x=160e9ea0680000
console output: https://syzkaller.appspot.com/x/log.txt?x=120e9ea0680000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6e4f59235036c3c2e296@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: b8575fa4abaa ("mm/rmap: simplify PageAnonExclusive sanity checks when adding anon rmap")
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1138 [inline]
free_unref_page+0x554/0xd70 mm/page_alloc.c:2460
free_contig_range+0xb6/0x190 mm/page_alloc.c:6396
destroy_args+0x768/0x990 mm/debug_vm_pgtable.c:1028
debug_vm_pgtable+0x1d79/0x3df0 mm/debug_vm_pgtable.c:1408
do_one_initcall+0x117/0x630 init/main.c:1232
do_initcall_level init/main.c:1294 [inline]
do_initcalls init/main.c:1310 [inline]
do_basic_setup init/main.c:1329 [inline]
kernel_init_freeable+0x5c2/0x8f0 init/main.c:1547
kernel_init+0x1c/0x2a0 init/main.c:1437
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
------------[ cut here ]------------
WARNING: CPU: 0 PID: 5039 at mm/rmap.c:1252 page_add_anon_rmap+0xc33/0x1a70 mm/rmap.c:1252
Modules linked in:
CPU: 0 PID: 5039 Comm: syz-executor266 Not tainted 6.6.0-rc1-next-20230914-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
RIP: 0010:page_add_anon_rmap+0xc33/0x1a70 mm/rmap.c:1252
Code: 48 c1 eb 11 83 e3 01 89 de e8 79 d4 b8 ff 84 db 0f 84 36 fb ff ff e8 3c d9 b8 ff 48 c7 c6 80 83 99 8a 4c 89 e7 e8 dd 02 f7 ff <0f> 0b e9 1b fb ff ff e8 21 d9 b8 ff 49 89 dd 31 ff 41 81 e5 ff 0f
RSP: 0018:ffffc90003ccf900 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
RDX: ffff88801c4a5940 RSI: ffffffff81cf16a3 RDI: 0000000000000000
RBP: ffff888072c4fb00 R08: 0000000000000000 R09: fffffbfff1d9c7b2
R10: ffffffff8ece3d97 R11: 0000000000000001 R12: ffffea0001c88000
R13: 00fff800000a0078 R14: 0000000000000000 R15: ffffea0001cc4d88
FS: 0000555555943380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020123008 CR3: 000000001c4d7000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__split_huge_pmd_locked mm/huge_memory.c:2276 [inline]
__split_huge_pmd+0x17d5/0x31e0 mm/huge_memory.c:2320
split_huge_pmd_address mm/huge_memory.c:2336 [inline]
split_huge_pmd_if_needed mm/huge_memory.c:2348 [inline]
split_huge_pmd_if_needed mm/huge_memory.c:2339 [inline]
vma_adjust_trans_huge+0x2da/0x560 mm/huge_memory.c:2360
__split_vma+0xba3/0x1070 mm/mmap.c:2376
split_vma+0xc8/0x110 mm/mmap.c:2412
mlock_fixup+0x9b7/0x1290 mm/mlock.c:438
apply_vma_lock_flags+0x250/0x370 mm/mlock.c:514
do_mlock+0x263/0x820 mm/mlock.c:610
__do_sys_mlock mm/mlock.c:624 [inline]
__se_sys_mlock mm/mlock.c:622 [inline]
__x64_sys_mlock+0x59/0x80 mm/mlock.c:622
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f23893c4329
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 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:00007ffc63bf5018 EFLAGS: 00000246 ORIG_RAX: 0000000000000095
RAX: ffffffffffffffda RBX: 00007ffc63bf51f8 RCX: 00007f23893c4329
RDX: 00007f23893c4329 RSI: 0000000000001000 RDI: 00000000202cf000
RBP: 00007f2389437610 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000023a R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffc63bf51e8 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@xxxxxxxxxxxxxxxx.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
If the bug is already fixed, 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.
From 4b945ca15817b491123cc922f022b253134075b7 Mon Sep 17 00:00:00 2001
From: David Hildenbrand <david@xxxxxxxxxx>
Date: Mon, 18 Sep 2023 11:16:57 +0200
Subject: [PATCH] fixup: mm/rmap: simplify PageAnonExclusive sanity checks when
adding anon rmap
While PTE-mapping a THP, we temporarily have an exclusive page of a THP
mapped by both, a PMD and a PTE at the same time. Update our check to
allow for that combination.
Reported-by: syzbot+6e4f59235036c3c2e296@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
---
mm/rmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 789a2beb8b3a..f13a2927163d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1249,8 +1249,10 @@ void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma,
}
if (flags & RMAP_EXCLUSIVE)
SetPageAnonExclusive(page);
- VM_WARN_ON_FOLIO(page_mapcount(page) > 1 && PageAnonExclusive(page),
- folio);
+ /* While PTE-mapping a THP we have a PMD and a PTE mapping. */
+ VM_WARN_ON_FOLIO((atomic_read(&page->_mapcount) > 0 ||
+ (folio_test_large(folio) && folio_entire_mapcount(folio) > 1)) &&
+ PageAnonExclusive(page), folio);
mlock_vma_folio(folio, vma, compound);
}
--
2.41.0
--
Cheers,
David / dhildenb