Re: [PATCH v2] x86/sgx: Fix deadlock and race conditions between fork() and EPC reclaim

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

 



On Mon, Apr 06, 2020 at 08:10:29PM +0300, Jarkko Sakkinen wrote:
> On Mon, Apr 06, 2020 at 07:36:38AM -0700, Sean Christopherson wrote:
> > On Sat, Apr 04, 2020 at 04:12:02AM +0300, Jarkko Sakkinen wrote:
> > > On Fri, Apr 03, 2020 at 04:42:39PM -0700, Sean Christopherson wrote:
> > > > On Fri, Apr 03, 2020 at 12:35:50PM +0300, Jarkko Sakkinen wrote:
> > > > > From: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> > > > > @@ -221,12 +224,16 @@ int sgx_encl_mm_add(struct sgx_encl *encl, struct mm_struct *mm)
> > > > >  		return ret;
> > > > >  	}
> > > > >  
> > > > > +	/*
> > > > > +	 * The page reclaimer uses list version for synchronization instead of
> > > > > +	 * synchronize_scru() because otherwise we could conflict with
> > > > > +	 * dup_mmap().
> > > > > +	 */
> > > > >  	spin_lock(&encl->mm_lock);
> > > > >  	list_add_rcu(&encl_mm->list, &encl->mm_list);
> > > > 
> > > > You dropped the smp_wmb().
> > > 
> > > As I said to you in my review x86 pipeline does not reorder writes.
> > 
> > And as I pointed out in this thread, smp_wmb() is a _compiler_ barrier if
> > and only if CONFIG_SMP=y.  The compiler can reorder list_add_rcu() and
> > mm_list_version++ because from it's perspective there is no dependency
> > between the two.  And that's entirely true except for the SMP case where
> > the consumer of mm_list_version is relying on the list to be updated before
> > the version changes.
> 
> I see.
> 
> So why not change the variable volatile given that x86 is the only
> arch that this code gets used?

Please note that I'm fully aware of

https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html

Just wondering. Anyway, I'll add smp_wmb() back since it is safe play
in terms of acceptance.

/Jarkko



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

  Powered by Linux