From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932176AbbCWM14 (ORCPT ); Mon, 23 Mar 2015 08:27:56 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41549 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752783AbbCWM1y (ORCPT ); Mon, 23 Mar 2015 08:27:54 -0400 Date: Mon, 23 Mar 2015 05:27:29 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, luto@kernel.org, mingo@kernel.org, spender@grsecurity.net, dvlasenk@redhat.com, torvalds@linux-foundation.org, bp@alien8.de, tglx@linutronix.de Reply-To: spender@grsecurity.net, mingo@kernel.org, luto@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, dvlasenk@redhat.com, torvalds@linux-foundation.org, tglx@linutronix.de, bp@alien8.de In-Reply-To: <0dd03eacb5f0a2b5ba0240de25347a31b493c289.1426728647.git.luto@kernel.org> References: <0dd03eacb5f0a2b5ba0240de25347a31b493c289.1426728647.git.luto@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode Git-Commit-ID: efa704510342b81ae58d7b8a0c7f676a4289b603 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: efa704510342b81ae58d7b8a0c7f676a4289b603 Gitweb: http://git.kernel.org/tip/efa704510342b81ae58d7b8a0c7f676a4289b603 Author: Andy Lutomirski AuthorDate: Wed, 18 Mar 2015 18:33:32 -0700 Committer: Ingo Molnar CommitDate: Mon, 23 Mar 2015 11:13:51 +0100 x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode user_mode() is now identical to user_mode_vm(). Subsequent patches will change all callers of user_mode_vm() to user_mode() and then delete user_mode_vm(). Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Brad Spengler Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/0dd03eacb5f0a2b5ba0240de25347a31b493c289.1426728647.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/ptrace.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h index 4a040f0..70c439f 100644 --- a/arch/x86/include/asm/ptrace.h +++ b/arch/x86/include/asm/ptrace.h @@ -96,11 +96,13 @@ static inline unsigned long regs_return_value(struct pt_regs *regs) } /* - * user_mode_vm(regs) determines whether a register set came from user mode. - * This is true if V8086 mode was enabled OR if the register set was from - * protected mode with RPL-3 CS value. This tricky test checks that with - * one comparison. Many places in the kernel can bypass this full check - * if they have already ruled out V8086 mode, so user_mode(regs) can be used. + * user_mode(regs) determines whether a register set came from user + * mode. On x86_32, this is true if V8086 mode was enabled OR if the + * register set was from protected mode with RPL-3 CS value. This + * tricky test checks that with one comparison. + * + * On x86_64, vm86 mode is mercifully nonexistent, and we don't need + * the extra check. */ static inline int user_mode(struct pt_regs *regs) { @@ -113,12 +115,7 @@ static inline int user_mode(struct pt_regs *regs) static inline int user_mode_vm(struct pt_regs *regs) { -#ifdef CONFIG_X86_32 - return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >= - USER_RPL; -#else return user_mode(regs); -#endif } /*