lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 28 Oct 2017 09:49:37 -0700
From:   Tejun Heo <>
To:     Peter Zijlstra <>,
        Ingo Molnar <>,
        Arnaldo Carvalho de Melo <>
        David Carrillo-Cisneros <>,
Subject: [PATCH] cgroup, perf_event: Fix perf cgroup hierarchy support

864c2357ca89 ("perf/core: Do not set cpuctx->cgrp for unscheduled
cgroups") made list_update_cgroup_event() skip setting cpuctx->cgrp if
no cgroup event targets %current's cgroup.  This breaks perf_event's
hierarchical support because events which target one of the ancestors
get ignored.

Fix it by using cgroup_is_descendant() test instead of equality.

Signed-off-by: Tejun Heo <>
Fixes: 864c2357ca89 ("perf/core: Do not set cpuctx->cgrp for unscheduled cgroups")
Cc: # v4.9+
Cc: David Carrillo-Cisneros <>
 kernel/events/core.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9d93db8..db2e630 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -901,9 +901,12 @@ list_update_cgroup_event(struct perf_event *event,
 	cpuctx_entry = &cpuctx->cgrp_cpuctx_entry;
 	/* cpuctx->cgrp is NULL unless a cgroup event is active in this CPU .*/
 	if (add) {
+		struct perf_cgroup *cgrp = perf_cgroup_from_task(current, ctx);
 		list_add(cpuctx_entry, this_cpu_ptr(&cgrp_cpuctx_list));
-		if (perf_cgroup_from_task(current, ctx) == event->cgrp)
-			cpuctx->cgrp = event->cgrp;
+		if (cgroup_is_descendant(cgrp->css.cgroup,
+					 event->cgrp->css.cgroup))
+			cpuctx->cgrp = cgrp;
 	} else {
 		cpuctx->cgrp = NULL;

Powered by blists - more mailing lists