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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110124153354.GA21612@redhat.com>
Date:	Mon, 24 Jan 2011 16:33:54 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	Hugh Dickins <hughd@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	David Miller <davem@...emloft.net>,
	Nick Piggin <npiggin@...nel.dk>,
	Martin Schwidefsky <schwidefsky@...ibm.com>,
	linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
	linux-mm@...ck.org, Andrea Arcangeli <aarcange@...hat.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Subject: Re: [PATCH 00/21] mm: Preemptibility -v6

On 01/24, Peter Zijlstra wrote:
>
> On Mon, 2011-01-24 at 15:34 +0100, Oleg Nesterov wrote:
> > On 01/24, Peter Zijlstra wrote:
> > >
> > > On Fri, 2011-01-21 at 16:33 +0100, Peter Zijlstra wrote:
> > >
> > > > Index: linux-2.6/mm/rmap.c
> > > > ===================================================================
> > > > --- linux-2.6.orig/mm/rmap.c
> > > > +++ linux-2.6/mm/rmap.c
> > > > @@ -1559,9 +1559,20 @@ void __put_anon_vma(struct anon_vma *ano
> > > >  	 * Synchronize against page_lock_anon_vma() such that
> > > >  	 * we can safely hold the lock without the anon_vma getting
> > > >  	 * freed.
> > > > +	 *
> > > > +	 * Relies on the full mb implied by the atomic_dec_and_test() from
> > > > +	 * put_anon_vma() against the full mb implied by mutex_trylock() from
> > > > +	 * page_lock_anon_vma(). This orders:
> > > > +	 *
> > > > +	 * page_lock_anon_vma()		VS	put_anon_vma()
> > > > +	 *   mutex_trylock()			  atomic_dec_and_test()
> > > > +	 *   smp_mb()				  smp_mb()
> > > > +	 *   atomic_read()			  mutex_is_locked()
> > >
> > > Bah!, I thought all mutex_trylock() implementations used an atomic op
> > > with return value (which implies a mb), but it looks like (at least*)
> > > PPC doesn't and only provides a LOCK barrier.
> >
> > But, mutex_trylock() must imply the one-way barrier, otherwise it
> > is buggy, no?
>
> > If this atomic_read() can leak out of the critical section, then
> > I think mutex_trylock() should be fixed. Or I misunderstood the
> > problem completely...
>
> It implies the LOCK barrier, the one way permeable thing, not a full mb.
>
> But I'm not sure the LOCK is sufficient to make the above scenario work.

OK, I can't say I am sure too.



Well. Thinking more, I can't understand why we can trust mutex_trylock()
at all. Suppose that page_lock_anon_vma() races with put_anon_vma()
and anon_vma->root != anon_vma. In this case page_lock_anon_vma() can
take anon_vma->root->lock, but if this vma was already freed then it can
be reused and anon_vma_alloc() can change ->root and set ->refcount == 1
before we check atomic_read(refcount) != 0.

IOW,
	page_lock_anon_vma:
							put_anon_vma() drops the
							last reference

	if (mutex_trylock(&anon_vma->root->lock)) {
							anon_vma_alloc() picks this
							memory, changes ->root and
							sets ->refcount == 1

		if (atomic_read(&anon_vma->refcount))
			return anon_vma;
	}

Most probably I missed something, I forgot everything I knew about this
code....

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ