From patchwork Mon Apr 26 07:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 427529 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6d12:0:0:0:0 with SMTP id m18csp3588401ejr; Mon, 26 Apr 2021 00:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgRZtmhkmpiP99lUrbRtWi/EgdthDC/7ehSxZZNpw1e5FZklqNHyUUDp9scvbsR7xBhFn+ X-Received: by 2002:a17:902:654b:b029:ec:a435:5b5c with SMTP id d11-20020a170902654bb02900eca4355b5cmr18090501pln.42.1619423118575; Mon, 26 Apr 2021 00:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619423118; cv=none; d=google.com; s=arc-20160816; b=w9ZCFGRQcNqU4zVNzfuWxRkTcYw4KliN8G5nGSYoCQIuug4rpZympYVSS0JfG7P9Un 7shr1jjfCVVodq06MNIq6VxZCDAtaUGTFn3nSKFM7bxL/skmy7SQMg7MbSaQi7rl+r2r 1ApuHvYOuvJaDPxdlcYHWYr3EpQcicCiyfj+LHpnPoIYoy3ZsukDS+P/rb2iK3Uo4WZ9 GI66OTV3y9uf/h4DBhdW/D4UWkZpBjaS+BcPGnGQCL96yKdenYPXnNmkyKPRD9Xh8QjG M1B5U/daKPpR2C7HR1Q14iXudUhpcV3r2U0rBcJRZckFHrJzkjm45ulJCwlF6Yd4iFQ0 RqXQ== 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=ImbEjbn+3dU8oqHoIOmdgSBV7I2vUqXmAKd96xddy3Q=; b=UsHqyGByXHv0T33KKvUHk9sCeLkQVLop7vAx/rd7ssWr6vIhalK6Xp/JJlKGR3MkH/ 22ccSeW4BzToasoGhQzQ1klDejmdWQ17GKV+WPOLuBJAs0TwZWC1h7LAePAZqfs1XRIf F/KaBlG5G336nrCsQ01BUKC0e4jSs3SvtndDUWmaf/zPPORmjXuYR3geIvc0qCWOMlJM ZCx2TtwFP8XSaMDQzpxuuj9MTgN+6cW7LVoVWFO1GkjwyB9cyIz1lt5RSb6WNEYONjzt NzuOJiHtn8il1nvZW57qJdlS04d2fbxztZYTDU/0071SPDEIoW2frPxhXba3TbTb3qJ4 AFCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uGV4Fcwq; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si16086476pgs.487.2021.04.26.00.45.18; Mon, 26 Apr 2021 00:45:18 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uGV4Fcwq; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S232271AbhDZHpv (ORCPT + 12 others); Mon, 26 Apr 2021 03:45:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:33310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233987AbhDZHoj (ORCPT ); Mon, 26 Apr 2021 03:44:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF7206140B; Mon, 26 Apr 2021 07:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422861; bh=FFoVKwFLreaTj0LAPzdMX0zxogpbj2fSJU4J/H0YkKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGV4FcwqKflnjye2YIZe3VUfkziYviTDf8AFuFET4JnGdy9ic5LewEZ3qBFUSQLRf mPT8JZ0rBarT2gpbsC7Jqckgq7Dm/vxL/itnwp0hzoSZtkIatG5A1GuywTN5NDnmiM GCnnIeyE0YUWbRen4IGgom/JDakfbF7UyNU+vEIM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Adrian Hunter , Alexander Shishkin , Andi Kleen , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Tiezhu Yang , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.11 20/41] perf auxtrace: Fix potential NULL pointer dereference Date: Mon, 26 Apr 2021 09:30:07 +0200 Message-Id: <20210426072820.365678962@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072819.666570770@linuxfoundation.org> References: <20210426072819.666570770@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Leo Yan [ Upstream commit b14585d9f18dc617e975815570fe836be656b1da ] In the function auxtrace_parse_snapshot_options(), the callback pointer "itr->parse_snapshot_options" can be NULL if it has not been set during the AUX record initialization. This can cause tool crashing if the callback pointer "itr->parse_snapshot_options" is dereferenced without performing NULL check. Add a NULL check for the pointer "itr->parse_snapshot_options" before invoke the callback. Fixes: d20031bb63dd6dde ("perf tools: Add AUX area tracing Snapshot Mode") Signed-off-by: Leo Yan Acked-by: Adrian Hunter Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Tiezhu Yang Link: http://lore.kernel.org/lkml/20210420151554.2031768-1-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/auxtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.2 diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 2723082f3817..e7a071a15470 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -634,7 +634,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, break; } - if (itr) + if (itr && itr->parse_snapshot_options) return itr->parse_snapshot_options(itr, opts, str); pr_err("No AUX area tracing to snapshot\n");