All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [GIT PULL] x86 fix
Date: Sat, 28 Mar 2015 14:58:22 +0100	[thread overview]
Message-ID: <20150328135822.GA15255@gmail.com> (raw)

Linus,

Please pull the latest x86-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-for-linus

   # HEAD: b3494a4ab20f6bdf74cdf2badf7918bb65ee8a00 x86/asm/entry: Check for syscall exit work with IRQs disabled

Fix x86 syscall exit code bug that resulted in spurious non-execution 
of TIF-driven user-return worklets, causing big trouble for things 
like KVM that rely on user notifiers for correctness of their vcpu 
model, causing crashes like double faults.

 Thanks,

	Ingo

------------------>
Andy Lutomirski (1):
      x86/asm/entry: Check for syscall exit work with IRQs disabled


 arch/x86/kernel/entry_64.S | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 1d74d161687c..2babb393915e 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -364,12 +364,21 @@ GLOBAL(system_call_after_swapgs)
  * Has incomplete stack frame and undefined top of stack.
  */
 ret_from_sys_call:
-	testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
-	jnz int_ret_from_sys_call_fixup	/* Go the the slow path */
-
 	LOCKDEP_SYS_EXIT
 	DISABLE_INTERRUPTS(CLBR_NONE)
 	TRACE_IRQS_OFF
+
+	/*
+	 * We must check ti flags with interrupts (or at least preemption)
+	 * off because we must *never* return to userspace without
+	 * processing exit work that is enqueued if we're preempted here.
+	 * In particular, returning to userspace with any of the one-shot
+	 * flags (TIF_NOTIFY_RESUME, TIF_USER_RETURN_NOTIFY, etc) set is
+	 * very bad.
+	 */
+	testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
+	jnz int_ret_from_sys_call_fixup	/* Go the the slow path */
+
 	CFI_REMEMBER_STATE
 	/*
 	 * sysretq will re-enable interrupts:
@@ -386,7 +395,7 @@ GLOBAL(system_call_after_swapgs)
 
 int_ret_from_sys_call_fixup:
 	FIXUP_TOP_OF_STACK %r11, -ARGOFFSET
-	jmp int_ret_from_sys_call
+	jmp int_ret_from_sys_call_irqs_off
 
 	/* Do syscall tracing */
 tracesys:
@@ -432,6 +441,7 @@ GLOBAL(system_call_after_swapgs)
 GLOBAL(int_ret_from_sys_call)
 	DISABLE_INTERRUPTS(CLBR_NONE)
 	TRACE_IRQS_OFF
+int_ret_from_sys_call_irqs_off:
 	movl $_TIF_ALLWORK_MASK,%edi
 	/* edi:	mask to check */
 GLOBAL(int_with_check)

             reply	other threads:[~2015-03-28 13:58 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-28 13:58 Ingo Molnar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-09-02 10:24 [GIT PULL] x86 fix Ingo Molnar
2023-09-02 16:13 ` pr-tracker-bot
2022-08-13 10:40 Ingo Molnar
2022-08-13 21:48 ` pr-tracker-bot
2020-08-02 19:17 Ingo Molnar
2020-08-02 20:15 ` pr-tracker-bot
2020-04-02  9:51 Ingo Molnar
2020-04-02 22:00 ` Linus Torvalds
2020-04-02 22:45 ` pr-tracker-bot
2020-03-24  9:06 Ingo Molnar
2020-03-24 17:15 ` pr-tracker-bot
2019-12-17 11:58 Ingo Molnar
2019-12-17 19:20 ` pr-tracker-bot
2019-09-28 12:42 Ingo Molnar
2019-09-28 20:50 ` pr-tracker-bot
2019-07-14 11:32 Ingo Molnar
2019-07-14 18:45 ` pr-tracker-bot
2019-05-05 11:00 Ingo Molnar
2019-05-05 22:10 ` pr-tracker-bot
2018-07-21 12:55 Ingo Molnar
2016-07-25 15:54 Ingo Molnar
2015-05-15  7:26 Ingo Molnar
2015-02-06 18:41 Ingo Molnar
2014-12-19 12:16 Ingo Molnar
2014-04-19 10:58 Ingo Molnar
2013-11-19 15:48 Ingo Molnar
2013-09-28 18:23 Ingo Molnar
2013-07-10 14:32 Ingo Molnar
2012-10-23 11:06 Ingo Molnar
2012-10-23 15:00 ` H. Peter Anvin
2012-10-23 15:17   ` Borislav Petkov
2011-12-20 19:30 Ingo Molnar
2011-10-13  9:00 Ingo Molnar
2011-09-30 18:22 Ingo Molnar
2011-09-30 18:59 ` Jeremy Fitzhardinge
2011-09-30 19:44 ` Thomas Gleixner
2011-07-23  8:43 Ingo Molnar
2011-02-07 15:03 Ingo Molnar
2010-12-28 22:27 Ingo Molnar
2010-12-23 13:00 Ingo Molnar
2010-12-08  7:51 Ingo Molnar
2010-10-30 18:26 Ingo Molnar
2009-09-27  8:02 Ingo Molnar
2009-08-10 18:08 Ingo Molnar
2009-06-29  8:36 Ingo Molnar
2009-03-10 18:25 [git pull] " Ingo Molnar
2009-02-28 13:02 i915 needs pgprot_writecombine() and is_io_mapping_posible() Theodore Ts'o
2009-02-28 13:34 ` [git pull] x86 fix Ingo Molnar
2009-01-13  1:17 Ingo Molnar
2008-11-07 16:30 Ingo Molnar
2008-10-04 14:55 Ingo Molnar
2008-07-01 19:57 Ingo Molnar
2008-04-26 19:47 Ingo Molnar
2008-04-26 20:15 ` Harvey Harrison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150328135822.GA15255@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.