Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp807243rwi; Wed, 19 Oct 2022 03:15:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4z3HKfImQl2BmkalPYNl6MUK/y1EcyBCUslIzSPzXPZW8t4iHgb5klV5vOjfIlqJAPgFVM X-Received: by 2002:a05:6402:550e:b0:456:f79f:2bed with SMTP id fi14-20020a056402550e00b00456f79f2bedmr6803123edb.106.1666174557293; Wed, 19 Oct 2022 03:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174557; cv=none; d=google.com; s=arc-20160816; b=GOBSXRB1MVKzczr8bMQIbJnTA4jCMHM4CtF0s61xPrrKQcC+KTk2P/TriixoRkG80E g6oswJh+9kDPIIsz3xVek+CvFv8RWSUVOohxkUIJC2lwAF3+3ZgVzR9fb7UavApXKCWN XTSa1+jB0Uj3Uqr6jGlonE5/ZnjpqoPfJly8Yhxw1ctEO9Vm0tMmikgtQvuBrJcOZCla daYrnmngLiVUXbvUx94gg5XQOPQ8XwuWzgdzT9n9MfSWHLxlxJicapahz3FWFfnSybnB G4oLhpW2AOskweTDL0SD+f5tgsLrF2gH2ge/Sfi0wjshvpyAQhhht5wOEV4XBz9U4SLi n5tw== 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=KnkOJevIMxVQ55F/TzQkOO48aMi3h4cjf0n+Nojdx7M=; b=W89QX2CjNEieZVd2fFeN3KMgGVAkBvoDiUkxqGIgu1FuqzfIj9LMil60PlNSsWXEPi 8vxJua4DH93k+oxTQGFVi27cJJl2rRqOlbgCpwoJFWpZeWKAhSd289ieHMPFPwUXsDbc YUJGblrvkd5LSritdAnbsEcvRgAjZFTQWSnGZUmE4Pwyttmzh/Uiy7rX1k5JEbqeQ6BO aeD3qEO5c7FqQQgI4JrVBmG3JDABLiNTAtMGgKMknaSNIqDlCahkbN45b/0NKIFb9pOx xmrK5yo4BWdeXJaxM2YcDPhw24SfK5Q9xykf5wAY1T2hZM4bCl26gWJHLwG0sTATlnUT aAZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ntG3Rq4f; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go10-20020a1709070d8a00b0078d4c9d77adsi17130588ejc.94.2022.10.19.03.15.29; Wed, 19 Oct 2022 03:15:57 -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=ntG3Rq4f; 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 S233748AbiJSJpF (ORCPT + 99 others); Wed, 19 Oct 2022 05:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234953AbiJSJl5 (ORCPT ); Wed, 19 Oct 2022 05:41:57 -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 9FDDCF5CDF; Wed, 19 Oct 2022 02:18:36 -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 4CF1F6181A; Wed, 19 Oct 2022 09:15:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E78AC433D6; Wed, 19 Oct 2022 09:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170929; bh=Cjo4WF83Lp3JlA7ZtBZMDCxCi1/3fmTXVCVb5izr2JY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ntG3Rq4fVdxT3EoUt/YBoAgTFK0pX70lZBDomp3Qkd5XElD0SdVPQ7SUphQWGsHN4 rzi+iBfcYGONEvi9cc7iQlVWq3i1WXx0WGObTsqPFmImlrUQSDBL29Ndf8M4gTvDxI 9SR/TvXkVY4JYOikOwm9ouphNuanbMRU2KymSMx4= 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 6.0 840/862] perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc Date: Wed, 19 Oct 2022 10:35:27 +0200 Message-Id: <20221019083327.001758539@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 @@ -4033,6 +4033,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", @@ -4047,8 +4048,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)