aboutsummaryrefslogtreecommitdiff
path: root/include/linux/perf_event.h
diff options
context:
space:
mode:
authorJohn Dias <joaodias@google.com>2016-10-10 14:44:30 -0700
committerMister Oyster <oysterized@gmail.com>2017-04-11 10:59:44 +0200
commit0fa18f53a9d4b875c1033507b08f8677caaad7ef (patch)
treead94d6b1944d4f55f760e9f212e3c257fb86a314 /include/linux/perf_event.h
parent4b9e26df11bcd4c4c132406f09f17111a0016d4a (diff)
perf: protect group_leader from races that cause ctx double-free
When moving a group_leader perf event from a software-context to a hardware-context, there's a race in checking and updating that context. The existing locking solution doesn't work; note that it tries to grab a lock inside the group_leader's context object, which you can only get at by going through a pointer that should be protected from these races. To avoid that problem, and to produce a simple solution, we can just use a lock per group_leader to protect all checks on the group_leader's context. The new lock is grabbed and released when no context locks are held. Bug: 30955111 Bug: 31095224 Change-Id: If37124c100ca6f4aa962559fba3bd5dbbec8e052
Diffstat (limited to 'include/linux/perf_event.h')
-rw-r--r--include/linux/perf_event.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index c71d6de2d..f9715158f 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -314,6 +314,12 @@ struct perf_event {
int nr_siblings;
int group_flags;
struct perf_event *group_leader;
+
+ /*
+ * Protect the pmu, attributes and context of a group leader.
+ * Note: does not protect the pointer to the group_leader.
+ */
+ struct mutex group_leader_mutex;
struct pmu *pmu;
enum perf_event_active_state state;