summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAmulya Y <ayarlagadda@nvidia.com>2018-04-06 15:42:31 -0700
committerWinnie Hsu <whsu@nvidia.com>2018-04-19 10:58:33 -0700
commitac43b10b632fac3412f18100e463e2129318bd3a (patch)
tree2820113616dc252ba2abbaeb6789c57d95fad595 /kernel
parent6b8d6d331daaa7d2118fdd61eac514363e0625e7 (diff)
perf: Fix race in swevent hash
There's a race on CPU unplug where we free the swevent hash array while it can still have events on. This will result in a use-after-free which is BAD. Simply do not free the hash array on unplug. This leaves the thing around and no use-after-free takes place. When the last swevent dies, we do a for_each_possible_cpu() iteration anyway to clean these up, at which time we'll free it, so no leakage will occur. Bug 1823317 But 1935735 Change-Id: I309528873f8576f96663afbe51ce2739934df16c Reported-by: Sasha Levin <sasha.levin@oracle.com> Tested-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Gagan Grover <ggrover@nvidia.com> Signed-off-by: Amulya Yarlagadda <ayarlagadda@nvidia.com> Reviewed-on: http://git-master/r/1259934 (cherry picked from commit 5ea640855404df656d94bfa3990d8eba2b5f90f9) Reviewed-on: https://git-master.nvidia.com/r/1690284 GVS: Gerrit_Virtual_Submit Reviewed-by: Bibek Basu <bbasu@nvidia.com> Reviewed-by: Winnie Hsu <whsu@nvidia.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/core.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f8eb2b154bdb..be3b4cc87eeb 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7450,13 +7450,7 @@ static void perf_event_exit_cpu_context(int cpu)
static void perf_event_exit_cpu(int cpu)
{
- struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
-
perf_event_exit_cpu_context(cpu);
-
- mutex_lock(&swhash->hlist_mutex);
- swevent_hlist_release(swhash);
- mutex_unlock(&swhash->hlist_mutex);
}
#else
static inline void perf_event_exit_cpu(int cpu) { }