diff options
author | Andy Lutomirski <luto@kernel.org> | 2019-11-20 12:59:13 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-29 10:08:09 +0100 |
commit | 3d99448d1b86fc34413cc6f2cec8d32321ba76bd (patch) | |
tree | 64340bd63894bca9a611bf9bd304bbaf7f9d497f /tools/testing/selftests | |
parent | 25a997e3db80a803aba030579c54f2702194a6d3 (diff) | |
download | linux-stable-3d99448d1b86fc34413cc6f2cec8d32321ba76bd.tar.gz linux-stable-3d99448d1b86fc34413cc6f2cec8d32321ba76bd.tar.bz2 linux-stable-3d99448d1b86fc34413cc6f2cec8d32321ba76bd.zip |
selftests/x86/mov_ss_trap: Fix the SYSENTER test
commit 8caa016bfc129f2c925d52da43022171d1d1de91 upstream.
For reasons that I haven't quite fully diagnosed, running
mov_ss_trap_32 on a 32-bit kernel results in an infinite loop in
userspace. This appears to be because the hacky SYSENTER test
doesn't segfault as desired; instead it corrupts the program state
such that it infinite loops.
Fix it by explicitly clearing EBP before doing SYSENTER. This will
give a more reliable segfault.
Fixes: 59c2a7226fc5 ("x86/selftests: Add mov_to_ss test")
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/x86/mov_ss_trap.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/x86/mov_ss_trap.c b/tools/testing/selftests/x86/mov_ss_trap.c index 3c3a022654f3..6da0ac3f0135 100644 --- a/tools/testing/selftests/x86/mov_ss_trap.c +++ b/tools/testing/selftests/x86/mov_ss_trap.c @@ -257,7 +257,8 @@ int main() err(1, "sigaltstack"); sethandler(SIGSEGV, handle_and_longjmp, SA_RESETHAND | SA_ONSTACK); nr = SYS_getpid; - asm volatile ("mov %[ss], %%ss; SYSENTER" : "+a" (nr) + /* Clear EBP first to make sure we segfault cleanly. */ + asm volatile ("xorl %%ebp, %%ebp; mov %[ss], %%ss; SYSENTER" : "+a" (nr) : [ss] "m" (ss) : "flags", "rcx" #ifdef __x86_64__ , "r11" |