Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1652229ybc; Wed, 13 Nov 2019 02:09:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzTLd0nsO76jMpHEsmjXcebg8jLcrgQDn4nJ5Qqsiv9VZu82abMPVGr8jpLJ8cvec76VnX6 X-Received: by 2002:a17:906:230f:: with SMTP id l15mr1864294eja.222.1573639793397; Wed, 13 Nov 2019 02:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573639793; cv=none; d=google.com; s=arc-20160816; b=0Yx+cyl0Y4unx1VRbB/9boPPSoS40qW+qnFNgPoQIxVMvyzoeuKaySctIrDJF9DU3w y1/g0mAcFX/odp5rAegQ/NlW9MY3vsZchivB1V/Rey79AAYGstu4A4S+hQ1kF1PRcjaX rqQ/r5onhUFqTZMcZIwLOgd2nYUaO9dW2a/wbQvW0ocmM274DqSL4xlbcPo+5xvsEe1b tL9JP0evmIdLEAhqsp8b09KmSC0jD2An65r29KJW+b+8lu+GJP26/F5fa1IU9jGyHao5 lhn/zeGi7Kzn5ITaTTs+0nQ9S9ygFj1Duv4+M6dSpj1svXS150V50uYZDWFBY7m7Z9iw WaVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=xBtXqE+iUBdodEKTOnjV48hMdDWDXviDhDuL/DtHD90=; b=CpKBdV9jZBDXAwjlvyixYvYdTO9lqAYrnruysVvK0LlDhTRwGR1ukXX2LL+T5tZPAx 1a9bw71HqwwlXkE5tLROkgkVfF0PBRv+MbSvEeWtWR+0Z9100B7xaTgHCnZ2A5ut+k4z WBOfpRjcE21iV6Y/BPiaFw/wS4HFQU8s/7Q2+nApO9I605k9ENumeCWDRX52u2fDuDym jo/j0VswIHJXeYdo/HqmVLkgmbLLDw6oEsjxyQ9x7oyI9DqMRg7bI1HNFPdhXV3Oc0bn SDaztCL62doB9pVBvaYxPCk1IvDzpkcuMK9jZ67AnAXLCgKcaAXTyFa95sNmQy6fB55F SOqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x17si880707edq.340.2019.11.13.02.09.29; Wed, 13 Nov 2019 02:09:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbfKMKGx (ORCPT + 99 others); Wed, 13 Nov 2019 05:06:53 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:37171 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727361AbfKMKGn (ORCPT ); Wed, 13 Nov 2019 05:06:43 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iUpXg-0000HQ-6Q; Wed, 13 Nov 2019 11:06:28 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id CC85C1C0357; Wed, 13 Nov 2019 11:06:27 +0100 (CET) Date: Wed, 13 Nov 2019 10:06:27 -0000 From: "tip-bot2 for Alexander Shishkin" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/aux: Fix the aux_output group inheritance fix Cc: Alexander Shishkin , "Peter Zijlstra (Intel)" , Arnaldo Carvalho de Melo , David Ahern , Jiri Olsa , Linus Torvalds , Mark Rutland , Namhyung Kim , Stephane Eranian , Thomas Gleixner , Vince Weaver , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191101151248.47327-1-alexander.shishkin@linux.intel.com> References: <20191101151248.47327-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Message-ID: <157363958745.29376.17174699138865617684.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 00496fe5e09e8c8bb115540e7e3470553cd07a5c Gitweb: https://git.kernel.org/tip/00496fe5e09e8c8bb115540e7e3470553cd07a5c Author: Alexander Shishkin AuthorDate: Fri, 01 Nov 2019 17:12:48 +02:00 Committer: Ingo Molnar CommitterDate: Wed, 13 Nov 2019 08:16:40 +01:00 perf/aux: Fix the aux_output group inheritance fix Commit f733c6b508bc ("perf/core: Fix inheritance of aux_output groups") adds a NULL pointer dereference in case inherit_group() races with perf_release(), which causes the below crash: > BUG: kernel NULL pointer dereference, address: 000000000000010b > #PF: supervisor read access in kernel mode > #PF: error_code(0x0000) - not-present page > PGD 3b203b067 P4D 3b203b067 PUD 3b2040067 PMD 0 > Oops: 0000 [#1] SMP KASAN > CPU: 0 PID: 315 Comm: exclusive-group Tainted: G B 5.4.0-rc3-00181-g72e1839403cb-dirty #878 > RIP: 0010:perf_get_aux_event+0x86/0x270 > Call Trace: > ? __perf_read_group_add+0x3b0/0x3b0 > ? __kasan_check_write+0x14/0x20 > ? __perf_event_init_context+0x154/0x170 > inherit_task_group.isra.0.part.0+0x14b/0x170 > perf_event_init_task+0x296/0x4b0 Fix this by skipping over events that are getting closed, in the inheritance path. Signed-off-by: Alexander Shishkin Signed-off-by: Peter Zijlstra (Intel) Cc: Arnaldo Carvalho de Melo Cc: David Ahern Cc: Jiri Olsa Cc: Linus Torvalds Cc: Mark Rutland Cc: Namhyung Kim Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Fixes: f733c6b508bc ("perf/core: Fix inheritance of aux_output groups") Link: https://lkml.kernel.org/r/20191101151248.47327-1-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 022a34b..b752bd3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11899,7 +11899,7 @@ static int inherit_group(struct perf_event *parent_event, if (IS_ERR(child_ctr)) return PTR_ERR(child_ctr); - if (sub->aux_event == parent_event && + if (sub->aux_event == parent_event && child_ctr && !perf_get_aux_event(child_ctr, leader)) return -EINVAL; }