diff options
author | Peter Zijlstra <peterz@infradead.org> | 2015-12-15 13:49:05 +0100 |
---|---|---|
committer | Andreas Blaesius <skate4life@gmx.de> | 2017-05-17 19:25:35 +0200 |
commit | 88d65c2b18f68f0001e647b94e6a576d931d2faa (patch) | |
tree | 3c219892c26f87440bec1fa8598793ba4ebcc921 | |
parent | 64127ff6ce9a3c9d89d70e9a40e0bf76221348fa (diff) | |
download | kernel_samsung_tuna-88d65c2b18f68f0001e647b94e6a576d931d2faa.tar.gz kernel_samsung_tuna-88d65c2b18f68f0001e647b94e6a576d931d2faa.tar.bz2 kernel_samsung_tuna-88d65c2b18f68f0001e647b94e6a576d931d2faa.zip |
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.
Change-Id: I751faf3215bbdaa6b6358f3a752bdd24126cfa0b
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>
-rw-r--r-- | kernel/events/core.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 4d6c8e6ff4c..177c8f01492 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5421,7 +5421,6 @@ static int swevent_hlist_get_cpu(struct perf_event *event, int cpu) int err = 0; mutex_lock(&swhash->hlist_mutex); - if (!swevent_hlist_deref(swhash) && cpu_online(cpu)) { struct swevent_hlist *hlist; @@ -7320,12 +7319,6 @@ 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); - - mutex_lock(&swhash->hlist_mutex); - swevent_hlist_release(swhash); - mutex_unlock(&swhash->hlist_mutex); - perf_event_exit_cpu_context(cpu); } #else |