[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrUtW2t7bqDdCdZddeoO9maynV4WaVa418_jNFenzsCc6Q@mail.gmail.com>
Date: Wed, 14 Feb 2018 17:16:37 +0000
From: Andy Lutomirski <luto@...nel.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Dave Hansen <dave.hansen@...el.com>,
Josh Poimboeuf <jpoimboe@...hat.com>, X86 ML <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
David Woodhouse <dwmw2@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH] x86/entry/64: Fix CR3 restore order in paranoid_exit()
On Wed, Feb 14, 2018 at 7:39 AM, Ingo Molnar <mingo@...nel.org> wrote:
>
> * Dave Hansen <dave.hansen@...el.com> wrote:
>
>> On 02/13/2018 06:27 PM, Josh Poimboeuf wrote:
>> > --- a/arch/x86/entry/entry_64.S
>> > +++ b/arch/x86/entry/entry_64.S
>> > @@ -1167,10 +1167,10 @@ ENTRY(paranoid_exit)
>> > UNWIND_HINT_REGS
>> > DISABLE_INTERRUPTS(CLBR_ANY)
>> > TRACE_IRQS_OFF_DEBUG
>> > + RESTORE_CR3 scratch_reg=%r15 save_reg=%r14
>> > testl %ebx, %ebx /* swapgs needed? */
>> > jnz .Lparanoid_exit_no_swapgs
>> > TRACE_IRQS_IRETQ
>> > - RESTORE_CR3 scratch_reg=%rbx save_reg=%r14
>> > SWAPGS_UNSAFE_STACK
>> > jmp .Lparanoid_exit_restore
>> > .Lparanoid_exit_no_swapgs:
>>
>> TRACE_IRQS_* call non-entry functions that are not mapped by the user
>> CR3. How can this possibly work? What am I missing?
>
> How about something like the patch below? (Totally untested)
>
> Thanks,
>
> Ingo
> ---
> arch/x86/entry/entry_64.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index cd216c9431e1..8971bd64d515 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -1175,6 +1175,7 @@ ENTRY(paranoid_exit)
> jmp .Lparanoid_exit_restore
> .Lparanoid_exit_no_swapgs:
> TRACE_IRQS_IRETQ_DEBUG
> + RESTORE_CR3 scratch_reg=%rbx save_reg=%r14
> .Lparanoid_exit_restore:
> jmp restore_regs_and_return_to_kernel
> END(paranoid_exit)
Reviewed-by: Andy Lutomirski <luto@...nel.org>
Powered by blists - more mailing lists