[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-ccd41c86ad4d464d0ed4e48d80759ff85c2115b0@git.kernel.org>
Date: Fri, 27 Mar 2015 04:46:26 -0700
From: tip-bot for Peter Zijlstra <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: tglx@...utronix.de, sasha.levin@...cle.com,
linux-kernel@...r.kernel.org, peterz@...radead.org, hpa@...or.com,
jolsa@...hat.com, mingo@...nel.org, vincent.weaver@...ne.edu
Subject: [tip:perf/core] perf: Fix racy group access
Commit-ID: ccd41c86ad4d464d0ed4e48d80759ff85c2115b0
Gitweb: http://git.kernel.org/tip/ccd41c86ad4d464d0ed4e48d80759ff85c2115b0
Author: Peter Zijlstra <peterz@...radead.org>
AuthorDate: Wed, 25 Feb 2015 15:56:04 +0100
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Fri, 27 Mar 2015 09:49:45 +0100
perf: Fix racy group access
While looking at some fuzzer output I noticed that we do not hold any
locks on leader->ctx and therefore the sibling_list iteration is
unsafe.
Acquire the relevant ctx->mutex before calling into the pmu specific
code.
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Vince Weaver <vincent.weaver@...ne.edu>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Sasha Levin <sasha.levin@...cle.com>
Link: http://lkml.kernel.org/r/20150225151639.GL5029@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/events/core.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index b01dfb6..bb1a7c3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7036,12 +7036,23 @@ EXPORT_SYMBOL_GPL(perf_pmu_unregister);
static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
{
+ struct perf_event_context *ctx = NULL;
int ret;
if (!try_module_get(pmu->module))
return -ENODEV;
+
+ if (event->group_leader != event) {
+ ctx = perf_event_ctx_lock(event->group_leader);
+ BUG_ON(!ctx);
+ }
+
event->pmu = pmu;
ret = pmu->event_init(event);
+
+ if (ctx)
+ perf_event_ctx_unlock(event->group_leader, ctx);
+
if (ret)
module_put(pmu->module);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists