From patchwork Mon Oct 24 11:32:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp436151wru; Mon, 24 Oct 2022 05:56:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41TzdS9LWOGUGhscVV97zxm4QPAcKAHoij68BhJAck5QNyyxmz024cvcp1z3BI/q5jwnIl X-Received: by 2002:a17:902:e902:b0:186:9c03:5f27 with SMTP id k2-20020a170902e90200b001869c035f27mr8131210pld.16.1666616193428; Mon, 24 Oct 2022 05:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616193; cv=none; d=google.com; s=arc-20160816; b=DVCKLnc67ry1JG98djw9ZA8iWGJezHK/LjXq2l8U86jvuh62aq+XKJ0QHpvqucll3x ITJSF0JaHhr5lTmIvCTRGPdSLINLkh3LCmhb4nPXoBhouQW8RM/cAdlmkrbC0NfdO6n4 n8ieaiXJ2fTa5yYXpeSE6ALQH7xlitWFD6QChP9LFO+FyfOG0ukAY3BfA1M4Afevlr3A C+44HKyG9Zua6cV653ZeQLilTuaQq9qAuDZKd+PX7z2Gjxi9523hYcFwBvNi107QsvIx E5mhtBadNLRNWkMLRlreGrKd/jJHjJdpnYEGDECM22wk9PcAHlpP/iL3AqVYtLpTRTtL Uq1A== 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=6Y8d9y4cD27hwdK2bOfgFib9vmYCK8Awq2WCbQsfX40=; b=b2USbxDyOy8IYlXbzj3EyuAzdo5w9eLtBBo2q7mxnLET0uTS2xiHnCQ/TGycpXx6z4 YAGtJ661yTkY7OQPsOBNGluDDYH/lFity4g2UXMeEzjn/DwwA5Ax+rxr3sr63wwFqWWd cwcJOrLu/7zmefXScxrqxGp3UlzPE5VHYHQ35cYSVqV+nPzK1vlfa+EdN9Bcm+lJxQ+a U5DV6hd41z5mE0MXr/xTz0SJar2pejLRPs67Vt3NiD3pzBw8NxbzxPlXmTQ3JgnL5OvH UnWrffEvXCqYHz5O+TkQv+rMexkKkAw3/MqlRF99tKSFuyhSC+mzzmIxpgtBUCfcgxBS IGJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u6Krc4ig; 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 v6-20020a1709029a0600b001614cd997a6si10351021plp.481.2022.10.24.05.56.20; Mon, 24 Oct 2022 05:56:33 -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=u6Krc4ig; 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 S234565AbiJXMzY (ORCPT + 99 others); Mon, 24 Oct 2022 08:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231911AbiJXMy1 (ORCPT ); Mon, 24 Oct 2022 08:54:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78967201B3; Mon, 24 Oct 2022 05:15:00 -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 B9C106121A; Mon, 24 Oct 2022 12:04:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE001C433D6; Mon, 24 Oct 2022 12:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613085; bh=Z6Jp/s2PYgjHFNbyhiSArB81BC6Uh7z2TR6mIj/hsJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6Krc4ig5wuTlJvS9/Bl+j6E68bURc996UbCJF+5xIh5azFRl72o4lxBahOXRwSOS rJQfDBzNerr50NrReDAwAnxacAvpqhpoi7MzDRdLUkwMv9ki8feBOEu1b1NZwkpQIa QgJFG1EdFry86B78qxGXdinHPNWHMvB5uFbXCX3o= 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.19 221/229] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Mon, 24 Oct 2022 13:32:20 +0200 Message-Id: <20221024113006.403705714@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747573741534855006?= X-GMAIL-MSGID: =?utf-8?q?1747573741534855006?= 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 @@ -2373,6 +2373,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", @@ -2387,8 +2388,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)