From: Pedro Alves <pedro@codesourcery.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>,
Oleg Nesterov <oleg@redhat.com>, Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] Make PTRACE_SEIZE set ptrace options specified in 'data'
Date: Sat, 10 Sep 2011 16:36:36 +0100 [thread overview]
Message-ID: <201109101636.37007.pedro@codesourcery.com> (raw)
In-Reply-To: <201109101312.39256.pedro@codesourcery.com>
On Saturday 10 September 2011 13:12:38, Pedro Alves wrote:
> (just-options-on-SEIZE scares me in terms of future expansion,
> as it assumes only bitflags will ever be necessary.)
The more I think of this, the more I think we could do this
some other way --- why don't we allow setting the default
options _on the ptracer_, and then tracee's inherit those
options from the ptracer-set-of-default-options if their
parent is not currently ptraced by own tracer? That is, you'd make
the ptracer set options on itself:
options = PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACECLONE|FORK|VFORK|EXEC ...;
ptrace(PTRACE_SETOPTIONS, gettid(), 0, options);
And then, in all of
ptrace(PTRACE_ATTACH, foo_pid, 0, 0);
ptrace(PTRACE_TRACEME, 0, 0, 0);
ptrace(PTRACE_SEIZE, foo_pid, 0, 0);
you'd end up with the tracee already with your chosen options set.
Clones, vforks and forks that are auto-attached would still inherit their
options from their parent, just like today.
Some pro points:
- works for PTRACE_ATTACH AND PTRACE_TRACEME too.
- most ptracers on earth will only need to set options once.
- backwards compatible. The "default ptrace options" default
to 0, so old tracers on new kernels will still behave the same.
- future proof. If some other PTRACE_SET_NEAT_OPTION ptrace
command appears in the future, we can make it work the same
way, instead of getting stuck with PTRACE_SEIZE's `data'
already being taken...
- if ptrace(PTRACE_SETOPTIONS, gettid(), 0, 0) works, then
we can stop gdb (and probably other tracers) from forking a new
child just to check if PTRACE_O_TRACEFOO works before actually
attaching/spawning the process of interest.
(see code around linux_supports_tracefork_flag at
<http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/linux-nat.c?rev=1.215&content-type=text/x-cvsweb-markup&cvsroot=src>)
Cons:
- is there any real con?
Note the default ptrace options would _not_ conflict with
the ptracer's own ptrace options in case the ptracer itself
is being ptraced.
WDYT?
--
Pedro Alves
next prev parent reply other threads:[~2011-09-10 15:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-08 18:22 [PATCH v3] Make PTRACE_SEIZE set ptrace options specified in 'data' Denys Vlasenko
2011-09-08 19:24 ` Oleg Nesterov
2011-09-09 11:12 ` Pedro Alves
2011-09-09 12:28 ` Denys Vlasenko
2011-09-09 13:15 ` Pedro Alves
2011-09-09 16:30 ` Oleg Nesterov
2011-09-09 16:55 ` Denys Vlasenko
2011-09-09 17:09 ` Pedro Alves
2011-09-09 17:18 ` Oleg Nesterov
2011-09-09 20:03 ` Denys Vlasenko
2011-09-10 11:19 ` Pedro Alves
2011-09-10 11:40 ` Denys Vlasenko
2011-09-10 12:12 ` Pedro Alves
2011-09-10 15:36 ` Pedro Alves [this message]
2011-09-13 7:45 ` Indan Zupancic
2011-09-13 8:04 ` Indan Zupancic
2011-09-10 23:34 ` Tejun Heo
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=201109101636.37007.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=dvlasenk@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=tj@kernel.org \
--cc=vda.linux@googlemail.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.
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).