linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joao Martins <joao.m.martins@oracle.com>
To: Sean Christopherson <seanjc@google.com>,
	Mike Kravetz <mike.kravetz@oracle.com>
Cc: syzbot <syzbot+a3fcd59df1b372066f5a@syzkaller.appspotmail.com>,
	akpm@linux-foundation.org, bp@alien8.de, hpa@zytor.com,
	jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	mark.rutland@arm.com, masahiroy@kernel.org, mingo@redhat.com,
	pbonzini@redhat.com, peterz@infradead.org,
	rafael.j.wysocki@intel.com, rostedt@goodmis.org,
	sedat.dilek@gmail.com, syzkaller-bugs@googlegroups.com,
	vitor@massaru.org, vkuznets@redhat.com, wanpengli@tencent.com,
	will@kernel.org, x86@kernel.org,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [syzbot] general protection fault in try_grab_compound_head
Date: Tue, 13 Jul 2021 02:08:31 +0100	[thread overview]
Message-ID: <9afe2365-4448-51b1-f711-a81ec79be817@oracle.com> (raw)
In-Reply-To: <YOy0HAnhsXJ4W210@google.com>

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@arm.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@syzkaller.appspotmail.com
Fixes: 82e5d378b0e47 ("mm/hugetlb: refactor subpage recording")
Signed-off-by: Joao Martins <joao.m.martins@oracle.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),


      reply	other threads:[~2021-07-13  1:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03 15:41 syzbot
2021-07-03 20:24 ` syzbot
2021-07-08 13:03   ` Thomas Gleixner
2021-07-12 21:29     ` Sean Christopherson
2021-07-13  1:08       ` Joao Martins [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9afe2365-4448-51b1-f711-a81ec79be817@oracle.com \
    --to=joao.m.martins@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=masahiroy@kernel.org \
    --cc=mike.kravetz@oracle.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.org \
    --cc=seanjc@google.com \
    --cc=sedat.dilek@gmail.com \
    --cc=syzbot+a3fcd59df1b372066f5a@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    --cc=vitor@massaru.org \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox