@@ -37,22 +37,19 @@
#define ASM_BARRIER_NOSPEC ALTERNATIVE "", "lfence", X86_FEATURE_LFENCE_RDTSC
-.macro check_range size:req
+.macro mask_user_address size:req
.if IS_ENABLED(CONFIG_X86_64)
movq $0x0123456789abcdef,%rdx
1:
.pushsection runtime_ptr_USER_PTR_MAX,"a"
.long 1b - 8 - .
.popsection
- cmp %rax, %rdx
- sbb %rdx, %rdx
- or %rdx, %rax
.else
- cmp $TASK_SIZE_MAX-\size+1, %eax
- jae .Lbad_get_user
- sbb %edx, %edx /* array_index_mask_nospec() */
- and %edx, %eax
+ mov $TASK_SIZE_MAX-\size, %edx
.endif
+ cmp %_ASM_AX, %_ASM_DX
+ sbb %_ASM_DX, %_ASM_DX
+ or %_ASM_DX, %_ASM_AX
.endm
.macro UACCESS op src dst
@@ -63,7 +60,7 @@
.text
SYM_FUNC_START(__get_user_1)
- check_range size=1
+ mask_user_address size=1
ASM_STAC
UACCESS movzbl (%_ASM_AX),%edx
xor %eax,%eax
@@ -73,7 +70,7 @@ SYM_FUNC_END(__get_user_1)
EXPORT_SYMBOL(__get_user_1)
SYM_FUNC_START(__get_user_2)
- check_range size=2
+ mask_user_address size=2
ASM_STAC
UACCESS movzwl (%_ASM_AX),%edx
xor %eax,%eax
@@ -83,7 +80,7 @@ SYM_FUNC_END(__get_user_2)
EXPORT_SYMBOL(__get_user_2)
SYM_FUNC_START(__get_user_4)
- check_range size=4
+ mask_user_address size=4
ASM_STAC
UACCESS movl (%_ASM_AX),%edx
xor %eax,%eax
@@ -93,14 +90,12 @@ SYM_FUNC_END(__get_user_4)
EXPORT_SYMBOL(__get_user_4)
SYM_FUNC_START(__get_user_8)
-#ifndef CONFIG_X86_64
- xor %ecx,%ecx
-#endif
- check_range size=8
+ mask_user_address size=8
ASM_STAC
#ifdef CONFIG_X86_64
UACCESS movq (%_ASM_AX),%rdx
#else
+ xor %ecx,%ecx
UACCESS movl (%_ASM_AX),%edx
UACCESS movl 4(%_ASM_AX),%ecx
#endif
@@ -113,7 +108,7 @@ EXPORT_SYMBOL(__get_user_8)
/* .. and the same for __get_user, just without the range checks */
SYM_FUNC_START(__get_user_nocheck_1)
#ifdef CONFIG_X86_64
- check_range size=1
+ mask_user_address size=1
#else
ASM_BARRIER_NOSPEC
#endif
@@ -127,7 +122,7 @@ EXPORT_SYMBOL(__get_user_nocheck_1)
SYM_FUNC_START(__get_user_nocheck_2)
#ifdef CONFIG_X86_64
- check_range size=2
+ mask_user_address size=2
#else
ASM_BARRIER_NOSPEC
#endif
@@ -141,7 +136,7 @@ EXPORT_SYMBOL(__get_user_nocheck_2)
SYM_FUNC_START(__get_user_nocheck_4)
#ifdef CONFIG_X86_64
- check_range size=4
+ mask_user_address size=4
#else
ASM_BARRIER_NOSPEC
#endif
@@ -155,7 +150,7 @@ EXPORT_SYMBOL(__get_user_nocheck_4)
SYM_FUNC_START(__get_user_nocheck_8)
#ifdef CONFIG_X86_64
- check_range size=8
+ mask_user_address size=8
#else
ASM_BARRIER_NOSPEC
#endif
Convert the 32-bit get_user() implementations to use the new unconditional masking scheme for consistency with 64-bit. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> --- arch/x86/lib/getuser.S | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-)