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, 8 Jul 2020 08:19:35 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
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>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Leo Yan <leo.yan@...aro.org>, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org, bpf@...r.kernel.org,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf parse-events: report bpf errors

Em Tue, Jul 07, 2020 at 02:14:49PM -0700, Ian Rogers escreveu:
> Setting the parse_events_error directly doesn't increment num_errors
> causing the error message not to be displayed. Use the
> parse_events__handle_error function that sets num_errors and handle
> multiple errors.

What was the command line you used to exercise the error and then the
fix?

- Arnaldo

> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
>  tools/perf/util/parse-events.c | 38 ++++++++++++++++++----------------
>  1 file changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index c4906a6a9f1a..e88e4c7a2a9a 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -767,8 +767,8 @@ int parse_events_load_bpf_obj(struct parse_events_state *parse_state,
>  
>  	return 0;
>  errout:
> -	parse_state->error->help = strdup("(add -v to see detail)");
> -	parse_state->error->str = strdup(errbuf);
> +	parse_events__handle_error(parse_state->error, 0,
> +				strdup(errbuf), strdup("(add -v to see detail)"));
>  	return err;
>  }
>  
> @@ -784,36 +784,38 @@ parse_events_config_bpf(struct parse_events_state *parse_state,
>  		return 0;
>  
>  	list_for_each_entry(term, head_config, list) {
> -		char errbuf[BUFSIZ];
>  		int err;
>  
>  		if (term->type_term != PARSE_EVENTS__TERM_TYPE_USER) {
> -			snprintf(errbuf, sizeof(errbuf),
> -				 "Invalid config term for BPF object");
> -			errbuf[BUFSIZ - 1] = '\0';
> -
> -			parse_state->error->idx = term->err_term;
> -			parse_state->error->str = strdup(errbuf);
> +			parse_events__handle_error(parse_state->error, term->err_term,
> +						strdup("Invalid config term for BPF object"),
> +						NULL);
>  			return -EINVAL;
>  		}
>  
>  		err = bpf__config_obj(obj, term, parse_state->evlist, &error_pos);
>  		if (err) {
> +			char errbuf[BUFSIZ];
> +			int idx;
> +
>  			bpf__strerror_config_obj(obj, term, parse_state->evlist,
>  						 &error_pos, err, errbuf,
>  						 sizeof(errbuf));
> -			parse_state->error->help = strdup(
> +
> +			if (err == -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUE)
> +				idx = term->err_val;
> +			else
> +				idx = term->err_term + error_pos;
> +
> +			parse_events__handle_error(parse_state->error, idx,
> +						strdup(errbuf),
> +						strdup(
>  "Hint:\tValid config terms:\n"
>  "     \tmap:[<arraymap>].value<indices>=[value]\n"
>  "     \tmap:[<eventmap>].event<indices>=[event]\n"
>  "\n"
>  "     \twhere <indices> is something like [0,3...5] or [all]\n"
> -"     \t(add -v to see detail)");
> -			parse_state->error->str = strdup(errbuf);
> -			if (err == -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUE)
> -				parse_state->error->idx = term->err_val;
> -			else
> -				parse_state->error->idx = term->err_term + error_pos;
> +"     \t(add -v to see detail)"));
>  			return err;
>  		}
>  	}
> @@ -877,8 +879,8 @@ int parse_events_load_bpf(struct parse_events_state *parse_state,
>  						   -err, errbuf,
>  						   sizeof(errbuf));
>  
> -		parse_state->error->help = strdup("(add -v to see detail)");
> -		parse_state->error->str = strdup(errbuf);
> +		parse_events__handle_error(parse_state->error, 0,
> +					strdup(errbuf), strdup("(add -v to see detail)"));
>  		return err;
>  	}
>  
> -- 
> 2.27.0.383.g050319c2ae-goog
> 

-- 

- Arnaldo

Powered by blists - more mailing lists