ix86: really make user_mode() work correctly for VM86 mode
Subsystems (2)
PATCH 1/1 ix86: really make user_mode() work correctly for VM86 mode
While commit efa7045103 ("x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode") claims that "user_mode() is now identical to user_mode_vm()", this wasn't actually the case - no prior commit made it so.
--- arch/x86/include/asm/ptrace.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/ptrace.h +2 -1
@@ -107,7 +107,8 @@ static inline unsigned long regs_return_static inline int user_mode (struct pt_regs *regs) {#ifdef CONFIG_X86_32 -return (regs->cs &SEGMENT_RPL_MASK ) ==USER_RPL ; +return ((regs->cs &SEGMENT_RPL_MASK ) | (regs->flags &X86_VM_MASK )) + >=USER_RPL ;#else return !!(regs->cs &3 );#endif
Quoted 5 lines · Jan Beulich
While commit
efa7045103("x86/asm/entry: Makeuser_mode()work correctly if regs came from VM86 mode") claims that "user_mode()is now identical touser_mode_vm()", this wasn't actually the case - no prior commit made it so.
That's embarrassing! I'm not sure how I screwed that up.
This is needed for x86/urgent. I'll see if I can write a simple test case, too. My old do_bounds test should be a good start.
--Andy
Quoted 8 lines · Andy Lutomirski
Quoted 5 lines · Jan Beulich
While commit
efa7045103("x86/asm/entry: Makeuser_mode()work correctly if regs came from VM86 mode") claims that "user_mode()is now identical touser_mode_vm()", this wasn't actually the case - no prior commit made it so.That's embarrassing! I'm not sure how I screwed that up.
I should have noticed it too :-/
In fact I remember that I wanted to double check it all because the algorithmic complexity of the new test looked suspiciously too simple on the 32-bit side (we _did_ have a legitimate reason to keep the API split originally) - but forgot about it.
Quoted 3 lines
Acked-by Andy Lutomirski <[email protected]>This is needed for x86/urgent.
Yeah, queued it up.
Quoted 2 lines
[...] I'll see if I can write a simple test case, too. My old
do_boundstest should be a good start.
That kind of test would be absolutely fantastic to have.
Thanks,
Ingo
tip-bot for Jan Beulich
merge bot[tip:x86/urgent] x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode
In reply to Jan Beulichx86/asm/entry/32: Really make user_mode() work correctly for VM86 mode
Commit-ID: 7ba554b5ac69e5f3edac9ce3233beb5acd480878 Gitweb: http://git.kernel.org/tip/7ba554b5ac69e5f3edac9ce3233beb5acd480878 Author: Jan Beulich <[email protected]> AuthorDate: Thu, 28 May 2015 09:16:45 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 29 May 2015 09:46:40 +0200
x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode
While commit efa7045103 ("x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode") claims that "user_mode() is now identical to user_mode_vm()", this wasn't actually the case - no prior commit made it so.
--- arch/x86/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/ptrace.h +1 -1
@@ -107,7 +107,7 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)static inline int user_mode (struct pt_regs *regs) {#ifdef CONFIG_X86_32 -return (regs->cs &SEGMENT_RPL_MASK ) ==USER_RPL ; +return ((regs->cs &SEGMENT_RPL_MASK ) | (regs->flags &X86_VM_MASK )) >=USER_RPL ;#else return !!(regs->cs &3 );#endif