Commit 540804b5c52065a87d826f7714b18a3ec0b269f9
Committed by
Ingo Molnar
1 parent
d6dad199a1
Exists in
master
and in
4 other branches
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. 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>
Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff
kernel/perf_event.c
... | ... | @@ -5616,8 +5616,13 @@ |
5616 | 5616 | } |
5617 | 5617 | } |
5618 | 5618 | |
5619 | - if (pid != -1) | |
5619 | + if (pid != -1) { | |
5620 | 5620 | task = find_lively_task_by_vpid(pid); |
5621 | + if (IS_ERR(task)) { | |
5622 | + err = PTR_ERR(task); | |
5623 | + goto err_group_fd; | |
5624 | + } | |
5625 | + } | |
5621 | 5626 | |
5622 | 5627 | /* |
5623 | 5628 | * Get the target context (task or percpu): |