From 86d073674efd148fbc454d0b646619d8e6c66bde Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 21 Nov 2018 01:44:16 +0000 Subject: [PATCH] Add definitions for PTRACE_GET_SYSCALL_INFO API Provide fallback definitions for PTRACE_GET_SYSCALL_INFO API. Add very basic PTRACE_GET_SYSCALL_INFO support in the parser of ptrace syscall. * ptrace.h: Include . [!PTRACE_GET_SYSCALL_INFO] (PTRACE_GET_SYSCALL_INFO, PTRACE_SYSCALL_INFO_NONE, PTRACE_SYSCALL_INFO_ENTRY, PTRACE_SYSCALL_INFO_EXIT, PTRACE_SYSCALL_INFO_SECCOMP, struct ptrace_syscall_info): Define. * xlat/ptrace_cmds.in: Add PTRACE_GET_SYSCALL_INFO. * process.c (SYS_FUNC(ptrace)): Handle it. --- process.c | 1 + ptrace.h | 30 ++++++++++++++++++++++++++++++ xlat/ptrace_cmds.in | 1 + 3 files changed, 32 insertions(+) diff --git a/process.c b/process.c index 562921d7..04b2a114 100644 --- a/process.c +++ b/process.c @@ -111,6 +111,7 @@ SYS_FUNC(ptrace) case PTRACE_SETSIGMASK: case PTRACE_SECCOMP_GET_FILTER: case PTRACE_SECCOMP_GET_METADATA: + case PTRACE_GET_SYSCALL_INFO: tprintf(", %" PRI_klu, addr); break; case PTRACE_PEEKSIGINFO: { diff --git a/ptrace.h b/ptrace.h index fe3d8b96..89d4b95d 100644 --- a/ptrace.h +++ b/ptrace.h @@ -17,6 +17,7 @@ #ifndef STRACE_PTRACE_H #define STRACE_PTRACE_H +#include #include #ifdef HAVE_STRUCT_IA64_FPREG @@ -155,6 +156,35 @@ #ifndef PTRACE_SECCOMP_GET_METADATA # define PTRACE_SECCOMP_GET_METADATA 0x420d #endif +#ifndef PTRACE_GET_SYSCALL_INFO +# define PTRACE_GET_SYSCALL_INFO 0x420e +# define PTRACE_SYSCALL_INFO_NONE 0 +# define PTRACE_SYSCALL_INFO_ENTRY 1 +# define PTRACE_SYSCALL_INFO_EXIT 2 +# define PTRACE_SYSCALL_INFO_SECCOMP 3 +struct ptrace_syscall_info { + uint8_t op; + uint8_t pad[3]; + uint32_t arch; + uint64_t instruction_pointer; + uint64_t stack_pointer; + union { + struct { + uint64_t nr; + uint64_t args[6]; + } entry; + struct { + int64_t rval; + uint8_t is_error; + } exit; + struct { + uint64_t nr; + uint64_t args[6]; + uint32_t ret_data; + } seccomp; + }; +}; +#endif #if !HAVE_DECL_PTRACE_PEEKUSER # define PTRACE_PEEKUSER PTRACE_PEEKUSR diff --git a/xlat/ptrace_cmds.in b/xlat/ptrace_cmds.in index da7030d4..3840f346 100644 --- a/xlat/ptrace_cmds.in +++ b/xlat/ptrace_cmds.in @@ -34,6 +34,7 @@ PTRACE_GETSIGMASK PTRACE_SETSIGMASK PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_METADATA +PTRACE_GET_SYSCALL_INFO /* arch-specific */ PTRACE_GET_THREAD_AREA PTRACE_SET_THREAD_AREA -- 2.40.0