kernel BUG in __vma_reservation_common
Subsystems (4)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 8953285d7bd6 rxrpc: Clients must accept conn from any addr.. git tree: net console output: https://syzkaller.appspot.com/x/log.txt?x=1347a228980000 kernel config: https://syzkaller.appspot.com/x/.config?x=98d5a8e00ed1044a dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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/5b9c540d7f6b/disk-8953285d.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/831b091085cc/vmlinux-8953285d.xz
kernel image: https://storage.googleapis.com/syzbot-assets/97a6dd56102c/bzImage-8953285d.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
</TASK> ------------[ cut here ]------------ kernel BUG at mm/hugetlb.c:813! invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 1 PID: 9895 Comm: syz-executor.3 Not tainted 6.9.0-rc5-syzkaller-00192-g8953285d7bd6 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024 RIP: 0010:region_abort mm/hugetlb.c:813 [inline] RIP: 0010:__vma_reservation_common+0x795/0x7d0 mm/hugetlb.c:2856 Code: f1 f2 89 09 e8 0c e6 9f ff 90 0f 0b e8 04 e6 9f ff 90 0f 0b e8 fc e5 9f ff 90 0f 0b e8 f4 e5 9f ff 90 0f 0b e8 ec e5 9f ff 90 <0f> 0b e8 e4 e5 9f ff 90 0f 0b e8 dc e5 9f ff 90 0f 0b e8 d4 e5 9f RSP: 0018:ffffc90009c17240 EFLAGS: 00010293 RAX: ffffffff81f61a14 RBX: 0000000000000000 RCX: ffff88806eaf1e00 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffc90009c17310 R08: ffffffff81f61526 R09: fffff52001382e38 R10: dffffc0000000000 R11: fffff52001382e38 R12: 0000000000000000 R13: dffffc0000000000 R14: ffff888064f61408 R15: ffff888064f61400 FS: 00007fba641616c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055558b067788 CR3: 00000000762e8000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> vma_add_reservation mm/hugetlb.c:2919 [inline] __unmap_hugepage_range+0x1257/0x2340 mm/hugetlb.c:5791 unmap_vmas+0x3cc/0x5f0 mm/memory.c:1883 unmap_region+0x1ec/0x350 mm/mmap.c:2310 do_vmi_align_munmap+0x11bf/0x1930 mm/mmap.c:2628 do_vmi_munmap+0x24e/0x2d0 mm/mmap.c:2696 mmap_region+0x6af/0x1e50 mm/mmap.c:2747 do_mmap+0x7af/0xe60 mm/mmap.c:1385 vm_mmap_pgoff+0x1e3/0x420 mm/util.c:573 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fba6347dea9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fba641610c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000009 RAX: ffffffffffffffda RBX: 00007fba635abf80 RCX: 00007fba6347dea9 RDX: 0000000000000000 RSI: 00000000001fffff RDI: 0000000020000000 RBP: 00007fba64161120 R08: ffffffffffffffff R09: 0000000000000000 R10: 0000000000028031 R11: 0000000000000246 R12: 0000000000000001 R13: 000000000000000b R14: 00007fba635abf80 R15: 00007ffc5b82e2c8 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:region_abort mm/hugetlb.c:813 [inline] RIP: 0010:__vma_reservation_common+0x795/0x7d0 mm/hugetlb.c:2856 Code: f1 f2 89 09 e8 0c e6 9f ff 90 0f 0b e8 04 e6 9f ff 90 0f 0b e8 fc e5 9f ff 90 0f 0b e8 f4 e5 9f ff 90 0f 0b e8 ec e5 9f ff 90 <0f> 0b e8 e4 e5 9f ff 90 0f 0b e8 dc e5 9f ff 90 0f 0b e8 d4 e5 9f RSP: 0018:ffffc90009c17240 EFLAGS: 00010293 RAX: ffffffff81f61a14 RBX: 0000000000000000 RCX: ffff88806eaf1e00 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffc90009c17310 R08: ffffffff81f61526 R09: fffff52001382e38 R10: dffffc0000000000 R11: fffff52001382e38 R12: 0000000000000000 R13: dffffc0000000000 R14: ffff888064f61408 R15: ffff888064f61400 FS: 00007fba641616c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055558b067788 CR3: 00000000762e8000 CR4: 00000000003506f0 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 [email protected].
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
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
RBP: 0000000000000001 R08: 00000000ffffffff R09: 0000000000000000
R10: 0000000000028031 R11: 0000000000000246 R12: 0000000000000001
R13: 431bde82d7b634db R14: 00007f64830b0035 R15: 0000000000000001
</TASK> ------------[ cut here ]------------ kernel BUG at mm/hugetlb.c:813! Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 0 PID: 5089 Comm: syz-executor179 Not tainted 6.9.0-syzkaller-12071-g66ad4829ddd0 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024 RIP: 0010:region_abort mm/hugetlb.c:813 [inline] RIP: 0010:__vma_reservation_common+0x795/0x7d0 mm/hugetlb.c:2835 Code: 21 65 8e 09 e8 8c a3 9e ff 90 0f 0b e8 84 a3 9e ff 90 0f 0b e8 7c a3 9e ff 90 0f 0b e8 74 a3 9e ff 90 0f 0b e8 6c a3 9e ff 90 <0f> 0b e8 64 a3 9e ff 90 0f 0b e8 5c a3 9e ff 90 0f 0b e8 54 a3 9e RSP: 0018:ffffc900035ff1c0 EFLAGS: 00010293 RAX: ffffffff81f77114 RBX: 0000000000000000 RCX: ffff88801ff90000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffc900035ff290 R08: ffffffff81f76c26 R09: fffff520006bfe28 R10: dffffc0000000000 R11: fffff520006bfe28 R12: 0000000000000000 R13: dffffc0000000000 R14: ffff88802ce84c08 R15: ffff88802ce84c00 FS: 00005555950a7380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6483099c40 CR3: 00000000746f4000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> vma_add_reservation mm/hugetlb.c:2898 [inline] __unmap_hugepage_range+0x125d/0x2350 mm/hugetlb.c:5772 unmap_vmas+0x3cc/0x5f0 mm/memory.c:1891 unmap_region+0x1ec/0x350 mm/mmap.c:2355 do_vmi_align_munmap+0x1122/0x18c0 mm/mmap.c:2673 do_vmi_munmap+0x24e/0x2d0 mm/mmap.c:2741 mmap_region+0x72f/0x2070 mm/mmap.c:2792 do_mmap+0x8ad/0xfa0 mm/mmap.c:1387 vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:573 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:0x7f6483066d39 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:00007fff7dc97c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000009 RAX: ffffffffffffffda RBX: 00007fff7dc97c80 RCX: 00007f6483066d39 RDX: 0000000000000000 RSI: 00000000001fffff RDI: 0000000020000000 RBP: 0000000000000001 R08: 00000000ffffffff R09: 0000000000000000 R10: 0000000000028031 R11: 0000000000000246 R12: 0000000000000001 R13: 431bde82d7b634db R14: 00007f64830b0035 R15: 0000000000000001 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:region_abort mm/hugetlb.c:813 [inline] RIP: 0010:__vma_reservation_common+0x795/0x7d0 mm/hugetlb.c:2835 Code: 21 65 8e 09 e8 8c a3 9e ff 90 0f 0b e8 84 a3 9e ff 90 0f 0b e8 7c a3 9e ff 90 0f 0b e8 74 a3 9e ff 90 0f 0b e8 6c a3 9e ff 90 <0f> 0b e8 64 a3 9e ff 90 0f 0b e8 5c a3 9e ff 90 0f 0b e8 54 a3 9e RSP: 0018:ffffc900035ff1c0 EFLAGS: 00010293 RAX: ffffffff81f77114 RBX: 0000000000000000 RCX: ffff88801ff90000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffc900035ff290 R08: ffffffff81f76c26 R09: fffff520006bfe28 R10: dffffc0000000000 R11: fffff520006bfe28 R12: 0000000000000000 R13: dffffc0000000000 R14: ffff88802ce84c08 R15: ffff88802ce84c00 FS: 00005555950a7380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6483099c40 CR3: 00000000746f4000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
---
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.
Oscar Salvador
maintainerQuoted 11 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Quoted 7 lines
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
Let us see if the attached patch fixes it.
Signature · 2 lines
Oscar Salvador SUSE Labs
From 917fa54481422c650425c8b0330439f8a3308479 Mon Sep 17 00:00:00 2001
From: Oscar Salvador <[email protected]>
Date: Tue, 28 May 2024 10:43:14 +0200
Subject: [PATCH] mm/hugetlb: Do not call vma_add_reservation upon ENOMEM
sysbot reported a splat [1] on __unmap_hugepage_range().
This is because vma_needs_reservation() can return -ENOMEM if allocate_file_region_entries() fails to allocate the file_region struct for the reservation.
Check for that and do not call vma_add_reservation() if that is the case, otherwise region_abort() and region_del() will see that we do not have any file_regions.
If we detect that vma_needs_reservation returned -ENOMEM, we clear the hugetlb_restore_reserve flag as if this reservation was still consumed, so free_huge_folio will not increment the resv count.
[1] https://lore.kernel.org/linux-mm/[email protected]/T/#ma5983bc1ab18a54910da83416b3f89f3c7ee43aa
--- mm/hugetlb.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
mm/hugetlb.c +14 -2
@@ -5768,8 +5768,20 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,* do_exit() will not see it, and will keep the reservation * forever. */ -if (adjust_reservation &&vma_needs_reservation (h, vma, address)) -vma_add_reservation (h, vma, address); +if (adjust_reservation) { + int rc = vma_needs_reservation(h, vma, address) + +if (rc <0 ) +/* Pressumably allocate_file_region_entries failed +* to allocate a file_region struct. Clear +* hugetlb_restore_reserve so that global reserve +* count will not be incremented by free_huge_folio. +* Act as if we consumed the reservation. +*/ +folio_clear_hugetlb_restore_reserve (folio); +else if (rc) +vma_add_reservation (h, vma, address); + }tlb_remove_page_size (tlb, page,huge_page_size (h));/*
Signature · 1 line
2.45.1
Quoted 11 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Quoted 7 lines
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
#syz test: git://github.com/leberus/linux.git hugetlb-vma_resv-enomem
Signature · 2 lines
Oscar Salvador SUSE Labs
syzbot
syzbotsyzbot tried to test the proposed patch but the build/boot failed:
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to checkout kernel repo git://github.com/leberus/linux.git/hugetlb-vma_resv-enomem: failed to run ["git" "fetch" "--force" "ce94c574238e17bd72d74b088bd1c16ce6447814" "hugetlb-vma_resv-enomem"]: exit status 128
fatal: unable to connect to github.com:
github.com[0: 140.82.112.3]: errno=Connection timed out
Tested on:
commit: [unknown git tree: git://github.com/leberus/linux.git hugetlb-vma_resv-enomem kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b
compiler:
Note: no patches were applied.
Quoted 11 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Quoted 7 lines
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
And let us have it here as well
Signature · 2 lines
Oscar Salvador SUSE Labs
From 917fa54481422c650425c8b0330439f8a3308479 Mon Sep 17 00:00:00 2001
From: Oscar Salvador <[email protected]>
Date: Tue, 28 May 2024 10:43:14 +0200
Subject: [PATCH] mm/hugetlb: Do not call vma_add_reservation upon ENOMEM
sysbot reported a splat [1] on __unmap_hugepage_range().
This is because vma_needs_reservation() can return -ENOMEM if allocate_file_region_entries() fails to allocate the file_region struct for the reservation.
Check for that and do not call vma_add_reservation() if that is the case, otherwise region_abort() and region_del() will see that we do not have any file_regions.
If we detect that vma_needs_reservation returned -ENOMEM, we clear the hugetlb_restore_reserve flag as if this reservation was still consumed, so free_huge_folio will not increment the resv count.
[1] https://lore.kernel.org/linux-mm/[email protected]/T/#ma5983bc1ab18a54910da83416b3f89f3c7ee43aa
--- mm/hugetlb.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
mm/hugetlb.c +14 -2
@@ -5768,8 +5768,20 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,* do_exit() will not see it, and will keep the reservation * forever. */ -if (adjust_reservation &&vma_needs_reservation (h, vma, address)) -vma_add_reservation (h, vma, address); +if (adjust_reservation) { + int rc = vma_needs_reservation(h, vma, address) + +if (rc <0 ) +/* Pressumably allocate_file_region_entries failed +* to allocate a file_region struct. Clear +* hugetlb_restore_reserve so that global reserve +* count will not be incremented by free_huge_folio. +* Act as if we consumed the reservation. +*/ +folio_clear_hugetlb_restore_reserve (folio); +else if (rc) +vma_add_reservation (h, vma, address); + }tlb_remove_page_size (tlb, page,huge_page_size (h));/*
Signature · 1 line
2.45.1
Quoted 11 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Quoted 7 lines
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
#syz test
From 917fa54481422c650425c8b0330439f8a3308479 Mon Sep 17 00:00:00 2001
From: Oscar Salvador <[email protected]>
Date: Tue, 28 May 2024 10:43:14 +0200
Subject: [PATCH] mm/hugetlb: Do not call vma_add_reservation upon ENOMEM
sysbot reported a splat [1] on __unmap_hugepage_range().
This is because vma_needs_reservation() can return -ENOMEM if allocate_file_region_entries() fails to allocate the file_region struct for the reservation.
Check for that and do not call vma_add_reservation() if that is the case, otherwise region_abort() and region_del() will see that we do not have any file_regions.
If we detect that vma_needs_reservation returned -ENOMEM, we clear the hugetlb_restore_reserve flag as if this reservation was still consumed, so free_huge_folio will not increment the resv count.
[1] https://lore.kernel.org/linux-mm/[email protected]/T/#ma5983bc1ab18a54910da83416b3f89f3c7ee43aa
--- mm/hugetlb.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
mm/hugetlb.c +14 -2
@@ -5768,8 +5768,20 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,* do_exit() will not see it, and will keep the reservation * forever. */ -if (adjust_reservation &&vma_needs_reservation (h, vma, address)) -vma_add_reservation (h, vma, address); +if (adjust_reservation) { + int rc = vma_needs_reservation(h, vma, address) + +if (rc <0 ) +/* Pressumably allocate_file_region_entries failed +* to allocate a file_region struct. Clear +* hugetlb_restore_reserve so that global reserve +* count will not be incremented by free_huge_folio. +* Act as if we consumed the reservation. +*/ +folio_clear_hugetlb_restore_reserve (folio); +else if (rc) +vma_add_reservation (h, vma, address); + }tlb_remove_page_size (tlb, page,huge_page_size (h));/*
Signature · 5 lines
2.45.1 -- Oscar Salvador SUSE Labs
syzbot
syzbotsyzbot tried to test the proposed patch but the build/boot failed:
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
mm/hugetlb.c:5772:51: error: expected ';' at end of declaration mm/hugetlb.c:5782:4: error: expected expression
Tested on:
commit: 4b3529ed Merge tag 'for-netdev' of https://git.kernel... git tree: net-next kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=17c8c38a980000
Quoted 6 lines · syzbot
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
mm/hugetlb.c:5772:51: error: expected ';' at end of declarationmm/hugetlb.c:5782:4: error: expected expression
Heh, silly me, I should have compile-tested, but was confident. Anyway, now pushed a fixed version.
Signature · 2 lines
Oscar Salvador SUSE Labs
Quoted 11 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Quoted 7 lines
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
#syz test https://github.com/leberus/linux.git hugetlb-vma_resv-enomem
Signature · 2 lines
Oscar Salvador SUSE Labs
syzbot
syzbotsyzbot tried to test the proposed patch but the build/boot failed:
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
mm/hugetlb.c:5772:51: error: expected ';' at end of declaration mm/hugetlb.c:5782:4: error: expected expression
Tested on:
commit: a2868b0f mm/hugetlb: Do not call vma_add_reservation u.. git tree: https://github.com/leberus/linux.git hugetlb-vma_resv-enomem kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
Note: no patches were applied.
Quoted 11 lines · syzbot
syzbot has found a reproducer for the following issue on:
HEAD commit: 66ad4829ddd0 Merge tag 'net-6.10-rc1' of git://git.kernel... git tree: net-next console+strace: https://syzkaller.appspot.com/x/log.txt?x=15c114aa980000 kernel config: https://syzkaller.appspot.com/x/.config?x=48c05addbb27f3b0 dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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=17770d72980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10db1592980000
Quoted 7 lines
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/05c6f2231ef8/disk-66ad4829.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5f4fc63b22e3/vmlinux-66ad4829.xz
kernel image: https://storage.googleapis.com/syzbot-assets/67f5c4c88729/bzImage-66ad4829.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
#syz test https://github.com/leberus/linux.git hugetlb-vma_resv-enomem
Signature · 2 lines
Oscar Salvador SUSE Labs
syzbot
syzbotsyzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: c80d58cd mm/hugetlb: Do not call vma_add_reservation u.. git tree: https://github.com/leberus/linux.git hugetlb-vma_resv-enomem console output: https://syzkaller.appspot.com/x/log.txt?x=1763ba0c980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b9016f104992d69c dashboard link: https://syzkaller.appspot.com/bug?extid=d3fe2dc5ffe9380b714b 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.