From: Andy Lutomirski <luto@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
"Anvin, H. Peter" <hpa@zytor.com>,
lttng-dev <lttng-dev@lists.lttng.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Compat syscall instrumentation and return from execve issue
Date: Mon, 9 Nov 2015 11:29:10 -0800 [thread overview]
Message-ID: <5640F406.3020207@kernel.org> (raw)
In-Reply-To: <20151109110536.7bce67e8@gandalf.local.home>
On 11/09/2015 08:05 AM, Steven Rostedt wrote:
> On Sun, 8 Nov 2015 19:37:37 +0000 (UTC)
> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>
>> I have a few ideas on how to overcome this, and would like your
>> feedback on the matter:
>>
>> 1) One possible approach would be to reserve an extra status flag
>> in struct thread_info to get the TS_COMPAT status at syscall
>> entry. It would _not_ be updated when the executable is loaded,
>> so the state at return from execve would match the state when
>> entering execve. This is a simple approach, but requires kernel
>> changes.
>
> Or add a flag TS_EXECVE that can be set by the tracepoint syscall
> enter, and checked on exit. If set, we know that the exec happened.
>
>>
>> 2) Keep the compat state at system call entry in a data structure
>> (e.g. hash table) indexed by thread number within each tracer.
>> This could work around this issue within each tracer.
>
> This is of course what you can do now. As it doesn't touch the kernel.
>
>>
>> 3) Change the syscall number in the struct pt_regs whenever we
>> change the compat mode of a process. A 64-bit execve system
>> call number would be mapped to a 32-bit compat execve number,
>> or the opposite. This requires a kernel change, and seems to be
>> rather intrusive.
>>
>
> This is a definite no.
>
>
> I'm thinking the TS_EXECVE flag would be the least intrusive. Add a
> comment that it is used by tracepoints to map between compat and
> non-compat syscalls when execve switches the flag. This would not need
> to touch any of the logic of the hotpaths within the systemcalls
> themselves.
Let's make it really simple: add an 'unsigned int arch' to
syscall_return_slowpath. As of last week, Linus' tree sends all compat
returns, without exception (except brand new children, depending on your
point of view), through that path, and the caller always knows the
architecture.
But keep in mind that any games you play here are going to get
completely and utterly screwed up if anyone is playing with ptrace to
change syscall numbers. You'd also going to have problems with syscall
restart, sigreturn, etc, so it would be nice to have an argument that
the putative solution solves the problem for real instead of just adding
complexity to paper it over.
Meanwhile, I'm trying to remove all of the magic from the handling of
execve, and I'm half-way there. Let's please not add more, especially
if that magic needs to touch asm code.
--Andy
next prev parent reply other threads:[~2015-11-09 19:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-08 19:37 Compat syscall instrumentation and return from execve issue Mathieu Desnoyers
2015-11-09 16:05 ` Steven Rostedt
2015-11-09 19:29 ` Andy Lutomirski [this message]
2015-11-09 19:43 ` Steven Rostedt
2015-11-09 20:57 ` Andy Lutomirski
2015-11-09 21:12 ` Steven Rostedt
2015-11-10 1:39 ` Mathieu Desnoyers
2015-11-10 1:51 ` Andy Lutomirski
2015-11-10 2:31 ` Steven Rostedt
2015-11-12 1:08 ` Andy Lutomirski
2015-11-18 14:57 ` Mathieu Desnoyers
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=5640F406.3020207@kernel.org \
--to=luto@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lttng-dev@lists.lttng.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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.
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).