lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 1 Nov 2017 04:32:43 -0700
From:   Andy Lutomirski <luto@...nel.org>
To:     Borislav Petkov <bp@...e.de>
Cc:     Andy Lutomirski <luto@...nel.org>, X86 ML <x86@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Brian Gerst <brgerst@...il.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 02/18] x86/asm/64: Split the iret-to-user and
 iret-to-kernel paths

On Fri, Oct 27, 2017 at 1:04 PM, Borislav Petkov <bp@...e.de> wrote:
> On Thu, Oct 26, 2017 at 01:26:34AM -0700, Andy Lutomirski wrote:
>> These code paths will diverge soon.
>>
>> Signed-off-by: Andy Lutomirski <luto@...nel.org>
>> ---
>>  arch/x86/entry/entry_64.S        | 32 +++++++++++++++++++++++---------
>>  arch/x86/entry/entry_64_compat.S |  2 +-
>>  arch/x86/kernel/head_64.S        |  2 +-
>>  3 files changed, 25 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>> index afe1f403fa0e..493e5e234d36 100644
>> --- a/arch/x86/entry/entry_64.S
>> +++ b/arch/x86/entry/entry_64.S
>> @@ -321,7 +321,7 @@ syscall_return_via_sysret:
>>
>>  opportunistic_sysret_failed:
>>       SWAPGS
>> -     jmp     restore_regs_and_iret
>> +     jmp     restore_regs_and_return_to_usermode
>
> rstor_regs_ret_user
>
> still sounds pretty ok to me and it is shorter and it is using the
> *RSTOR spelling the respective FPU insns use, so should be recognizable. :-)
>
> And the other one could be
>
> rstor_regs_ret_kernel
>
> of course.
>
>>  END(entry_SYSCALL_64)
>>
>>  ENTRY(stub_ptregs_64)
>> @@ -423,7 +423,7 @@ ENTRY(ret_from_fork)
>>       call    syscall_return_slowpath /* returns with IRQs disabled */
>>       TRACE_IRQS_ON                   /* user mode is traced as IRQS on */
>>       SWAPGS
>> -     jmp     restore_regs_and_iret
>> +     jmp     restore_regs_and_return_to_usermode
>>
>>  1:
>>       /* kernel thread */
>> @@ -612,7 +612,19 @@ GLOBAL(retint_user)
>>       call    prepare_exit_to_usermode
>>       TRACE_IRQS_IRETQ
>>       SWAPGS
>> -     jmp     restore_regs_and_iret
>> +
>> +GLOBAL(restore_regs_and_return_to_usermode)
>> +#ifdef CONFIG_DEBUG_ENTRY
>> +     testl   $3, CS(%rsp)
>
> testb
>
> ditto for the other spot.
>
>> +     jnz     1f
>> +     ud2
>> +1:
>> +#endif
>
> Why aren't we exploding here unconditionally? I mean, we don't want to
> return with RPL != 3 CS for whatever reason...

Performance?  I'll admit that both of these paths are extremely slow
no matter what, but it's nice to get a real dump if we screw it up.

I'll leave it as is for v2.  Feel free to argue more in v2 :)

Powered by blists - more mailing lists