On Mon, Oct 28, 2024 at 08:31:20PM -0700, syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit: 4e46774408d9 Merge tag 'for-6.12-rc4-tag' of git://git.ker.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=10fb2ebb980000 > kernel config: https://syzkaller.appspot.com/x/.config?x=fc6f8ce8c5369043 > dashboard link: https://syzkaller.appspot.com/bug?extid=4b5c704012892c4d22fd > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11f730e7980000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=177eae40580000 > > Downloadable assets: > disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-4e467744.raw.xz > vmlinux: https://storage.googleapis.com/syzbot-assets/058a92aaf61a/vmlinux-4e467744.xz > kernel image: https://storage.googleapis.com/syzbot-assets/0b79757fbe5e/bzImage-4e467744.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+4b5c704012892c4d22fd@xxxxxxxxxxxxxxxxxxxxxxxxx > > R10: 000000000401d031 R11: 0000000000000246 R12: 0000000000000004 > R13: 00007f33ed7673fc R14: 00007f33ed737334 R15: 00007f33ed7673e4 > </TASK> > ------------[ cut here ]------------ > kernel BUG at mm/huge_memory.c:2085! > Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI > CPU: 0 UID: 0 PID: 5095 Comm: syz-executor380 Not tainted 6.12.0-rc4-syzkaller-00085-g4e46774408d9 #0 > Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 > RIP: 0010:zap_huge_pmd+0x953/0xc40 mm/huge_memory.c:2085 I believe it is bug in mmap_region() around handling vms_gather_munmap_vmas() and vms_complete_munmap_vmas(). What reproduces does is: 1. Creating hugetlb mapping 2. Setting up UFFD on it 3. Creating a new that partially overlaps with mapping created on step 1 On step 3 an error is injected which makes vma_iter_prealloc() fail and unmap_region() is called in error path. The unmap_region() is called with the newly created as an argument, but page tables still contain entries from hugetlb mapping that was never fully unmapped because vms_complete_munmap_vmas() has not called yet. Since the new VMA is not hugetlb, unmapping code takes THP codepath and calls zap_huge_pmd(). zap_huge_pmd() sees PTE marker swap entry installed by hugetlb_mfill_atomic_pte() and gets confused. I don't understand vms_gather/complete_munmap_vmas() code well enough. I am not sure what the right fix would be. Maybe call vms_complete_munmap_vmas() earlier? -- Kiryl Shutsemau / Kirill A. Shutemov