Re: [tip:x86/asm] x86/asm/entry: Add user_mode_ignore_vm86()
From: Denys Vlasenko
Date: Fri Mar 27 2015 - 09:48:52 EST
On 03/24/2015 08:46 PM, Andy Lutomirski wrote:
> On Tue, Mar 24, 2015 at 12:44 PM, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>>
>> * Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>>
>>> On Mon, Mar 23, 2015 at 5:26 AM, tip-bot for Andy Lutomirski
>>> <tipbot@xxxxxxxxx> wrote:
>>>> Commit-ID: a67e7277d01ccfd39b0db5a198c2643cc19dd79c
>>>> Gitweb: http://git.kernel.org/tip/a67e7277d01ccfd39b0db5a198c2643cc19dd79c
>>>> Author: Andy Lutomirski <luto@xxxxxxxxxx>
>>>> AuthorDate: Wed, 18 Mar 2015 18:33:29 -0700
>>>> Committer: Ingo Molnar <mingo@xxxxxxxxxx>
>>>> CommitDate: Mon, 23 Mar 2015 11:13:36 +0100
>>>>
>>>> x86/asm/entry: Add user_mode_ignore_vm86()
>>>>
>>>> user_mode() is dangerous and user_mode_vm() has a confusing name.
>>>>
>>>> Add user_mode_ignore_vm86() (equivalent to current user_mode()).
>>>> We'll change the small number of legitimate users of user_mode()
>>>> to user_mode_ignore_vm86().
>>>>
>>>> Inspired by grsec, although this works rather differently.
>>>
>>> Ingo, does this mean that you changed your mind or do you still want
>>> a patch to delete user_mode_ignore_vm86 and just use user_mode
>>> everywhere instead?
>>
>> Would be still nice to have it as an add on patch, if you agree with
>> my arguments.
>
> Given that there are only a very small number of callers left and
> they're all Obviously Correct (tm), I'm not too worried about it.
> Maybe if we kill off __copy_to_user, I'll be inspired to kill off
> user_mode_ignore_vm86 as well :)
I was looking at the code involving this function and it looks
like a much better name for user_mode_ignore_vm86() would be
user_mode_cs().
Every time we use it, we check vm8086 mode just before it:
perf_event.c
if (regs->flags & X86_VM_MASK)
return 0x10 * regs->cs;
if (user_mode_ignore_vm86(regs) && regs->cs != __USER_CS)
return get_segment_base(regs->cs);
traps.c (three similar instances):
if (v8086_mode(regs)) {
...
goto exit;
}
if (user_mode_ignore_vm86(regs))...
"_ignore_vm86" part doesn't quite work as an explanation.
user_mode_cs() would immediately tell me "do we have a user's cs?"
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/