Commit e0a04cff authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

[PATCH] mincore: vma crossing fix

My mincore also forgot about crossing vmas.
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4a76ef03
...@@ -77,8 +77,16 @@ static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pag ...@@ -77,8 +77,16 @@ static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pag
* PTE array for our address. * PTE array for our address.
*/ */
nr = PTRS_PER_PTE - ((addr >> PAGE_SHIFT) & (PTRS_PER_PTE-1)); nr = PTRS_PER_PTE - ((addr >> PAGE_SHIFT) & (PTRS_PER_PTE-1));
if (nr > pages)
nr = pages; /*
* Don't overrun this vma
*/
nr = min(nr, (vma->vm_end - addr) >> PAGE_SHIFT);
/*
* Don't return more than the caller asked for
*/
nr = min(nr, pages);
pgd = pgd_offset(vma->vm_mm, addr); pgd = pgd_offset(vma->vm_mm, addr);
if (pgd_none_or_clear_bad(pgd)) if (pgd_none_or_clear_bad(pgd))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment