Re: [PATCH] x86: do not overrun page table ranges in gup

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Weiner <hannes@...>
Cc: Alexey Dobriyan <adobriyan@...>, <akpm@...>, <torvalds@...>, <npiggin@...>, <linux-kernel@...>
Date: Monday, July 28, 2008 - 8:39 pm

On Mon, 28 Jul 2008, Linus Torvalds wrote:

Does this work?

Not pretty, but it stands _some_ chance of being correct.

		Linus


---
 arch/x86/mm/gup.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
index 3085f25..007bb06 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,
 			struct page **pages)
 {
 	struct mm_struct *mm = current->mm;
-	unsigned long end = start + (nr_pages << PAGE_SHIFT);
-	unsigned long addr = start;
+	unsigned long addr, len, end;
 	unsigned long next;
 	pgd_t *pgdp;
 	int nr = 0;
 
+	start &= PAGE_MASK;
+	addr = start;
+	len = (unsigned long) nr_pages << PAGE_SHIFT;
+	end = start + len;
 	if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
-					start, nr_pages*PAGE_SIZE)))
+					start, len)))
 		goto slow_irqon;
 
 	/*
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.26-$sha1: RIP gup_pte_range+0x54/0x120, Alexey Dobriyan, (Mon Jul 28, 2:49 pm)
Re: 2.6.26-$sha1: RIP gup_pte_range+0x54/0x120, Alexey Dobriyan, (Mon Jul 28, 2:53 pm)
[PATCH] x86: do not overrun page table ranges in gup, Johannes Weiner, (Mon Jul 28, 8:00 pm)
Re: [PATCH] x86: do not overrun page table ranges in gup, Alexey Dobriyan, (Mon Jul 28, 8:26 pm)
Re: [PATCH] x86: do not overrun page table ranges in gup, Johannes Weiner, (Mon Jul 28, 8:18 pm)
Re: [PATCH] x86: do not overrun page table ranges in gup, Linus Torvalds, (Mon Jul 28, 8:33 pm)
Re: [PATCH] x86: do not overrun page table ranges in gup, Johannes Weiner, (Mon Jul 28, 8:53 pm)
Re: [PATCH] x86: do not overrun page table ranges in gup, Linus Torvalds, (Mon Jul 28, 8:39 pm)
Re: [PATCH] x86: do not overrun page table ranges in gup, Alexey Dobriyan, (Mon Jul 28, 8:51 pm)