Skip to content

Commit

Permalink
perf_events: Fix invalid pointer when pid is invalid
Browse files Browse the repository at this point in the history
This patch fixes an error in perf_event_open() when the pid
provided by the user is invalid. find_lively_task_by_vpid()
does not return NULL on error but an error code. Without the
fix the error code was silently passed to find_get_context()
which would eventually cause a invalid pointer dereference.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: paulus@samba.org
Cc: davem@davemloft.net
Cc: fweisbec@gmail.com
Cc: perfmon2-devel@lists.sf.net
Cc: eranian@gmail.com
Cc: robert.richter@amd.com
LKML-Reference: <4ca9a5d1.e8e9d80a.3dbb.ffff8f2e@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Oct 4, 2010
1 parent d6dad19 commit 540804b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5616,8 +5616,13 @@ SYSCALL_DEFINE5(perf_event_open,
}
}

if (pid != -1)
if (pid != -1) {
task = find_lively_task_by_vpid(pid);
if (IS_ERR(task)) {
err = PTR_ERR(task);
goto err_group_fd;
}
}

/*
* Get the target context (task or percpu):
Expand Down

0 comments on commit 540804b

Please sign in to comment.