Re: [PATCH v4 11/17] x86/entry/64: Migrate 64-bit and compat syscalls to new exit hooks

Andy Lutomirski
2015-07-02T15:56:39Z

On Thu, Jul 2, 2015 at 3:49 AM, Borislav Petkov <bp@alien8.de> wrote:
> On Mon, Jun 29, 2015 at 12:33:43PM -0700, Andy Lutomirski wrote:
>> These need to be migrated together, as the compat case used to jump
>> into the middle of the 64-bit exit code.
>>

>> diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
>> index efe0b1e499fa..ac0658142ae1 100644
>> --- a/arch/x86/entry/entry_64_compat.S
>> +++ b/arch/x86/entry/entry_64_compat.S
>> @@ -209,10 +209,10 @@ sysexit_from_sys_call:
>> .endm
>>
>> .macro auditsys_exit exit
>> - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
>> - jnz ia32_ret_from_sys_call
>> TRACE_IRQS_ON
>> ENABLE_INTERRUPTS(CLBR_NONE)
>> + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
>> + jnz ia32_ret_from_sys_call
>
> I guess you want to use tabs here like the rest of the macro does.
>

Oops. I wrote this before everything got tabified and I guess I
didn't fix it up right.

>> movl %eax, %esi /* second arg, syscall return value */
>> cmpl $-MAX_ERRNO, %eax /* is it an error ? */
>> jbe 1f
>> @@ -227,11 +227,10 @@ sysexit_from_sys_call:
>> testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
>> jz \exit
>> xorl %eax, %eax /* Do not leak kernel information */
>> - movq %rax, R11(%rsp)
>
> I guess that change needs at least some explanation in the commit
> message. AFAIU, this is RIP we shouldn't be zeroing for we need it in
> int_ret_from_sys_call...

This change is a mistake. There was another rebase issue in here that
I fixed, but apparently I still haven't gotten it right. Sigh.

--Andy