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]
Date:	Wed, 18 Nov 2009 17:46:25 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Stephane Eranian <eranian@...glemail.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, paulus@...ba.org,
	perfmon2-devel@...ts.sf.net, Stephane Eranian <eranian@...il.com>
Subject: Re: [PATCH] perf_events: fix validate_event bug

On Thu, 2009-10-22 at 16:51 +0200, Stephane Eranian wrote:
> 	The validate_event() was failing on valid event
> 	combinations. The function was assuming that if
> 	x86_schedule_event() returned 0, it meant error.
> 	But x86_schedule_event() returns the counter index
> 	and 0 is a perfectly valid value. An error is returned
> 	if the function returns a negative value.

Good point.

> 	Furthermore, validate_event() was also failing for
> 	event groups because the event->pmu was not set until
> 	after hw_perf_pmu_init().

(hw_perf_event_init, right?)

Won't this give very funny results for mixed pmu groups?

How about something like:

 if (event->pmu && event->pmu != &pmu)
	return 0;

That should deal with new events, who do not yet have their pmu set and
for those we know they're for us, but exclude events for other PMUs.

> 	Signed-off-by: Stephane Eranian <eranian@...il.com>
> --
>  arch/x86/kernel/cpu/perf_event.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
> index 2e20bca..d321ff7 100644
> --- a/arch/x86/kernel/cpu/perf_event.c
> +++ b/arch/x86/kernel/cpu/perf_event.c
> @@ -2229,10 +2229,7 @@ validate_event(struct cpu_hw_events *cpuc, struct perf_event *event)
>  {
>  	struct hw_perf_event fake_event = event->hw;
>  
> -	if (event->pmu != &pmu)
> -		return 0;
> -
> -	return x86_schedule_event(cpuc, &fake_event);
> +	return x86_schedule_event(cpuc, &fake_event) >= 0;
>  }
>  
>  static int validate_group(struct perf_event *event)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists