Re: [PATCH v1] mm/hugetlb: fix refs calculation from unaligned @vaddr

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

 



On Tue, 13 Jul 2021 13:29:20 -0700 Mike Kravetz <mike.kravetz@xxxxxxxxxx> 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@xxxxxxxxxx>

I'll add cc:stable to this.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux