lkml.org 
[lkml]   [2011]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ptrace: make former thread ID available via PTRACE_GETEVENTMSG after PTRACE_EVENT_EXEC stop (v.2)
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.



\
 
 \ /
  Last update: 2011-06-26 22:13    [W:0.165 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site