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  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:   Wed, 13 May 2020 19:52:53 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>, linux-kernel@...r.kernel.org,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf expr: Fix memory leaks in metric bison

On Tue, May 12, 2020 at 05:03:18PM -0700, Ian Rogers wrote:
> Add a destructor for strings to reclaim memory in the event of errors.
> Free the ID given for a lookup, it was previously strdup-ed in the lex
> code.
> 
> Reviewed-by: Andi Kleen <ak@...ux.intel.com>
> Signed-off-by: Ian Rogers <irogers@...gle.com>

Acked-by: Jiri Olsa <jolsa@...hat.com>

thanks,
jirka

> ---
>  tools/perf/util/expr.y | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y
> index 21e82a1e11a2..3b49b230b111 100644
> --- a/tools/perf/util/expr.y
> +++ b/tools/perf/util/expr.y
> @@ -27,6 +27,7 @@
>  %token EXPR_PARSE EXPR_OTHER EXPR_ERROR
>  %token <num> NUMBER
>  %token <str> ID
> +%destructor { free ($$); } <str>
>  %token MIN MAX IF ELSE SMT_ON
>  %left MIN MAX IF
>  %left '|'
> @@ -94,8 +95,10 @@ if_expr:
>  expr:	  NUMBER
>  	| ID			{ if (lookup_id(ctx, $1, &$$) < 0) {
>  					pr_debug("%s not found\n", $1);
> +					free($1);
>  					YYABORT;
>  				  }
> +				  free($1);
>  				}
>  	| expr '|' expr		{ $$ = (long)$1 | (long)$3; }
>  	| expr '&' expr		{ $$ = (long)$1 & (long)$3; }
> -- 
> 2.26.2.645.ge9eca65c58-goog
> 

Powered by blists - more mailing lists