summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorBudimir Markovic <markovicbudimir@gmail.com>2023-03-15 00:29:01 -0700
committerPeter Zijlstra <peterz@infradead.org>2023-03-15 21:49:47 +0100
commitfd0815f632c24878e325821943edccc7fde947a2 (patch)
tree9ed4e2f38abaa693526d389e017443117256a467 /kernel
parentbaf1b12a67f5b24f395baca03e442ce27cab0c18 (diff)
downloadlinux-stable-fd0815f632c24878e325821943edccc7fde947a2.tar.gz
linux-stable-fd0815f632c24878e325821943edccc7fde947a2.tar.bz2
linux-stable-fd0815f632c24878e325821943edccc7fde947a2.zip
perf: Fix check before add_event_to_groups() in perf_group_detach()
Events should only be added to a groups rb tree if they have not been removed from their context by list_del_event(). Since remove_on_exec made it possible to call list_del_event() on individual events before they are detached from their group, perf_group_detach() should check each sibling's attach_state before calling add_event_to_groups() on it. Fixes: 2e498d0a74e5 ("perf: Add support for event removal on exec") Signed-off-by: Budimir Markovic <markovicbudimir@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/ZBFzvQV9tEqoHEtH@gentoo
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 52b4aa0b3bd1..fb3e436bcd4a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2163,7 +2163,7 @@ static void perf_group_detach(struct perf_event *event)
/* Inherit group flags from the previous leader */
sibling->group_caps = event->group_caps;
- if (!RB_EMPTY_NODE(&event->group_node)) {
+ if (sibling->attach_state & PERF_ATTACH_CONTEXT) {
add_event_to_groups(sibling, event->ctx);
if (sibling->state == PERF_EVENT_STATE_ACTIVE)