Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp191259rdh; Tue, 13 Feb 2024 13:48:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUS848rbeOsuRymVLzvU5lVglLaO96Xj7tO9/kaIwN1/my1VFDPw6e8bhxdZIPkNmXkXm+DUCO+H6dL6dB2kQDHXlxj22JjYbeLhAF8Tw== X-Google-Smtp-Source: AGHT+IHfW/sRZk7cZ4CeRk/VDKG0HAeWCCRz5iPPPgkZXfsOwb9eo08E5vI0Cj3v3zLnFpbbtWXk X-Received: by 2002:a0c:df0c:0:b0:685:7125:67e6 with SMTP id g12-20020a0cdf0c000000b00685712567e6mr738001qvl.1.1707860885329; Tue, 13 Feb 2024 13:48:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707860885; cv=pass; d=google.com; s=arc-20160816; b=Bs0UdYaU6rAypvdkCJHConHOtxEkT82+lHsxT5I4jsFLGsq3UlGmW8o+blid92uByg uCV+FJKHKDJOQxFxU3dyD4bWeWpK8IyQyi/pbOEWMjdreE1LkyslxqHcHoFCVBit/QbR 2V9N7WDFMRwLoFxVKmDZr9+UwPRVVjgzXZxepMKrxGEmjKszS6uhsNupsw5BsibYCYV9 glUWawqzIvpU3C7ZU0gSO6yYDsybEElIflk3F5Td1HAP0KcWwJvwG8HcOGzJjDF3XvIc 9Qq/TxnkanidWF1MOatahHVSwQ9H7PpbrfEo4M0KKMdjGbkZ1Bi6SB/Y+F8W/1ufCoLt F0gw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=NF3MBlA6g5fE/nQpkUVGLsVhm1KDVfSDHE1cj8tEnnk=; fh=QJCqErpWPtfREZ4nGkYpv/fm2BNaGPHV7A9jSdEs6HM=; b=nFHH+6m/kPktNaugZilrNsOVqnAn77lB++1ZsD77MVaWryHFKx3g1ZGlSgpYke9o8Q Ht8aMDlYOVBlwKlTz0DhgvTEQyZrdvnfH0QO9sIv4RtSAET9Q2xzRx2t3KovR6n6HMOV JsjmCkV3JAzY8iq/VeIL3O0oJfCBAL1QtDaoiP4KE74ps4MR1hkGIxQBSuudRTPnfa/D a/0EUMCyd3s1KCKP0Si8BKaOy/rWh71zMNINgjzv67MGgUpbwkm9nVxHELdStZ7AKBa6 yme0Of6QsYXaHVMd0L+xmFXEl3RmTXo0WKjKtjKX8yzx5BMq3NjbFe++7QIXX4oWKwoz g5Jw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXkdzjnd6yBFBUsBoZ5estXN2ut0dorjR6Fwy7/2wNc6hsGs1VMfBgL1zS0ybmoqKDCPYVAFHpPwnfa3zaantWea6g7TSH7XwGWRr/4dA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gh11-20020a05621429cb00b0068d18477088si3752821qvb.599.2024.02.13.13.48.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:48:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64370-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64370-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 19E7E1C27B6B for ; Tue, 13 Feb 2024 21:48:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A91D62813; Tue, 13 Feb 2024 21:45:35 +0000 (UTC) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3498B6167E; Tue, 13 Feb 2024 21:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707860734; cv=none; b=uf94qJUWtzjLpUnFY2JUS8RVu/jBLMTxrqdfzoqNooxrZYabsJ4WQ83p1HgcvLqW/+kiXDENOKf5Fe8cb4t3pbhLc32wzzicTBjERmqBgvGNNrxuYa3qKX1n/438xjr1w9iYpg6D/8KgJCPQwFXXk+nUTRmNYBVBEYaPQW57mIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707860734; c=relaxed/simple; bh=zlrnLAVzSU1Jn8766Ja1eXbCBgSYS2I1GytV//3vZNg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XsOWRVok3u/fS7a2JMLk7aKO+Kh7+j6HHnVGd4hcJwJKDkpIiLtq1Chr5XkYi6iN/wrGg4TNfqsaLcVu/+tpDQhZ9dI9HPCle0zfmjdvIxQxHZYQLDJXSBRlQCXGzgDWRPij6Hy8CwT2j/QXvDbHRsUZ102jXxKH0Uw21lfmpzw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-297108e7001so2432070a91.1; Tue, 13 Feb 2024 13:45:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707860732; x=1708465532; 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=NF3MBlA6g5fE/nQpkUVGLsVhm1KDVfSDHE1cj8tEnnk=; b=mmL++hYk7ca+lvx/ov0MK5P0PSo/MY/sAKXIpVbz8GKXM3jyOjEHazpsJSim1sgQnC kclMpn4jm+AzyxOKMTDRKkdrLQzKL7kaoPEClKfePWa+5bb3edG016BXvsJfmg47qVX0 fRYpsw/f7gWv7bX6pfE07lj/vBmdIxFjB/+KIkQ1l/zLQ0tVix4NIgnqvHBzMGQaOgsA ZI1F/lxZk/3H0/t5pmd0zXGLGGOlDTh08AXZG8R9CRy1qdwaEJAnwJLWGAedPAEUdGxv n/YObxWdCupl4SZMo0eJDBrzuJUi1dKhHVrJLg08UWpIK9U0y8nuUp097UsUD+bGrF9/ gGvg== X-Forwarded-Encrypted: i=1; AJvYcCWlnVGZXvb497sguWsE8nGFvk7nYto3hjcmBVaA4NeKvZISwBp+fNf4Gpd4SLeIRnuDMo3tPrQ49+xT2lLodqY1D7CR5uRv0Gn7pHraWiAoE3kKiiz45AGEuY/kKjNKiYDgHVX+kMDSrBsJb/dV2Q== X-Gm-Message-State: AOJu0YxfjkDFg+TwXJMe35QoUuqolK946vnNX3pCNnjoFEdiq3ncf3pw hshAp2z/bY4lIuUt4LqrLiLHbUd7TSVHtaXjccc66ZE+d+lCH2CS6ii7UsXWQk9Ta94mwha9oUM JVyQHOEVzsiZBV+JwEd8tLjM+khM= X-Received: by 2002:a17:90a:7406:b0:297:3305:a690 with SMTP id a6-20020a17090a740600b002973305a690mr855014pjg.9.1707860732331; Tue, 13 Feb 2024 13:45:32 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240209204947.3873294-1-irogers@google.com> <20240209204947.3873294-4-irogers@google.com> In-Reply-To: <20240209204947.3873294-4-irogers@google.com> From: Namhyung Kim Date: Tue, 13 Feb 2024 13:45:20 -0800 Message-ID: Subject: Re: [PATCH v1 3/4] perf stat: Avoid metric-only segv To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , John Garry , Kan Liang , James Clark , K Prateek Nayak , Kaige Ye , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 9, 2024 at 12:50=E2=80=AFPM Ian Rogers wro= te: > > Cycles is recognized as part of a hard coded metric in stat-shadow.c, > it may call print_metric_only with a NULL fmt string leading to a > segfault. Handle the NULL fmt explicitly. > > Fixes: 088519f318be ("perf stat: Move the display functions to stat-displ= ay.c") > Signed-off-by: Ian Rogers > --- > Note, the fixes tag is to a refactor that moved the function. The bug > existed before this. Yeah I noticed that. > --- > tools/perf/util/stat-display.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-displa= y.c > index 8c61f8627ebc..b7d00a538d70 100644 > --- a/tools/perf/util/stat-display.c > +++ b/tools/perf/util/stat-display.c > @@ -560,7 +560,7 @@ static void print_metric_only(struct perf_stat_config= *config, > if (color) > mlen +=3D strlen(color) + sizeof(PERF_COLOR_RESET) - 1; > > - color_snprintf(str, sizeof(str), color ?: "", fmt, val); > + color_snprintf(str, sizeof(str), color ?: "", fmt ?: "", val); I was thinking about fixing the callers to pass valid format strings but it seems they don't care about the output string anyway so I think it's fine. Thanks, Namhyung > fprintf(out, "%*s ", mlen, str); > os->first =3D false; > } > -- > 2.43.0.687.g38aa6559b0-goog >