[MODERATED] Re: LVI

Josh Poimboeuf <[email protected]> Tue, 19 Nov 2019 12:21:20 -0600
Newsgroups org.kernel.lore.historical-speck
Message-ID <20191119182120.w4pjlvkjncqmv7ln@treble>
On Tue, Nov 19, 2019 at 07:12:57PM +0100, speck for Greg KH wrote:
> > --- a/arch/x86/include/asm/uaccess.h
> > +++ b/arch/x86/include/asm/uaccess.h
> > @@ -119,9 +119,9 @@ extern int __get_user_bad(void);
> >  
> >  #define __uaccess_begin() stac()
> >  #define __uaccess_end()   clac()
> > -#define __uaccess_begin_nospec()	\
> > +#define __uaccess_end_nospec()	\
> >  ({					\
> > -	stac();				\
> > +	clac();				\
> >  	barrier_nospec();		\
> >  })
> 
> Um, don't we _really_ want stac() here?  That's the only thing that is
> saving our butts in a number of places.  Why get rid of it?  Otherwise
> it should be easy to cause a speculatave load by userspace for any
> address they feel like.
> 
> Or am I mistaken about what you are trying to solve here?

Notice I renamed it to from __uaccess_begin_nospec() to
__uaccess_end_nospec() ;-)

The idea is to move the LFENCE from _before_ the copy to _after_ the
copy.  I didn't mess with stac/clac.

-- 
Josh