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: <b8796aea7c0396dab59cf539a7de3c5e8c8e2933.camel@intel.com>
Date:   Fri, 14 Oct 2022 15:45:44 +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>,
        "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
        "kcc@...gle.com" <kcc@...gle.com>, "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>,
        "Moreira, Joao" <joao.moreira@...el.com>,
        "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>
Subject: Re: [PATCH v2 16/39] x86/mm: Update maybe_mkwrite() for shadow stack

On Fri, 2022-10-14 at 17:32 +0200, Peter Zijlstra wrote:
> On Thu, Sep 29, 2022 at 03:29:13PM -0700, Rick Edgecombe wrote:
> 
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 8cd413c5a329..fef14ab3abcb 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -981,13 +981,25 @@ void free_compound_page(struct page *page);
> >    * servicing faults for write access.  In the normal case, do
> > always want
> >    * pte_mkwrite.  But get_user_pages can cause write faults for
> > mappings
> >    * that do not have writing enabled, when used by
> > access_process_vm.
> > + *
> > + * If a vma is shadow stack (a type of writable memory), mark the
> > pte shadow
> > + * stack.
> >    */
> > +#ifndef maybe_mkwrite
> >   static inline pte_t maybe_mkwrite(pte_t pte, struct
> > vm_area_struct *vma)
> >   {
> > -     if (likely(vma->vm_flags & VM_WRITE))
> > +     if (!(vma->vm_flags & VM_WRITE))
> > +             goto out;
> > +
> > +     if (vma->vm_flags & VM_SHADOW_STACK)
> > +             pte = pte_mkwrite_shstk(pte);
> > +     else
> >                pte = pte_mkwrite(pte);
> > +
> > +out:
> >        return pte;
> >   }
> > +#endif
> 
> Why the #ifndef guard? There is no other implementation, nor does
> this
> patch introduce one.

Oh yea, this series used to add another one, but I forgot to remove the
guards. Thanks.

> 
> Also, wouldn't it be simpler to write it like:
> 
> static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct
> *vma)
> {
>         if (!(vma->vm_flags & VM_WRITE))
>                 return pte;
> 
>         if (vma->vm_flags & VM_SHADOW_STACK)
>                 return pte_mkwrite_shstk(pte);
> 
>         return pte_mkwrite(pte);
> }

Yep, that looks better. Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ