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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 14 Aug 2018 14:28:45 -0700
From:   Yu-cheng Yu <yu-cheng.yu@...el.com>
To:     Peter Zijlstra <peterz@...radead.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>
Cc:     x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
        linux-doc@...r.kernel.org, linux-mm@...ck.org,
        linux-arch@...r.kernel.org, linux-api@...r.kernel.org,
        Arnd Bergmann <arnd@...db.de>,
        Andy Lutomirski <luto@...capital.net>,
        Balbir Singh <bsingharora@...il.com>,
        Cyrill Gorcunov <gorcunov@...il.com>,
        Florian Weimer <fweimer@...hat.com>,
        "H.J. Lu" <hjl.tools@...il.com>, Jann Horn <jannh@...gle.com>,
        Jonathan Corbet <corbet@....net>,
        Kees Cook <keescook@...omiun.org>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Nadav Amit <nadav.amit@...il.com>,
        Oleg Nesterov <oleg@...hat.com>, Pavel Machek <pavel@....cz>,
        "Ravi V. Shankar" <ravi.v.shankar@...el.com>,
        Vedvyas Shanbhogue <vedvyas.shanbhogue@...el.com>
Subject: Re: [RFC PATCH v2 13/27] mm: Handle shadow stack page fault

On Wed, 2018-07-11 at 11:06 +0200, Peter Zijlstra wrote:
> On Tue, Jul 10, 2018 at 04:06:25PM -0700, Dave Hansen wrote:
> > 
> > On 07/10/2018 03:26 PM, Yu-cheng Yu wrote:
> > > 
> > > +	if (is_shstk_mapping(vma->vm_flags))
> > > +		entry = pte_mkdirty_shstk(entry);
> > > +	else
> > > +		entry = pte_mkdirty(entry);
> > > +
> > > +	entry = maybe_mkwrite(entry, vma);
> > >  	if (ptep_set_access_flags(vma, vmf->address, vmf->pte,
> > > entry, 1))
> > >  		update_mmu_cache(vma, vmf->address, vmf->pte);
> > >  	pte_unmap_unlock(vmf->pte, vmf->ptl);
> > > @@ -2526,7 +2532,11 @@ static int wp_page_copy(struct vm_fault
> > > *vmf)
> > >  		}
> > >  		flush_cache_page(vma, vmf->address,
> > > pte_pfn(vmf->orig_pte));
> > >  		entry = mk_pte(new_page, vma->vm_page_prot);
> > > -		entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> > > +		if (is_shstk_mapping(vma->vm_flags))
> > > +			entry = pte_mkdirty_shstk(entry);
> > > +		else
> > > +			entry = pte_mkdirty(entry);
> > > +		entry = maybe_mkwrite(entry, vma);
> > Do we want to lift this hunk of code and put it elsewhere?  Maybe:
> > 
> > 	entry = pte_set_vma_features(entry, vma);
> > 
> > and then:
> > 
> > pte_t pte_set_vma_features(pte_t entry, struct vm_area_struct)
> > {
> > 		/*
> > 		 * Shadow stack PTEs are always dirty and always
> > 		 * writable.  They have a different encoding for
> > 		 * this than normal PTEs, though.
> > 		 */
> > 		if (is_shstk_mapping(vma->vm_flags))
> > 			entry = pte_mkdirty_shstk(entry);
> > 		else
> > 			entry = pte_mkdirty(entry);
> > 
> > 		entry = maybe_mkwrite(entry, vma);
> > 
> > 	return entry;
> > }
> Yes, that wants a helper like that. Not sold on the name, but
> whatever.
> 
> Is there any way we can hide all the shadow stack magic in arch
> code?

We use is_shstk_mapping() only to determine PAGE_DIRTY_SW or
PAGE_DIRTY_HW should be set in a PTE.  One way to remove this shadow
stack code from generic code is changing pte_mkdirty(pte) to
pte_mkdirty(pte, vma), and in the arch code we handle shadow stack.
Is this acceptable?

Thanks,
Yu-cheng

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ