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: <20170817172232.GF10891@kernel.org>
Date:   Thu, 17 Aug 2017 14:22:32 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Andi Kleen <ak@...ux.intel.com>
Cc:     Andi Kleen <andi@...stfloor.org>, jolsa@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] perf, tools: Avoid segfault on alias parse error

Em Thu, Aug 17, 2017 at 10:04:53AM -0700, Andi Kleen escreveu:
> > So it will _not_ set to null a member that it doesn't have, i.e. the
> > minimal fix is to just have the hunks below, making sure that the error
> > field is present in both structs. No need to set
> > parse_event_terms->error to anything, it will be set to null since other
> > fields are set to something.
> 
> Right but I want to see the error too. That is why I added a real 
> error handler.

Ok, but I was first trying to figure out the fix for that separate
problem (the void pointer being dereferenced to two different types in
the same function, yyparse, aka parse_events_parse), then we can go to
the 'too' part :-)

I'm adding the patch below, that should fix things by using just one
state struct for parsing.

This is done on top of another that renames 'struct parse_events_evlist'
to a more clearer 'struct parse_events_state'.

I'll then add what is left of your patch, run tests and we go from
there, holler if I'm now missing something.

- Arnaldo

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 272eab7f5ac8..d4fcf048aa9e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1656,7 +1656,7 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
  */
 int parse_events_terms(struct list_head *terms, const char *str)
 {
-	struct parse_events_terms data = {
+	struct parse_events_state data = {
 		.terms = NULL,
 	};
 	int ret;
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8fff8423469b..2a3617937894 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -114,10 +114,7 @@ struct parse_events_state {
 	int			   nr_groups;
 	struct parse_events_error *error;
 	struct perf_evlist	  *evlist;
-};
-
-struct parse_events_terms {
-	struct list_head *terms;
+	struct list_head	  *terms;
 };
 
 void parse_events__shrink_config_terms(void);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index ffb4914142cf..8acb2c4ca711 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -494,7 +494,7 @@ opt_event_config:
 
 start_terms: event_config
 {
-	struct parse_events_terms *data = _data;
+	struct parse_events_state *data = _data;
 	data->terms = $1;
 }
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ