From patchwork Mon Jun 17 09:11:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 166980 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2605503ilk; Mon, 17 Jun 2019 02:12:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiCfpSElid3JuzT3BHzBXeYWxtSRWSooUJgq873s1K0HxqnCEwas85cweX4cwnJA63Useg X-Received: by 2002:a63:2b92:: with SMTP id r140mr48822069pgr.363.1560762736208; Mon, 17 Jun 2019 02:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560762736; cv=none; d=google.com; s=arc-20160816; b=iQfH7DwAlPrBC34BWY9blUCzqSmEK+u3TXpxeGWJOHIEGN9mJ1aqiLTO6YAT82QKsN HyPbLI1b8KVdMXWToGYAHrqfAZxvTsxO8XRdupIt2C8PLs5gYZ5A2lNSdXte2m6G7rBi BeDHaF6Ba7wJJXQ4HzNYVJJIENvp41f6elNBnBjf3mNNxu8kZFzC7kklcv9mOlgc7V9E +bgBR8nD47MDhC9Obw3sLiDdQELi+HBatfiuM0qFlXADulNj3+z0MWLBfMb8VZranLg+ OqLdhLffjCtfHaAcgOMTusYGaWK92osXtskjGyyFWLmr4+gWJw4hLKvsOYl6Q3fhddaQ +MXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=XkQKkEqj0Dk+yMwwMUT9kq+YcOABBfUMfQA+OLQkIhs=; b=I4xgCO7ZXOpY3v4UJxpqGElmujHwP16DERq4UPSWuFc2eebXStibdqrXnnGpCe0chH TJNDS2tE4OH5sH3Nqu8SHeGCddTRPugv78Pz4Ys70jscWQwqLC/BGRfmZwS7feMilCJG 8a52RzU7hgTD2ldNOD+HqTAaCon46PCOEOUht+XZk8r7pi1LM7CuinyJR6ulLUdiUZgm MItbt2CXRjvBKIlhRWDQiGqBHhrmXQE8CP0dwQVixmoWmstsTxFYEsMSQ/oT/KMXchVV I9HtmY4HcfB2nlxDZmJbg7z6Bft5AUi/MFNhixh6HY9MOtwVVZA5JJv+BzULNeyADsAN Mzow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A97y2r8a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d191si10009852pgc.460.2019.06.17.02.12.15; Mon, 17 Jun 2019 02:12:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A97y2r8a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728070AbfFQJMN (ORCPT + 26 others); Mon, 17 Jun 2019 05:12:13 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:46014 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbfFQJMM (ORCPT ); Mon, 17 Jun 2019 05:12:12 -0400 Received: by mail-ot1-f66.google.com with SMTP id x21so8543789otq.12 for ; Mon, 17 Jun 2019 02:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XkQKkEqj0Dk+yMwwMUT9kq+YcOABBfUMfQA+OLQkIhs=; b=A97y2r8a4SElnnqWxEgYt9hqzUlV/cOq2E2WwDSEdCBsMl4m9cFtY2fwwCpdvcakGW awt+SV7bLv8nxXRVmEnrNMG5nFwayb31HFNIpLayWLPTVlHkQNzKb7SuHGb/q/kFN1iG KVV5NavH8nIx9y83mXraGlVjJ8aelPhg8mONarGKKwUmLvP7zgFt9KexSKptxXiLGBtB AghmJ9J5muwb89JeCF2VbT9c8bxFbPOzohfyudUTv0h+bt9tmpFijVpS7R1W1toW/CwL o9HaBfx9fAnEFi8vjuByIGu5qiqhE5bzRO7ym7pfTmOyYah4LXxvPFkfhV2bB4XvMmBB qZjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XkQKkEqj0Dk+yMwwMUT9kq+YcOABBfUMfQA+OLQkIhs=; b=Zv17fUOqDrR5uXhzs1TPTcIAeuc4glU91hCBkm94dS70PmgChUkz60VvuLMTqZhpJS +XprgPQkPfszf8lmenkzYwIjGJf7Hy1+SRp9GGo9JrNZWj8cXD4aUmVUdnh69Roz4qtd 8U8MRVyTk1NgzSc01EhKuPwpDfN9T3girYQZPTudILsyNC1hzsxWjvzsS5mknLGeuhlL B1dwmWH9xZsCLTTg35iQKyg+mA4nGn6D5sBRwCDo4gbPvf1uh9uuwGVwRC62ZiVyw0HO CeWiju+B997MWnyLIBGneD/03rbsMrCq3o1Xeosam3hVRDCvsFOaxwVQ4N03GCd93aen 2g3Q== X-Gm-Message-State: APjAAAXTtiimRw6sN647JorYjGNJsvsmx6oozGmplZgzj+Qc8eQ4fID4 l3Jj2gUjSISUGrViQGgu9WRVGA== X-Received: by 2002:a9d:4b88:: with SMTP id k8mr61017358otf.285.1560762731712; Mon, 17 Jun 2019 02:12:11 -0700 (PDT) Received: from localhost.localdomain (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id l145sm4418324oib.6.2019.06.17.02.12.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 02:12:11 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Leo Yan Subject: [PATCH 2/2] perf trace: Handle NULL pointer dereference in trace__syscall_info() Date: Mon, 17 Jun 2019 17:11:40 +0800 Message-Id: <20190617091140.24372-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190617091140.24372-1-leo.yan@linaro.org> References: <20190617091140.24372-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org trace__init_bpf_map_syscall_args() invokes trace__syscall_info() to retrieve system calls information, it always passes NULL for 'evsel' argument; when id is an invalid value then the logging will try to output event name, this triggers NULL pointer dereference. This patch directly uses string "unknown" for event name when 'evsel' is NULL pointer. Signed-off-by: Leo Yan --- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 5cd74651db4c..49dfb2fd393b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1764,7 +1764,7 @@ static struct syscall *trace__syscall_info(struct trace *trace, static u64 n; pr_debug("Invalid syscall %d id, skipping (%s, %" PRIu64 ")\n", - id, perf_evsel__name(evsel), ++n); + id, evsel ? perf_evsel__name(evsel) : "unknown", ++n); return NULL; }