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 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.

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.

> 
> I don't think we need to check any alignment constraints here anymore.
> 
> The summarize end result would be:
> 
> static unsigned long sgx_get_unmapped_area(struct file *file,
> 					   unsigned long addr,
> 					   unsigned long len,
> 					   unsigned long pgoff,
> 					   unsigned long flags)
> {
> 	if (flags & MAP_PRIVATE)
> 		return -EINVAL;
> 
> 	if (flags & MAP_FIXED)
> 		return addr;
> 
> 	return current->mm->get_unmapped_area(file, addr, 2 * len, pgoff,
> 					      flags);
> }
> 
> /Jarkko
> 



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

  Powered by Linux