From nobody Sat Oct 18 02:15:29 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E31D3C433FE for ; Wed, 19 Oct 2022 09:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234033AbiJSJpH (ORCPT ); Wed, 19 Oct 2022 05:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234953AbiJSJl5 (ORCPT ); Wed, 19 Oct 2022 05:41:57 -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 9FDDCF5CDF; Wed, 19 Oct 2022 02:18:36 -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 4CF1F6181A; Wed, 19 Oct 2022 09:15:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E78AC433D6; Wed, 19 Oct 2022 09:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170929; bh=Cjo4WF83Lp3JlA7ZtBZMDCxCi1/3fmTXVCVb5izr2JY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ntG3Rq4fVdxT3EoUt/YBoAgTFK0pX70lZBDomp3Qkd5XElD0SdVPQ7SUphQWGsHN4 rzi+iBfcYGONEvi9cc7iQlVWq3i1WXx0WGObTsqPFmImlrUQSDBL29Ndf8M4gTvDxI 9SR/TvXkVY4JYOikOwm9ouphNuanbMRU2KymSMx4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Namhyung Kim , Ian Rogers , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH 6.0 840/862] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Wed, 19 Oct 2022 10:35:27 +0200 Message-Id: <20221019083327.001758539@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Adrian Hunter commit 5a3d47071f0ced0431ef82a5fb6bd077ed9493db upstream. uClibc segfaulted because NULL was passed as the format to fprintf(). That happened because one of the format strings was missing and intel_pt_print_info() didn't check that before calling fprintf(). Add the missing format string, and check format is not NULL before calling fprintf(). Fixes: 11fa7cb86b56d361 ("perf tools: Pass Intel PT information for decodin= g MTC and CYC") Signed-off-by: Adrian Hunter Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20221012082259.22394-2-adrian.hunter@intel.= com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/intel-pt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -4033,6 +4033,7 @@ static const char * const intel_pt_info_ [INTEL_PT_SNAPSHOT_MODE] =3D " Snapshot mode %"PRId64"\n", [INTEL_PT_PER_CPU_MMAPS] =3D " Per-cpu maps %"PRId64"\n", [INTEL_PT_MTC_BIT] =3D " MTC bit %#"PRIx64"\n", + [INTEL_PT_MTC_FREQ_BITS] =3D " MTC freq bits %#"PRIx64"\n", [INTEL_PT_TSC_CTC_N] =3D " TSC:CTC numerator %"PRIu64"\n", [INTEL_PT_TSC_CTC_D] =3D " TSC:CTC denominator %"PRIu64"\n", [INTEL_PT_CYC_BIT] =3D " CYC bit %#"PRIx64"\n", @@ -4047,8 +4048,12 @@ static void intel_pt_print_info(__u64 *a if (!dump_trace) return; =20 - for (i =3D start; i <=3D finish; i++) - fprintf(stdout, intel_pt_info_fmts[i], arr[i]); + for (i =3D start; i <=3D finish; i++) { + const char *fmt =3D intel_pt_info_fmts[i]; + + if (fmt) + fprintf(stdout, fmt, arr[i]); + } } =20 static void intel_pt_print_info_str(const char *name, const char *str)