Skip to content

Commit 8caa016

Browse files
amlutoPeter Zijlstra
authored andcommitted
selftests/x86/mov_ss_trap: Fix the SYSENTER test
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: 59c2a72 ("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
1 parent 8954290 commit 8caa016

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎tools/testing/selftests/x86/mov_ss_trap.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ int main()
257257
err(1, "sigaltstack");
258258
sethandler(SIGSEGV, handle_and_longjmp, SA_RESETHAND | SA_ONSTACK);
259259
nr = SYS_getpid;
260-
asm volatile ("mov %[ss], %%ss; SYSENTER" : "+a" (nr)
260+
/* Clear EBP first to make sure we segfault cleanly. */
261+
asm volatile ("xorl %%ebp, %%ebp; mov %[ss], %%ss; SYSENTER" : "+a" (nr)
261262
: [ss] "m" (ss) : "flags", "rcx"
262263
#ifdef __x86_64__
263264
, "r11"

0 commit comments

Comments
 (0)