x86, selftests: Add a test for the "sysret_ss_attrs" bug
PATCH 1/1 x86, selftests: Add a test for the "sysret_ss_attrs" bug
On AMD CPUs, SYSRET can return with a valid SS descriptor with with the hidden attributes set to an unusable state. Make sure the kernel doesn't let this happen. This detects an as-yet-unfixed regression.
Note that the 64-bit version of this test fails on AMD CPUs on all kernel versions, although the issue in the 64-bit case is much less severe than in the 32-bit case.
Tests: e7d6eefaaa44 x86/vdso32/syscall.S: Do not load __USER32_DS to %ss
---
[resend -- it seems like only some recipients got it last time]
We're still mulling over the fix, but we have a good test case now.
tools/testing/selftests/x86/Makefile | 5 +-
tools/testing/selftests/x86/run_x86_tests.sh | 2 + tools/testing/selftests/x86/sysret_ss_attrs.c | 112 ++++++++++++++++++++++++++ tools/testing/selftests/x86/thunks.S | 67 +++++++++++++++ 4 files changed, 185 insertions(+), 1 deletion(-) mode change 100644 => 100755 tools/testing/selftests/x86/run_x86_tests.sh create mode 100644 tools/testing/selftests/x86/sysret_ss_attrs.c create mode 100644 tools/testing/selftests/x86/thunks.S
tools/testing/selftests/x86/Makefile +4 -1
@@ -1,6 +1,6 @@ .PHONY: all all_32 all_64 check_build32 clean run_tests -TARGETS_C_BOTHBITS := sigreturn single_step_syscall +TARGETS_C_BOTHBITS := sigreturn single_step_syscall sysret_ss_attrs BINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32) BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
@@ -46,3 +46,6 @@ check_build32: echo " yum install glibc-devel.*i686"; \ exit 1; \ fi + +# Some tests have additional dependencies. +sysret_ss_attrs_64: thunks.S
tools/testing/selftests/x86/run_x86_tests.sh +2 -0
@@ -4,10 +4,12 @@ # script here. ./sigreturn_32 || exit 1 ./single_step_syscall_32 || exit 1 +./sysret_ss_attrs_32 || exit 1 if [[ "$uname -p" -eq "x86_64" ]]; then ./sigreturn_64 || exit 1 ./single_step_syscall_64 || exit 1 + ./sysret_ss_attrs_64 || exit 1 fi exit 0
tools/testing/selftests/x86/sysret_ss_attrs.c new file +112 -0
112 lines not on this page · raw message
tools/testing/selftests/x86/thunks.S new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.3.0
Quoted 7 lines · Andy Lutomirski
On AMD CPUs, SYSRET can return with a valid SS descriptor with with the hidden attributes set to an unusable state. Make sure the kernel doesn't let this happen. This detects an as-yet-unfixed regression.
Note that the 64-bit version of this test fails on AMD CPUs on all kernel versions, although the issue in the 64-bit case is much less severe than in the 32-bit case.
Confirmed to detect the "bug" in 64-bit userspace.
tip-bot for Andy Lutomirski
merge bot[tip:x86/asm] x86, selftests: Add a test for the "sysret_ss_attrs " bug
In reply to Andy Lutomirskix86, selftests: Add a test for the "sysret_ss_attrs" bug
Commit-ID: e22438f8e997ac1c8911d8808b6a4c492cd8bc6e Gitweb: http://git.kernel.org/tip/e22438f8e997ac1c8911d8808b6a4c492cd8bc6e Author: Andy Lutomirski <[email protected]> AuthorDate: Fri, 24 Apr 2015 15:09:19 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 8 May 2015 13:33:59 +0200
x86, selftests: Add a test for the "sysret_ss_attrs" bug
On AMD CPUs, SYSRET can return with a valid SS descriptor with with the hidden attributes set to an unusable state. Make sure the kernel doesn't let this happen. This detects an as-yet-unfixed regression.
Note that the 64-bit version of this test fails on AMD CPUs on all kernel versions, although the issue in the 64-bit case is much less severe than in the 32-bit case.
Tests: e7d6eefaaa44 ("x86/vdso32/syscall.S: Do not load __USER32_DS to %ss")
--- tools/testing/selftests/x86/Makefile | 5 +- tools/testing/selftests/x86/run_x86_tests.sh | 2 + tools/testing/selftests/x86/sysret_ss_attrs.c | 112 ++++++++++++++++++++++++++ tools/testing/selftests/x86/thunks.S | 67 +++++++++++++++ 4 files changed, 185 insertions(+), 1 deletion(-)
tools/testing/selftests/x86/Makefile +4 -1
@@ -1,6 +1,6 @@ .PHONY: all all_32 all_64 check_build32 clean run_tests -TARGETS_C_BOTHBITS := sigreturn single_step_syscall +TARGETS_C_BOTHBITS := sigreturn single_step_syscall sysret_ss_attrs BINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32) BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
@@ -46,3 +46,6 @@ check_build32: echo " yum install glibc-devel.*i686"; \ exit 1; \ fi + +# Some tests have additional dependencies. +sysret_ss_attrs_64: thunks.S
tools/testing/selftests/x86/run_x86_tests.sh +2 -0
@@ -4,10 +4,12 @@ # script here. ./sigreturn_32 || exit 1 ./single_step_syscall_32 || exit 1 +./sysret_ss_attrs_32 || exit 1 if [[ "$uname -p" -eq "x86_64" ]]; then ./sigreturn_64 || exit 1 ./single_step_syscall_64 || exit 1 + ./sysret_ss_attrs_64 || exit 1 fi exit 0
tools/testing/selftests/x86/sysret_ss_attrs.c new file +112 -0
112 lines not on this page · raw message
tools/testing/selftests/x86/thunks.S new file +67 -0
67 lines not on this page · raw message