Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161106AbbKFKDi (ORCPT ); Fri, 6 Nov 2015 05:03:38 -0500 Received: from mail7.hitachi.co.jp ([133.145.228.42]:47054 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754933AbbKFKDf (ORCPT ); Fri, 6 Nov 2015 05:03:35 -0500 From: =?utf-8?B?5bmz5p2+6ZuF5bezIC8gSElSQU1BVFXvvIxNQVNBTUk=?= To: "'Wang Nan'" , "acme@kernel.org" , "namhyung@kernel.org" CC: "lizefan@huawei.com" , "pi3orama@163.com" , "linux-kernel@vger.kernel.org" , "jolsa@kernel.org" , Arnaldo Carvalho de Melo Subject: RE: [PATCH v2] perf probe: Verify parameters for two functions Thread-Topic: [!][PATCH v2] perf probe: Verify parameters for two functions Thread-Index: AQHRGHiZfOC9mzCxOU+c1qCiXEeb/Z6Ow4IQ Date: Fri, 6 Nov 2015 10:03:31 +0000 Message-ID: <50399556C9727B4D88A595C8584AAB37526076B9@GSjpTKYDCembx32.service.hitachi.net> 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> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.198.219.51] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tA6A3iK9027024 Content-Length: 2011 Lines: 62 From: Wang Nan [mailto:wangnan0@huawei.com] > >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. Looks good to me ! :) Acked-by: Masami Hiramatsu Thank you! > >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; >-- >1.8.3.4 ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?