From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Date: Fri, 21 Jun 2019 13:39:11 +0000 Subject: Re: [PATCH 01/16] mm: use untagged_addr() for get_user_pages_fast addresses Message-Id: <20190621133911.GL19891@ziepe.ca> List-Id: References: <20190611144102.8848-1-hch@lst.de> <20190611144102.8848-2-hch@lst.de> In-Reply-To: <20190611144102.8848-2-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Christoph Hellwig Cc: Linus Torvalds , Paul Burton , James Hogan , Yoshinori Sato , Rich Felker , "David S. Miller" , Nicholas Piggin , Khalid Aziz , Andrey Konovalov , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linux-mips@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 04:40:47PM +0200, Christoph Hellwig wrote: > This will allow sparc64 to override its ADI tags for > get_user_pages and get_user_pages_fast. > > Signed-off-by: Christoph Hellwig > mm/gup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index ddde097cf9e4..6bb521db67ec 100644 > +++ b/mm/gup.c > @@ -2146,7 +2146,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, > unsigned long flags; > int nr = 0; > > - start &= PAGE_MASK; > + start = untagged_addr(start) & PAGE_MASK; > len = (unsigned long) nr_pages << PAGE_SHIFT; > end = start + len; Hmm, this function, and the other, goes on to do: if (unlikely(!access_ok((void __user *)start, len))) return 0; and I thought that access_ok takes in the tagged pointer? How about re-order it a bit? diff --git a/mm/gup.c b/mm/gup.c index ddde097cf9e410..f48747ced4723b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2148,11 +2148,12 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, start &= PAGE_MASK; len = (unsigned long) nr_pages << PAGE_SHIFT; - end = start + len; - if (unlikely(!access_ok((void __user *)start, len))) return 0; + start = untagged_ptr(start); + end = start + len; + /* * Disable interrupts. We use the nested form as we can already have * interrupts disabled by get_futex_key.