Re: [syzbot] general protection fault in try_grab_compound_head

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/12/21 10:29 PM, Sean Christopherson wrote:
> On Thu, Jul 08, 2021, Thomas Gleixner wrote:
>> On Sat, Jul 03 2021 at 13:24, syzbot wrote:
>>> syzbot has bisected this issue to:
>>>
>>> commit 997acaf6b4b59c6a9c259740312a69ea549cc684
>>> Author: Mark Rutland <mark.rutland@xxxxxxx>
>>> Date:   Mon Jan 11 15:37:07 2021 +0000
>>>
>>>     lockdep: report broken irq restoration
>>
>> That's the commit which makes the underlying problem visible:
>>
>>        raw_local_irq_restore() called with IRQs enabled
>>
>> and is triggered by this call chain:
>>
>>  kvm_wait arch/x86/kernel/kvm.c:860 [inline]
>>  kvm_wait+0xc3/0xe0 arch/x86/kernel/kvm.c:837
> 
> And the bug in kvm_wait() was fixed by commit f4e61f0c9add ("x86/kvm: Fix broken
> irq restoration in kvm_wait").  The bisection is bad, syzbot happened into the
> kvm_wait() WARN and got distracted.  The original #GP looks stable, if someone
> from mm land has bandwidth.
> 

I've bisected this to (my) recent commit 82e5d378b0e47 ("mm/hugetlb: refactor subpage
recording").

I have this fix below and should formally submit tomorrow after more testing.
My apologies for the trouble.

	Joao

------>8------

Subject: mm/hugetlb: fix refs calculation from unaligned @vaddr

commit 82e5d378b0e47 ("mm/hugetlb: refactor subpage recording")
refactored the count of subpages but missed an edge case when @vaddr is
less than a PAGE_SIZE close to vma->vm_end. It would errousnly set @refs
to 0 and record_subpages_vmas() wouldn't set the pages array element to
its value, consequently causing the reported #GP by syzbot.

Fix it by aligning down @vaddr in @refs calculation.

Reported-by: syzbot+a3fcd59df1b372066f5a@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: 82e5d378b0e47 ("mm/hugetlb: refactor subpage recording")
Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a86a58ef132d..cbc448c1a3c8 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4949,8 +4949,9 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct
*vma,
                        continue;
                }

-               refs = min3(pages_per_huge_page(h) - pfn_offset,
-                           (vma->vm_end - vaddr) >> PAGE_SHIFT, remainder);
+               /* [vaddr .. vm_end] may not be aligned to PAGE_SIZE */
+               refs = min3(pages_per_huge_page(h) - pfn_offset, remainder,
+                   (vma->vm_end - ALIGN_DOWN(vaddr, PAGE_SIZE)) >> PAGE_SHIFT);

                if (pages || vmas)
                        record_subpages_vmas(mem_map_offset(page, pfn_offset),



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux