Re: [RFC][PATCH 01/22] x86 user stack frame reads: switch to explicit __get_user()
From: Ingo Molnar
Date: Sun Mar 29 2020 - 05:26:10 EST
* Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> > but the __get_user() API doesn't carry the 'unsafe' tag yet.
> >
> > Should we add an __unsafe_get_user() alias to it perhaps, and use it
> > in all code that adds it, like the chunk above? Or rename it to
> > __unsafe_get_user() outright? No change to the logic, but it would be
> > more obvious what code has inherited old __get_user() uses and which
> > code uses __unsafe_get_user() intentionally.
> >
> > Even after your series there's 700 uses of __get_user(), so it would
> > make sense to make a distinction in name at least and tag all unsafe
> > APIs with an 'unsafe_' prefix.
>
> "unsafe" != "lacks access_ok", it's "done under user_access_begin".
Well, I thought the principle was that we'd mark generic APIs that had
*either* a missing access_ok() check or a missing
user_access_begin()/end() wrapping marked unsafe_*(), right?
__get_user() has __uaccess_begin()/end() on the inside, but doesn't have
the access_ok() check, so those calls are 'unsafe' with regard to not
being safe to untrusted (ptr,size) ranges.
I agree that all of these topics need equal attention:
- leaking of cleared SMAP state (CLAC), which results in a silent
failure.
- running user accesses without STAC, which results in a crash.
- not doing an access_ok() check on untrusted (pointer,size) ranges,
which results in a silent failure as well.
I just think that any API that doesn't guarantee all of these are handled
right probably needs to be unsafe_*() tagged.
> FWIW, with the currently linearized part I see 26 users in arch/x86 and
> 108 - outside of arch/*. With 43 of the latter supplied by the sodding
> comedi_compat32.c, which needs to be rewritten anyway (or git rm'ed,
> for that matter)...
>
> We'll get there; the tricky part is the ones that come in pair with
> something other than access_ok() in the first place (many of those are
> KVM-related, but not all such are).
>
> This part had been more about untangling uaccess_try stuff,,,
It's much appreciated! In my previous mail I just wanted to inquire about
the long term plan, whether we are going to get rid of all uses of
__get_user() - to which the answer appears to be "yes". :-)
Thanks,
Ingo