Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-20 Thread Thomas Gleixner
On Fri, 20 Jan 2017, Peter Zijlstra wrote: > On Wed, Jan 18, 2017 at 04:19:47PM -0800, Andy Lutomirski wrote: > > ISTM even with pagefault_disable() in play, using access_ok() from, > > say, interrupt context is dangerous unless you've first checked that > > you're in a task. But I guess that in_

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-20 Thread Peter Zijlstra
On Wed, Jan 18, 2017 at 04:19:47PM -0800, Andy Lutomirski wrote: > ISTM even with pagefault_disable() in play, using access_ok() from, > say, interrupt context is dangerous unless you've first checked that > you're in a task. But I guess that in_task() would still return > false, e.g. in perf. Th

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread Thomas Gleixner
Frank. On Thu, 19 Jan 2017, Frank Ch. Eigler wrote: > > Well, if you are not in thread context then the check is pointless: > > __range_not_ok(addr, size, user_addr_max()) > > and: > > #define user_addr_max() (current->thread.addr_limit.seg) > > > > So what guarantees when you are not in cont

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread Peter Zijlstra
On Thu, Jan 19, 2017 at 04:27:18PM -0500, Frank Ch. Eigler wrote: > Hi, Thomas - > > > Well, if you are not in thread context then the check is pointless: > > __range_not_ok(addr, size, user_addr_max()) > > and: > > #define user_addr_max() (current->thread.addr_limit.seg) > > > > So what guar

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread Frank Ch. Eigler
Hi, Thomas - > Well, if you are not in thread context then the check is pointless: > __range_not_ok(addr, size, user_addr_max()) > and: > #define user_addr_max() (current->thread.addr_limit.seg) > > So what guarantees when you are not in context of current, i.e. in thread > context, that th

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread Thomas Gleixner
On Thu, 19 Jan 2017, Frank Ch. Eigler wrote: > Hi, Thomas - > > On Thu, Jan 19, 2017 at 07:12:48PM +0100, Thomas Gleixner wrote: > > [...] > > It does matter very much, because the fact that the warning triggers tells > > me that it's placed in code which is NOT executed in task context. > > [...

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread Frank Ch. Eigler
Hi, Thomas - On Thu, Jan 19, 2017 at 07:12:48PM +0100, Thomas Gleixner wrote: > [...] > It does matter very much, because the fact that the warning triggers tells > me that it's placed in code which is NOT executed in task context. > [...] > We are not papering over problems. Understood. We were

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread Thomas Gleixner
On Wed, 18 Jan 2017, David Smith wrote: > On 01/16/2017 03:14 PM, Thomas Gleixner wrote: > >> If you put that new access_ok() call in a module that gets > >> loaded/unloaded, you see one warning for every module load, which gets a > >> bit annoying. > > > > Can you please elaborate where this acce

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-19 Thread David Smith
On 01/18/2017 06:19 PM, Andy Lutomirski wrote: > On Wed, Jan 18, 2017 at 2:16 PM, David Smith wrote: >> On 01/16/2017 03:14 PM, Thomas Gleixner wrote: >>> On Mon, 16 Jan 2017, David Smith wrote: ... stuff deleted ... If you put that new access_ok() call in a module that gets loaded/unl

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-18 Thread Andy Lutomirski
On Wed, Jan 18, 2017 at 2:16 PM, David Smith wrote: > On 01/16/2017 03:14 PM, Thomas Gleixner wrote: >> On Mon, 16 Jan 2017, David Smith wrote: >> >>> If you call access_ok() with page faulting disabled, you'll still see >>> this new warning. >> >> And how so? It's just checking for task context.

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-18 Thread David Smith
On 01/16/2017 03:14 PM, Thomas Gleixner wrote: > On Mon, 16 Jan 2017, David Smith wrote: > >> If you call access_ok() with page faulting disabled, you'll still see >> this new warning. > > And how so? It's just checking for task context. page fault disable/enable > has absolutely nothing to do wi

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-16 Thread Thomas Gleixner
On Mon, 16 Jan 2017, David Smith wrote: > If you call access_ok() with page faulting disabled, you'll still see > this new warning. And how so? It's just checking for task context. page fault disable/enable has absolutely nothing to do with that. > If you put that new access_ok() call in a modul

Re: [RFC][PATCH] x86: Verify access_ok() context

2017-01-16 Thread David Smith
If you call access_ok() with page faulting disabled, you'll still see this new warning. If you put that new access_ok() call in a module that gets loaded/unloaded, you see one warning for every module load, which gets a bit annoying. How about modifying it like this: --- From: David Smith Dat

Re: [RFC][PATCH] x86: Verify access_ok() context

2016-12-05 Thread Peter Zijlstra
On Tue, Nov 22, 2016 at 11:42:19AM -0800, Linus Torvalds wrote: > On Tue, Nov 22, 2016 at 11:37 AM, Peter Zijlstra wrote: > > > > CONFIG_DEBUG_VM seems somehow inappropriate. > > The usual might_fault() logic? That uses > > defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)

Re: [RFC][PATCH] x86: Verify access_ok() context

2016-11-22 Thread Linus Torvalds
On Tue, Nov 22, 2016 at 11:37 AM, Peter Zijlstra wrote: > > CONFIG_DEBUG_VM seems somehow inappropriate. The usual might_fault() logic? That uses defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP) (and "might_sleep()" uses just CONFIG_DEBUG_ATOMIC_SLEEP, maybe that's fine).

Re: [RFC][PATCH] x86: Verify access_ok() context

2016-11-22 Thread Peter Zijlstra
On Tue, Nov 22, 2016 at 09:28:01AM -0800, Andy Lutomirski wrote: > On Tue, Nov 22, 2016 at 1:57 AM, Peter Zijlstra wrote: > > +#define access_ok(type, addr, size)\ > > +({ \ > > + WARN_ON

Re: [RFC][PATCH] x86: Verify access_ok() context

2016-11-22 Thread Andy Lutomirski
On Tue, Nov 22, 2016 at 1:57 AM, Peter Zijlstra wrote: > > I recently encountered wreckage because access_ok() was used where it > should not be, add an explicit WARN when access_ok() is used wrongly. > > Signed-off-by: Peter Zijlstra (Intel) > --- > arch/x86/include/asm/uaccess.h | 7 +-- >