[PATCH 4.19 01/57] perf event: Check ref_reloc_sym before using it
Greg Kroah-Hartman
gregkh at linuxfoundation.org
Tue Dec 1 03:53:06 EST 2020
From: Igor Lubashev <ilubashe at akamai.com>
commit e9a6882f267a8105461066e3ea6b4b6b9be1b807 upstream.
Check for ref_reloc_sym before using it instead of checking
symbol_conf.kptr_restrict and relying solely on that check.
Reported-by: Mathieu Poirier <mathieu.poirier at linaro.org>
Signed-off-by: Igor Lubashev <ilubashe at akamai.com>
Tested-by: Mathieu Poirier <mathieu.poirier at linaro.org>
Cc: Alexander Shishkin <alexander.shishkin at linux.intel.com>
Cc: Alexey Budankov <alexey.budankov at linux.intel.com>
Cc: James Morris <jmorris at namei.org>
Cc: Jiri Olsa <jolsa at kernel.org>
Cc: Namhyung Kim <namhyung at kernel.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose at arm.com>
Cc: linux-arm-kernel at lists.infradead.org
Link: http://lkml.kernel.org/r/1566869956-7154-2-git-send-email-ilubashe@akamai.com
Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>
Cc: Alexander Dahl <ada at thorsis.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
tools/perf/util/event.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -912,11 +912,13 @@ static int __perf_event__synthesize_kern
int err;
union perf_event *event;
- if (symbol_conf.kptr_restrict)
- return -1;
if (map == NULL)
return -1;
+ kmap = map__kmap(map);
+ if (!kmap->ref_reloc_sym)
+ return -1;
+
/*
* We should get this from /sys/kernel/sections/.text, but till that is
* available use this, and after it is use this as a fallback for older
@@ -939,7 +941,6 @@ static int __perf_event__synthesize_kern
event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
}
- kmap = map__kmap(map);
size = snprintf(event->mmap.filename, sizeof(event->mmap.filename),
"%s%s", machine->mmap_name, kmap->ref_reloc_sym->name) + 1;
size = PERF_ALIGN(size, sizeof(u64));
More information about the linux-arm-kernel
mailing list