From: "Wangnan (F)" <wangnan0@huawei.com>
To: <acme@kernel.org>
Cc: <namhyung@kernel.org>, <lizefan@huawei.com>, <pi3orama@163.com>,
<linux-kernel@vger.kernel.org>, <jolsa@kernel.org>,
<masami.hiramatsu.pt@hitachi.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH v2] perf probe: Verify parameters for two functions
Date: Wed, 11 Nov 2015 15:00:42 +0800 [thread overview]
Message-ID: <5642E79A.4040606@huawei.com> (raw)
In-Reply-To: <1446803415-83382-1-git-send-email-wangnan0@huawei.com>
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 <wangnan0@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> ---
> 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;
next prev parent reply other threads:[~2015-11-11 7:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 13:19 [PATCH 0/2] perf tools: Two bugfixs related to perf probe Wang Nan
2015-11-05 13:19 ` [PATCH 1/2] perf probe: Only call probe_file__get_events() when fd is valid Wang Nan
2015-11-05 14:23 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-05 14:57 ` Arnaldo Carvalho de Melo
2015-11-05 15:07 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-05 15:58 ` 'Arnaldo Carvalho de Melo'
2015-11-06 9:50 ` [PATCH v2] perf probe: Verify parameters for two functions Wang Nan
2015-11-06 10:03 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-11 7:00 ` Wangnan (F) [this message]
2015-11-12 6:43 ` [tip:perf/urgent] perf probe: Verify parameters in " tip-bot for Wang Nan
2015-11-05 13:19 ` [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns success Wang Nan
2015-11-05 14:08 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-05 16:00 ` acme
2015-11-06 6:28 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-06 7:12 ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-06 8:30 ` Wangnan (F)
2015-11-06 9:27 ` Wangnan (F)
2015-11-06 13:43 ` Arnaldo Carvalho de Melo
2015-11-08 7:31 ` [tip:perf/urgent] perf tools: Fix find_perf_probe_point_from_map( ) " tip-bot for Wang Nan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5642E79A.4040606@huawei.com \
--to=wangnan0@huawei.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=namhyung@kernel.org \
--cc=pi3orama@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome