Re: [PATCH-V2 v4.9] x86/uaccess: Don't leak the AC flag into __put_user() value evaluation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 03, 2019 at 07:45:05PM +0300, Maxim Zhukov wrote:
> From: Andy Lutomirski <luto@xxxxxxxxxx>
> 
> commit 2a418cf3f5f1caf911af288e978d61c9844b0695 upstream.
> 
> When calling __put_user(foo(), ptr), the __put_user() macro would call
> foo() in between __uaccess_begin() and __uaccess_end().  If that code
> were buggy, then those bugs would be run without SMAP protection.
> 
> Fortunately, there seem to be few instances of the problem in the
> kernel. Nevertheless, __put_user() should be fixed to avoid doing this.
> Therefore, evaluate __put_user()'s argument before setting AC.
> 
> This issue was noticed when an objtool hack by Peter Zijlstra complained
> about genregs_get() and I compared the assembly output to the C source.
> 
>  [ bp: Massage commit message and fixed up whitespace. ]
> 
> Fixes: 11f1a4b9755f ("x86: reorganize SMAP handling in user space accesses")
> Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
> Signed-off-by: Borislav Petkov <bp@xxxxxxx>
> Acked-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Brian Gerst <brgerst@xxxxxxxxx>
> Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Cc: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Link: http://lkml.kernel.org/r/20190225125231.845656645@xxxxxxxxxxxxx
> Signed-off-by: Maxim Zhukov <mussitantesmortem@xxxxxxxxx>
> ---
>  arch/x86/include/asm/uaccess.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index a8d85a687cf4..20f86ae9d92f 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -292,7 +292,7 @@ do {									\
>  		__put_user_asm(x, ptr, retval, "l", "k", "ir", errret);	\
>  		break;							\
>  	case 8:								\
> -		__put_user_asm_u64((__typeof__(*ptr))(x), ptr, retval,	\
> +		__put_user_asm_u64(x, ptr, retval,	\
>  				   errret);				\

That can all be on one line now :(

Let me go see if I can do the backport, it doesn't look that complex...

greg k-h



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux