Skip to content

Commit

Permalink
perf: Fix orphan hole
Browse files Browse the repository at this point in the history
We should set event->owner before we install the event,
otherwise there is a hole where the target task can fork() and
we'll not inherit the event because it thinks the event is
orphaned.

Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jan 28, 2016
1 parent 45c815f commit 78cd2c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/events/core.c
Expand Up @@ -8489,6 +8489,8 @@ SYSCALL_DEFINE5(perf_event_open,
perf_event__header_size(event);
perf_event__id_header_size(event);

event->owner = current;

perf_install_in_context(ctx, event, event->cpu);
perf_unpin_context(ctx);

Expand All @@ -8498,8 +8500,6 @@ SYSCALL_DEFINE5(perf_event_open,

put_online_cpus();

event->owner = current;

mutex_lock(&current->perf_event_mutex);
list_add_tail(&event->owner_entry, &current->perf_event_list);
mutex_unlock(&current->perf_event_mutex);
Expand Down

0 comments on commit 78cd2c7

Please sign in to comment.