Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4422253ioa; Wed, 27 Apr 2022 03:37:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIJPU5jjSpehwqIRTCbf27hAS4tNDdKGLZ9wQiCi54z6g+RqF73UkpQLW5fnYQoCGKjUCw X-Received: by 2002:a62:cf44:0:b0:50d:6d18:17f9 with SMTP id b65-20020a62cf44000000b0050d6d1817f9mr4673352pfg.63.1651055821162; Wed, 27 Apr 2022 03:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651055821; cv=none; d=google.com; s=arc-20160816; b=efRUIVEcCdnINGiLAvBrn+OwCXFkSKyNpR0X8vhU8JMcO9aq9SLKqDDyVUIlMll9VC 7RfXJM/RDpBO3lL7DO7ifr1HdZ8j2UEX6Zubmng2nbYJmyvOIiSLchPtbpUWOGu1iPNO JG6afVkla50kCriC/Mz7DvVnkKuhJXwBLvxab97PYyk3+95QMWbdj+jGIBCxGSMB/CEp XIoUv7zJinV0CWyRxcvdU6h321DBdYT+w4J0MHep/UYqxKMWOIL5RIEZEdAUVnc9Lkdq foYf5xsTHanCu6PCkksr9x4cxe7HJhB0cLIpjk9i27QV745mT1I+7GLZ448VuuM8FYut OoEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IDJni+MJLrR+guK4hmIdjbo0AXeBOH0Uavohm0cmgyg=; b=U6y37Daj9QMVxfGEhpnQ4OBfjRd4H4dvtM+cLIO8fp041nq0ng5d4wzUU0T7luPMv2 GsLTVaO7CsFGZVavpOEH19NP6AndpcFjPt46uvFMkMk8u1YZcMAd4HTyAk0V3pxMPCeB 8sLSP+qx7lujGsbzBJsQPL4vej8ZCgGdPryzv7c/AsFKpkLXX4GZaP/lD3bXXGQOSrH3 HdKp8zqB3pJurw96R+REK3EcqqBQmwhnAKDca4eA+8cQdFfrJhpzJCr+R1Z+DOkJ+cWp s2AidAEWIIkMPri/87OJiJJvIAZmlRF6CQUr79qWvSe4/IjWhRJW0SZ+3VOW//25sZa9 xaBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NAjEYCoP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i21-20020aa78b55000000b0050d429bb67esi908699pfd.82.2022.04.27.03.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:37:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NAjEYCoP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B9B713C84B0; Wed, 27 Apr 2022 02:48:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343529AbiDZImP (ORCPT + 99 others); Tue, 26 Apr 2022 04:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345498AbiDZIek (ORCPT ); Tue, 26 Apr 2022 04:34:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13237762B1; Tue, 26 Apr 2022 01:27:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4425E617F1; Tue, 26 Apr 2022 08:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07E75C385A0; Tue, 26 Apr 2022 08:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961648; bh=uohlWFwBq9UC0CYbsoaezznRmsKwW5dkGs3AXvj3XO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAjEYCoPu8Cg5Hx93RdZpGYeSyzt869XDG06BkDd7hNqHp8hq/4LC/zHAYdTOAzVD JpxgiHvea1VV3TiLPhU8ie1464rksKOp20e3UTui8e/MO8GUHOTCbsU6/Th//PSogW eTkAAITVc0utVWZYHL2sn2iR2Vsx8HRcHaBiDA9Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Grant , Will Deacon , Mark Rutland , Rob Herring Subject: [PATCH 4.19 38/53] arm_pmu: Validate single/group leader events Date: Tue, 26 Apr 2022 10:21:18 +0200 Message-Id: <20220426081736.765051355@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081735.651926456@linuxfoundation.org> References: <20220426081735.651926456@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Herring commit e5c23779f93d45e39a52758ca593bd7e62e9b4be upstream. In the case where there is only a cycle counter available (i.e. PMCR_EL0.N is 0) and an event other than CPU cycles is opened, the open should fail as the event can never possibly be scheduled. However, the event validation when an event is opened is skipped when the group leader is opened. Fix this by always validating the group leader events. Reported-by: Al Grant Cc: Will Deacon Cc: Mark Rutland Signed-off-by: Rob Herring Acked-by: Mark Rutland Link: https://lore.kernel.org/r/20220408203330.4014015-1-robh@kernel.org Cc: Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- drivers/perf/arm_pmu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -321,6 +321,9 @@ validate_group(struct perf_event *event) if (!validate_event(event->pmu, &fake_pmu, leader)) return -EINVAL; + if (event == leader) + return 0; + for_each_sibling_event(sibling, leader) { if (!validate_event(event->pmu, &fake_pmu, sibling)) return -EINVAL; @@ -418,12 +421,7 @@ __hw_perf_event_init(struct perf_event * local64_set(&hwc->period_left, hwc->sample_period); } - if (event->group_leader != event) { - if (validate_group(event) != 0) - return -EINVAL; - } - - return 0; + return validate_group(event); } static int armpmu_event_init(struct perf_event *event)