Commit 1f4ee503 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf: Ensure consistent inherit state in groups

Make sure all events in a group have the same inherit state. It was
possible for group leaders to have inherit set while sibling events
would not have inherit set.

In this case we'd still inherit the siblings, leading to some
non-fatal weirdness.
Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-r32tt8yldvic3jlcghd3g35u@git.kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 37b16bea
...@@ -7081,20 +7081,26 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -7081,20 +7081,26 @@ SYSCALL_DEFINE5(perf_event_open,
} }
} }
if (task && group_leader &&
group_leader->attr.inherit != attr.inherit) {
err = -EINVAL;
goto err_task;
}
get_online_cpus(); get_online_cpus();
event = perf_event_alloc(&attr, cpu, task, group_leader, NULL, event = perf_event_alloc(&attr, cpu, task, group_leader, NULL,
NULL, NULL); NULL, NULL);
if (IS_ERR(event)) { if (IS_ERR(event)) {
err = PTR_ERR(event); err = PTR_ERR(event);
goto err_task; goto err_cpus;
} }
if (flags & PERF_FLAG_PID_CGROUP) { if (flags & PERF_FLAG_PID_CGROUP) {
err = perf_cgroup_connect(pid, event, &attr, group_leader); err = perf_cgroup_connect(pid, event, &attr, group_leader);
if (err) { if (err) {
__free_event(event); __free_event(event);
goto err_task; goto err_cpus;
} }
} }
...@@ -7256,8 +7262,9 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -7256,8 +7262,9 @@ SYSCALL_DEFINE5(perf_event_open,
put_ctx(ctx); put_ctx(ctx);
err_alloc: err_alloc:
free_event(event); free_event(event);
err_task: err_cpus:
put_online_cpus(); put_online_cpus();
err_task:
if (task) if (task)
put_task_struct(task); put_task_struct(task);
err_group_fd: err_group_fd:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment