mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH 0/6] updates for linux v5.3
Date: Sun, 10 Nov 2019 13:02:53 +0100	[thread overview]
Message-ID: <20191110120253.GD25646@port70.net> (raw)
In-Reply-To: <20191110061409.GM16318@brightrain.aerifal.cx>

* Rich Felker <dalias@libc.org> [2019-11-10 01:14:09 -0500]:
> On Sun, Nov 10, 2019 at 02:08:02AM +0100, Szabolcs Nagy wrote:
> > >From 560fd1ebe616fd59c0abcaf86bec6109bfcd2141 Mon Sep 17 00:00:00 2001
> > From: Szabolcs Nagy <nsz@port70.net>
> > 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
> > 
> > the align attribute was used to keep the layout the same across targets
> > e.g. on m68k uint32_t is 2 byte aligned, this helps with compat ptrace.
> 
> Can you explain the motivation for this? At first I thought it was for
> overall alignment of the structure, but there are also 64-bit members
> that aren't aligned, so presumably this is only to get padding after
> the initial uint8_t? If so, just add 3 explicit padding members:

the original linux struct had padding but during
review they changed it to aligned because some
linux devs thought that made the intent clearer
or more future proof (e.g. what if uint64_t is
also 2byte aligned, but on the 64bit version of
the same architecture it's 8byte aligned, then
compat ptrace would not work because one abi
would have padding and the other wouldnt).

i guess for musl either works, but the current
struct is how it is defined in glibc.

> >  struct __ptrace_peeksiginfo_args {
> > @@ -101,6 +107,28 @@ struct __ptrace_seccomp_metadata {
> >  	uint64_t flags;
> >  };
> >  
> > +struct __ptrace_syscall_info {
> > +	uint8_t op;
> 
> Like uint8_t op, __pad[3];
> 
> > +	uint32_t arch __attribute__((__aligned__(4)));
> > +	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, ...);
> 
> Otherwise, the API having reserved-namespace struct names is ugly but
> it seems this is nothing new...

glibc started using this style (i guess not to conflict
with linux uapi, which is often included when ptrace is
used: strace, gdb,..)


  reply	other threads:[~2019-11-10 12:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-10  1:08 Szabolcs Nagy
2019-11-10  6:14 ` Rich Felker
2019-11-10 12:02   ` Szabolcs Nagy [this message]
2019-11-12  3:01     ` Rich Felker
2019-11-12  5:16       ` Markus Wichmann
2019-11-12 11:16       ` Szabolcs Nagy
2019-11-12 16:34         ` Rich Felker
2019-11-12 17:05           ` Szabolcs Nagy
2019-11-13  0:06           ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191110120253.GD25646@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).