Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6804695rwi; Mon, 24 Oct 2022 06:22:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4n10nZJ9DreG/SqnMLZ7duFMbK353KLjqz6jxzsA2wXlVIwAOQBwjWZkG8+rE/cxS+n9M2 X-Received: by 2002:a17:907:7245:b0:78d:ec9c:e743 with SMTP id ds5-20020a170907724500b0078dec9ce743mr28245674ejc.466.1666617768779; Mon, 24 Oct 2022 06:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666617768; cv=none; d=google.com; s=arc-20160816; b=cY280qcoVl/0Sj6xwAlcBynknQL5h9Jb4VL4ExMs4ykP5fcr3Qudr1KECN6kfp5Son YHlsr3kVPGzxVN2pAqyUvMdetYPECKIvdx8JouM12jraGqbEE9Ay1aNcgCkI4vVwG42J TFwFcJUGcxL/oyxMAUWRAl6WJNdkxVkzb6C5G7mT4t7WiuBWJ4l1o9SsH2sioO1GtdlO J64Yo8moXSifBULIWR2DfcmpZOJviYvv0WL0OiS3h8deWhKhLF2WeEyICXRqW862K85w Lihb7ikY2ugWfzQ+STToBAOsMfX9XJcgq8nr8saGn9rvq0MLo1ZbFs3G/wVklSK7tE8Q s8vA== 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=mbd4xz6vHxl5sj6cS2xTY51Wigzg/ebPu54m02TTNmY=; b=E3BhRL9w8P0vJDWVM73cDswhbeXfohrKjWtn5ijEMa4sZcox5kH1f92/E6yhb9zCb5 4fuyqGNRevkHBIHVQuk7iDCnvu4k0UlMASGynD2I2HYVaSswbbKKrGS3kuPuMZRoUHFV ZmQHmGXMbg+12f9yzYsA7y9ojYIDbX7pXhkNQcA1E/kwmQ8WjmE1bNQMKWCaXYQMjuGh /lmgDsyQceK7CwI4UdBiL1pzfYuX0yH1/LceDwhoQ8CHpRsWzgnWhqvg2cNrSh8e53+C qT/QLqBS+L6RvdMR1BD2x8sQXwNFT2dAwCBeOghQeomWPvhzGIVo+vHJFLW/apIcIr8A TBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rrov728l; 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 ne40-20020a1709077ba800b0078da42195c2si27688310ejc.547.2022.10.24.06.22.23; Mon, 24 Oct 2022 06:22:48 -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=rrov728l; 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 S233163AbiJXMQ5 (ORCPT + 99 others); Mon, 24 Oct 2022 08:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233062AbiJXMOF (ORCPT ); Mon, 24 Oct 2022 08:14:05 -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 9508B36BCF; Mon, 24 Oct 2022 04:55:13 -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 0141D612B9; Mon, 24 Oct 2022 11:54:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 134DEC433C1; Mon, 24 Oct 2022 11:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612478; bh=sIVVFNzUhGVUuv6vdAiIrXMPSxdti2gXGjKG94av/UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rrov728lubW213Gr/6QVUxOcCgKlePU8/4pGvWHpfbwz1pjZ/yw4DsareyprlKnIL C/Brd0D2Y0kuZMrhlt2ZX30xKqrPdDo9rVZrR/hrVFT+Kp0qrfhSNvtLhWPo5JKUUH i+i8maFZcAC9tSXtYrFu5WBWZyijpIaFI4OVkJ4o= 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 4.14 203/210] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Mon, 24 Oct 2022 13:32:00 +0200 Message-Id: <20221024113003.574627712@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 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: 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 decoding 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 @@ -2411,6 +2411,7 @@ static const char * const intel_pt_info_ [INTEL_PT_SNAPSHOT_MODE] = " Snapshot mode %"PRId64"\n", [INTEL_PT_PER_CPU_MMAPS] = " Per-cpu maps %"PRId64"\n", [INTEL_PT_MTC_BIT] = " MTC bit %#"PRIx64"\n", + [INTEL_PT_MTC_FREQ_BITS] = " MTC freq bits %#"PRIx64"\n", [INTEL_PT_TSC_CTC_N] = " TSC:CTC numerator %"PRIu64"\n", [INTEL_PT_TSC_CTC_D] = " TSC:CTC denominator %"PRIu64"\n", [INTEL_PT_CYC_BIT] = " CYC bit %#"PRIx64"\n", @@ -2425,8 +2426,12 @@ static void intel_pt_print_info(u64 *arr if (!dump_trace) return; - for (i = start; i <= finish; i++) - fprintf(stdout, intel_pt_info_fmts[i], arr[i]); + for (i = start; i <= finish; i++) { + const char *fmt = intel_pt_info_fmts[i]; + + if (fmt) + fprintf(stdout, fmt, arr[i]); + } } static void intel_pt_print_info_str(const char *name, const char *str)