lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160531222743.90eea3df64157f6ed3c097ef@kernel.org>
Date:	Tue, 31 May 2016 22:27:43 +0900
From:	Masami Hiramatsu <mhiramat@...nel.org>
To:	Wang Nan <wangnan0@...wei.com>
Cc:	<acme@...nel.org>, <pi3orama@....com>,
	<linux-kernel@...r.kernel.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	He Kuang <hekuang@...wei.com>, Jiri Olsa <jolsa@...nel.org>,
	Masami Hiramatsu <mhiramat@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Zefan Li <lizefan@...wei.com>
Subject: Re: [PATCH] perf tools: Fix perf_evlist__alloc_mmap() failure path

On Tue, 31 May 2016 13:06:15 +0000
Wang Nan <wangnan0@...wei.com> wrote:

> If zalloc fail, setting evlist->mmap[i].fd is unsafe.
> perf_evlist__alloc_mmap() should fail right after zalloc() fail.

Good catch!!

Reviewed-by: Masami Hiramatsu <mhiramat@...nel.org>

Thanks!

> 
> Signed-off-by: Wang Nan <wangnan0@...wei.com>
> Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> Cc: He Kuang <hekuang@...wei.com>
> Cc: Jiri Olsa <jolsa@...nel.org>
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Cc: Namhyung Kim <namhyung@...nel.org>
> Cc: Zefan Li <lizefan@...wei.com>
> Cc: pi3orama@....com
> ---
>  tools/perf/util/evlist.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index e0f3094..1b918aa 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -946,9 +946,12 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
>  	if (cpu_map__empty(evlist->cpus))
>  		evlist->nr_mmaps = thread_map__nr(evlist->threads);
>  	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
> +	if (!evlist->mmap)
> +		return -ENOMEM;
> +
>  	for (i = 0; i < evlist->nr_mmaps; i++)
>  		evlist->mmap[i].fd = -1;
> -	return evlist->mmap != NULL ? 0 : -ENOMEM;
> +	return 0;
>  }
>  
>  struct mmap_params {
> -- 
> 1.8.3.4
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ