linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Johannes Weiner <hannes@saeurebad.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	akpm@linuxfoundation.org, torvalds@linuxfoundation.org,
	npiggin@suse.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: do not overrun page table ranges in gup
Date: Mon, 28 Jul 2008 17:39:18 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0807281737480.3486@nehalem.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.1.10.0807281721200.3486@nehalem.linux-foundation.org>



On Mon, 28 Jul 2008, Linus Torvalds wrote:
> 
> So no, the right fix would be to align 'start' first, which means that 
> everything else (including 'end') will be page-aligned. Aligning just one 
> or the other is very very wrong.

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;
 
 	/*

  reply	other threads:[~2008-07-29  0:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-28 18:49 2.6.26-$sha1: RIP gup_pte_range+0x54/0x120 Alexey Dobriyan
2008-07-28 18:53 ` Alexey Dobriyan
2008-07-29  0:00   ` [PATCH] x86: do not overrun page table ranges in gup Johannes Weiner
2008-07-29  0:18     ` Johannes Weiner
2008-07-29  0:33       ` Linus Torvalds
2008-07-29  0:39         ` Linus Torvalds [this message]
2008-07-29  0:51           ` Alexey Dobriyan
2008-07-29  1:25           ` Hugh Dickins
2008-07-29  1:37           ` Nick Piggin
2008-07-29  0:53         ` Johannes Weiner
2008-07-29  1:39         ` Nick Piggin
2008-07-29  0:26     ` Alexey Dobriyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.10.0807281737480.3486@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linuxfoundation.org \
    --cc=hannes@saeurebad.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=torvalds@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).