Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3658906rwo; Mon, 24 Jul 2023 14:44:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfczbfGh8pM0wEhVlIdlW0bGmdWjMGDnx5hSKZT5rsdqOy8M9YpUuHxC3GtzinSoyBVEeg X-Received: by 2002:a17:906:77c8:b0:977:e310:1ce7 with SMTP id m8-20020a17090677c800b00977e3101ce7mr11403758ejn.38.1690235072342; Mon, 24 Jul 2023 14:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690235072; cv=none; d=google.com; s=arc-20160816; b=jY+BRjU0O4AguTEjUbCy+pEPxilHYpuMOujbXoco165g1bNJ1NbmpV4tUc3Mo3vp4N E5K96YeoaGQ8uwiRtrFd6mfL62eZJbupLYH7zR2U0TgDnYtqZGytPTwnwj7xryzyPWb0 SkxMftLaIJy32YZW1smVhGdKFn018d7qq4Gm12V6LKGrmMDbJkg4BXEAHZNHfwA3Er+G /GWhTT//OV/7IMS66s71PTiDPaFC09jrR9E+29CjjuI1knMryrdS/QrHan+RUlPG7Eeh 78+G6ABse3EB2fSOWGa2T9kve8Ij6xXba+fNNl9MPyP/0mR4fCOw9G3Vq5C4JjkM5HVJ iETA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=F4R7OXxyA6++6H908qvwT/4xVlAoInx/mRJrgLvZp3I=; fh=DaEtDrgDr1LPTSaNuq0RJp7cCpUYMoVYFCVtmGKA8Ew=; b=VU0kR+M8g4Sfwza8lqOFPBmE/roepW7mmmfdKoIra+esFDMAvjv4EV1Q2lOb2hAR5N qcCMM4PP3Ao6a2N71OYxxvuWJ23egb1DZArQDZ3oW4dgbcvLvKgIcbtfS0rGb+O8nnBk NMU+gGgfjitg2pYoiz+wpKUZaTEvaNLPqEiYmx5WICu45pBTvn2Qu+5d4o0VlwBPqYOI UC8P/3/VbUU0a02M7aVd37eOWDG0rAtY/UX/HcbLzS0wXFn40iOdPmidaUBX4A7Sw1U3 gGnmg5q4IdyN9xEj5cmEq7gxQcGBLwHWjIHnc966Zf4gpSSN/O4iTNFSN/qwKKHWN34V U3DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=7VPLC3FM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id md22-20020a170906ae9600b0098295eed929si6563795ejb.998.2023.07.24.14.44.08; Mon, 24 Jul 2023 14:44:32 -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=@google.com header.s=20221208 header.b=7VPLC3FM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbjGXVJe (ORCPT + 99 others); Mon, 24 Jul 2023 17:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjGXVJd (ORCPT ); Mon, 24 Jul 2023 17:09:33 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE411700 for ; Mon, 24 Jul 2023 14:09:31 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-63d09d886a3so5690916d6.2 for ; Mon, 24 Jul 2023 14:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690232970; x=1690837770; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=F4R7OXxyA6++6H908qvwT/4xVlAoInx/mRJrgLvZp3I=; b=7VPLC3FM4ARsMPpxFByktScwoRDHY1+O3k6ji1oMHXcyc6BWzJO2kc65fqEz/njpKS 1e7OlV2JEjMDqg5/b/8JhzaVftGznHjCljWM27BrP56UMgo4L8DdTIELZGyd7UD9rWPk qQbnqI5NpI7yY40RMK0+86Sbiiv6BJBD6PmxYo61TZv00unQD3dW63wIjlZ4uU5YLag4 6T0PNkCCqQKY3fRRiocbDQLEC+UAeiYQ8kf5hL3Z5wM+rOMs1zhoGu6GcqpFEj1KU9Dh YSpeA+8GtomB9U/LAI/r00dP87tOUdSYkkqZmSXVpqurgoIAKEF3A5KjksJiib/fhSTg muAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690232970; x=1690837770; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F4R7OXxyA6++6H908qvwT/4xVlAoInx/mRJrgLvZp3I=; b=ayHYjHPDoni+SkA4ANX6blk+AZlo1ik2UQqBhfjxM990EgvgaSoBdR7NTs4+6nOZrk qB6MrdeLNE/pS9GNR9LHFjQdyw6hyudSmGaxAsDp66XsRuUtJDdrfT2oBVPo6in5gwpD +sFQi13iUvjENoFK4RWGsaFKWM6gfEQSXbkbCl5N3KhtLgbSrLgm+D9oMxvyB9QA2JOu DBdrohG3l+nWBAotq2AgOTxZqg5mFcGkSzypkK5B3OUce9CwPQDwx52CpQACMHxUHZtu kl6gTWy4LXVWaNr0ovH1WribnxdO7yatrSf1PReJ6SYvJ3i3T5xan8pmiAkdvp7g7byN 5fLA== X-Gm-Message-State: ABy/qLa08ww8T551bsBeaZ8Y0pOcCJZaT5Nnzh8GJcfAUozaYC9vgvQD /VbefazVE7XTvv2bcGdekJdhmWq1bG4YTUnnpbDqjQ== X-Received: by 2002:a05:6214:11b0:b0:63c:fac8:ec0b with SMTP id u16-20020a05621411b000b0063cfac8ec0bmr786313qvv.39.1690232970451; Mon, 24 Jul 2023 14:09:30 -0700 (PDT) MIME-Version: 1.0 References: <20230724201247.748146-1-irogers@google.com> <20230724201247.748146-2-irogers@google.com> In-Reply-To: <20230724201247.748146-2-irogers@google.com> From: Nick Desaulniers Date: Mon, 24 Jul 2023 14:09:19 -0700 Message-ID: Subject: Re: [PATCH v1 1/4] perf stat: Avoid uninitialized use of perf_stat_config To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Nathan Chancellor , Tom Rix , Kan Liang , Yang Jihong , Ravi Bangoria , Carsten Haitzler , Zhengjun Xing , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev, maskray@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Mon, Jul 24, 2023 at 1:12=E2=80=AFPM Ian Rogers wro= te: > > perf_event__read_stat_config will assign values based on number of > tags and tag values. Initialize the structs to zero before they are > assigned so that no uninitialized values can be seen. > > This potential error was reported by GCC with LTO enabled. > > Signed-off-by: Ian Rogers > --- > tools/perf/tests/stat.c | 2 +- > tools/perf/util/stat.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c > index 500974040fe3..706780fb5695 100644 > --- a/tools/perf/tests/stat.c > +++ b/tools/perf/tests/stat.c > @@ -27,7 +27,7 @@ static int process_stat_config_event(struct perf_tool *= tool __maybe_unused, > struct machine *machine __maybe_unus= ed) > { > struct perf_record_stat_config *config =3D &event->stat_config; > - struct perf_stat_config stat_config; > + struct perf_stat_config stat_config =3D {}; ^ how did this code ever work? 1. stat_config is not initialized 2. perf_event__read_stat_config maybe assigns to &stat_config->__val 3. process_stat_config_event() tests other members of stat_config I hope I've missed something obvious. Reviewed-by: Nick Desaulniers > > #define HAS(term, val) \ > has_term(config, PERF_STAT_CONFIG_TERM__##term, val) > diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c > index 967e583392c7..ec3506042217 100644 > --- a/tools/perf/util/stat.c > +++ b/tools/perf/util/stat.c > @@ -729,7 +729,7 @@ size_t perf_event__fprintf_stat_round(union perf_even= t *event, FILE *fp) > > size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp= ) > { > - struct perf_stat_config sc; > + struct perf_stat_config sc =3D {}; > size_t ret; > > perf_event__read_stat_config(&sc, &event->stat_config); > -- > 2.41.0.487.g6d72f3e995-goog > --=20 Thanks, ~Nick Desaulniers