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:	Tue, 19 Mar 2013 13:43:04 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Stephane Eranian <eranian@...gle.com>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, jolsa@...hat.com,
	sqazi@...gle.com, ak@...ux.intel.com
Subject: Re: [PATCH] perf,x86: fix uninitialized pt_regs in
 intel_pmu_drain_bts_buffer()

On Mon, 2013-03-18 at 14:46 +0100, Stephane Eranian wrote:
> 
> This patch fixes an uninitialized pt_regs struct in drain BTS
> function. The pt_regs struct is propagated all the way to the
> code_get_segment() function from perf_instruction_pointer()
> and may get garbage.
> 
> We cannot simply inherit the actual pt_regs from the interrupt
> because BTS must be flushed on context-switch or when the associated
> event is disabled. And there we do not have a pt_regs handy.
> 
> Setting pt_regs to all zeroes may not be the best option but it is
> not clear what else to do given where the drain_bts_buffer() is called
> from.
> 
> Signed-off-by: Stephane Eranian <eranian@...gle.com>
> ---
> 
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
> index b05a575..208f0c8 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
> @@ -302,6 +302,8 @@ int intel_pmu_drain_bts_buffer(void)
>  	struct perf_sample_data data;
>  	struct pt_regs regs;
>  
> +	memset(&regs, 0, sizeof(regs));
> +
>  	if (!event)
>  		return 0;
>  

Should we not replace:

	regs.ip     = 0;

with that memset? It avoids the memset work in a few cases and removes
the then superfluous clearing of the IP field.

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ