]> git.baikalelectronics.ru Git - kernel.git/commit
x86/nmi/64: Use DF to avoid userspace RSP confusing nested NMI detection
authorAndy Lutomirski <luto@kernel.org>
Wed, 15 Jul 2015 17:29:38 +0000 (10:29 -0700)
committerIngo Molnar <mingo@kernel.org>
Fri, 17 Jul 2015 10:50:12 +0000 (12:50 +0200)
commitb5615338e25e636b54fb9f10c132cbcafdab6b40
treed558081a62bb49f80e733c755201fe8cbc4cfe39
parentb45a0f71981a59e848aa14ad514097a761f2fa7d
x86/nmi/64: Use DF to avoid userspace RSP confusing nested NMI detection

We have a tricky bug in the nested NMI code: if we see RSP
pointing to the NMI stack on NMI entry from kernel mode, we
assume that we are executing a nested NMI.

This isn't quite true.  A malicious userspace program can point
RSP at the NMI stack, issue SYSCALL, and arrange for an NMI to
happen while RSP is still pointing at the NMI stack.

Fix it with a sneaky trick.  Set DF in the region of code that
the RSP check is intended to detect.  IRET will clear DF
atomically.

( Note: other than paravirt, there's little need for all this
  complexity. We could check RIP instead of RSP. )

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/entry/entry_64.S