aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-08-26 11:59:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-08-26 11:59:50 -0400
commit53ede64de3da17f76628b493f5e19a01804939d3 (patch)
treed30cf6f8249781a4867280558cd61999201bc2e5
parentb3242dba9ff285962fe84d1135cafe9383d721f0 (diff)
parent64aee2a965cf2954a038b5522f11d2cd2f0f8f3e (diff)
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fix from Ingo Molnar: "A single fix to not allow nonsensical event groups that result in kernel warnings" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/core: Fix group {cpu,task} validation
-rw-r--r--kernel/events/core.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index ee20d4c546b5..3504125871d2 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10032,28 +10032,27 @@ SYSCALL_DEFINE5(perf_event_open,
10032 goto err_context; 10032 goto err_context;
10033 10033
10034 /* 10034 /*
10035 * Do not allow to attach to a group in a different 10035 * Make sure we're both events for the same CPU;
10036 * task or CPU context: 10036 * grouping events for different CPUs is broken; since
10037 * you can never concurrently schedule them anyhow.
10037 */ 10038 */
10038 if (move_group) { 10039 if (group_leader->cpu != event->cpu)
10039 /* 10040 goto err_context;
10040 * Make sure we're both on the same task, or both
10041 * per-cpu events.
10042 */
10043 if (group_leader->ctx->task != ctx->task)
10044 goto err_context;
10045 10041
10046 /* 10042 /*
10047 * Make sure we're both events for the same CPU; 10043 * Make sure we're both on the same task, or both
10048 * grouping events for different CPUs is broken; since 10044 * per-CPU events.
10049 * you can never concurrently schedule them anyhow. 10045 */
10050 */ 10046 if (group_leader->ctx->task != ctx->task)
10051 if (group_leader->cpu != event->cpu) 10047 goto err_context;
10052 goto err_context; 10048
10053 } else { 10049 /*
10054 if (group_leader->ctx != ctx) 10050 * Do not allow to attach to a group in a different task
10055 goto err_context; 10051 * or CPU context. If we're moving SW events, we'll fix
10056 } 10052 * this up later, so allow that.
10053 */
10054 if (!move_group && group_leader->ctx != ctx)
10055 goto err_context;
10057 10056
10058 /* 10057 /*
10059 * Only a group leader can be exclusive or pinned 10058 * Only a group leader can be exclusive or pinned