[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-7f635ff187ab6be0b350b3ec06791e376af238ab@git.kernel.org>
Date: Wed, 25 Jul 2018 07:31:23 -0700
From: tip-bot for Mathieu Poirier <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, vincent.weaver@...ne.edu,
mingo@...nel.org, peterz@...radead.org, hpa@...or.com,
acme@...hat.com, mathieu.poirier@...aro.org, tglx@...utronix.de,
alexander.shishkin@...ux.intel.com, eranian@...gle.com,
jolsa@...hat.com, torvalds@...ux-foundation.org
Subject: [tip:perf/core] perf/core: Fix crash when using HW tracing kernel
filters
Commit-ID: 7f635ff187ab6be0b350b3ec06791e376af238ab
Gitweb: https://git.kernel.org/tip/7f635ff187ab6be0b350b3ec06791e376af238ab
Author: Mathieu Poirier <mathieu.poirier@...aro.org>
AuthorDate: Mon, 16 Jul 2018 17:13:51 -0600
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 25 Jul 2018 11:46:22 +0200
perf/core: Fix crash when using HW tracing kernel filters
In function perf_event_parse_addr_filter(), the path::dentry of each struct
perf_addr_filter is left unassigned (as it should be) when the pattern
being parsed is related to kernel space. But in function
perf_addr_filter_match() the same dentries are given to d_inode() where
the value is not expected to be NULL, resulting in the following splat:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000058
pc : perf_event_mmap+0x2fc/0x5a0
lr : perf_event_mmap+0x2c8/0x5a0
Process uname (pid: 2860, stack limit = 0x000000001cbcca37)
Call trace:
perf_event_mmap+0x2fc/0x5a0
mmap_region+0x124/0x570
do_mmap+0x344/0x4f8
vm_mmap_pgoff+0xe4/0x110
vm_mmap+0x2c/0x40
elf_map+0x60/0x108
load_elf_binary+0x450/0x12c4
search_binary_handler+0x90/0x290
__do_execve_file.isra.13+0x6e4/0x858
sys_execve+0x3c/0x50
el0_svc_naked+0x30/0x34
This patch is fixing the problem by introducing a new check in function
perf_addr_filter_match() to see if the filter's dentry is NULL.
Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Acked-by: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Vince Weaver <vincent.weaver@...ne.edu>
Cc: acme@...nel.org
Cc: miklos@...redi.hu
Cc: namhyung@...nel.org
Cc: songliubraving@...com
Fixes: 9511bce9fe8e ("perf/core: Fix bad use of igrab()")
Link: http://lkml.kernel.org/r/1531782831-1186-1-git-send-email-mathieu.poirier@linaro.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/events/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index cdb32cf8e33c..eec2d5fb676b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7337,6 +7337,10 @@ static bool perf_addr_filter_match(struct perf_addr_filter *filter,
struct file *file, unsigned long offset,
unsigned long size)
{
+ /* d_inode(NULL) won't be equal to any mapped user-space file */
+ if (!filter->path.dentry)
+ return false;
+
if (d_inode(filter->path.dentry) != file_inode(file))
return false;
Powered by blists - more mailing lists