Commit 6308191f authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar

tracing, sched, vfs: Fix 'old_pid' usage in trace_sched_process_exec()

1. TRACE_EVENT(sched_process_exec) forgets to actually use the
   old pid argument, it sets ->old_pid = p->pid.

2. search_binary_handler() uses the wrong pid number. tracepoint
   needs the global pid_t from the root namespace, while old_pid
   is the virtual pid number as it seen by the tracer/parent.

With this patch we have two pid_t's in search_binary_handler(),
not really nice. Perhaps we should switch to "struct pid*", but
in this case it would be better to cleanup the current code
first and move the "depth == 0" code outside.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: David Smith <dsmith@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Link: http://lkml.kernel.org/r/20120330162636.GA4857@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 8ebfdf2b
...@@ -1370,7 +1370,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) ...@@ -1370,7 +1370,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
unsigned int depth = bprm->recursion_depth; unsigned int depth = bprm->recursion_depth;
int try,retval; int try,retval;
struct linux_binfmt *fmt; struct linux_binfmt *fmt;
pid_t old_pid; pid_t old_pid, old_vpid;
retval = security_bprm_check(bprm); retval = security_bprm_check(bprm);
if (retval) if (retval)
...@@ -1381,8 +1381,9 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) ...@@ -1381,8 +1381,9 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
return retval; return retval;
/* Need to fetch pid before load_binary changes it */ /* Need to fetch pid before load_binary changes it */
old_pid = current->pid;
rcu_read_lock(); rcu_read_lock();
old_pid = task_pid_nr_ns(current, task_active_pid_ns(current->parent)); old_vpid = task_pid_nr_ns(current, task_active_pid_ns(current->parent));
rcu_read_unlock(); rcu_read_unlock();
retval = -ENOENT; retval = -ENOENT;
...@@ -1405,7 +1406,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) ...@@ -1405,7 +1406,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
if (retval >= 0) { if (retval >= 0) {
if (depth == 0) { if (depth == 0) {
trace_sched_process_exec(current, old_pid, bprm); trace_sched_process_exec(current, old_pid, bprm);
ptrace_event(PTRACE_EVENT_EXEC, old_pid); ptrace_event(PTRACE_EVENT_EXEC, old_vpid);
} }
put_binfmt(fmt); put_binfmt(fmt);
allow_write_access(bprm->file); allow_write_access(bprm->file);
......
...@@ -295,7 +295,7 @@ TRACE_EVENT(sched_process_exec, ...@@ -295,7 +295,7 @@ TRACE_EVENT(sched_process_exec,
TP_fast_assign( TP_fast_assign(
__assign_str(filename, bprm->filename); __assign_str(filename, bprm->filename);
__entry->pid = p->pid; __entry->pid = p->pid;
__entry->old_pid = p->pid; __entry->old_pid = old_pid;
), ),
TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename), TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment