From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14936 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 0/6] updates for linux v5.3 Date: Wed, 13 Nov 2019 01:06:27 +0100 Message-ID: <20191113000626.GK25646@port70.net> References: <20191110010802.GC25646@port70.net> <20191110061409.GM16318@brightrain.aerifal.cx> <20191110120253.GD25646@port70.net> <20191112030150.GQ16318@brightrain.aerifal.cx> <20191112111606.GE25646@port70.net> <20191112163446.GR16318@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="3lcZGd9BuhuYXNfi" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="143900"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-14952-gllmg-musl=m.gmane.org@lists.openwall.com Wed Nov 13 01:06:41 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iUgBF-000bKC-PP for gllmg-musl@m.gmane.org; Wed, 13 Nov 2019 01:06:41 +0100 Original-Received: (qmail 2019 invoked by uid 550); 13 Nov 2019 00:06:39 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 2001 invoked from network); 13 Nov 2019 00:06:38 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20191112163446.GR16318@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:14936 Archived-At: --3lcZGd9BuhuYXNfi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline v2 with padding. --3lcZGd9BuhuYXNfi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0004-sys-ptrace.h-add-PTRACE_GET_SYSCALL_INFO-from-linux-.patch" >From 846dd904a3f8b120794bcf1972c8ccbcf3def12f Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 3 Nov 2019 22:45:05 +0000 Subject: [PATCH 4/6] sys/ptrace.h: add PTRACE_GET_SYSCALL_INFO from linux v5.3 ptrace API to get details of the syscall the tracee is blocked in, see linux commit 201766a20e30f982ccfe36bebfad9602c3ff574a ptrace: add PTRACE_GET_SYSCALL_INFO request compared to the linux uapi (and glibc) a padding is used instead of aligned attribute for keeping the layout the same across targets, this means the alignment of the struct may be different on some targets (e.g. m68k where uint64_t is 2 byte aligned) but that should not affect syscalls and this way the abi does not depend on nonstandard extensions. --- include/sys/ptrace.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/sys/ptrace.h b/include/sys/ptrace.h index 229e1f3d..5d62a985 100644 --- a/include/sys/ptrace.h +++ b/include/sys/ptrace.h @@ -41,6 +41,7 @@ extern "C" { #define PTRACE_SETSIGMASK 0x420b #define PTRACE_SECCOMP_GET_FILTER 0x420c #define PTRACE_SECCOMP_GET_METADATA 0x420d +#define PTRACE_GET_SYSCALL_INFO 0x420e #define PT_READ_I PTRACE_PEEKTEXT #define PT_READ_D PTRACE_PEEKDATA @@ -88,6 +89,11 @@ extern "C" { #define PTRACE_PEEKSIGINFO_SHARED 1 +#define PTRACE_SYSCALL_INFO_NONE 0 +#define PTRACE_SYSCALL_INFO_ENTRY 1 +#define PTRACE_SYSCALL_INFO_EXIT 2 +#define PTRACE_SYSCALL_INFO_SECCOMP 3 + #include struct __ptrace_peeksiginfo_args { @@ -101,6 +107,29 @@ struct __ptrace_seccomp_metadata { uint64_t flags; }; +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; + }; +}; + long ptrace(int, ...); #ifdef __cplusplus -- 2.23.0 --3lcZGd9BuhuYXNfi--