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]
Date:   Thu, 6 Dec 2018 14:05:35 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Alexey Budankov <alexey.budankov@...ux.intel.com>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1] perf record: fix memory leak on AIO objects
 deallocation

Em Wed, Dec 05, 2018 at 08:19:41PM +0300, Alexey Budankov escreveu:
> 
> Sending a part which was missed between v12 and v13 of the patch set
> introducing AIO trace streaming for perf record mode. 
> 
> The part is essential to avoid memory leakage during deallocation
> of AIO related trace data buffers.
> 
> It is applied on top of acme perf/core repo.
> 
> Signed-off-by: Alexey Budankov <alexey.budankov@...ux.intel.com>
> ---
> tools/perf/util/mmap.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
> index ab30555d2afc..169d02973757 100644
> --- a/tools/perf/util/mmap.c
> +++ b/tools/perf/util/mmap.c
> @@ -207,8 +207,18 @@ static int perf_mmap__aio_mmap(struct perf_mmap *map, struct mmap_params *mp)
>  
>  static void perf_mmap__aio_munmap(struct perf_mmap *map)
>  {
> +	int i;
> +
> +	for (i = 0; i < map->aio.nr_cblocks; ++i) {
> +		if (map->aio.data[i])
> +			zfree(&map->aio.data[i]);
> +	}
>  	if (map->aio.data)
>  		zfree(&map->aio.data);
> +	if (map->aio.cblocks)
> +		zfree(&map->aio.cblocks);
> +	if (map->aio.aiocb)
> +		zfree(&map->aio.aiocb);

There is no need to check for NULL before calling zfree(), as it is just
a wrapper for free that sets that variable to NULL after calling it.

And free(NULL) is valid, just a noop to avoid having all those tests
before each call to free(). I'm making those plain zfree() and later
will do a sweep at removing other cases.

>  }
>  
>  int perf_mmap__aio_push(struct perf_mmap *md, void *to, int idx,

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ