From: Oleg Nesterov <oleg@redhat.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptrace: make former thread ID available via PTRACE_GETEVENTMSG after PTRACE_EVENT_EXEC stop (v.2)
Date: Sun, 26 Jun 2011 22:04:42 +0200 [thread overview]
Message-ID: <20110626200442.GA16293@redhat.com> (raw)
In-Reply-To: <201106262108.43011.vda.linux@googlemail.com>
On 06/26, Denys Vlasenko wrote:
>
> @@ -1366,13 +1366,22 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
> for (try=0; try<2; try++) {
> read_lock(&binfmt_lock);
> list_for_each_entry(fmt, &formats, lh) {
> - int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary;
> - if (!fn)
> + int (*load_binary)(struct linux_binprm *, struct pt_regs *);
> + pid_t old_pid = old_pid; /* for compiler */
we have uninitialized_var() for this,
pid_t uninitialized_var(old_pid);
> +
> + load_binary = fmt->load_binary;
> + if (!load_binary)
> continue;
> if (!try_module_get(fmt->module))
> continue;
> read_unlock(&binfmt_lock);
> - retval = fn(bprm, regs);
> + if (task_ptrace(current) & PT_PTRACED) {
May be PT_TRACE_EXEC makes more sense. Note that ptrace_event_enabled() was
recently added.
> + /* Need to fetch pid before load_binary changes it */
> + rcu_read_lock();
> + old_pid = task_pid_nr_ns(current, task_active_pid_ns(current->parent));
OK, this looks correct. But imho this code looks strange inside the
for (;;) loop. Perhaps it would be more clean to record the old pid
before.
Also, this line is too long. Personally I do not care, but I told you
we have the coding style police. Please use ./scripts/checkpatch.pl
> @@ -1381,7 +1390,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
> bprm->recursion_depth = depth;
> if (retval >= 0) {
> if (depth == 0)
> - tracehook_report_exec(fmt, bprm, regs);
> + tracehook_report_exec(fmt, bprm, regs, old_pid);
Heh, you are out of luck ;) This hook was already killed. Please redo
against git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git ptrace
Also, please update the changelog. It should clearly explain why do we
need this feature and what this patch does. The output from a test
program doesn't make too much sense unless you show the source code.
Oleg.
next prev parent reply other threads:[~2011-06-26 20:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-26 19:08 [PATCH] ptrace: make former thread ID available via PTRACE_GETEVENTMSG after PTRACE_EVENT_EXEC stop (v.2) Denys Vlasenko
2011-06-26 20:04 ` Oleg Nesterov [this message]
2011-06-27 8:11 ` Tejun Heo
2011-06-27 13:47 ` Oleg Nesterov
2011-06-27 13:52 ` Tejun Heo
2011-06-27 15:18 ` Oleg Nesterov
2011-06-28 8:25 ` Tejun Heo
2011-06-28 12:30 ` Denys Vlasenko
2011-06-28 12:38 ` Tejun Heo
2011-06-28 16:35 ` Oleg Nesterov
2011-06-28 16:49 ` Tejun Heo
2011-06-28 0:31 ` Denys Vlasenko
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=20110626200442.GA16293@redhat.com \
--to=oleg@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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