aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Lutomirski <[email protected]>2016-05-03 10:31:50 -0700
committerIngo Molnar <[email protected]>2016-05-04 08:34:13 +0200
commit158b67b5c5ccda9b909f18028a3cd17185ca1efd (patch)
treeb0b742cd3d36cb10186c3b20c9d76f5a0bcebf43
parentc876eeab6432687846d4cd5fe1e43dbc348de134 (diff)
selftests/sigaltstack: Fix the sigaltstack test on old kernels
The handling for old kernels was wrong, resulting in a segfault. Fix it. Reported-by: Ingo Molnar <[email protected]> Signed-off-by: Andy Lutomirski <[email protected]> Cc: Al Viro <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Stas Sergeev <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/f3e739bf435beeaecbd5f038f1359d2eac6d1e63.1462296606.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]>
-rw-r--r--tools/testing/selftests/sigaltstack/sas.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/testing/selftests/sigaltstack/sas.c b/tools/testing/selftests/sigaltstack/sas.c
index 57da8bfde60b..a98c3ef8141f 100644
--- a/tools/testing/selftests/sigaltstack/sas.c
+++ b/tools/testing/selftests/sigaltstack/sas.c
@@ -15,6 +15,7 @@
#include <alloca.h>
#include <string.h>
#include <assert.h>
+#include <errno.h>
#ifndef SS_AUTODISARM
#define SS_AUTODISARM (1 << 4)
@@ -117,13 +118,19 @@ int main(void)
stk.ss_flags = SS_ONSTACK | SS_AUTODISARM;
err = sigaltstack(&stk, NULL);
if (err) {
- perror("[FAIL]\tsigaltstack(SS_ONSTACK | SS_AUTODISARM)");
- stk.ss_flags = SS_ONSTACK;
- }
- err = sigaltstack(&stk, NULL);
- if (err) {
- perror("[FAIL]\tsigaltstack(SS_ONSTACK)");
- return EXIT_FAILURE;
+ if (errno == EINVAL) {
+ printf("[NOTE]\tThe running kernel doesn't support SS_AUTODISARM\n");
+ /*
+ * If test cases for the !SS_AUTODISARM variant were
+ * added, we could still run them. We don't have any
+ * test cases like that yet, so just exit and report
+ * success.
+ */
+ return 0;
+ } else {
+ perror("[FAIL]\tsigaltstack(SS_ONSTACK | SS_AUTODISARM)");
+ return EXIT_FAILURE;
+ }
}
ustack = mmap(NULL, SIGSTKSZ, PROT_READ | PROT_WRITE,