Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757728AbbEFEh2 (ORCPT ); Wed, 6 May 2015 00:37:28 -0400 Received: from terminus.zytor.com ([198.137.202.10]:37433 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757348AbbEFEhY (ORCPT ); Wed, 6 May 2015 00:37:24 -0400 Date: Tue, 5 May 2015 21:36:58 -0700 From: tip-bot for Wang Nan Message-ID: Cc: masami.hiramatsu.pt@hitachi.com, acme@redhat.com, hpa@zytor.com, a.p.zijlstra@chello.nl, wangnan0@huawei.com, dsahern@gmail.com, mingo@kernel.org, lizefan@huawei.com, jolsa@kernel.org, paulus@samba.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Reply-To: hpa@zytor.com, a.p.zijlstra@chello.nl, dsahern@gmail.com, mingo@kernel.org, wangnan0@huawei.com, masami.hiramatsu.pt@hitachi.com, acme@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@kernel.org, lizefan@huawei.com, paulus@samba.org In-Reply-To: <1430210769-94177-1-git-send-email-wangnan0@huawei.com> References: <1430210769-94177-1-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf probe: Fix segfault if passed with ''. Git-Commit-ID: e59d29e88f7b7e3d1231202b0203d0af6f15a440 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: 2080 Lines: 60 Commit-ID: e59d29e88f7b7e3d1231202b0203d0af6f15a440 Gitweb: http://git.kernel.org/tip/e59d29e88f7b7e3d1231202b0203d0af6f15a440 Author: Wang Nan AuthorDate: Tue, 28 Apr 2015 08:46:09 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 5 May 2015 12:26:52 -0300 perf probe: Fix segfault if passed with ''. Since parse_perf_probe_point() deals with a user passed argument, we should not assume it to be a valid string. Without this patch, if pass '' to perf probe, a segfault raises: $ perf probe -a '' Segmentation fault This patch checks argument of parse_perf_probe_point() before string processing. After this patch: $ perf probe -a '' usage: perf probe [] 'PROBEDEF' ['PROBEDEF' ...] or: perf probe [] --add 'PROBEDEF' [--add 'PROBEDEF' ...] ... Signed-off-by: Wang Nan Acked-by: Masami Hiramatsu Tested-by: Arnaldo Carvalho de Melo Cc: David Ahern Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Zefan Li Link: http://lkml.kernel.org/r/1430210769-94177-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index d8bb616..d05b77c 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -1084,6 +1084,8 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) * * TODO:Group name support */ + if (!arg) + return -EINVAL; ptr = strpbrk(arg, ";=@+%"); if (ptr && *ptr == '=') { /* Event name */ -- 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/