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: <20200914153554.GF160517@kernel.org>
Date:   Mon, 14 Sep 2020 12:35:54 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Jiri Olsa <jolsa@...nel.org>
Cc:     lkml <linux-kernel@...r.kernel.org>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Ingo Molnar <mingo@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Michael Petlan <mpetlan@...hat.com>,
        Song Liu <songliubraving@...com>,
        "Frank Ch. Eigler" <fche@...hat.com>,
        Ian Rogers <irogers@...gle.com>,
        Stephane Eranian <eranian@...gle.com>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Adrian Hunter <adrian.hunter@...el.com>
Subject: Re: [PATCH 04/26] perf tools: Add filename__decompress function

Em Sun, Sep 13, 2020 at 11:02:51PM +0200, Jiri Olsa escreveu:
> Factor filename__decompress from decompress_kmodule function.
> It can decompress files with compressions supported in perf -
> xz and gz, the support needs to be compiled in.
> 
> It will to be used in following changes to get build id out of
> compressed elf objects.

This is prep work, can be applied now, done.

- Arnaldo
 
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
>  tools/perf/util/dso.c | 31 +++++++++++++++++++------------
>  tools/perf/util/dso.h |  2 ++
>  2 files changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 5a3b4755f0b3..0faa96ca7a04 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -279,18 +279,12 @@ bool dso__needs_decompress(struct dso *dso)
>  		dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
>  }
>  
> -static int decompress_kmodule(struct dso *dso, const char *name,
> -			      char *pathname, size_t len)
> +int filename__decompress(const char *name, char *pathname,
> +			 size_t len, int comp, int *err)
>  {
>  	char tmpbuf[] = KMOD_DECOMP_NAME;
>  	int fd = -1;
>  
> -	if (!dso__needs_decompress(dso))
> -		return -1;
> -
> -	if (dso->comp == COMP_ID__NONE)
> -		return -1;
> -
>  	/*
>  	 * We have proper compression id for DSO and yet the file
>  	 * behind the 'name' can still be plain uncompressed object.
> @@ -304,17 +298,17 @@ static int decompress_kmodule(struct dso *dso, const char *name,
>  	 * To keep this transparent, we detect this and return the file
>  	 * descriptor to the uncompressed file.
>  	 */
> -	if (!compressions[dso->comp].is_compressed(name))
> +	if (!compressions[comp].is_compressed(name))
>  		return open(name, O_RDONLY);
>  
>  	fd = mkstemp(tmpbuf);
>  	if (fd < 0) {
> -		dso->load_errno = errno;
> +		*err = errno;
>  		return -1;
>  	}
>  
> -	if (compressions[dso->comp].decompress(name, fd)) {
> -		dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
> +	if (compressions[comp].decompress(name, fd)) {
> +		*err = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
>  		close(fd);
>  		fd = -1;
>  	}
> @@ -328,6 +322,19 @@ static int decompress_kmodule(struct dso *dso, const char *name,
>  	return fd;
>  }
>  
> +static int decompress_kmodule(struct dso *dso, const char *name,
> +			      char *pathname, size_t len)
> +{
> +	if (!dso__needs_decompress(dso))
> +		return -1;
> +
> +	if (dso->comp == COMP_ID__NONE)
> +		return -1;
> +
> +	return filename__decompress(name, pathname, len, dso->comp,
> +				    &dso->load_errno);
> +}
> +
>  int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
>  {
>  	return decompress_kmodule(dso, name, NULL, 0);
> diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
> index 8ad17f395a19..f1efd2e11547 100644
> --- a/tools/perf/util/dso.h
> +++ b/tools/perf/util/dso.h
> @@ -274,6 +274,8 @@ bool dso__needs_decompress(struct dso *dso);
>  int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
>  int dso__decompress_kmodule_path(struct dso *dso, const char *name,
>  				 char *pathname, size_t len);
> +int filename__decompress(const char *name, char *pathname,
> +			 size_t len, int comp, int *err);
>  
>  #define KMOD_DECOMP_NAME  "/tmp/perf-kmod-XXXXXX"
>  #define KMOD_DECOMP_LEN   sizeof(KMOD_DECOMP_NAME)
> -- 
> 2.26.2
> 

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ