From patchwork Mon Oct 24 11:32: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: 9255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp461552wru; Mon, 24 Oct 2022 06:44:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HSW1NsSJCy2xS/fTPKrPd5d8XEntdMvlEDBzUc1ykPA01hFLia/+EjkJ0uVYnvPRbHePD X-Received: by 2002:aa7:c504:0:b0:461:122b:882b with SMTP id o4-20020aa7c504000000b00461122b882bmr19734751edq.14.1666619052898; Mon, 24 Oct 2022 06:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619052; cv=none; d=google.com; s=arc-20160816; b=ZWstLMSTmINcFwbhJM/LTEMI/j+8XsBvBLs/cvkNthBVm0ftREK+BziKqrkU8N2Y11 h5cFSQP7w6sC9eazHlv07QeMZiK/v1mnZkfoqGj0KbJS2PQexaH41ZF+pmBiWC1P6dz+ Ku+iD8lhmQeyg1R2CT/bIN4kY36P+upLI6K+djHRXpSlVBpxA8KQG7F+taP5XJq875tu vujCz88uX2WDIgOo3FwG/iEmoeOnJG9yE8OTk7VUsOnPsOEp3JLdcVh4XomWSvjL5gpu ut7QEuhRVBUAzFeGkPx/8mRKAg8/EI9WKf75Bnq5bbGUz6ePuvRbKpE9EfOMHHP4ov/V H/wQ== 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=q1DeWLJ7xnd5qhnmRZnFFdpFiX8o2o3x61YCyeHzV3k=; b=lUzzOaTGN/fryHlkJJy6EJrCWymc1E0/4b2alsZma4YI9917QRj8PivIJ5qWKuSxTN 3/TsPcqo1R+TIP8DQLtgyokg+bjFOEp91G7E3GZE+dMxVUlxkL148TeRryQ9X3JbvOnU C64EmR1w3ZH7lLcssgNK8js0JlwJqjYWzeBOKiGfEdvyzz5MMSNEfvnPj62Lyfa6kOKD xaRUYyvlvt9qngrIPX8t23gK4XQ3i/xIQ80SR9F1Ki7+wflX0wqOeaaDmLurSA7ms2wy HyNz84WRWYrHTEbF1EUA/eH9Em1LlNPmouR+/MTSU3hQPdndqMmq1V4HyfmWLVWfara/ IZQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1JEpOgZa; 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 g6-20020a056402320600b00461cdda451dsi2229502eda.435.2022.10.24.06.43.48; Mon, 24 Oct 2022 06:44:12 -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=1JEpOgZa; 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 S233733AbiJXNiW (ORCPT + 99 others); Mon, 24 Oct 2022 09:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236172AbiJXNe6 (ORCPT ); Mon, 24 Oct 2022 09:34:58 -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 8B5D75925E; Mon, 24 Oct 2022 05:35:22 -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 1FDD96132A; Mon, 24 Oct 2022 12:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B198C433D7; Mon, 24 Oct 2022 12:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613726; bh=B5IjQZsAWjCQMxDIcwqlkqYSdaq9puYmFTFdYNsrZ6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1JEpOgZaBxepwReSQmb4TGE25Ht1rylCprheb5LQIpABEEPGB0+9awVtF/3xTpLWB 8agZtxAeCOWCv6Fe15tFJcqpnl8StNOrx23Vof2I9FCUG3zJOL/XBR+7e3GBPi3y1T BTcP+Wgng6arTDzU3HK55mfngmy0nBagjbLsuFso= 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.4 246/255] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Mon, 24 Oct 2022 13:32:36 +0200 Message-Id: <20221024113011.445356713@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747576740168628445?= X-GMAIL-MSGID: =?utf-8?q?1747576740168628445?= 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 @@ -3038,6 +3038,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", @@ -3052,8 +3053,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)