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

From: Thomas Gleixner
Date: Thu Jan 19 2017 - 16:14:38 EST


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.
> > [...]
> > We are not papering over problems.
>
> Understood. We were interpreting the comments around access_ok to
> mean that the underlying hazard condition was different (stricter)
> than in_task(). If the warning could be made to match that hazard
> condition more precisely, then safe but non-in_task() callers can use
> access_ok() without the warning.

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 the addr/size which is checked against the limits of current
actually belongs to current?

I assume this is about systemtap modules. Can you please explain what you
are trying to achieve? I guess you know that you actually access current,
but then we need a seperate special function and not relaxing of the
checks.

Thanks,

tglx