aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 20:54:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 20:54:21 -0400
commit9b79022ca909b66e2cd0cfd9248f832fc165f77f (patch)
treebcd8c3204886fcbc8422aeb482f8e42c0b5b6124 /arch/x86
parent34ee55014283a60efa3534c06e010579ffdd3756 (diff)
Fix 'get_user_pages_fast()' with non-page-aligned start address
Alexey Dobriyan reported trouble with LTP with the new fast-gup code, and Johannes Weiner debugged it to non-page-aligned addresses, where the new get_user_pages_fast() code would do all the wrong things, including just traversing past the end of the requested area due to 'addr' never matching 'end' exactly. This is not a pretty fix, and we may actually want to move the alignment into generic code, leaving just the core code per-arch, but Alexey verified that the vmsplice01 LTP test doesn't crash with this. Reported-and-tested-by: Alexey Dobriyan <adobriyan@gmail.com> Debugged-by: Johannes Weiner <hannes@saeurebad.de> Cc: Nick Piggin <npiggin@suse.de> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/mm/gup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
index 3085f25b4355..007bb06c7504 100644
--- a/arch/x86/mm/gup.c
+++ b/arch/x86/mm/gup.c
@@ -223,14 +223,17 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
223 struct page **pages) 223 struct page **pages)
224{ 224{
225 struct mm_struct *mm = current->mm; 225 struct mm_struct *mm = current->mm;
226 unsigned long end = start + (nr_pages << PAGE_SHIFT); 226 unsigned long addr, len, end;
227 unsigned long addr = start;
228 unsigned long next; 227 unsigned long next;
229 pgd_t *pgdp; 228 pgd_t *pgdp;
230 int nr = 0; 229 int nr = 0;
231 230
231 start &= PAGE_MASK;
232 addr = start;
233 len = (unsigned long) nr_pages << PAGE_SHIFT;
234 end = start + len;
232 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ, 235 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
233 start, nr_pages*PAGE_SIZE))) 236 start, len)))
234 goto slow_irqon; 237 goto slow_irqon;
235 238
236 /* 239 /*