From patchwork Sat Oct 22 07:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1138191wrr; Sat, 22 Oct 2022 03:17:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wFH3sFFG5PYx/YHNfIZXl7aRzjeEZdLLYNVyH2e7qNsYdAu3rIs1x9OCrXPsRHQCJAhoD X-Received: by 2002:a05:6402:354d:b0:45c:b772:5ef4 with SMTP id f13-20020a056402354d00b0045cb7725ef4mr22078982edd.225.1666433863811; Sat, 22 Oct 2022 03:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666433863; cv=none; d=google.com; s=arc-20160816; b=0lF20UfHeS0RT6zBRpgc5SOksWw2lGNpwnpAiG+H2vt9IBlSm+J4keB23GnEaiy28Q Uds8t8NseCxdkar4VJXOJwu6s04CIDdHaPhcgexh401QXgwEk1gB93KqowJ3CN1mGuXb JZ4buHDCKZSafLJ+OYdwNwWxsft9jsSQgMvo/Y9LDOj2sJ2bWZxM3vMHop4IA/jkxMWE iA6DhL4Ef2Emjl0CxODhlETQoEPIPQdcGP5H8D29gzTH4XSvDM7BHnnTdNEeO/17FM+y qOILuc4m8oVKWesVkCPR7gUqE7T1mU5e/IxlbykEsKVOH2KQn6eOiKGDrtT7rbkFg41A u62w== 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=qUaXSaj3cDD3aJhweshAGDCudJsxDN3HBdxDYshTqkA=; b=OXFdQYizUytKpL/sCdpSCP7VJqxD5fcTfBdPdpdAIdb/Zh72PmgeB6M3z5RIuVHV9j YNkVzgzVsjAmRfSO9g77k1xbMhC9EjBdGz8WqFJdQWicDSrSoFO39RGFHehwTg35oFSy 1yo4AmVq1pP0W77HD9vRWwiYD3cKIvwTjJxhUuGFV+urL5Uh+n4EkRgYnZUrcaNy38wE ERH8I+lNQwQpJNuHnEWSqm+9G6aj+hH6sANYmcnBDTSCNQhyLIXkH5ivu/YOS2G6EPXU IGmfW6Exf9qXBcqCtwVOcPa7wU07yHSKmVFs4sXI0SkGm2fwOuckjBNLQ9q6F1mBvspO Q4zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GgiL+dA8; 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 r11-20020a05640251cb00b0045d9ceae6d8si15297903edd.492.2022.10.22.03.17.18; Sat, 22 Oct 2022 03:17:43 -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=GgiL+dA8; 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 S230238AbiJVKMO (ORCPT + 99 others); Sat, 22 Oct 2022 06:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbiJVKLs (ORCPT ); Sat, 22 Oct 2022 06:11:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FD952D452A; Sat, 22 Oct 2022 02:29:15 -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 ams.source.kernel.org (Postfix) with ESMTPS id 39447B82E13; Sat, 22 Oct 2022 08:07:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C9E0C433D6; Sat, 22 Oct 2022 08:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666426032; bh=2Ab8NC/nMg7sY+5HGefX95dp+GqVgVdbTfyI40GmjLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgiL+dA8EAsV0Nse4sWkxrsBYwYN6W3NaUP5PIt0uOYmfpyu5clJ2VxaZVagbVZkd RWwzVkOyK0QfepJaSvweYUGPdgkFDWhnRZft+PlY411NXEROnV0bRXbTmchJHvzMfS qp3P2VtK/m1nIQCpKQg8ETt06l8t9S9USlChGJlY= 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 5.19 697/717] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Sat, 22 Oct 2022 09:29:36 +0200 Message-Id: <20221022072529.291679010@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747382555143198344?= X-GMAIL-MSGID: =?utf-8?q?1747382555143198344?= 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 @@ -3878,6 +3878,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", @@ -3892,8 +3893,12 @@ static void intel_pt_print_info(__u64 *a 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)