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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b89565c96a0330c27ae179d96be05d2fc006121c.camel@intel.com>
Date:   Tue, 15 Nov 2022 20:03:06 +0000
From:   "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To:     "peterz@...radead.org" <peterz@...radead.org>
CC:     "bsingharora@...il.com" <bsingharora@...il.com>,
        "hpa@...or.com" <hpa@...or.com>,
        "Syromiatnikov, Eugene" <esyr@...hat.com>,
        "rdunlap@...radead.org" <rdunlap@...radead.org>,
        "keescook@...omium.org" <keescook@...omium.org>,
        "Yu, Yu-cheng" <yu-cheng.yu@...el.com>,
        "dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
        "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
        "Eranian, Stephane" <eranian@...gle.com>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "fweimer@...hat.com" <fweimer@...hat.com>,
        "nadav.amit@...il.com" <nadav.amit@...il.com>,
        "jannh@...gle.com" <jannh@...gle.com>,
        "dethoma@...rosoft.com" <dethoma@...rosoft.com>,
        "kcc@...gle.com" <kcc@...gle.com>,
        "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
        "bp@...en8.de" <bp@...en8.de>, "oleg@...hat.com" <oleg@...hat.com>,
        "hjl.tools@...il.com" <hjl.tools@...il.com>,
        "Yang, Weijiang" <weijiang.yang@...el.com>,
        "Lutomirski, Andy" <luto@...nel.org>,
        "pavel@....cz" <pavel@....cz>, "arnd@...db.de" <arnd@...db.de>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "mike.kravetz@...cle.com" <mike.kravetz@...cle.com>,
        "x86@...nel.org" <x86@...nel.org>,
        "linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
        "jamorris@...ux.microsoft.com" <jamorris@...ux.microsoft.com>,
        "john.allen@....com" <john.allen@....com>,
        "rppt@...nel.org" <rppt@...nel.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "Shankar, Ravi V" <ravi.v.shankar@...el.com>,
        "corbet@....net" <corbet@....net>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
        "gorcunov@...il.com" <gorcunov@...il.com>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: Re: [PATCH v3 15/37] x86/mm: Check Shadow Stack page fault errors

On Tue, 2022-11-15 at 12:47 +0100, Peter Zijlstra wrote:
> On Fri, Nov 04, 2022 at 03:35:42PM -0700, Rick Edgecombe wrote:
> > @@ -1331,6 +1345,18 @@ void do_user_addr_fault(struct pt_regs
> > *regs,
> >   
> >        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
> >   
> > +     /*
> > +      * To service shadow stack read faults, unlike normal read
> > faults, the
> > +      * fault handler needs to create a type of memory that will
> > also be
> > +      * writable (with instructions that generate shadow stack
> > writes).
> > +      * In the case of COW memory, the COW needs to take place
> > even with
> > +      * a shadow stack read. Otherwise the shared page will be
> > left (shadow
> > +      * stack) writable in userspace. So to trigger the
> > appropriate behavior
> > +      * by setting FAULT_FLAG_WRITE for shadow stack accesses,
> > even if the
> > +      * access was a shadow stack read.
> > +      */
> 
> Clear as mud... So SS pages are 'Write=0,Dirty=1', which, per
> construction, lack a RW bit. And these pages are writable (WRUSS).
> 
> pte_wrprotect() seems to do: _PAGE_DIRTY->_PAGE_COW (which is really
> weird in this situation), resulting in: 'Write=0,Dirty=0,Cow=1'.
> 
> That's regular RO memory and won't raise read-faults.
> 
> But I'm thinking RET will trip #PF here when it tries to read the SS
> because the SSP is not a proper shadow stack page?
> 
> And in that case you want to tickle pte_mkwrite() to undo the
> pte_wrprotect() above?
> 
> So while the #PF is a 'read' fault due to RET not actually writing to
> the shadow stack, you want to force a write fault so it will re-
> instate
> the SS page.
> 
> Did I get that right?

That's right. I think the assumption that needs to be broken in the
readers head is that you can satisfy a read fault with read-only PTE.
This is kind of baked in all over the place with the zero-pfn, COW,
etc. Maybe I should try to start with that.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ