diff options
author | Andy Lutomirski <luto@kernel.org> | 2015-03-18 21:33:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-23 06:13:51 -0400 |
commit | efa704510342b81ae58d7b8a0c7f676a4289b603 (patch) | |
tree | 3162527a9ad26a50eef9f14b012ac02e5cf834c7 | |
parent | ae60f0710ae6b33092267ef8ac853c498f6d3e5d (diff) |
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 <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brad Spengler <spender@grsecurity.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/0dd03eacb5f0a2b5ba0240de25347a31b493c289.1426728647.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/ptrace.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h index 4a040f0078f2..70c439f9071b 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) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | /* | 98 | /* |
99 | * user_mode_vm(regs) determines whether a register set came from user mode. | 99 | * user_mode(regs) determines whether a register set came from user |
100 | * This is true if V8086 mode was enabled OR if the register set was from | 100 | * mode. On x86_32, this is true if V8086 mode was enabled OR if the |
101 | * protected mode with RPL-3 CS value. This tricky test checks that with | 101 | * register set was from protected mode with RPL-3 CS value. This |
102 | * one comparison. Many places in the kernel can bypass this full check | 102 | * tricky test checks that with one comparison. |
103 | * if they have already ruled out V8086 mode, so user_mode(regs) can be used. | 103 | * |
104 | * On x86_64, vm86 mode is mercifully nonexistent, and we don't need | ||
105 | * the extra check. | ||
104 | */ | 106 | */ |
105 | static inline int user_mode(struct pt_regs *regs) | 107 | static inline int user_mode(struct pt_regs *regs) |
106 | { | 108 | { |
@@ -113,12 +115,7 @@ static inline int user_mode(struct pt_regs *regs) | |||
113 | 115 | ||
114 | static inline int user_mode_vm(struct pt_regs *regs) | 116 | static inline int user_mode_vm(struct pt_regs *regs) |
115 | { | 117 | { |
116 | #ifdef CONFIG_X86_32 | ||
117 | return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >= | ||
118 | USER_RPL; | ||
119 | #else | ||
120 | return user_mode(regs); | 118 | return user_mode(regs); |
121 | #endif | ||
122 | } | 119 | } |
123 | 120 | ||
124 | /* | 121 | /* |