summaryrefslogtreecommitdiff
path: root/tests/ptrace.c
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2021-09-11 14:46:15 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2021-10-08 03:50:59 +0200
commitbf6fc7290f479ad3d1e8d1f8537b741686d21145 (patch)
tree6c23a8df356d38657212c8b133ab47f774815a74 /tests/ptrace.c
parentd4ee5d43b199ef73e60718440c9391283385ff56 (diff)
downloadstrace-bf6fc7290f479ad3d1e8d1f8537b741686d21145.tar.gz
printsiginfo: decode si_syscall field using syscall_name_arch
It was subtly broken all this time as si_arch may be not equivalent to strace's current personality's audit arch: this may well happen when siginfo_t is decoded as an argument (like in ptrace(PTRACE_SETSIGINFO)), as the author of the comment in v4.21~43 should have definitely known. * src/printsiginfo.c: Remove "nr_prefix.c" include. [HAVE_SIGINFO_T_SI_SYSCALL] (print_si_syscall): Remove. (print_si_info): Use PRINT_SYSCALL_NAME for si_syscall field printing. * tests/ptrace.c: Update expected output, add checks for the cases when {CUR,PERS0,M32,MX32}_AUDIT_ARCH are defined. * src/linux/generic/nr_prefix.c [!HAVE_SIGINFO_T_SI_SYSCALL && !PERSONALITY0_AUDIT_ARCH] (nr_prefix): Do not provide the function. * NEWS: Mention it.
Diffstat (limited to 'tests/ptrace.c')
-rw-r--r--tests/ptrace.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/tests/ptrace.c b/tests/ptrace.c
index 8c98219c6..46415d444 100644
--- a/tests/ptrace.c
+++ b/tests/ptrace.c
@@ -25,6 +25,14 @@
#include <sys/uio.h>
#include <sys/user.h>
+#include "cur_audit_arch.h"
+
+#include "xlat.h"
+#define XLAT_MACROS_ONLY
+# include "xlat/elf_em.h"
+#undef XLAT_MACROS_ONLY
+#include "xlat/audit_arch.h"
+
static const char *errstr;
static long
@@ -1735,9 +1743,62 @@ main(void)
do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
printf("ptrace(PTRACE_SETSIGINFO, %d, %#lx, {si_signo=SIGSYS"
", si_code=SYS_SECCOMP, si_errno=%u, si_call_addr=NULL"
- ", si_syscall=__NR_read, si_arch=%#x /* AUDIT_ARCH_??? */})"
+ ", si_syscall=%u, si_arch=%#x /* AUDIT_ARCH_??? */})"
" = %s\n",
- pid, bad_request, sip->si_errno, sip->si_arch, errstr);
+ pid, bad_request, sip->si_errno, sip->si_syscall, sip->si_arch,
+ errstr);
+
+# ifdef CUR_AUDIT_ARCH
+ sip->si_arch = CUR_AUDIT_ARCH;
+
+ do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
+ printf("ptrace(PTRACE_SETSIGINFO, %d, %#lx, {si_signo=SIGSYS"
+ ", si_code=SYS_SECCOMP, si_errno=%u, si_call_addr=NULL"
+ ", si_syscall=__NR_read, si_arch=%s"
+ "}) = %s\n",
+ pid, bad_request, sip->si_errno,
+ sprintxval(audit_arch, CUR_AUDIT_ARCH, "AUDIT_ARCH_???"),
+ errstr);
+# endif
+# if defined(PERS0_AUDIT_ARCH)
+ sip->si_arch = PERS0_AUDIT_ARCH;
+ sip->si_syscall = PERS0__NR_gettid;
+
+ do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
+ printf("ptrace(PTRACE_SETSIGINFO, %d, %#lx, {si_signo=SIGSYS"
+ ", si_code=SYS_SECCOMP, si_errno=%u, si_call_addr=NULL"
+ ", si_syscall=%u /* gettid */, si_arch=%s"
+ "}) = %s\n",
+ pid, bad_request, sip->si_errno, PERS0__NR_gettid,
+ sprintxval(audit_arch, PERS0_AUDIT_ARCH, "AUDIT_ARCH_???"),
+ errstr);
+# endif
+# if defined(M32_AUDIT_ARCH)
+ sip->si_arch = M32_AUDIT_ARCH;
+ sip->si_syscall = M32__NR_gettid;
+
+ do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
+ printf("ptrace(PTRACE_SETSIGINFO, %d, %#lx, {si_signo=SIGSYS"
+ ", si_code=SYS_SECCOMP, si_errno=%u, si_call_addr=NULL"
+ ", si_syscall=%u /* gettid */, si_arch=%s"
+ "}) = %s\n",
+ pid, bad_request, sip->si_errno, M32__NR_gettid,
+ sprintxval(audit_arch, M32_AUDIT_ARCH, "AUDIT_ARCH_???"),
+ errstr);
+# endif
+# if defined(MX32_AUDIT_ARCH)
+ sip->si_arch = MX32_AUDIT_ARCH;
+ sip->si_syscall = MX32__NR_gettid;
+
+ do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
+ printf("ptrace(PTRACE_SETSIGINFO, %d, %#lx, {si_signo=SIGSYS"
+ ", si_code=SYS_SECCOMP, si_errno=%u, si_call_addr=NULL"
+ ", si_syscall=%u /* gettid */, si_arch=%s"
+ "}) = %s\n",
+ pid, bad_request, sip->si_errno, MX32__NR_gettid,
+ sprintxval(audit_arch, MX32_AUDIT_ARCH, "AUDIT_ARCH_???"),
+ errstr);
+# endif
#endif
#if defined HAVE_SIGINFO_T_SI_TIMERID && defined HAVE_SIGINFO_T_SI_OVERRUN