linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] x86/entry/nmi: solidify userspace NMI entry
@ 2021-06-01  6:52 Lai Jiangshan
  2021-06-01  6:52 ` [RFC PATCH 1/4] x86/entry/nmi: Switch to the entry stack before switching to the thread stack Lai Jiangshan
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Lai Jiangshan @ 2021-06-01  6:52 UTC (permalink / raw)
  To: linux-kernel
  Cc: Steven Rostedt, Lai Jiangshan, Andy Lutomirski, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin

From: Lai Jiangshan <laijs@linux.alibaba.com>

Current kernel has no code to enforce data breakpoint not on the thread
stack.  If there is any data breakpoint on the top area of the thread
stack, there might be problem.

For example, when NMI hits on userspace in this setting, the code copies
the exception frame from the NMI stack to the thread stack and it will
cause #DB and after #DB is handled, the not yet copied portion on the
NMI stack is in danger of corruption because the NMI is unmasked.

The similar problem happens when #DB hits on userspace with data
breakpoint on the thread stack.  We will also fix it for #DB when we
agree on the problem on NMI and the way to fix it.

The way to fix for NMI is to switch to the entry stack before switching
to the thread stack.  It also paves the path to use idtentry_body
macro for NMI since the huge refactor on entry code made idtentry
macros really low level.

Lai Jiangshan (4):
  x86/entry/nmi: Switch to the entry stack before switching to the
    thread stack
  x86/entry/nmi: Use normal idtentry macro for NMI from userspace
  x86/entry: Remove parameter rdx from macro PUSH_AND_CLEAR_REGS and
    PUSH_REGS
  x86/entry/nmi: unmask NMIs on userspace NMI when entry debugging

Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Andy Lutomirski <luto@kernel.org>,
Cc: Thomas Gleixner <tglx@linutronix.de>,
Cc: Ingo Molnar <mingo@redhat.com>,
Cc: Borislav Petkov <bp@alien8.de>,
Cc: x86@kernel.org,
Cc: "H. Peter Anvin" <hpa@zytor.com>

 arch/x86/entry/calling.h      |  8 ++--
 arch/x86/entry/entry_64.S     | 82 +++++++++++++++++------------------
 arch/x86/kernel/asm-offsets.c |  1 +
 3 files changed, 44 insertions(+), 47 deletions(-)

-- 
2.19.1.6.gb485710b


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-06-26  8:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01  6:52 [RFC PATCH 0/4] x86/entry/nmi: solidify userspace NMI entry Lai Jiangshan
2021-06-01  6:52 ` [RFC PATCH 1/4] x86/entry/nmi: Switch to the entry stack before switching to the thread stack Lai Jiangshan
2021-06-01 17:05   ` Steven Rostedt
2021-06-02  0:09     ` Lai Jiangshan
2021-06-02  0:16     ` Lai Jiangshan
2021-06-19 22:51   ` Thomas Gleixner
2021-06-20  3:13     ` Andy Lutomirski
2021-06-20 11:23       ` Thomas Gleixner
2021-06-25 10:40       ` Peter Zijlstra
2021-06-25 11:00         ` Peter Zijlstra
2021-06-26  7:03           ` Thomas Gleixner
2021-06-26  8:28             ` Peter Zijlstra
2021-06-01  6:52 ` [RFC PATCH 2/4] x86/entry/nmi: Use normal idtentry macro for NMI from userspace Lai Jiangshan
2021-06-03 17:36   ` Andy Lutomirski
2021-06-01  6:52 ` [RFC PATCH 3/4] x86/entry: Remove parameter rdx from macro PUSH_AND_CLEAR_REGS and PUSH_REGS Lai Jiangshan
2021-06-01  6:52 ` [RFC PATCH 4/4] x86/entry/nmi: unmask NMIs on userspace NMI when entry debugging Lai Jiangshan
2021-06-03 17:38   ` Andy Lutomirski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).