From: David Howells Date: Thu, 25 Mar 2010 16:48:44 +0000 (+0000) Subject: NOMMU: Fix __get_user_pages() to pin last page on offset buffers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e1ee65d85904c5dd4b9cea1b15d5e85e20eae8a1;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git NOMMU: Fix __get_user_pages() to pin last page on offset buffers Fix __get_user_pages() to make it pin the last page on a buffer that doesn't begin at the start of a page, but is a multiple of PAGE_SIZE in size. The problem is that __get_user_pages() advances the pointer too much when it iterates to the next page if the page it's currently looking at isn't used from the first byte. This can cause the end of a short VMA to be reached prematurely, resulting in the last page being lost. Signed-off-by: Steven J. Magnani Signed-off-by: David Howells Signed-off-by: Linus Torvalds --- diff --git a/mm/nommu.c b/mm/nommu.c index 089982f5a4cf..63fa17d121f0 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -162,7 +162,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, } if (vmas) vmas[i] = vma; - start += PAGE_SIZE; + start = (start + PAGE_SIZE) & PAGE_MASK; } return i;