Skip to content

Commit dd35a09

Browse files
sulixKAGA-KOKO
authored andcommitted
x86/uaccess: Zero the 8-byte get_range case on failure on 32-bit
While zeroing the upper 32 bits of an 8-byte getuser on 32-bit x86 was fixed by commit 8c860ed ("x86/uaccess: Fix missed zeroing of ia32 u64 get_user() range checking") it was broken again in commit 8a2462d ("x86/uaccess: Improve the 8-byte getuser() case"). This is because the register which holds the upper 32 bits (%ecx) is being cleared _after_ the check_range, so if the range check fails, %ecx is never cleared. This can be reproduced with: ./tools/testing/kunit/kunit.py run --arch i386 usercopy Instead, clear %ecx _before_ check_range in the 8-byte case. This reintroduces a bit of the ugliness we were trying to avoid by adding another #ifndef CONFIG_X86_64, but at least keeps check_range from needing a separate bad_get_user_8 jump. Fixes: 8a2462d ("x86/uaccess: Improve the 8-byte getuser() case") Signed-off-by: David Gow <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 3db03fb commit dd35a09

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/lib/getuser.S

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ SYM_FUNC_END(__get_user_4)
8888
EXPORT_SYMBOL(__get_user_4)
8989

9090
SYM_FUNC_START(__get_user_8)
91+
#ifndef CONFIG_X86_64
92+
xor %ecx,%ecx
93+
#endif
9194
check_range size=8
9295
ASM_STAC
9396
#ifdef CONFIG_X86_64
9497
UACCESS movq (%_ASM_AX),%rdx
9598
#else
96-
xor %ecx,%ecx
9799
UACCESS movl (%_ASM_AX),%edx
98100
UACCESS movl 4(%_ASM_AX),%ecx
99101
#endif

0 commit comments

Comments
 (0)