[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9afe2365-4448-51b1-f711-a81ec79be817@oracle.com>
Date: Tue, 13 Jul 2021 02:08:31 +0100
From: Joao Martins <joao.m.martins@...cle.com>
To: Sean Christopherson <seanjc@...gle.com>,
Mike Kravetz <mike.kravetz@...cle.com>
Cc: syzbot <syzbot+a3fcd59df1b372066f5a@...kaller.appspotmail.com>,
akpm@...ux-foundation.org, bp@...en8.de, hpa@...or.com,
jmattson@...gle.com, joro@...tes.org, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
mark.rutland@....com, masahiroy@...nel.org, mingo@...hat.com,
pbonzini@...hat.com, peterz@...radead.org,
rafael.j.wysocki@...el.com, rostedt@...dmis.org,
sedat.dilek@...il.com, syzkaller-bugs@...glegroups.com,
vitor@...saru.org, vkuznets@...hat.com, wanpengli@...cent.com,
will@...nel.org, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [syzbot] general protection fault in try_grab_compound_head
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@....com>
>>> 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@...kaller.appspotmail.com
Fixes: 82e5d378b0e47 ("mm/hugetlb: refactor subpage recording")
Signed-off-by: Joao Martins <joao.m.martins@...cle.com>
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),
Powered by blists - more mailing lists