Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161562AbbKEOXJ (ORCPT ); Thu, 5 Nov 2015 09:23:09 -0500 Received: from mail4.hitachi.co.jp ([133.145.228.5]:43129 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161445AbbKEOXE (ORCPT ); Thu, 5 Nov 2015 09:23:04 -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 1/2] perf probe: Only call probe_file__get_events() when fd is valid Thread-Topic: [PATCH 1/2] perf probe: Only call probe_file__get_events() when fd is valid Thread-Index: AQHRF8ymxc9fOcUu6Ue6O0lx8xS3JZ6Nah4w Date: Thu, 5 Nov 2015 14:23:00 +0000 Message-ID: <50399556C9727B4D88A595C8584AAB37526048E3@GSjpTKYDCembx32.service.hitachi.net> References: <1446729565-27592-1-git-send-email-wangnan0@huawei.com> <1446729565-27592-2-git-send-email-wangnan0@huawei.com> In-Reply-To: <1446729565-27592-2-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 tA5ENG8Q021041 Content-Length: 1971 Lines: 61 From: Wang Nan [mailto:wangnan0@huawei.com] > >In system with kprobe enabled but uprobe turned off, 'perf probe -d' >causes segfault because it calls probe_file__get_events() with a >negative fd (when deleting uprobe events). Hmm, OK. This may happen if user runs perf probe on the kernel which only enables either CONFIG_KPROBE_EVENTS or CONFIG_UPROBE_EVENTS. > >This patch validates fds before calling probe_file__get_events(). Hmm, could you improve probe_file__get_events() to check the fd instead of checking it at call-site? I think that is more generic fixup. Thank you, > >Signed-off-by: Wang Nan >Cc: Arnaldo Carvalho de Melo >Cc: Jiri Olsa >Cc: Masami Hiramatsu >Cc: Namhyung Kim >--- > tools/perf/builtin-probe.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > >diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c >index 132afc9..861aa89 100644 >--- a/tools/perf/builtin-probe.c >+++ b/tools/perf/builtin-probe.c >@@ -384,7 +384,11 @@ static int perf_del_probe_events(struct strfilter *filter) > goto out; > } > >- ret = probe_file__get_events(kfd, filter, klist); >+ if (kfd < 0) >+ ret = -ENOENT; >+ else >+ ret = probe_file__get_events(kfd, filter, klist); >+ > if (ret == 0) { > strlist__for_each(ent, klist) > pr_info("Removed event: %s\n", ent->s); >@@ -394,7 +398,11 @@ static int perf_del_probe_events(struct strfilter *filter) > goto error; > } > >- ret2 = probe_file__get_events(ufd, filter, ulist); >+ if (ufd < 0) >+ ret2 = -ENOENT; >+ else >+ ret2 = probe_file__get_events(ufd, filter, ulist); >+ > if (ret2 == 0) { > strlist__for_each(ent, ulist) > pr_info("Removed event: %s\n", ent->s); >-- >1.8.3.4 ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?