Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Enable 3 new ptrace(2) tests for SIGILL
details: https://anonhg.NetBSD.org/src/rev/d7105a88d12a
branches: trunk
changeset: 448678:d7105a88d12a
user: kamil <kamil%NetBSD.org@localhost>
date: Thu Feb 07 00:24:59 2019 +0000
description:
Enable 3 new ptrace(2) tests for SIGILL
Add missing code for SIGILL verification and enable new SIGILL tests:
- traceme_crash_ill
- traceme_vfork_crash_ill
- unrelated_tracer_sees_crash_ill
SIGILL is caused by a crash signal and needs special treatement that has
to be asserted to behave correctly.
In the unrelated_tracer_sees_crash* tests add additional check to catch
scenarios when a test dies due to abnormal condition and it's not caught
as the tracer is collected by initproc.
All tests pass on NetBSD/amd64, other ports have temporarily unimplemented
PTRACE_ILLEGAL_ASM.
diffstat:
tests/lib/libc/sys/t_ptrace_wait.c | 49 +++++++++++++++++++++++++++----------
1 files changed, 35 insertions(+), 14 deletions(-)
diffs (154 lines):
diff -r 8ac9b74eeffe -r d7105a88d12a tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c Thu Feb 07 00:19:54 2019 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c Thu Feb 07 00:24:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.70 2019/02/03 03:19:28 mrg Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.71 2019/02/07 00:24:59 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.70 2019/02/03 03:19:28 mrg Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.71 2019/02/07 00:24:59 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -190,6 +190,11 @@
#endif
struct ptrace_siginfo info;
+#ifndef PTRACE_ILLEGAL_ASM
+ if (sig == SIGILL)
+ atf_tc_skip("PTRACE_ILLEGAL_ASM not defined");
+#endif
+
memset(&info, 0, sizeof(info));
DPRINTF("Before forking process PID=%d\n", getpid());
@@ -247,9 +252,9 @@
case SIGSEGV:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SEGV_MAPERR);
break;
-// case SIGILL:
-// ATF_REQUIRE_EQ(info.psi_siginfo.si_code, ILL_ILLOP);
-// break;
+ case SIGILL:
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, ILL_PRVOPC);
+ break;
case SIGFPE:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
break;
@@ -285,7 +290,7 @@
TRACEME_CRASH(traceme_crash_trap, SIGTRAP)
TRACEME_CRASH(traceme_crash_segv, SIGSEGV)
-//TRACEME_CRASH(traceme_crash_ill, SIGILL)
+TRACEME_CRASH(traceme_crash_ill, SIGILL)
TRACEME_CRASH(traceme_crash_fpe, SIGFPE)
TRACEME_CRASH(traceme_crash_bus, SIGBUS)
@@ -871,6 +876,11 @@
int status;
#endif
+#ifndef PTRACE_ILLEGAL_ASM
+ if (sig == SIGILL)
+ atf_tc_skip("PTRACE_ILLEGAL_ASM not defined");
+#endif
+
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = vfork()) != -1);
if (child == 0) {
@@ -930,7 +940,7 @@
TRACEME_VFORK_CRASH(traceme_vfork_crash_trap, SIGTRAP)
TRACEME_VFORK_CRASH(traceme_vfork_crash_segv, SIGSEGV)
-//TRACEME_VFORK_CRASH(traceme_vfork_crash_ill, SIGILL)
+TRACEME_VFORK_CRASH(traceme_vfork_crash_ill, SIGILL)
TRACEME_VFORK_CRASH(traceme_vfork_crash_fpe, SIGFPE)
TRACEME_VFORK_CRASH(traceme_vfork_crash_bus, SIGBUS)
@@ -1011,6 +1021,11 @@
#endif
struct ptrace_siginfo info;
+#ifndef PTRACE_ILLEGAL_ASM
+ if (sig == SIGILL)
+ atf_tc_skip("PTRACE_ILLEGAL_ASM not defined");
+#endif
+
memset(&info, 0, sizeof(info));
DPRINTF("Spawn tracee\n");
@@ -1097,9 +1112,9 @@
case SIGSEGV:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SEGV_MAPERR);
break;
-// case SIGILL:
-// ATF_REQUIRE_EQ(info.psi_siginfo.si_code, ILL_ILLOP);
-// break;
+ case SIGILL:
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, ILL_PRVOPC);
+ break;
case SIGFPE:
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
break;
@@ -1119,6 +1134,9 @@
TWAIT_REQUIRE_FAILURE(ECHILD,
wpid = TWAIT_GENERIC(tracee, &status, 0));
+ /* Inform parent that tracer is exiting normally */
+ CHILD_TO_PARENT("tracer done", parent_tracer, msg);
+
DPRINTF("Before exiting of the tracer process\n");
_exit(0 /* collect by initproc */);
}
@@ -1150,6 +1168,9 @@
validate_status_signaled(status, SIGKILL, 0);
+ DPRINTF("Await normal exit of tracer\n");
+ PARENT_FROM_CHILD("tracer done", parent_tracer, msg);
+
msg_close(&parent_tracer);
msg_close(&parent_tracee);
}
@@ -1171,7 +1192,7 @@
UNRELATED_TRACER_SEES_CRASH(unrelated_tracer_sees_crash_trap, SIGTRAP)
UNRELATED_TRACER_SEES_CRASH(unrelated_tracer_sees_crash_segv, SIGSEGV)
-//UNRELATED_TRACER_SEES_CRASH(unrelated_tracer_sees_crash_ill, SIGILL)
+UNRELATED_TRACER_SEES_CRASH(unrelated_tracer_sees_crash_ill, SIGILL)
UNRELATED_TRACER_SEES_CRASH(unrelated_tracer_sees_crash_fpe, SIGFPE)
UNRELATED_TRACER_SEES_CRASH(unrelated_tracer_sees_crash_bus, SIGBUS)
#endif
@@ -5679,7 +5700,7 @@
ATF_TP_ADD_TC(tp, traceme_crash_trap);
ATF_TP_ADD_TC(tp, traceme_crash_segv);
-// ATF_TP_ADD_TC(tp, traceme_crash_ill);
+ ATF_TP_ADD_TC(tp, traceme_crash_ill);
ATF_TP_ADD_TC(tp, traceme_crash_fpe);
ATF_TP_ADD_TC(tp, traceme_crash_bus);
@@ -5714,7 +5735,7 @@
ATF_TP_ADD_TC(tp, traceme_vfork_crash_trap);
ATF_TP_ADD_TC(tp, traceme_vfork_crash_segv);
-// ATF_TP_ADD_TC(tp, traceme_vfork_crash_ill);
+ ATF_TP_ADD_TC(tp, traceme_vfork_crash_ill);
ATF_TP_ADD_TC(tp, traceme_vfork_crash_fpe);
ATF_TP_ADD_TC(tp, traceme_vfork_crash_bus);
@@ -5722,7 +5743,7 @@
ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_sees_crash_trap);
ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_sees_crash_segv);
-// ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_sees_crash_ill);
+ ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_sees_crash_ill);
ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_sees_crash_fpe);
ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_sees_crash_bus);
Home |
Main Index |
Thread Index |
Old Index