lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160314153747.GH17923@kvack.org>
Date:	Mon, 14 Mar 2016 11:37:47 -0400
From:	Benjamin LaHaise <bcrl@...ck.org>
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	Ingo Molnar <mingo@...hat.com>,
	Russell King <rmk@....linux.org.uk>,
	Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86_32: add support for 64 bit __get_user() v3

Any more comments/feedback on this?  Can this be merged for 4.6?

		-ben

On Wed, Mar 09, 2016 at 03:05:56PM -0500, Benjamin LaHaise wrote:
> The existing __get_user() implementation does not support fetching
> 64 bit values on 32 bit x86.  Implement this in a way that does not 
> generate any incorrect warnings as cautioned by Russell King.  Test 
> code available at http://www.kvack.org/~bcrl/x86_32-get_user.tar .
> 
> v2: use __inttype() as suggested by H. Peter Anvin, which cleans the
> code up nicely, and fix things to work on x86_64 as well.
> 
> v3: fix undefined behaviour on 32 bit x86 caused by multiple expansion 
> of ptr in the 64 bit case.
> 
> Signed-off-by: Benjamin LaHaise <bcrl@...ck.org>
> 
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index a4a30e4..8743552 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -333,7 +333,26 @@ do {									\
>  } while (0)
>  
>  #ifdef CONFIG_X86_32
> -#define __get_user_asm_u64(x, ptr, retval, errret)	(x) = __get_user_bad()
> +#define __get_user_asm_u64(x, ptr, retval, errret)			\
> +({									\
> +	__typeof__(ptr) __ptr = (ptr);					\
> +	asm volatile(ASM_STAC "\n"					\
> +		     "1:	movl %2,%%eax\n"			\
> +		     "2:	movl %3,%%edx\n"			\
> +		     "3: " ASM_CLAC "\n"				\
> +		     ".section .fixup,\"ax\"\n"				\
> +		     "4:	mov %4,%0\n"				\
> +		     "	xorl %%eax,%%eax\n"				\
> +		     "	xorl %%edx,%%edx\n"				\
> +		     "	jmp 3b\n"					\
> +		     ".previous\n"					\
> +		     _ASM_EXTABLE(1b, 4b)				\
> +		     _ASM_EXTABLE(2b, 4b)				\
> +		     : "=r" (retval), "=A"(x)				\
> +		     : "m" (__m(__ptr)), "m" __m(((u32 *)(__ptr)) + 1),	\
> +		       "i" (errret), "0" (retval));			\
> +})
> +
>  #define __get_user_asm_ex_u64(x, ptr)			(x) = __get_user_bad()
>  #else
>  #define __get_user_asm_u64(x, ptr, retval, errret) \
> @@ -420,7 +439,7 @@ do {									\
>  #define __get_user_nocheck(x, ptr, size)				\
>  ({									\
>  	int __gu_err;							\
> -	unsigned long __gu_val;						\
> +	__inttype(*(ptr)) __gu_val;					\
>  	__uaccess_begin();						\
>  	__get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT);	\
>  	__uaccess_end();						\
> 
> -- 
> "Thought is the essence of where you are now."

-- 
"Thought is the essence of where you are now."

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ