From patchwork Mon Oct 24 11:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp416951wru; Mon, 24 Oct 2022 05:12:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Wm3IVvjBMuXZSUUf8mzx/0hcdMvaizX38xBxbbJwaH35TbwZHN9a7/Iiu/yHchsXpy4JP X-Received: by 2002:aa7:ce8d:0:b0:461:50fd:e358 with SMTP id y13-20020aa7ce8d000000b0046150fde358mr15300348edv.194.1666613547074; Mon, 24 Oct 2022 05:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666613547; cv=none; d=google.com; s=arc-20160816; b=Xk89WT5o3PqAAzQZeZPandFjF6q9JuPA778/d8GACa3z8CHI+2yqYLErxGDLPwhPqt FlptWZQFbCZd9FbM0PMgbnqiYRtFFrB7IzGLPrCjW+IlEmR0bVmdU8MKnYGw4jN3n2xG zvpDKx3kItvZioXOwpVSHntjvA6dOZi1igUiKf8cEasnzKjUxnIzzTfqbCmoRMPBHhma vD01oPSpAP5bdVtFP9JbxpRG9ud+JXfDhQgiBIdF+tgVYgxejPNxGSLtfkMWEAieVSpk inwcDnoxExpfwhZrJ+A2amY3pc8ZIYht5DOaGsaSlGFzEgBf10PblEEl3UMBXdhMQb/5 zjqg== 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=XosWSMrVhCgCEY5S25EeVp5xVe3pPLVFCjKJQVEk5EM=; b=hyDCqbNARfZxmBk3Nzmqcn0i3RYwOABiUs6LvIIww0hoLorei9IAnJhhDcbqoNjtKl BzEVwTslot0Vjn9LR9VCwsxnhzcEVtcjatifMHb+XjCmOPOMO8T8kuFcoa/SrQAbAxng sQfCrwJZQ5yMusXwAI2qtGdkBOC8/2AW1bP5Hvh089x/FTD60H+bvJeryTDsD0+lfkfZ sQRoNUOUhLOd9U2ZOe31wDmYbsi6H6EI1hYucCMMoUNKPh2IMi+LgOG4pWy0e00+Q9wo cs0OdN1T8a03pKT6fgYft6V/+VdmAbTqWIOeJhtw5RieLlIeKBZAzhltHtl5lyRUD+Vi fRzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EgEHscso; 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 i19-20020a05640242d300b0045bd55b122fsi34053344edc.57.2022.10.24.05.12.01; Mon, 24 Oct 2022 05:12:27 -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=EgEHscso; 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 S230149AbiJXMAi (ORCPT + 99 others); Mon, 24 Oct 2022 08:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbiJXL6f (ORCPT ); Mon, 24 Oct 2022 07:58:35 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C10DE2B1A6; Mon, 24 Oct 2022 04:47:53 -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 sin.source.kernel.org (Postfix) with ESMTPS id B855DCE12CF; Mon, 24 Oct 2022 11:45:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B294AC433C1; Mon, 24 Oct 2022 11:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611928; bh=UE6C/YunwoRMuPQGwLI+pqaEFufW26X4AEXY60j0vS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EgEHscsoJSqI9zC9vJTC9uD3a1jKtL7xIwyQuR9/8YoQv2vgz9pwKxVkAN1AK7zOs qrNBOk966QC0v0sfxzwbKoh/nqrFPS7+uO+C9qGTJoT8iOf7gLP6hxK4gx82TJEiNf UScXv6VbzaYZ3Pb6iB8Gbgm7TBWIWCaBdwrpUyQI= 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.9 153/159] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Mon, 24 Oct 2022 13:31:47 +0200 Message-Id: <20221024112955.006882965@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747570967154090710?= X-GMAIL-MSGID: =?utf-8?q?1747570967154090710?= 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 @@ -2124,6 +2124,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", @@ -2138,8 +2139,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)