Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753474AbbKLGoJ (ORCPT ); Thu, 12 Nov 2015 01:44:09 -0500 Received: from terminus.zytor.com ([198.137.202.10]:50325 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650AbbKLGoG (ORCPT ); Thu, 12 Nov 2015 01:44:06 -0500 Date: Wed, 11 Nov 2015 22:43:47 -0800 From: tip-bot for Wang Nan Message-ID: Cc: namhyung@kernel.org, lizefan@huawei.com, hpa@zytor.com, masami.hiramatsu.pt@hitachi.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, acme@redhat.com, tglx@linutronix.de, jolsa@kernel.org, mingo@kernel.org Reply-To: namhyung@kernel.org, hpa@zytor.com, lizefan@huawei.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, masami.hiramatsu.pt@hitachi.com, mingo@kernel.org, jolsa@kernel.org, tglx@linutronix.de, acme@redhat.com In-Reply-To: <1446803415-83382-1-git-send-email-wangnan0@huawei.com> References: <1446803415-83382-1-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf probe: Verify parameters in two functions Git-Commit-ID: 421fd0845eaeecce6b3806f7f0c0d67d1f9ad108 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2424 Lines: 66 Commit-ID: 421fd0845eaeecce6b3806f7f0c0d67d1f9ad108 Gitweb: http://git.kernel.org/tip/421fd0845eaeecce6b3806f7f0c0d67d1f9ad108 Author: Wang Nan AuthorDate: Fri, 6 Nov 2015 09:50:15 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 11 Nov 2015 18:41:32 -0300 perf probe: Verify parameters in two functions On kernel with only one out of CONFIG_KPROBE_EVENTS and CONFIG_UPROBE_EVENTS enabled, 'perf probe -d' causes a segfault because perf_del_probe_events() calls probe_file__get_events() with a negative fd. This patch fixes it by adding parameter validation at the entry of probe_file__get_events() and probe_file__get_rawlist(). Since they are both non-static public functions (in .h file), parameter verifying is required. v1 -> v2: Verify fd at the head of probe_file__get_rawlist() instead of checking at call site (suggested by Masami and Arnaldo at [1,2]). [1] http://lkml.kernel.org/r/50399556C9727B4D88A595C8584AAB37526048E3@GSjpTKYDCembx32.service.hitachi.net [2] http://lkml.kernel.org/r/20151105155830.GV13236@kernel.org Signed-off-by: Wang Nan Acked-by: Masami Hiramatsu Cc: Jiri Olsa Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1446803415-83382-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 89dbeb9..e3b3b92 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -138,6 +138,9 @@ struct strlist *probe_file__get_rawlist(int fd) char *p; struct strlist *sl; + if (fd < 0) + return NULL; + sl = strlist__new(NULL, NULL); fp = fdopen(dup(fd), "r"); @@ -271,6 +274,9 @@ int probe_file__get_events(int fd, struct strfilter *filter, const char *p; int ret = -ENOENT; + if (!plist) + return -EINVAL; + namelist = __probe_file__get_namelist(fd, true); if (!namelist) return -ENOENT; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/