linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] [mm?] kernel BUG in zap_huge_pmd
@ 2024-10-29  3:31 syzbot
  2024-10-29 11:44 ` Kirill A. Shutemov
  2024-10-29 12:09 ` Lorenzo Stoakes
  0 siblings, 2 replies; 7+ messages in thread
From: syzbot @ 2024-10-29  3:31 UTC (permalink / raw)
  To: akpm, linux-kernel, linux-mm, syzkaller-bugs

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@syzkaller.appspotmail.com

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
Code: fe ff ff f3 0f 1e fa e8 ab 16 92 ff 48 89 df 4c 89 fe e8 50 ba 08 00 e9 2c f8 ff ff e8 96 16 92 ff 90 0f 0b e8 8e 16 92 ff 90 <0f> 0b e8 86 16 92 ff 4c 89 ef 48 c7 c6 20 65 17 8c e8 37 a2 dd ff
RSP: 0018:ffffc9000aeef1e0 EFLAGS: 00010293
RAX: ffffffff8202c152 RBX: 000000000000001e RCX: ffff888000b70000
RDX: 0000000000000000 RSI: 000000000000001f RDI: 000000000000001a
RBP: 000000000000001f R08: ffffffff8202bca6 R09: 1ffff11008416106
R10: dffffc0000000000 R11: ffffed1008416107 R12: 0000000000000000
R13: ffffc9000aeef750 R14: 0000000020e00000 R15: fffffffffffffa00
FS:  000055555711b380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055e22940b470 CR3: 000000003daee000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 zap_pmd_range mm/memory.c:1719 [inline]
 zap_pud_range mm/memory.c:1768 [inline]
 zap_p4d_range mm/memory.c:1789 [inline]
 unmap_page_range+0x762/0x40e0 mm/memory.c:1810
 unmap_vmas+0x3cc/0x5f0 mm/memory.c:1900
 unmap_region+0x214/0x380 mm/vma.c:354
 mmap_region+0x23fa/0x2a30 mm/mmap.c:1583
 do_mmap+0x8f0/0x1000 mm/mmap.c:496
 vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:588
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f33ed6f19e9
Code: 48 83 c4 28 c3 e8 c7 1b 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:00007ffc77c44b78 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007ffc77c44be0 RCX: 00007f33ed6f19e9
RDX: 0000000002000007 RSI: 0000000000c00000 RDI: 0000000020400000
RBP: 0000000000000001 R08: 00000000ffffffff R09: 0000000000000000
R10: 000000000401d031 R11: 0000000000000246 R12: 0000000000000004
R13: 00007f33ed7673fc R14: 00007f33ed737334 R15: 00007f33ed7673e4
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:zap_huge_pmd+0x953/0xc40 mm/huge_memory.c:2085
Code: fe ff ff f3 0f 1e fa e8 ab 16 92 ff 48 89 df 4c 89 fe e8 50 ba 08 00 e9 2c f8 ff ff e8 96 16 92 ff 90 0f 0b e8 8e 16 92 ff 90 <0f> 0b e8 86 16 92 ff 4c 89 ef 48 c7 c6 20 65 17 8c e8 37 a2 dd ff
RSP: 0018:ffffc9000aeef1e0 EFLAGS: 00010293
RAX: ffffffff8202c152 RBX: 000000000000001e RCX: ffff888000b70000
RDX: 0000000000000000 RSI: 000000000000001f RDI: 000000000000001a
RBP: 000000000000001f R08: ffffffff8202bca6 R09: 1ffff11008416106
R10: dffffc0000000000 R11: ffffed1008416107 R12: 0000000000000000
R13: ffffc9000aeef750 R14: 0000000020e00000 R15: fffffffffffffa00
FS:  000055555711b380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055e22940b470 CR3: 000000003daee000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] kernel BUG in zap_huge_pmd
  2024-10-29  3:31 [syzbot] [mm?] kernel BUG in zap_huge_pmd syzbot
@ 2024-10-29 11:44 ` Kirill A. Shutemov
  2024-10-29 12:07   ` Lorenzo Stoakes
  2024-10-29 12:09 ` Lorenzo Stoakes
  1 sibling, 1 reply; 7+ messages in thread
From: Kirill A. Shutemov @ 2024-10-29 11:44 UTC (permalink / raw)
  To: Liam R. Howlett, Lorenzo Stoakes, Vlastimil Babka, Jann Horn
  Cc: syzbot, akpm, linux-kernel, linux-mm, syzkaller-bugs

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@syzkaller.appspotmail.com
> 
> 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] kernel BUG in zap_huge_pmd
  2024-10-29 11:44 ` Kirill A. Shutemov
@ 2024-10-29 12:07   ` Lorenzo Stoakes
  2024-10-29 12:58     ` Kirill A. Shutemov
  0 siblings, 1 reply; 7+ messages in thread
From: Lorenzo Stoakes @ 2024-10-29 12:07 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Liam R. Howlett, Vlastimil Babka, Jann Horn, syzbot, akpm,
	linux-kernel, linux-mm, syzkaller-bugs

On Tue, Oct 29, 2024 at 01:44:47PM +0200, Kirill A. Shutemov wrote:
> 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@syzkaller.appspotmail.com
> >
> > 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?

We just changed around how this stuff aborts in a hotfix series that should
avoid this, actually.

Unfortunately I don't have the netlink setup syzbot has locally so not sure
how reliably i can repro.

I guess I'll try to tell the bot to try a commit that should work (one that
I'm about to respin, unfortunate timing here...)

>
> --
>   Kiryl Shutsemau / Kirill A. Shutemov


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] kernel BUG in zap_huge_pmd
  2024-10-29  3:31 [syzbot] [mm?] kernel BUG in zap_huge_pmd syzbot
  2024-10-29 11:44 ` Kirill A. Shutemov
@ 2024-10-29 12:09 ` Lorenzo Stoakes
  2024-10-29 12:31   ` syzbot
  1 sibling, 1 reply; 7+ messages in thread
From: Lorenzo Stoakes @ 2024-10-29 12:09 UTC (permalink / raw)
  To: syzbot; +Cc: akpm, linux-kernel, linux-mm, syzkaller-bugs

On Mon, Oct 28, 2024 at 08:31:20PM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:

Thanks!

>
> 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@syzkaller.appspotmail.com
>
> 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
> Code: fe ff ff f3 0f 1e fa e8 ab 16 92 ff 48 89 df 4c 89 fe e8 50 ba 08 00 e9 2c f8 ff ff e8 96 16 92 ff 90 0f 0b e8 8e 16 92 ff 90 <0f> 0b e8 86 16 92 ff 4c 89 ef 48 c7 c6 20 65 17 8c e8 37 a2 dd ff
> RSP: 0018:ffffc9000aeef1e0 EFLAGS: 00010293
> RAX: ffffffff8202c152 RBX: 000000000000001e RCX: ffff888000b70000
> RDX: 0000000000000000 RSI: 000000000000001f RDI: 000000000000001a
> RBP: 000000000000001f R08: ffffffff8202bca6 R09: 1ffff11008416106
> R10: dffffc0000000000 R11: ffffed1008416107 R12: 0000000000000000
> R13: ffffc9000aeef750 R14: 0000000020e00000 R15: fffffffffffffa00
> FS:  000055555711b380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000055e22940b470 CR3: 000000003daee000 CR4: 0000000000352ef0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  <TASK>
>  zap_pmd_range mm/memory.c:1719 [inline]
>  zap_pud_range mm/memory.c:1768 [inline]
>  zap_p4d_range mm/memory.c:1789 [inline]
>  unmap_page_range+0x762/0x40e0 mm/memory.c:1810
>  unmap_vmas+0x3cc/0x5f0 mm/memory.c:1900
>  unmap_region+0x214/0x380 mm/vma.c:354
>  mmap_region+0x23fa/0x2a30 mm/mmap.c:1583
>  do_mmap+0x8f0/0x1000 mm/mmap.c:496
>  vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:588
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7f33ed6f19e9
> Code: 48 83 c4 28 c3 e8 c7 1b 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:00007ffc77c44b78 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
> RAX: ffffffffffffffda RBX: 00007ffc77c44be0 RCX: 00007f33ed6f19e9
> RDX: 0000000002000007 RSI: 0000000000c00000 RDI: 0000000020400000
> RBP: 0000000000000001 R08: 00000000ffffffff R09: 0000000000000000
> R10: 000000000401d031 R11: 0000000000000246 R12: 0000000000000004
> R13: 00007f33ed7673fc R14: 00007f33ed737334 R15: 00007f33ed7673e4
>  </TASK>
> Modules linked in:
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:zap_huge_pmd+0x953/0xc40 mm/huge_memory.c:2085
> Code: fe ff ff f3 0f 1e fa e8 ab 16 92 ff 48 89 df 4c 89 fe e8 50 ba 08 00 e9 2c f8 ff ff e8 96 16 92 ff 90 0f 0b e8 8e 16 92 ff 90 <0f> 0b e8 86 16 92 ff 4c 89 ef 48 c7 c6 20 65 17 8c e8 37 a2 dd ff
> RSP: 0018:ffffc9000aeef1e0 EFLAGS: 00010293
> RAX: ffffffff8202c152 RBX: 000000000000001e RCX: ffff888000b70000
> RDX: 0000000000000000 RSI: 000000000000001f RDI: 000000000000001a
> RBP: 000000000000001f R08: ffffffff8202bca6 R09: 1ffff11008416106
> R10: dffffc0000000000 R11: ffffed1008416107 R12: 0000000000000000
> R13: ffffc9000aeef750 R14: 0000000020e00000 R15: fffffffffffffa00
> FS:  000055555711b380(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000055e22940b470 CR3: 000000003daee000 CR4: 0000000000352ef0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>
>
> ---
> 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

This should be resolved with recent changes to rework mmap_region(), let's see...

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] kernel BUG in zap_huge_pmd
  2024-10-29 12:09 ` Lorenzo Stoakes
@ 2024-10-29 12:31   ` syzbot
  0 siblings, 0 replies; 7+ messages in thread
From: syzbot @ 2024-10-29 12:31 UTC (permalink / raw)
  To: akpm, linux-kernel, linux-mm, lorenzo.stoakes, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+4b5c704012892c4d22fd@syzkaller.appspotmail.com
Tested-by: syzbot+4b5c704012892c4d22fd@syzkaller.appspotmail.com

Tested on:

commit:         b70a32bb mm/thp: fix deferred split unqueue naming and..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/ mm-hotfixes-unstable
console output: https://syzkaller.appspot.com/x/log.txt?x=155e4a30580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=35698c25466f388c
dashboard link: https://syzkaller.appspot.com/bug?extid=4b5c704012892c4d22fd
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] kernel BUG in zap_huge_pmd
  2024-10-29 12:07   ` Lorenzo Stoakes
@ 2024-10-29 12:58     ` Kirill A. Shutemov
  2024-10-29 13:08       ` Lorenzo Stoakes
  0 siblings, 1 reply; 7+ messages in thread
From: Kirill A. Shutemov @ 2024-10-29 12:58 UTC (permalink / raw)
  To: Lorenzo Stoakes
  Cc: Liam R. Howlett, Vlastimil Babka, Jann Horn, syzbot, akpm,
	linux-kernel, linux-mm, syzkaller-bugs

On Tue, Oct 29, 2024 at 12:07:00PM +0000, Lorenzo Stoakes wrote:
> On Tue, Oct 29, 2024 at 01:44:47PM +0200, Kirill A. Shutemov wrote:
> > 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@syzkaller.appspotmail.com
> > >
> > > 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?
> 
> We just changed around how this stuff aborts in a hotfix series that should
> avoid this, actually.
> 
> Unfortunately I don't have the netlink setup syzbot has locally so not sure
> how reliably i can repro.

Build the config in the report and run it under KVM (virtme?).


-- 
  Kiryl Shutsemau / Kirill A. Shutemov


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [syzbot] [mm?] kernel BUG in zap_huge_pmd
  2024-10-29 12:58     ` Kirill A. Shutemov
@ 2024-10-29 13:08       ` Lorenzo Stoakes
  0 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes @ 2024-10-29 13:08 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Liam R. Howlett, Vlastimil Babka, Jann Horn, syzbot, akpm,
	linux-kernel, linux-mm, syzkaller-bugs

On Tue, Oct 29, 2024 at 02:58:02PM +0200, Kirill A. Shutemov wrote:
> On Tue, Oct 29, 2024 at 12:07:00PM +0000, Lorenzo Stoakes wrote:
> > On Tue, Oct 29, 2024 at 01:44:47PM +0200, Kirill A. Shutemov wrote:
> > > 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@syzkaller.appspotmail.com
> > > >
> > > > 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?
> >
> > We just changed around how this stuff aborts in a hotfix series that should
> > avoid this, actually.
> >
> > Unfortunately I don't have the netlink setup syzbot has locally so not sure
> > how reliably i can repro.
>
> Build the config in the report and run it under KVM (virtme?).

No need, syzbot tried the branch with the pending hotfixes and it passes [0]

[0]:https://lore.kernel.org/linux-mm/6720d587.050a0220.4735a.025e.GAE@google.com/

>
>
> --
>   Kiryl Shutsemau / Kirill A. Shutemov


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-29 13:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-29  3:31 [syzbot] [mm?] kernel BUG in zap_huge_pmd syzbot
2024-10-29 11:44 ` Kirill A. Shutemov
2024-10-29 12:07   ` Lorenzo Stoakes
2024-10-29 12:58     ` Kirill A. Shutemov
2024-10-29 13:08       ` Lorenzo Stoakes
2024-10-29 12:09 ` Lorenzo Stoakes
2024-10-29 12:31   ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox