Re: [RFC PATCH v3 02/12] x86/sgx: Do not naturally align MAP_FIXED address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 19, 2019 at 07:08:53AM -0700, Sean Christopherson wrote:
> On Wed, Jun 19, 2019 at 04:24:05PM +0300, Jarkko Sakkinen wrote:
> > On Mon, 2019-06-17 at 15:24 -0700, Sean Christopherson wrote:
> > >  {
> > > -	if (len < 2 * PAGE_SIZE || len & (len - 1) || flags & MAP_PRIVATE)
> > > +	if (flags & MAP_PRIVATE)
> > > +		return -EINVAL;
> > > +
> > > +	if (flags & MAP_FIXED)
> > > +		return addr;
> > > +
> > > +	if (len < 2 * PAGE_SIZE || len & (len - 1))
> > >  		return -EINVAL;
> > >
> > >  	addr = current->mm->get_unmapped_area(file, addr, 2 * len, pgoff,
> > 
> > Just sanity checking that for MAP_FIXED case the mm checks that the area is
> > unmapped before calling this?
> 
> No, straight MAP_FIXED unmaps any existing mappings.  The NOREPLACE variant
> fails with -EEXIST if there are existing mappings.

Ah so it was [1]!

> The MAP_FIXED behavior is actually useful, bordering on mandatory, for the
> new flow.  It allows the loader to keep its initial mmap(PROT_NONE) of
> ELRANGE while (re)mapping the individual enclave sections, e.g. to prevent
> a different aspect of the process from mapping the require ELRANGE.

Yeah, totally agree.

[1] http://man7.org/linux/man-pages/man2/mmap.2.html

/Jarkko



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux