Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-28 Thread Yu-cheng Yu
On Tue, 2020-05-19 at 18:04 -0700, Andy Lutomirski wrote: > On Mon, May 18, 2020 at 6:35 PM Andy Lutomirski wrote: > > [...] > > > On May 18, 2020, at 5:38 PM, Dave Hansen wrote: > > > [...] > > > The sadistic parts of selftests/x86 come from real bugs. Either bugs > > > where the kernel fell

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-22 Thread Andrew Cooper
On 22/05/2020 17:49, Peter Zijlstra wrote: > On Sat, May 16, 2020 at 03:09:22PM +0100, Andrew Cooper wrote: > >> Sadly, the same is not true for kernel shadow stacks. >> >> SSP is 0 after SYSCALL, SYSENTER and CLRSSBSY, and you've got to be >> careful to re-establish the shadow stack before a

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-22 Thread Peter Zijlstra
On Sat, May 16, 2020 at 03:09:22PM +0100, Andrew Cooper wrote: > Sadly, the same is not true for kernel shadow stacks. > > SSP is 0 after SYSCALL, SYSENTER and CLRSSBSY, and you've got to be > careful to re-establish the shadow stack before a CALL, interrupt or > exception tries pushing a word

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-19 Thread Andy Lutomirski
On Mon, May 18, 2020 at 6:35 PM Andy Lutomirski wrote: > > > > > On May 18, 2020, at 5:38 PM, Dave Hansen wrote: > > > > On 5/18/20 4:47 PM, Yu-cheng Yu wrote: > >>> On Fri, 2020-05-15 at 19:53 -0700, Yu-cheng Yu wrote: > >>> On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: > On

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread Andy Lutomirski
> On May 18, 2020, at 5:38 PM, Dave Hansen wrote: > > On 5/18/20 4:47 PM, Yu-cheng Yu wrote: >>> On Fri, 2020-05-15 at 19:53 -0700, Yu-cheng Yu wrote: >>> On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: On 5/15/20 4:29 PM, Yu-cheng Yu wrote: > [...] > I have run them with

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread Dave Hansen
On 5/18/20 4:47 PM, Yu-cheng Yu wrote: > On Fri, 2020-05-15 at 19:53 -0700, Yu-cheng Yu wrote: >> On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: >>> On 5/15/20 4:29 PM, Yu-cheng Yu wrote: [...] I have run them with CET enabled. All of them pass, except for the following:

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread Yu-cheng Yu
On Fri, 2020-05-15 at 19:53 -0700, Yu-cheng Yu wrote: > On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: > > On 5/15/20 4:29 PM, Yu-cheng Yu wrote: > > > [...] > > > I have run them with CET enabled. All of them pass, except for the > > > following: > > > Sigreturn from 64-bit to 32-bit

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread Dave Hansen
On 5/18/20 7:01 AM, H.J. Lu wrote: >> Could some of this information be added to the documentation, please? >> It would also be nice to have some more details about how apps end up >> using ARCH_X86_CET_STATUS. Why would they care that CET is on? > CET software spec is at > >

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread Yu-cheng Yu
On Mon, 2020-05-18 at 06:41 -0700, Dave Hansen wrote: > On 5/15/20 7:53 PM, Yu-cheng Yu wrote: > > On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: > > > What's my recourse as an end user? I want to run my app and turn off > > > CET for that app. How can I do that? > > > >

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread H.J. Lu
On Mon, May 18, 2020 at 6:41 AM Dave Hansen wrote: > > On 5/15/20 7:53 PM, Yu-cheng Yu wrote: > > On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: > >> What's my recourse as an end user? I want to run my app and turn off > >> CET for that app. How can I do that? > > > >

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-18 Thread Dave Hansen
On 5/15/20 7:53 PM, Yu-cheng Yu wrote: > On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: >> What's my recourse as an end user? I want to run my app and turn off >> CET for that app. How can I do that? > > GLIBC_TUNABLES=glibc.tune.hwcaps=-SHSTK,-IBT Like I mentioned to H.J., this is

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-17 Thread Dave Hansen
On 5/15/20 7:51 PM, H.J. Lu wrote: > On Fri, May 15, 2020 at 4:56 PM Dave Hansen wrote: >> Let's say we have an app doing silly things like retpolines. (Lots of >> app do lots of silly things). It gets compiled in a distro but never >> runs on a system with CET. The app gets run for the first

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-16 Thread Andrew Cooper
On 16/05/2020 03:37, H.J. Lu wrote: > On Fri, May 15, 2020 at 5:13 PM Andrew Cooper > wrote: >> Finally seeing as the question was asked but not answered, it is >> actually quite easy to figure out whether shadow stacks are enabled in >> the current thread. >> >> mov $1, %eax >>

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread H.J. Lu
On Fri, May 15, 2020 at 4:56 PM Dave Hansen wrote: > > On 5/15/20 4:29 PM, Yu-cheng Yu wrote: > > On Fri, 2020-05-15 at 15:43 -0700, Dave Hansen wrote: > >> Basically, if there ends up being a bug in an app that violates the > >> shadow stack rules, the app is broken, period. The only recourse

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Yu-cheng Yu
On Fri, 2020-05-15 at 16:56 -0700, Dave Hansen wrote: > On 5/15/20 4:29 PM, Yu-cheng Yu wrote: > > On Fri, 2020-05-15 at 15:43 -0700, Dave Hansen wrote: > > > Basically, if there ends up being a bug in an app that violates the > > > shadow stack rules, the app is broken, period. The only recourse

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread H.J. Lu
On Fri, May 15, 2020 at 5:13 PM Andrew Cooper wrote: > > On 15/05/2020 23:43, Dave Hansen wrote: > > On 5/15/20 2:33 PM, Yu-cheng Yu wrote: > >> On Fri, 2020-05-15 at 11:39 -0700, Dave Hansen wrote: > >>> On 5/12/20 4:20 PM, Yu-cheng Yu wrote: > >>> Can a binary compiled with CET run without CET?

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Andrew Cooper
On 15/05/2020 23:43, Dave Hansen wrote: > On 5/15/20 2:33 PM, Yu-cheng Yu wrote: >> On Fri, 2020-05-15 at 11:39 -0700, Dave Hansen wrote: >>> On 5/12/20 4:20 PM, Yu-cheng Yu wrote: >>> Can a binary compiled with CET run without CET? >> Yes, but a few details: >> >> - The shadow stack is

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Dave Hansen
On 5/15/20 4:29 PM, Yu-cheng Yu wrote: > On Fri, 2020-05-15 at 15:43 -0700, Dave Hansen wrote: >> Basically, if there ends up being a bug in an app that violates the >> shadow stack rules, the app is broken, period. The only recourse is to >> have the kernel disable CET and reboot. >> >> Is that

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Yu-cheng Yu
On Fri, 2020-05-15 at 15:43 -0700, Dave Hansen wrote: > On 5/15/20 2:33 PM, Yu-cheng Yu wrote: > > On Fri, 2020-05-15 at 11:39 -0700, Dave Hansen wrote: > > > On 5/12/20 4:20 PM, Yu-cheng Yu wrote: > > > Can a binary compiled with CET run without CET? > > > > Yes, but a few details: > > > > -

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Dave Hansen
On 5/15/20 2:33 PM, Yu-cheng Yu wrote: > On Fri, 2020-05-15 at 11:39 -0700, Dave Hansen wrote: >> On 5/12/20 4:20 PM, Yu-cheng Yu wrote: >> Can a binary compiled with CET run without CET? > > Yes, but a few details: > > - The shadow stack is transparent to the application. A CET application

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Yu-cheng Yu
On Fri, 2020-05-15 at 11:39 -0700, Dave Hansen wrote: > On 5/12/20 4:20 PM, Yu-cheng Yu wrote: > > On Wed, 2020-04-29 at 16:02 -0700, Yu-cheng Yu wrote: > > > On Wed, 2020-04-29 at 15:53 -0700, Dave Hansen wrote: > > > > On 4/29/20 3:07 PM, Yu-cheng Yu wrote: > > > > > +Note: > > > > > + There is

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-15 Thread Dave Hansen
On 5/12/20 4:20 PM, Yu-cheng Yu wrote: > On Wed, 2020-04-29 at 16:02 -0700, Yu-cheng Yu wrote: >> On Wed, 2020-04-29 at 15:53 -0700, Dave Hansen wrote: >>> On 4/29/20 3:07 PM, Yu-cheng Yu wrote: +Note: + There is no CET-enabling arch_prctl function. By design, CET is enabled +

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-05-12 Thread Yu-cheng Yu
On Wed, 2020-04-29 at 16:02 -0700, Yu-cheng Yu wrote: > On Wed, 2020-04-29 at 15:53 -0700, Dave Hansen wrote: > > On 4/29/20 3:07 PM, Yu-cheng Yu wrote: > > > +Note: > > > + There is no CET-enabling arch_prctl function. By design, CET is > > > enabled > > > + automatically if the binary and

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-04-29 Thread Yu-cheng Yu
On Wed, 2020-04-29 at 15:53 -0700, Dave Hansen wrote: > On 4/29/20 3:07 PM, Yu-cheng Yu wrote: > > +Note: > > + There is no CET-enabling arch_prctl function. By design, CET is enabled > > + automatically if the binary and the system can support it. > > I think Andy and I danced around this

Re: [PATCH v10 01/26] Documentation/x86: Add CET description

2020-04-29 Thread Dave Hansen
On 4/29/20 3:07 PM, Yu-cheng Yu wrote: > +Note: > + There is no CET-enabling arch_prctl function. By design, CET is enabled > + automatically if the binary and the system can support it. I think Andy and I danced around this last time. Let me try to say it more explicitly. I want CET kernel

[PATCH v10 01/26] Documentation/x86: Add CET description

2020-04-29 Thread Yu-cheng Yu
Explain no_user_shstk/no_user_ibt kernel parameters, and introduce a new document on Control-flow Enforcement Technology (CET). Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook --- v10: - Change no_cet_shstk and no_cet_ibt to no_user_shstk and no_user_ibt. - Remove the opcode section, as it is