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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k45sr2yd.fsf@gmail.com>
Date:	Tue, 20 Dec 2011 00:33:30 +0900
From:	Namhyung Kim <namhyung@...il.com>
To:	Nelson Elhage <nelhage@...hage.com>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>, Ingo Molnar <mingo@...e.hu>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] perf: __perf_evlist__mmap: Fix errno value on failed map.

Hello, Nelson

Nelson Elhage <nelhage@...hage.com> writes:
> On failure, perf_evlist__mmap_per_{cpu,thread} will try to munmap()
> every map that doesn't have a NULL base. This will fail with EINVAL if
> one of them has base == MAP_FAILED, clobbering errno, so that
> perf_evlist__map will return EINVAL on any failure regardless of the
> root cause.
>
> Fix this by resetting failed maps to a NULL base.
>
> Signed-off-by: Nelson Elhage <nelhage@...hage.com>
> ---
>  tools/perf/util/evlist.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index fbb4b4a..271c849 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -298,8 +298,10 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
>  	evlist->mmap[idx].mask = mask;
>  	evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
>  				      MAP_SHARED, fd, 0);
> -	if (evlist->mmap[idx].base == MAP_FAILED)
> +	if (evlist->mmap[idx].base == MAP_FAILED) {
> +		evlist->mmap[idx].base = NULL;
>  		return -1;
> +	}
>  
>  	perf_evlist__add_pollfd(evlist, fd);
>  	return 0;

Thanks for fixing this. I posted a basically same patch for this [1]
last week, but it seems my patch doesn't get included yet (right?),
and your patch looks bit simpler. So Arnaldo, I'm totally fine if you
decide to take this instead of mine.

Thanks.
Namhyung Kim


[1] https://lkml.org/lkml/2011/12/12/275
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ