diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-03-30 12:26:36 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-03-31 05:53:22 -0400 |
commit | 6308191f6f55d3629c7dbe72dfb856ad9fa560fd (patch) | |
tree | d3f073b0e522fc7dbee52ca6c25d92f28059f2fd /fs/exec.c | |
parent | 8ebfdf2babcda5a3b06cc67523bca1f9aed46009 (diff) |
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: Oleg 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.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1370,7 +1370,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1370 | unsigned int depth = bprm->recursion_depth; | 1370 | unsigned int depth = bprm->recursion_depth; |
1371 | int try,retval; | 1371 | int try,retval; |
1372 | struct linux_binfmt *fmt; | 1372 | struct linux_binfmt *fmt; |
1373 | pid_t old_pid; | 1373 | pid_t old_pid, old_vpid; |
1374 | 1374 | ||
1375 | retval = security_bprm_check(bprm); | 1375 | retval = security_bprm_check(bprm); |
1376 | if (retval) | 1376 | if (retval) |
@@ -1381,8 +1381,9 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1381 | return retval; | 1381 | return retval; |
1382 | 1382 | ||
1383 | /* Need to fetch pid before load_binary changes it */ | 1383 | /* Need to fetch pid before load_binary changes it */ |
1384 | old_pid = current->pid; | ||
1384 | rcu_read_lock(); | 1385 | rcu_read_lock(); |
1385 | old_pid = task_pid_nr_ns(current, task_active_pid_ns(current->parent)); | 1386 | old_vpid = task_pid_nr_ns(current, task_active_pid_ns(current->parent)); |
1386 | rcu_read_unlock(); | 1387 | rcu_read_unlock(); |
1387 | 1388 | ||
1388 | retval = -ENOENT; | 1389 | retval = -ENOENT; |
@@ -1405,7 +1406,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) | |||
1405 | if (retval >= 0) { | 1406 | if (retval >= 0) { |
1406 | if (depth == 0) { | 1407 | if (depth == 0) { |
1407 | trace_sched_process_exec(current, old_pid, bprm); | 1408 | trace_sched_process_exec(current, old_pid, bprm); |
1408 | ptrace_event(PTRACE_EVENT_EXEC, old_pid); | 1409 | ptrace_event(PTRACE_EVENT_EXEC, old_vpid); |
1409 | } | 1410 | } |
1410 | put_binfmt(fmt); | 1411 | put_binfmt(fmt); |
1411 | allow_write_access(bprm->file); | 1412 | allow_write_access(bprm->file); |