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

From: Peter Zijlstra
Date: Tue Nov 22 2016 - 14:37:31 EST


On Tue, Nov 22, 2016 at 09:28:01AM -0800, Andy Lutomirski wrote:
> On Tue, Nov 22, 2016 at 1:57 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> > +#define access_ok(type, addr, size) \
> > +({ \
> > + WARN_ON_ONCE(!in_task()); \
>
> Should this be guarded by some debug option? This may hurt
> performance on production systems quite a bit.

I suspected something like that; any suitable CONFIG come to mind? I'm
somewhat reluctant to create yet another one for this.

CONFIG_DEBUG_VM seems somehow inappropriate.

> For what it's worth, I think ARM recently started saving the address
> limit and resetting it to USER_DS on NMI entry.

Up to them of course, but doing less on interrupt entry/exit seems
better.