From patchwork Mon Oct 24 11:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp421699wru; Mon, 24 Oct 2022 05:21:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM55C9LjbsPM0YyZBKvfbQ7K5FYTjz0vmxAF49GepI1CNaZK1ZJ2SiCdQp4uawv1/9x4THAk X-Received: by 2002:a05:6402:428a:b0:42e:8f7e:1638 with SMTP id g10-20020a056402428a00b0042e8f7e1638mr30881971edc.228.1666614063533; Mon, 24 Oct 2022 05:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614063; cv=none; d=google.com; s=arc-20160816; b=AqnuHCkFxlGegTlKYlyiHblfQZcKc+pYOYWzCJzCpQ9FjEU2mTxhL16Oim+TQ0KZ5W pu9rNebx4knhufgIldRQHFY4NdP+rlUm8hMCQdJsmkmVyXW/5ElwMJBquKhH36VjMWlH q970iCn/RZw8W3sQAgTS6Tj5R35yuyznLu21dJsbhfQyf5/5WLd17S7Q3jdoFjzzxtkC Yd9Jf4NyefiG/mZmp4935wzUvhoS257hTxAQVNY0fyZkCt0br83emy7bQ4D+GQZxvHui 3zek1OR5m4FSpf+sBNe14CSlx9fVGnWxE6DESXjNgkSRIn3ULbubvRNZWhUVHBKycdln NtLw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz13-20020a0564021d4d00b00458db439f07si32770740edb.14.2022.10.24.05.20.38; Mon, 24 Oct 2022 05:21:03 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747571507902153815?= X-GMAIL-MSGID: =?utf-8?q?1747571507902153815?= 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)