Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6868423rwi; Mon, 24 Oct 2022 07:06:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tTO29sk5wYLaxBlLhngJquPQtllbLprRpIYhWehGu9RRrSOAjudzWnUc1DUbzucRfoqmI X-Received: by 2002:a17:906:7944:b0:73c:838:ac3d with SMTP id l4-20020a170906794400b0073c0838ac3dmr27552314ejo.242.1666620364298; Mon, 24 Oct 2022 07:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666620364; cv=none; d=google.com; s=arc-20160816; b=uLaEpdkVBCfe+1mQ+qCghYxHLkjvRgfqnL6x6mvVBEALGncN0YjeyFToQoTGLnF5X/ UOrups8vgswURPSuDV+KJgMMx9+X3vU48feYZjSTS2t4qgxed35K2AvvYm1MZDmxb1hO hmNR9VcNTGro+2kRXqRhPJSZq5LP+OBZdTo4soGfD2VwybMw1y2kSFkRi6d+VUuN9doO EGYJUNR3LdQIZbzTx0pKEeJgINPSj9XAhFdxuxBs1ZVC9Uu09LVPQvm0rfMg7yWuVotl 6EdrGntU4mDMFvraJtGndu7SmBmb5MZZtW+Sp82BVWBdKaXxc3+pnDqlEnSE+5KfcaxE sjTA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a056402254700b00458ea275c22si31984240edb.325.2022.10.24.07.05.38; Mon, 24 Oct 2022 07:06:04 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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)