perf_events: fix invalid pointer when pid is invalid
PATCH 1/1 perf_events: fix invalid pointer when pid is invalid
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.
---
kernel/perf_event.c +6 -1
@@ -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):
[tip:perf/core] perf_events: Fix invalid pointer when pid is invalid
Commit-ID: 540804b5c52065a87d826f7714b18a3ec0b269f9 Gitweb: http://git.kernel.org/tip/540804b5c52065a87d826f7714b18a3ec0b269f9 Author: Stephane Eranian <[email protected]> AuthorDate: Mon, 4 Oct 2010 12:00:02 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 4 Oct 2010 12:47:20 +0200
perf_events: Fix invalid pointer when pid is invalid
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.
LKML-Reference: <[email protected]>
--- kernel/perf_event.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/perf_event.c +6 -1
@@ -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):