From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, mingo@kernel.org, peterz@infradead.org,
hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org,
zheng.z.yan@intel.com, jolsa@redhat.com,
torvalds@linux-foundation.org, eranian@google.com,
stable@vger.kernel.org, jolsa@kernel.org, fweisbec@gmail.com,
vince@deater.net
Subject: [tip:perf/urgent] perf/x86/intel/uncore: Make sure only uncore events are collected
Date: Thu, 11 Dec 2014 04:25:23 -0800 [thread overview]
Message-ID: <tip-af91568e762d04931dcbdd6bef4655433d8b9418@git.kernel.org> (raw)
In-Reply-To: <1418243031-20367-2-git-send-email-jolsa@kernel.org>
Commit-ID: af91568e762d04931dcbdd6bef4655433d8b9418
Gitweb: http://git.kernel.org/tip/af91568e762d04931dcbdd6bef4655433d8b9418
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 10 Dec 2014 21:23:50 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 11 Dec 2014 11:24:14 +0100
perf/x86/intel/uncore: Make sure only uncore events are collected
The uncore_collect_events functions assumes that event group
might contain only uncore events which is wrong, because it
might contain any type of events.
This bug leads to uncore framework touching 'not' uncore events,
which could end up all sorts of bugs.
One was triggered by Vince's perf fuzzer, when the uncore code
touched breakpoint event private event space as if it was uncore
event and caused BUG:
BUG: unable to handle kernel paging request at ffffffff82822068
IP: [<ffffffff81020338>] uncore_assign_events+0x188/0x250
...
The code in uncore_assign_events() function was looking for
event->hw.idx data while the event was initialized as a
breakpoint with different members in event->hw union.
This patch forces uncore_collect_events() to collect only uncore
events.
Reported-by: Vince Weaver <vince@deater.net>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Yan, Zheng <zheng.z.yan@intel.com>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/1418243031-20367-2-git-send-email-jolsa@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 9762dbd..e98f68c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -276,6 +276,17 @@ static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,
return box;
}
+/*
+ * Using uncore_pmu_event_init pmu event_init callback
+ * as a detection point for uncore events.
+ */
+static int uncore_pmu_event_init(struct perf_event *event);
+
+static bool is_uncore_event(struct perf_event *event)
+{
+ return event->pmu->event_init == uncore_pmu_event_init;
+}
+
static int
uncore_collect_events(struct intel_uncore_box *box, struct perf_event *leader, bool dogrp)
{
@@ -290,13 +301,18 @@ uncore_collect_events(struct intel_uncore_box *box, struct perf_event *leader, b
return -EINVAL;
n = box->n_events;
- box->event_list[n] = leader;
- n++;
+
+ if (is_uncore_event(leader)) {
+ box->event_list[n] = leader;
+ n++;
+ }
+
if (!dogrp)
return n;
list_for_each_entry(event, &leader->sibling_list, group_entry) {
- if (event->state <= PERF_EVENT_STATE_OFF)
+ if (!is_uncore_event(event) ||
+ event->state <= PERF_EVENT_STATE_OFF)
continue;
if (n >= max_count)
next prev parent reply other threads:[~2014-12-11 12:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 20:23 [PATCHSET/RFC 0/2] perf: Fix issues reported by perf fuzzer Jiri Olsa
2014-12-10 20:23 ` [PATCH 1/2] perf/x86/intel/uncore: Make sure only uncore events are collected Jiri Olsa
2014-12-10 23:51 ` Andi Kleen
2014-12-11 12:25 ` tip-bot for Jiri Olsa [this message]
2014-12-10 20:23 ` [PATCH 2/2] perf: Fix events installation during moving group Jiri Olsa
2014-12-11 12:25 ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2014-12-11 10:26 ` [PATCHSET/RFC 0/2] perf: Fix issues reported by perf fuzzer Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-af91568e762d04931dcbdd6bef4655433d8b9418@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vince@deater.net \
--cc=zheng.z.yan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox