Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-10-09 Thread Andy Lutomirski
gt;>> 00:00:00 2001 > >>>>>>>>> From: Yu-cheng Yu > >>>>>>>>> Date: Thu, 29 Nov 2018 14:15:38 -0800 > >>>>>>>>> Subject: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and > >>&

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-10-06 Thread Yu, Yu-cheng
09803e66dca38d7784e32687d0693550948199ed Mon Sep 17 00:00:00 2001 From: Yu-cheng Yu Date: Thu, 29 Nov 2018 14:15:38 -0800 Subject: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation Vsyscall entry points are effectively branch targets. Mark them with ENDBR64

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-10-01 Thread Andy Lutomirski
t;>From 09803e66dca38d7784e32687d0693550948199ed Mon Sep 17 00:00:00 > >>>>>>> 2001 > >>>>>>> From: Yu-cheng Yu > >>>>>>> Date: Thu, 29 Nov 2018 14:15:38 -0800 > >>>>>>> Subject: [PATCH v13

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-10-01 Thread Yu, Yu-cheng
Subject: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation Vsyscall entry points are effectively branch targets. Mark them with ENDBR64 opcodes. When emulating the RET instruction, unwind shadow stack and reset IBT state machine. Signed-off

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-30 Thread H.J. Lu
;> + > > > > >>>>> + if (cet->user_ssp && ((cet->user_ssp + 8) < > > > > >>>>> TASK_SIZE_MAX)) > > > > >>>>> + cet->user_ssp +=

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-30 Thread Andy Lutomirski
} > > > >>>>> + > > > >>>>> + if (cet->user_ssp && ((cet->user_ssp + 8) < > > > >>>>> TASK_SIZE_MAX)) > > > >>>>> + cet->user_ssp += 8;

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-30 Thread H.J. Lu
gt;>> + } > > >>>>> + > > >>>>> + if (cet->user_ssp && ((cet->user_ssp + 8) < > > >>>>> TASK_SIZE_MAX)) > > >>>>> + cet->user_ssp += 8; >

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-30 Thread Andy Lutomirski
cet->user_ssp += 8; > >>>> > >>>> This looks buggy. The condition should be "if SHSTK is on, then add 8 > >>>> to user_ssp". If the result is noncanonical, then some appropriate > >>>> exception should be generated,

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-30 Thread Yu, Yu-cheng
eng Yu Date: Thu, 29 Nov 2018 14:15:38 -0800 Subject: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation Vsyscall entry points are effectively branch targets. Mark them with ENDBR64 opcodes. When emulating the RET instruction, unwind shadow

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-29 Thread Andy Lutomirski
gt; > > This looks buggy. The condition should be "if SHSTK is on, then add 8 > > > to user_ssp". If the result is noncanonical, then some appropriate > > > exception should be generated, probably by the FPU restore code -- see > > > below. You should be checki

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-29 Thread Andy Lutomirski
You should be checking the SHSTK_EN bit, not SSP. > > Updated. Is this OK? I will resend the whole series later. > > Thanks, > Yu-cheng > > == > > From 09803e66dca38d7784e32687d0693550948199ed Mon Sep 17 00:00:00 2001 > From: Yu-cheng Yu > Date: Thu, 29 N

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-29 Thread Yu, Yu-cheng
will resend the whole series later. Thanks, Yu-cheng == From 09803e66dca38d7784e32687d0693550948199ed Mon Sep 17 00:00:00 2001 From: Yu-cheng Yu Date: Thu, 29 Nov 2018 14:15:38 -0800 Subject: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-28 Thread Yu, Yu-cheng
On 9/28/2020 10:37 AM, Andy Lutomirski wrote: On Mon, Sep 28, 2020 at 9:59 AM Yu-cheng Yu wrote: On Fri, 2020-09-25 at 09:51 -0700, Andy Lutomirski wrote: On Sep 25, 2020, at 9:48 AM, Yu, Yu-cheng wrote: + + cet = get_xsave_addr(>state.xsave, XFEATURE_CET_USER); +

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-28 Thread Andy Lutomirski
On Mon, Sep 28, 2020 at 9:59 AM Yu-cheng Yu wrote: > > On Fri, 2020-09-25 at 09:51 -0700, Andy Lutomirski wrote: > > > On Sep 25, 2020, at 9:48 AM, Yu, Yu-cheng wrote: > + > + cet = get_xsave_addr(>state.xsave, XFEATURE_CET_USER); > + if (!cet) { > +

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-28 Thread Yu-cheng Yu
a comment and a warning would be much > > > better than a random sigsegv. > > > > Yes, it should be impossible to get here. I will add a comment and a > > warning, but still do sigsegv. Should this happen, and the function > > return, the app gets a control-protectio

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-25 Thread Andy Lutomirski
> On Sep 25, 2020, at 9:48 AM, Yu, Yu-cheng wrote: > > On 9/25/2020 9:31 AM, Andy Lutomirski wrote: >>> On Fri, Sep 25, 2020 at 7:58 AM Yu-cheng Yu wrote: >>> > > [...] > >>> @@ -286,6 +289,37 @@ bool emulate_vsyscall(unsigned long error_code, >>> /* Emulate a ret instruction. */

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-25 Thread Yu, Yu-cheng
On 9/25/2020 9:31 AM, Andy Lutomirski wrote: On Fri, Sep 25, 2020 at 7:58 AM Yu-cheng Yu wrote: [...] @@ -286,6 +289,37 @@ bool emulate_vsyscall(unsigned long error_code, /* Emulate a ret instruction. */ regs->ip = caller; regs->sp += 8; + +#ifdef CONFIG_X86_CET

Re: [PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-25 Thread Andy Lutomirski
On Fri, Sep 25, 2020 at 7:58 AM Yu-cheng Yu wrote: > > Vsyscall entry points are effectively branch targets. Mark them with > ENDBR64 opcodes. When emulating the RET instruction, unwind shadow stack > and reset IBT state machine. > > Signed-off-by: Yu-cheng Yu > --- > v13: > - Check shadow

[PATCH v13 8/8] x86/vsyscall/64: Fixup Shadow Stack and Indirect Branch Tracking for vsyscall emulation

2020-09-25 Thread Yu-cheng Yu
Vsyscall entry points are effectively branch targets. Mark them with ENDBR64 opcodes. When emulating the RET instruction, unwind shadow stack and reset IBT state machine. Signed-off-by: Yu-cheng Yu --- v13: - Check shadow stack address is canonical. - Change from writing to MSRs to writing to