mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, hpa@zytor.com, tglx@linutronix.de,
	bp@alien8.de, dvlasenk@redhat.com, linux-kernel@vger.kernel.org,
	bp@suse.de, peterz@infradead.org, luto@kernel.org,
	mingo@kernel.org, luto@amacapital.net, brgerst@gmail.com
Subject: [tip:x86/asm] x86/entry/64: Fix an IRQ state error on ptregs-using syscalls
Date: Mon, 1 Feb 2016 00:03:38 -0800	[thread overview]
Message-ID: <tip-b7765086b7c5a5be029a739c2caa161da51c2076@git.kernel.org> (raw)
In-Reply-To: <ab92cd365fb7b0a56869e920017790d96610fdca.1454261517.git.luto@kernel.org>

Commit-ID:  b7765086b7c5a5be029a739c2caa161da51c2076
Gitweb:     http://git.kernel.org/tip/b7765086b7c5a5be029a739c2caa161da51c2076
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Sun, 31 Jan 2016 09:33:26 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 1 Feb 2016 08:53:25 +0100

x86/entry/64: Fix an IRQ state error on ptregs-using syscalls

I messed up the IRQ state when jumping off the fast path due to
invocation of a ptregs-using syscall.  This bug shouldn't have
had any impact yet, but it would have caused problems with
subsequent context tracking cleanups.

Reported-and-tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 1e423bff959e x86/entry/64: ("Migrate the 64-bit syscall slow path to C")
Link: http://lkml.kernel.org/r/ab92cd365fb7b0a56869e920017790d96610fdca.1454261517.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/entry/entry_64.S | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 567aa52..9f7bb80 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -191,8 +191,8 @@ entry_SYSCALL_64_fastpath:
 
 	/*
 	 * This call instruction is handled specially in stub_ptregs_64.
-	 * It might end up jumping to the slow path.  If it jumps, RAX is
-	 * clobbered.
+	 * It might end up jumping to the slow path.  If it jumps, RAX
+	 * and all argument registers are clobbered.
 	 */
 	call	*sys_call_table(, %rax, 8)
 .Lentry_SYSCALL_64_after_fastpath_call:
@@ -315,17 +315,24 @@ END(entry_SYSCALL_64)
 ENTRY(stub_ptregs_64)
 	/*
 	 * Syscalls marked as needing ptregs land here.
-	 * If we are on the fast path, we need to save the extra regs.
-	 * If we are on the slow path, the extra regs are already saved.
+	 * If we are on the fast path, we need to save the extra regs,
+	 * which we achieve by trying again on the slow path.  If we are on
+	 * the slow path, the extra regs are already saved.
 	 *
 	 * RAX stores a pointer to the C function implementing the syscall.
+	 * IRQs are on.
 	 */
 	cmpq	$.Lentry_SYSCALL_64_after_fastpath_call, (%rsp)
 	jne	1f
 
-	/* Called from fast path -- pop return address and jump to slow path */
+	/*
+	 * Called from fast path -- disable IRQs again, pop return address
+	 * and jump to slow path
+	 */
+	DISABLE_INTERRUPTS(CLBR_NONE)
+	TRACE_IRQS_OFF
 	popq	%rax
-	jmp	entry_SYSCALL64_slow_path	/* called from fast path */
+	jmp	entry_SYSCALL64_slow_path
 
 1:
 	/* Called from C */

  reply	other threads:[~2016-02-01  8:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-31 17:33 [PATCH 0/3] x86/entry/64: Fixes for syscall rework Andy Lutomirski
2016-01-31 17:33 ` [PATCH 1/3] x86/entry/64: Fix an IRQ state error on ptregs-using syscalls Andy Lutomirski
2016-02-01  8:03   ` tip-bot for Andy Lutomirski [this message]
2016-01-31 17:33 ` [PATCH 2/3] x86/entry/64: Fix fast-path syscall return register state Andy Lutomirski
2016-02-01  8:03   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2016-01-31 17:33 ` [PATCH 3/3] x86/syscalls/64: Mark sys_iopl as using ptregs Andy Lutomirski
2016-02-01  8:04   ` [tip:x86/asm] x86/syscalls/64: Mark sys_iopl() " tip-bot for Andy Lutomirski
2016-01-31 21:46 ` [PATCH 0/3] x86/entry/64: Fixes for syscall rework Borislav Petkov
2016-02-01  7:58   ` Ingo Molnar

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=tip-b7765086b7c5a5be029a739c2caa161da51c2076@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome