Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3403667rwb; Fri, 30 Sep 2022 03:08:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CtjC7O3UiumZfN3iydTLR/Yqj5/niQuI73dR9hHfH2EhDDKmZpyOR2ZANWFyZY60JXha6 X-Received: by 2002:a17:90b:3510:b0:202:f18c:fdb6 with SMTP id ls16-20020a17090b351000b00202f18cfdb6mr8806123pjb.122.1664532502935; Fri, 30 Sep 2022 03:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664532502; cv=none; d=google.com; s=arc-20160816; b=sPPSEmWqfyLHdjIM7v9IUJEsuyuxoKN1plCyu0elWXmmS9C8/k5tb5dloI540qnR+w 7z6yQ51HtKi/rhKsDoV7DaQ0iwUarW6rddwcieb1bpwxL5R3zKFu+YB+mjc5mvVq6Kqg EOuOW5Ylrv2g3f77eOfAsnuyG9SdsZ3Oy6PaOYLJ+PlTOrDlRj+pyUoJYLDHFb7LVWuI aXL9prnZh7B/KtscWMS6BHvuAL1ONWyd/mpTZu4id6H0JX+MJOgQZPV6xgaDccPPVH/f XAAG56MEatG3Eu8TJY0t59hWEEiTzfQH/8RdxMk326h3nWHSOTLrgXWNmBZA/lMgXu04 X/xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=4w2bdjCYeWY/jVNN3wkObamE/bPM4WH/dN6XlJz+t6E=; b=MAEwtMbCLuQbjJe0ZhVndtPFixNs8ELZRslAMBgIULnReuD55fotT3qrNb2EKBTnS+ whj+Vzaz42+vZvioNccJUaMijrKW15X/oWZUzDTmWlXBcNwyaiNA7OpWwPa2vv8nZei4 3jGbaOrA3jv6bgAPto/3+hg5BwhsO3oePK4taJQ1vYIzemUGjNfIeHL845kSOI6zsXHC pmT/WPcXcZanY4adWAg49SlH7kKS6pWdsfw89VwQnYhY/unx5v4KTqoFae36tchxzq1s ZqUZuWkWt29UgYqA6fv4JOP2OYko9w5b/QdvEw9/ft7Dr8wZqYl3tvDjDJzR01HKqPcm 0/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1H6+C8fb; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a17090301c800b00176e16b0c58si1202502plh.21.2022.09.30.03.08.08; Fri, 30 Sep 2022 03:08:22 -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=@linutronix.de header.s=2020 header.b=1H6+C8fb; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbiI3JbY (ORCPT + 99 others); Fri, 30 Sep 2022 05:31:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbiI3JbI (ORCPT ); Fri, 30 Sep 2022 05:31:08 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23F7C9027; Fri, 30 Sep 2022 02:31:04 -0700 (PDT) Date: Fri, 30 Sep 2022 09:31:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1664530262; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4w2bdjCYeWY/jVNN3wkObamE/bPM4WH/dN6XlJz+t6E=; b=1H6+C8fbLIJ2U5QskkEIWrl3U36DqPTaX4oKvvnUqjA/FTSXuI6TSoR5cOksFQ35R36zYa Lf4H0+UTmOF9IwDh4fmu5ZBRtX7t+vAPGHIUu1rC6vH9LPx5xlsQUsRt3tM/ZA6M3h8wy1 mnbWVDy4SRLQxC5XjReT9rwmW6ZMcYT9LJzV2zHKRwwvBRyM8zWhL/7nE3do6L2FfKzbmD XdmRnILLzka7e0BEkSeIXL29Sn3eb0HCSZ2eiFSJkZvg+AH8QoLjvJMgOYa734oSZp3HOU BNAYLzJfNb3gcKfnh2On5Iom56Y6SohgRM4q7WQDFHunYa/Vm0Acf3PTuwxCaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1664530262; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4w2bdjCYeWY/jVNN3wkObamE/bPM4WH/dN6XlJz+t6E=; b=XoQemUcmYvPxCY5Z3Qr/EPTq6VSR6CDL1/+09MkQhwdD2C5QYwolQv1uNBF9ix4YCyX4QR h5W48n+gYnNgxYAg== From: "tip-bot2 for Stephane Eranian" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/utils: Fix uninitialized var in get_branch_type() Cc: Stephane Eranian , "Peter Zijlstra (Intel)" , Sandipan Das , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220928184043.408364-2-eranian@google.com> References: <20220928184043.408364-2-eranian@google.com> MIME-Version: 1.0 Message-ID: <166453026135.401.4729222327000204709.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 The following commit has been merged into the perf/core branch of tip: Commit-ID: 117ceeb1f4f87331e45a77e71f18303d15ec882e Gitweb: https://git.kernel.org/tip/117ceeb1f4f87331e45a77e71f18303d15ec882e Author: Stephane Eranian AuthorDate: Wed, 28 Sep 2022 11:40:42 -07:00 Committer: Peter Zijlstra CommitterDate: Thu, 29 Sep 2022 12:20:56 +02:00 perf/x86/utils: Fix uninitialized var in get_branch_type() offset is passed as a pointer and on certain call path is not set by the function. If the caller does not re-initialize offset between calls, value could be inherited between calls. Prevent this by initializing offset on each call. This impacts the code in amd_pmu_lbr_filter() which does: for(i=0; ...) { ret = get_branch_type_fused(..., &offset); if (offset) lbr_entries[i].from += offset; } Fixes: df3e9612f758 ("perf/x86: Make branch classifier fusion-aware") Signed-off-by: Stephane Eranian Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Sandipan Das Link: https://lore.kernel.org/r/20220928184043.408364-2-eranian@google.com --- arch/x86/events/utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/events/utils.c b/arch/x86/events/utils.c index 5f5617a..76b1f8b 100644 --- a/arch/x86/events/utils.c +++ b/arch/x86/events/utils.c @@ -94,6 +94,10 @@ static int get_branch_type(unsigned long from, unsigned long to, int abort, u8 buf[MAX_INSN_SIZE]; int is64 = 0; + /* make sure we initialize offset */ + if (offset) + *offset = 0; + to_plm = kernel_ip(to) ? X86_BR_KERNEL : X86_BR_USER; from_plm = kernel_ip(from) ? X86_BR_KERNEL : X86_BR_USER;