* [PATCH 0/2] x86: NMI vs paravirt fixes
@ 2015-09-20 23:32 Andy Lutomirski
2015-09-20 23:32 ` [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function Andy Lutomirski
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Andy Lutomirski @ 2015-09-20 23:32 UTC (permalink / raw)
To: x86; +Cc: Sasha Levin, linux-kernel, Andy Lutomirski
These are for x86/urgent.
This fixes at least one problem that Sasha can trigger using some
crazy configuration + Trinity. I can't reproduce the full file of
nastiness that he's seeing, but these patches both look legit to me,
they fix what look like real bugs, and they seem to help Sasha's
tests.
Patch 1 is ugly. Feel free to tell me to shove the asm into the
entry asm files, although that will involve duplicating it for
32-bit and 64-bit kernels.
Andy Lutomirski (2):
x86/paravirt: Replace the paravirt nop with a bona fide empty function
x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
arch/x86/entry/entry_64.S | 16 +++++++++++++++-
arch/x86/kernel/paravirt.c | 16 ++++++++++++----
2 files changed, 27 insertions(+), 5 deletions(-)
--
2.4.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function
2015-09-20 23:32 [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
@ 2015-09-20 23:32 ` Andy Lutomirski
2015-09-22 19:48 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2015-09-22 20:42 ` tip-bot for Andy Lutomirski
2015-09-20 23:32 ` [PATCH 2/2] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Andy Lutomirski
2015-09-21 19:14 ` [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
2 siblings, 2 replies; 8+ messages in thread
From: Andy Lutomirski @ 2015-09-20 23:32 UTC (permalink / raw)
To: x86; +Cc: Sasha Levin, linux-kernel, Andy Lutomirski, stable
PARAVIRT_ADJUST_EXCEPTION_FRAME generates this code (using nmi as an
example, trimmed for readability):
ff 15 00 00 00 00 callq *0x0(%rip) # 2796 <nmi+0x6>
2792: R_X86_64_PC32 pv_irq_ops+0x2c
That's a call through a function pointer to regular C function that
does nothing on native boots, but that function isn't protected
against kprobes, isn't marked notrace, and is certainly not
guaranteed to preserve any registers if the compiler is feeling
perverse. This is bad news for a CLBR_NONE operation.
Of course, if everything works correctly, once paravirt ops are
patched, it gets nopped out, but what if we hit this code before
paravirt ops are patched in? This can potentially cause breakage
that is very difficult to debug.
A more subtle failure is possible here, too: if _paravirt_nop uses
the stack at all (even just to push RBP), it will overwrite the "NMI
executing" variable if it's called in the NMI prologue.
The Xen case, perhaps surprisingly, is fine, because it's already
written in asm.
Fix all of the cases that default to paravirt_nop (including
adjust_exception_frame) with a big hammer: replace paravirt_nop with
an asm function that is just a ret instruction.
The Xen case may have other problems, so document them.
This is part of a fix for some random crashes that Sasha saw.
Cc: stable@vger.kernel.org
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/entry_64.S | 11 +++++++++++
arch/x86/kernel/paravirt.c | 16 ++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index a25ac7afc951..f7492133a7bb 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1135,7 +1135,18 @@ END(error_exit)
/* Runs on exception stack */
ENTRY(nmi)
+ /*
+ * Fix up the exception frame if we're on Xen.
+ * PARAVIRT_ADJUST_EXCEPTION_FRAME is guaranteed to push at most
+ * one value to the stack on native, so it may clobber the rdx
+ * scratch slot, but it won't clobber any of the important
+ * slots past it.
+ *
+ * Xen is a different story, because the Xen frame itself overlaps
+ * the "NMI executing" variable.
+ */
PARAVIRT_ADJUST_EXCEPTION_FRAME
+
/*
* We allow breakpoints in NMIs. If a breakpoint occurs, then
* the iretq it performs will take us out of NMI context.
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index f68e48f5f6c2..c2130aef3f9d 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -41,10 +41,18 @@
#include <asm/timer.h>
#include <asm/special_insns.h>
-/* nop stub */
-void _paravirt_nop(void)
-{
-}
+/*
+ * nop stub, which must not clobber anything *including the stack* to
+ * avoid confusing the entry prologues.
+ */
+extern void _paravirt_nop(void);
+asm (".pushsection .entry.text, \"ax\"\n"
+ ".global _paravirt_nop\n"
+ "_paravirt_nop:\n\t"
+ "ret\n\t"
+ ".size _paravirt_nop, . - _paravirt_nop\n\t"
+ ".type _paravirt_nop, @function\n\t"
+ ".popsection");
/* identity function, which can be inlined */
u32 _paravirt_ident_32(u32 x)
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
2015-09-20 23:32 [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
2015-09-20 23:32 ` [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function Andy Lutomirski
@ 2015-09-20 23:32 ` Andy Lutomirski
2015-09-22 19:48 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2015-09-22 20:42 ` tip-bot for Andy Lutomirski
2015-09-21 19:14 ` [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
2 siblings, 2 replies; 8+ messages in thread
From: Andy Lutomirski @ 2015-09-20 23:32 UTC (permalink / raw)
To: x86; +Cc: Sasha Levin, linux-kernel, Andy Lutomirski, stable
The NMI entry code that switches to the normal kernel stack needs to
be very careful not to clobber any extra stack slots on the NMI
stack. The code is fine under the assumption that SWAPGS is just a
normal instruction, but that assumption isn't really true. Use
SWAPGS_UNSAFE_STACK instead.
This is part of a fix for some random crashes that Sasha saw.
Fixes: 9b6e6a8334d5 ("x86/nmi/64: Switch stacks on userspace NMI entry")
Cc: stable@vger.kernel.org
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/entry_64.S | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index f7492133a7bb..2c61e8070ba4 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1205,9 +1205,12 @@ ENTRY(nmi)
* we don't want to enable interrupts, because then we'll end
* up in an awkward situation in which IRQs are on but NMIs
* are off.
+ *
+ * We also must not push anything to the stack before switching
+ * stacks lest we corrupt the "NMI executing" variable.
*/
- SWAPGS
+ SWAPGS_UNSAFE_STACK
cld
movq %rsp, %rdx
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] x86: NMI vs paravirt fixes
2015-09-20 23:32 [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
2015-09-20 23:32 ` [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function Andy Lutomirski
2015-09-20 23:32 ` [PATCH 2/2] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Andy Lutomirski
@ 2015-09-21 19:14 ` Andy Lutomirski
2 siblings, 0 replies; 8+ messages in thread
From: Andy Lutomirski @ 2015-09-21 19:14 UTC (permalink / raw)
To: Andy Lutomirski; +Cc: X86 ML, Sasha Levin, linux-kernel@vger.kernel.org
On Sun, Sep 20, 2015 at 4:32 PM, Andy Lutomirski <luto@kernel.org> wrote:
> These are for x86/urgent.
>
> This fixes at least one problem that Sasha can trigger using some
> crazy configuration + Trinity. I can't reproduce the full file of
> nastiness that he's seeing, but these patches both look legit to me,
> they fix what look like real bugs, and they seem to help Sasha's
> tests.
>
> Patch 1 is ugly. Feel free to tell me to shove the asm into the
> entry asm files, although that will involve duplicating it for
> 32-bit and 64-bit kernels.
It turns out that Sasha had noreplace-paravirt on, which is probably
how he was able to hit these reliably.
They're still bugs, though.
--Andy
^ permalink raw reply [flat|nested] 8+ messages in thread
* [tip:x86/urgent] x86/paravirt: Replace the paravirt nop with a bona fide empty function
2015-09-20 23:32 ` [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function Andy Lutomirski
@ 2015-09-22 19:48 ` tip-bot for Andy Lutomirski
2015-09-22 20:42 ` tip-bot for Andy Lutomirski
1 sibling, 0 replies; 8+ messages in thread
From: tip-bot for Andy Lutomirski @ 2015-09-22 19:48 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, mingo, luto, sasha.levin, tglx, hpa
Commit-ID: 3e415db82ccd1d6bc1e30f87f0a66ed638f6908e
Gitweb: http://git.kernel.org/tip/3e415db82ccd1d6bc1e30f87f0a66ed638f6908e
Author: Andy Lutomirski <luto@kernel.org>
AuthorDate: Sun, 20 Sep 2015 16:32:04 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 22 Sep 2015 21:43:37 +0200
x86/paravirt: Replace the paravirt nop with a bona fide empty function
PARAVIRT_ADJUST_EXCEPTION_FRAME generates this code (using nmi as an
example, trimmed for readability):
ff 15 00 00 00 00 callq *0x0(%rip) # 2796 <nmi+0x6>
2792: R_X86_64_PC32 pv_irq_ops+0x2c
That's a call through a function pointer to regular C function that
does nothing on native boots, but that function isn't protected
against kprobes, isn't marked notrace, and is certainly not
guaranteed to preserve any registers if the compiler is feeling
perverse. This is bad news for a CLBR_NONE operation.
Of course, if everything works correctly, once paravirt ops are
patched, it gets nopped out, but what if we hit this code before
paravirt ops are patched in? This can potentially cause breakage
that is very difficult to debug.
A more subtle failure is possible here, too: if _paravirt_nop uses
the stack at all (even just to push RBP), it will overwrite the "NMI
executing" variable if it's called in the NMI prologue.
The Xen case, perhaps surprisingly, is fine, because it's already
written in asm.
Fix all of the cases that default to paravirt_nop (including
adjust_exception_frame) with a big hammer: replace paravirt_nop with
an asm function that is just a ret instruction.
The Xen case may have other problems, so document them.
This is part of a fix for some random crashes that Sasha saw.
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/8f5d2ba295f9d73751c33d97fda03e0495d9ade0.1442791737.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/entry/entry_64.S | 11 +++++++++++
arch/x86/kernel/paravirt.c | 16 ++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index d303318..404ca97 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1128,7 +1128,18 @@ END(error_exit)
/* Runs on exception stack */
ENTRY(nmi)
+ /*
+ * Fix up the exception frame if we're on Xen.
+ * PARAVIRT_ADJUST_EXCEPTION_FRAME is guaranteed to push at most
+ * one value to the stack on native, so it may clobber the rdx
+ * scratch slot, but it won't clobber any of the important
+ * slots past it.
+ *
+ * Xen is a different story, because the Xen frame itself overlaps
+ * the "NMI executing" variable.
+ */
PARAVIRT_ADJUST_EXCEPTION_FRAME
+
/*
* We allow breakpoints in NMIs. If a breakpoint occurs, then
* the iretq it performs will take us out of NMI context.
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index f68e48f..c2130ae 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -41,10 +41,18 @@
#include <asm/timer.h>
#include <asm/special_insns.h>
-/* nop stub */
-void _paravirt_nop(void)
-{
-}
+/*
+ * nop stub, which must not clobber anything *including the stack* to
+ * avoid confusing the entry prologues.
+ */
+extern void _paravirt_nop(void);
+asm (".pushsection .entry.text, \"ax\"\n"
+ ".global _paravirt_nop\n"
+ "_paravirt_nop:\n\t"
+ "ret\n\t"
+ ".size _paravirt_nop, . - _paravirt_nop\n\t"
+ ".type _paravirt_nop, @function\n\t"
+ ".popsection");
/* identity function, which can be inlined */
u32 _paravirt_ident_32(u32 x)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:x86/urgent] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
2015-09-20 23:32 ` [PATCH 2/2] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Andy Lutomirski
@ 2015-09-22 19:48 ` tip-bot for Andy Lutomirski
2015-09-22 20:42 ` tip-bot for Andy Lutomirski
1 sibling, 0 replies; 8+ messages in thread
From: tip-bot for Andy Lutomirski @ 2015-09-22 19:48 UTC (permalink / raw)
To: linux-tip-commits; +Cc: luto, hpa, mingo, linux-kernel, tglx, sasha.levin
Commit-ID: 47ca71ccc88972ed6af8d44dac988af59f5f1ac8
Gitweb: http://git.kernel.org/tip/47ca71ccc88972ed6af8d44dac988af59f5f1ac8
Author: Andy Lutomirski <luto@kernel.org>
AuthorDate: Sun, 20 Sep 2015 16:32:05 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 22 Sep 2015 21:43:37 +0200
x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
The NMI entry code that switches to the normal kernel stack needs to
be very careful not to clobber any extra stack slots on the NMI
stack. The code is fine under the assumption that SWAPGS is just a
normal instruction, but that assumption isn't really true. Use
SWAPGS_UNSAFE_STACK instead.
This is part of a fix for some random crashes that Sasha saw.
Fixes: 9b6e6a8334d5 ("x86/nmi/64: Switch stacks on userspace NMI entry")
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/974bc40edffdb5c2950a5c4977f821a446b76178.1442791737.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/entry/entry_64.S | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 404ca97..055a01d 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1190,9 +1190,12 @@ ENTRY(nmi)
* we don't want to enable interrupts, because then we'll end
* up in an awkward situation in which IRQs are on but NMIs
* are off.
+ *
+ * We also must not push anything to the stack before switching
+ * stacks lest we corrupt the "NMI executing" variable.
*/
- SWAPGS
+ SWAPGS_UNSAFE_STACK
cld
movq %rsp, %rdx
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:x86/urgent] x86/paravirt: Replace the paravirt nop with a bona fide empty function
2015-09-20 23:32 ` [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function Andy Lutomirski
2015-09-22 19:48 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
@ 2015-09-22 20:42 ` tip-bot for Andy Lutomirski
1 sibling, 0 replies; 8+ messages in thread
From: tip-bot for Andy Lutomirski @ 2015-09-22 20:42 UTC (permalink / raw)
To: linux-tip-commits; +Cc: hpa, mingo, sasha.levin, luto, tglx, linux-kernel
Commit-ID: fc57a7c68020dcf954428869eafd934c0ab1536f
Gitweb: http://git.kernel.org/tip/fc57a7c68020dcf954428869eafd934c0ab1536f
Author: Andy Lutomirski <luto@kernel.org>
AuthorDate: Sun, 20 Sep 2015 16:32:04 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 22 Sep 2015 22:40:28 +0200
x86/paravirt: Replace the paravirt nop with a bona fide empty function
PARAVIRT_ADJUST_EXCEPTION_FRAME generates this code (using nmi as an
example, trimmed for readability):
ff 15 00 00 00 00 callq *0x0(%rip) # 2796 <nmi+0x6>
2792: R_X86_64_PC32 pv_irq_ops+0x2c
That's a call through a function pointer to regular C function that
does nothing on native boots, but that function isn't protected
against kprobes, isn't marked notrace, and is certainly not
guaranteed to preserve any registers if the compiler is feeling
perverse. This is bad news for a CLBR_NONE operation.
Of course, if everything works correctly, once paravirt ops are
patched, it gets nopped out, but what if we hit this code before
paravirt ops are patched in? This can potentially cause breakage
that is very difficult to debug.
A more subtle failure is possible here, too: if _paravirt_nop uses
the stack at all (even just to push RBP), it will overwrite the "NMI
executing" variable if it's called in the NMI prologue.
The Xen case, perhaps surprisingly, is fine, because it's already
written in asm.
Fix all of the cases that default to paravirt_nop (including
adjust_exception_frame) with a big hammer: replace paravirt_nop with
an asm function that is just a ret instruction.
The Xen case may have other problems, so document them.
This is part of a fix for some random crashes that Sasha saw.
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/8f5d2ba295f9d73751c33d97fda03e0495d9ade0.1442791737.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/entry/entry_64.S | 11 +++++++++++
arch/x86/kernel/paravirt.c | 16 ++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index d303318..404ca97 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1128,7 +1128,18 @@ END(error_exit)
/* Runs on exception stack */
ENTRY(nmi)
+ /*
+ * Fix up the exception frame if we're on Xen.
+ * PARAVIRT_ADJUST_EXCEPTION_FRAME is guaranteed to push at most
+ * one value to the stack on native, so it may clobber the rdx
+ * scratch slot, but it won't clobber any of the important
+ * slots past it.
+ *
+ * Xen is a different story, because the Xen frame itself overlaps
+ * the "NMI executing" variable.
+ */
PARAVIRT_ADJUST_EXCEPTION_FRAME
+
/*
* We allow breakpoints in NMIs. If a breakpoint occurs, then
* the iretq it performs will take us out of NMI context.
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index f68e48f..c2130ae 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -41,10 +41,18 @@
#include <asm/timer.h>
#include <asm/special_insns.h>
-/* nop stub */
-void _paravirt_nop(void)
-{
-}
+/*
+ * nop stub, which must not clobber anything *including the stack* to
+ * avoid confusing the entry prologues.
+ */
+extern void _paravirt_nop(void);
+asm (".pushsection .entry.text, \"ax\"\n"
+ ".global _paravirt_nop\n"
+ "_paravirt_nop:\n\t"
+ "ret\n\t"
+ ".size _paravirt_nop, . - _paravirt_nop\n\t"
+ ".type _paravirt_nop, @function\n\t"
+ ".popsection");
/* identity function, which can be inlined */
u32 _paravirt_ident_32(u32 x)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [tip:x86/urgent] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
2015-09-20 23:32 ` [PATCH 2/2] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Andy Lutomirski
2015-09-22 19:48 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
@ 2015-09-22 20:42 ` tip-bot for Andy Lutomirski
1 sibling, 0 replies; 8+ messages in thread
From: tip-bot for Andy Lutomirski @ 2015-09-22 20:42 UTC (permalink / raw)
To: linux-tip-commits; +Cc: mingo, luto, hpa, sasha.levin, tglx, linux-kernel
Commit-ID: 83c133cf11fb0e68a51681447e372489f052d40e
Gitweb: http://git.kernel.org/tip/83c133cf11fb0e68a51681447e372489f052d40e
Author: Andy Lutomirski <luto@kernel.org>
AuthorDate: Sun, 20 Sep 2015 16:32:05 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 22 Sep 2015 22:40:36 +0200
x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code
The NMI entry code that switches to the normal kernel stack needs to
be very careful not to clobber any extra stack slots on the NMI
stack. The code is fine under the assumption that SWAPGS is just a
normal instruction, but that assumption isn't really true. Use
SWAPGS_UNSAFE_STACK instead.
This is part of a fix for some random crashes that Sasha saw.
Fixes: 9b6e6a8334d5 ("x86/nmi/64: Switch stacks on userspace NMI entry")
Reported-and-tested-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/974bc40edffdb5c2950a5c4977f821a446b76178.1442791737.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/entry/entry_64.S | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 404ca97..055a01d 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1190,9 +1190,12 @@ ENTRY(nmi)
* we don't want to enable interrupts, because then we'll end
* up in an awkward situation in which IRQs are on but NMIs
* are off.
+ *
+ * We also must not push anything to the stack before switching
+ * stacks lest we corrupt the "NMI executing" variable.
*/
- SWAPGS
+ SWAPGS_UNSAFE_STACK
cld
movq %rsp, %rdx
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-09-22 20:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-20 23:32 [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
2015-09-20 23:32 ` [PATCH 1/2] x86/paravirt: Replace the paravirt nop with a bona fide empty function Andy Lutomirski
2015-09-22 19:48 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2015-09-22 20:42 ` tip-bot for Andy Lutomirski
2015-09-20 23:32 ` [PATCH 2/2] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Andy Lutomirski
2015-09-22 19:48 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2015-09-22 20:42 ` tip-bot for Andy Lutomirski
2015-09-21 19:14 ` [PATCH 0/2] x86: NMI vs paravirt fixes Andy Lutomirski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox