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: <20191121144744.GI5078@kernel.org>
Date:   Thu, 21 Nov 2019 11:47:44 -0300
From:   Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Jin Yao <yao.jin@...ux.intel.com>,
        linux-kernel@...r.kernel.org, clang-built-linux@...glegroups.com,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf tools: fix potential memory leak

Em Wed, Nov 20, 2019 at 10:09:25AM -0800, Ian Rogers escreveu:
> An error may be in place when tracepoint_error is called, use
> parse_events__handle_error to avoid a memory leak and to capture the
> first and last error. Error detected by LLVM's libFuzzer using the
> following event:
> 
> $ perf stat -e 'msr/event/,f:e'
> event syntax error: 'msr/event/,f:e'
>                      \___ can't access trace events
> 
> Error:  No permissions to read /sys/kernel/debug/tracing/events/f/e
> Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing/'
> 
> Initial error:
> event syntax error: 'msr/event/,f:e'
>                                 \___ no value assigned for term
> Run 'perf list' for a list of valid events
> 
>  Usage: perf stat [<options>] [<command>]
> 
>     -e, --event <event>   event selector. use 'perf list' to list available events

Thanks, applied.

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  tools/perf/util/parse-events.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 6bae9d6edc12..ecef5b8037b4 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -511,6 +511,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,
>  static void tracepoint_error(struct parse_events_error *e, int err,
>  			     const char *sys, const char *name)
>  {
> +	const char *str;
>  	char help[BUFSIZ];
>  
>  	if (!e)
> @@ -524,18 +525,18 @@ static void tracepoint_error(struct parse_events_error *e, int err,
>  
>  	switch (err) {
>  	case EACCES:
> -		e->str = strdup("can't access trace events");
> +		str = "can't access trace events";
>  		break;
>  	case ENOENT:
> -		e->str = strdup("unknown tracepoint");
> +		str = "unknown tracepoint";
>  		break;
>  	default:
> -		e->str = strdup("failed to add tracepoint");
> +		str = "failed to add tracepoint";
>  		break;
>  	}
>  
>  	tracing_path__strerror_open_tp(err, help, sizeof(help), sys, name);
> -	e->help = strdup(help);
> +	parse_events__handle_error(e, 0, strdup(str), strdup(help));
>  }
>  
>  static int add_tracepoint(struct list_head *list, int *idx,
> -- 
> 2.24.0.432.g9d3f5f5b63-goog

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ