linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Joao Martins <joao.m.martins@oracle.com>, linux-mm@kvack.org
Subject: Re: [PATCH v1] mm/hugetlb: fix refs calculation from unaligned @vaddr
Date: Tue, 13 Jul 2021 18:02:19 -0700	[thread overview]
Message-ID: <20210713180219.26b834e4a21d817eee5c0863@linux-foundation.org> (raw)
In-Reply-To: <1d7eac17-8758-63bb-a0ac-968723af6e2d@oracle.com>

On Tue, 13 Jul 2021 13:29:20 -0700 Mike Kravetz <mike.kravetz@oracle.com> wrote:

> On 7/13/21 8:24 AM, Joao Martins wrote:
>
> > The syzbot repro no longer reproduces after this patch. Additionally, ran
> > the libhugetlbfs tests (which were passing without this), gup_test and an
> > extra gup_test extension that take an offset to exercise gup() starting
> > address not being page aligned.
> > ---
> >  mm/hugetlb.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index 924553aa8f78..dfc940d5221d 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -5440,8 +5440,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 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),
> > 
> 
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

I'll add cc:stable to this.


  reply	other threads:[~2021-07-14  1:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 15:24 Joao Martins
2021-07-13 20:29 ` Mike Kravetz
2021-07-14  1:02   ` Andrew Morton [this message]
2021-07-14  9:54   ` Joao Martins

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=20210713180219.26b834e4a21d817eee5c0863@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=joao.m.martins@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    /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