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: <1338492300.13348.384.camel@gandalf.stny.rr.com>
Date:	Thu, 31 May 2012 15:25:00 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...e.hu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	Dave Jones <davej@...hat.com>, Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 4/5] x86: Allow nesting of the debug stack IDT setting

On Thu, 2012-05-31 at 11:58 -0700, H. Peter Anvin wrote:

> What you have here is a nesting counter, which is good, but I have
> some objections to the implementation.
> 
> The name "debug_idt_zero" doesn't convey a counter in any way, shape
> or form; perhaps debug_stack_users or something like that.

Well, it is 'debug_idt_SET_zero' which is what it is doing, regardless
of counter (see below). But perhaps we should change it to:

debug_idt_get()
debug_idt_put()

?

> 
> Since this is percpu, there is no reason to use the atomic operations
> (globally locked!), and since it is on the local CPU there is no need
> to manifest a pointer; we can instead use this_cpu_inc/dec_return:
> 
> static DEFINE_PER_CPU(u32, debug_stack_use_ctr);
> 
> void debug_stack_set_zero(void)
> {
> 	if (this_cpu_inc_return(debug_stack_use_ctr) == 1)

If an NMI comes in here, it will not update the IDT and will corrupt the
stack. The load_idt() must happen for all calls. There's only two static
IDT tables. It's either one or the other. Thus, if it loads it twice, it
will just set it to the same value. The counter is to know when to set
it back.

-- Steve

> 	 	load_idt((const struct desc_ptr *)&nmi_idt_descr);
> }
> 
> void debug_stack_reset(void)
> {
> 	if (this_cpu_dec_return(debug_stack_use_ctr) == 0)
> 		load_idt((const struct desc_ptr *)&idt_descr);
> }
> 
> 	-hpa
> 


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