Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1579558
| From | Steve Capper <steve.capper@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call |
| Date | 2017-02-13 11:00 +0100 |
| Message-ID | <talAl-1ZB-7@gated-at.bofh.it> (permalink) |
| References | (5 earlier) <t6pjb-4nr-1@gated-at.bofh.it> <t6GDn-6W7-19@gated-at.bofh.it> <t6QMq-5eA-31@gated-at.bofh.it> <t6Rp9-5PP-41@gated-at.bofh.it> <t6RIu-5X6-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Feb 03, 2017 at 11:28:48AM -0800, Linus Torvalds wrote:
> On Fri, Feb 3, 2017 at 11:08 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > On x86 it does. I don't see anything equivalent in mm/gup.c one, and the
> > only kinda-sorta similar thing (access_ok() in __get_user_pages_fast()
> > there) is vulnerable to e.g. access via kernel_write().
>
> Yeah, access_ok() is bogus. It needs to just check against TASK_SIZE
> or whatever.
>
> > doesn't look promising - access_ok() is never sufficient. Something like
> > _PAGE_USER tests in x86 one solves that problem, but if anything similar
> > works for HAVE_GENERIC_RCU_GUP I don't see it. Thus the question re
> > what am I missing here...
>
> Ok, I definitely agree that it looks like __get_user_pages_fast() just
> needs to get rid of the access_ok() and replace it with a proper check
> for the user address space range.
>
> Looks like arm[64] and powerpc.are the current users. Adding in some
> people involved with the original submission a few years ago.
Hi,
[ Apologies for my late reply, I was on vacation then catchup... ]
>
> I do note that the x86 __get_user_pages_fast() thing looks dodgy too.
>
> In particular, we do it right in the *real* get_user_pages_fast(), see
> commit 7f8189068726 ("x86: don't use 'access_ok()' as a range check in
> get_user_pages_fast()"). But then the same bug was re-introduced when
> the "irq safe" version was merged. As well as in the GENERIC_RCU_GUP
> version.
>
> Gaah. Apparently PeterZ copied the old buggy version before the fix
> when he added __get_user_pages_fast() in commit 465a454f254e ("x86,
> mm: Add __get_user_pages_fast()").
>
> I guess it could be considered a merge error (both happened during the
> 2.6.31 merge window).
>
Okay so looking at what we have for access_ok(.) on arm64, my
understanding is that we perform a 65-bit add/compare (in assembler) to
see whether or not the range is below the current_thread_info->addr_limit.
So I think this is a roundabout way of checking for no-wrap around and <= TASK_SIZE.
Looking at powerpc, I see it's a little different...
So if it sounds reasonable to folk I was going to send a patch to
replace the call to access_ok(.) with a wraparound + TASK_SIZE check
written explicitly in C? (and remove some of the comments talking about
access_ok(.)).
Cheers,
--
Steve
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-02 11:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Christoph Hellwig <hch@infradead.org> - 2017-02-02 12:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-02 12:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Jeff Layton <jlayton@redhat.com> - 2017-02-02 14:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-03 08:40 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-03 19:30 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-03 20:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-03 20:30 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Steve Capper <steve.capper@linaro.org> - 2017-02-13 11:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-13 22:50 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Christoph Hellwig <hch@infradead.org> - 2017-02-03 08:50 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-03 10:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Christoph Hellwig <hch@infradead.org> - 2017-02-03 12:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Jan Kara <jack@suse.cz> - 2017-02-02 15:50 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-02 19:30 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Jan Kara <jack@suse.cz> - 2017-02-03 15:50 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-04 04:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-04 20:30 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-04 23:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-04 23:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-05 03:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-05 21:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-05 22:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-05 22:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-05 23:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-06 04:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-06 10:10 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-06 11:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-06 15:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-07 08:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-07 12:40 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-08 07:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-08 12:20 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Miklos Szeredi <miklos@szeredi.hu> - 2017-02-06 09:40 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Al Viro <viro@ZenIV.linux.org.uk> - 2017-02-05 22:00 +0100
Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call Jeff Layton <jlayton@redhat.com> - 2017-02-16 14:20 +0100
csiph-web