Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp594941ybx; Fri, 1 Nov 2019 08:14:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuuntZa/n44VF/ED0Q5F5remZrpYb8Tgbq5bpjZmjfB186wOvWnVEqL86FnKVT4ngEUA6E X-Received: by 2002:a17:906:6bc4:: with SMTP id t4mr10537791ejs.1.1572621297472; Fri, 01 Nov 2019 08:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572621297; cv=none; d=google.com; s=arc-20160816; b=zUeMQMhQEJZ54a0XUFDhXcYXJ1zco2eOY4m9AswyrS/lXX7lZfjPsu4NZZQNfIf3E6 MYUXJAdsFt/3W0VHZfq8pGuEcdLf2q4DXUNscQyDchIP6k8NxDyS4FGHvCTx0Mb2Cs1U IMeITY7GiXCZXEX1zzuOAGWhhMYmcqsgDV/Vc9qVxAhvxW/hYc4SQYA5jlUh6kpwkOK8 V0pYKMwh3voMgxQAv1Mb1J8ILwhijYFE5bEMtQKtmQREXULl1hQVT93fxHIZeur0qWWu USOlSAKJUJgaBebDDkG6E0AM4gorrDVM0dmEDuQHBrNW4e0bnpRMh/7wXv+FtIOey8Xs nbgA== 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:mime-version :message-id:date:subject:cc:to:from; bh=mDL0TIpze0zehL3s0uo0xxtM1HOFKXuHTQUK8TzWnNQ=; b=r16A99zI5T+lfWdnbyXsup0HLMO8hS6cfy4U8EIcjJCXtBzKEZQmfwPmlaFqRQ7upX nnWuMri8sI7BS7xCChIvB0DV/mqAYGPgFZvMXPfcjliehjNNBMZ+zbBJVxHVvjasDp7l 00HjFtET23YzBNMowJ/0E0+0T0Dx6swAUC7SxL/Yx40gMTB8P38CFirYW4oi1UW195Xp /ypjV5x1PWCJuuOPhLRLZjcba9HZNriKRLy22bD2JZhluyU5WjI50dm3J28VV0eTPWoe NBcXvP/q62bUiiGzrTsZleUH69tLl/CTUxZYUzkyzu4SVXE79120d+o+UgBI2jAFV/77 h+Gg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m21si5921729eja.161.2019.11.01.08.14.33; Fri, 01 Nov 2019 08:14:57 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbfKAPNH (ORCPT + 99 others); Fri, 1 Nov 2019 11:13:07 -0400 Received: from mga11.intel.com ([192.55.52.93]:32434 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727326AbfKAPNH (ORCPT ); Fri, 1 Nov 2019 11:13:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 08:13:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,256,1569308400"; d="scan'208";a="231256033" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 01 Nov 2019 08:13:04 -0700 From: Alexander Shishkin To: Peter Zijlstra Cc: Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, Alexander Shishkin Subject: [PATCH] perf: Fix the aux_output group inheritance fix Date: Fri, 1 Nov 2019 17:12:48 +0200 Message-Id: <20191101151248.47327-1-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.24.0.rc1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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 --- 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 b1aa5237052b..8ff1218e91b1 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12129,7 +12129,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; } -- 2.24.0.rc1