Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1266993

Re: [PATCH v2] perf probe: Verify parameters for two functions

From "Wangnan (F)" <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] perf probe: Verify parameters for two functions
Date 2015-11-11 08:10 +0100
Message-ID <qtxHA-80B-1@gated-at.bofh.it> (permalink)
References <qrv7d-9F-25@gated-at.bofh.it> <qrLYm-2Oc-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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;


--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] perf tools: Two bugfixs related to perf probe Wang Nan <wangnan0@huawei.com> - 2015-11-05 14:20 +0100
  [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns success Wang Nan <wangnan0@huawei.com> - 2015-11-05 14:30 +0100
    RE: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-11-05 15:10 +0100
      Re: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success "acme@kernel.org" <acme@kernel.org> - 2015-11-05 17:10 +0100
        RE: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-11-06 07:30 +0100
          RE: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-11-06 08:20 +0100
            Re: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-06 09:40 +0100
              Re: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-06 10:40 +0100
                Re: [PATCH 2/2] perf tools: Fix find_perf_probe_point_from_map()  which incorrectly returns success Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-06 14:50 +0100
    [tip:perf/urgent] perf tools: Fix find_perf_probe_point_from_map(  ) which incorrectly returns success tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-08 08:40 +0100
  [PATCH 1/2] perf probe: Only call probe_file__get_events() when fd is valid Wang Nan <wangnan0@huawei.com> - 2015-11-05 14:30 +0100
    RE: [PATCH 1/2] perf probe: Only call probe_file__get_events() when  fd is valid 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-11-05 15:30 +0100
    Re: [PATCH 1/2] perf probe: Only call probe_file__get_events() when  fd is valid Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-05 16:00 +0100
      RE: [PATCH 1/2] perf probe: Only call probe_file__get_events() when  fd is valid 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-11-05 16:10 +0100
        Re: [PATCH 1/2] perf probe: Only call probe_file__get_events() when  fd is valid 'Arnaldo Carvalho de Melo' <acme@kernel.org> - 2015-11-05 17:00 +0100
          [PATCH v2] perf probe: Verify parameters for two functions Wang Nan <wangnan0@huawei.com> - 2015-11-06 11:00 +0100
            RE: [PATCH v2] perf probe: Verify parameters for two functions 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2015-11-06 11:10 +0100
            Re: [PATCH v2] perf probe: Verify parameters for two functions "Wangnan (F)" <wangnan0@huawei.com> - 2015-11-11 08:10 +0100
            [tip:perf/urgent] perf probe: Verify parameters in two functions tip-bot for Wang Nan <tipbot@zytor.com> - 2015-11-12 07:50 +0100

csiph-web