Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752152AbbKKHBi (ORCPT ); Wed, 11 Nov 2015 02:01:38 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:41515 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbbKKHBg (ORCPT ); Wed, 11 Nov 2015 02:01:36 -0500 Message-ID: <5642E79A.4040606@huawei.com> Date: Wed, 11 Nov 2015 15:00:42 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: CC: , , , , , , Arnaldo Carvalho de Melo Subject: Re: [PATCH v2] perf probe: Verify parameters for two functions References: <20151105155830.GV13236@kernel.org> <1446803415-83382-1-git-send-email-wangnan0@huawei.com> In-Reply-To: <1446803415-83382-1-git-send-email-wangnan0@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5642E7B3.00CE,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 943c9d75534ec88d3ee4d472369e9c7b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2181 Lines: 64 Hi Arnaldo, Could you please collect this patch to your tree? It fixes a segfault when only one of kprobe and uprobe is enabled. Thank you. On 2015/11/6 17:50, Wang Nan wrote: > On kernel with only one of CONFIG_KPROBE_EVENTS and > CONFIG_UPROBE_EVENTS enabled, 'perf probe -d' causes segfault because > perf_del_probe_events() calls probe_file__get_events() with a negative > fd. > > This patch fixes it by add 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 > Cc: Arnaldo Carvalho de Melo > Cc: Jiri Olsa > Cc: Masami Hiramatsu > Cc: Namhyung Kim > --- > 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/