Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3565457ioa; Tue, 26 Apr 2022 06:12:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfDPrvdOw1q9kegRgF8I/zKnYxnxV9tDuZkwj9APrrvzjvGnEvwOthyb2yyZkEMtvmwS/q X-Received: by 2002:a17:907:3fa9:b0:6ef:f0e6:7285 with SMTP id hr41-20020a1709073fa900b006eff0e67285mr21536556ejc.350.1650978740113; Tue, 26 Apr 2022 06:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650978740; cv=none; d=google.com; s=arc-20160816; b=RfIMb2KtnCNT3I1dN3EUzjDkfm0lceeTniz8NHQYek7kJtaJFuuvJoYDItwD/S4y4l JBd3k3pBTwVVqOCiGXm0vUWdmdVxn4jG71cih1TPSLn2en/AV8dzwAkXQYAy8Bh0SQ/2 GYDURkJiWrjqkFsXDxqHh7WvUhZG5TVUGih9i9cg4ydrtvXhFpO/eO2AM03Wlw9QKVFY ZtghMXtWStWn125xvCU5RMomDMhqcWwkwmDDBnZpi9ezFO5saDU/tcWLUwz1c3diwPFa Xna53Lpc9wRleZfpXbwGFULupAPSo/5fzytTRlPjp8aAJM06yw6D2LF9HAI7cJ53U2/2 YtFA== 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=OfJDJ4fTSN0F3Qf+NBAjL62JL7ZKUvFk+lO9b4vkRsE=; b=F/7XAZK0aOFEbodGFPA/kGu8dq+D5e9uTTv07/M4+31V11CmXYGHsMGP428g7pT+SU s5MwDWyz5KmucDNyhhc54KZQr1viZsbtAhMeVqyUGn97Aj+e+5Ap4jfaL1ZnkRrlms2P y2NDm0IBPtFdG6xeCgNl/hwE4ChD0S/Dh52gVSkrTMm5SiRbcTTqQYUPGUR7QreZKDhp N9TwwG9OxU9JuSsvewduUcxbDoF+c4wRx6YQJl7ARNewr0/qKCazOzvssbjqWIJsRqBc TF7FI8G7Y5qOp+R4TVVYqZH968lb+2jvX6KhAxa3UBN76XKIxQyTDbW5akMfGLMWBg1W jZMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=svRegXr4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z27-20020a1709060adb00b006f38efefa6dsi5506752ejf.764.2022.04.26.06.11.55; Tue, 26 Apr 2022 06:12:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=svRegXr4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236442AbiDZJSF (ORCPT + 99 others); Tue, 26 Apr 2022 05:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346129AbiDZIyN (ORCPT ); Tue, 26 Apr 2022 04:54:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F30FDA6EB; Tue, 26 Apr 2022 01:41:06 -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 3AE8760A67; Tue, 26 Apr 2022 08:41:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38D37C385B2; Tue, 26 Apr 2022 08:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962465; bh=cO5fCD0ZzNkZaR/zh4/84j4XIbL0lFAwsD0hABYmrS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=svRegXr4hQBfWJpJex2ZQDiz9NX3YCRs51Zmw+eAhwf5O9AlV47YF31nCTO+174dg C0uLwKXfkr4klvDKJH/dDlL4If389AxxFDwktrQbnX5L7AnLsiHiiOikjWaxv0M8K8 nhxhZpCfkTXRp+BOHKIAqwOGCSYVpqxS52rSKNp8= 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 5.15 106/124] arm_pmu: Validate single/group leader events Date: Tue, 26 Apr 2022 10:21:47 +0200 Message-Id: <20220426081750.309103278@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 @@ -398,6 +398,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; @@ -487,12 +490,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)