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: <20160825222328.GN10138@twins.programming.kicks-ass.net>
Date:   Fri, 26 Aug 2016 00:23:28 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Waiman Long <waiman.long@....com>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Jason Low <jason.low2@....com>,
        Ding Tianhong <dingtianhong@...wei.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Will Deacon <Will.Deacon@....com>,
        Ingo Molnar <mingo@...hat.com>,
        Imre Deak <imre.deak@...el.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Davidlohr Bueso <dave@...olabs.net>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        Terry Rudd <terry.rudd@....com>,
        "Paul E. McKenney" <paulmck@...ibm.com>,
        Jason Low <jason.low2@...com>,
        Chris Wilson <chris@...is-wilson.co.uk>,
        Daniel Vetter <daniel.vetter@...ll.ch>
Subject: Re: [RFC][PATCH -v2 4/4] locking/mutex: Add lock handoff to avoid
 starvation

On Thu, Aug 25, 2016 at 06:00:19PM -0400, Waiman Long wrote:
> On 08/25/2016 02:37 PM, Peter Zijlstra wrote:
> >@@ -468,9 +496,12 @@ void __sched mutex_unlock(struct mutex *
> >  	DEBUG_LOCKS_WARN_ON(__mutex_owner(lock) != current);
> >  #endif
> >
> >-	owner = atomic_long_fetch_and(MUTEX_FLAGS,&lock->owner);
> >+	owner = atomic_long_read(&lock->owner);
> >+	if (!(owner&  MUTEX_FLAG_HANDOFF))
> >+		owner = atomic_long_fetch_and(MUTEX_FLAGS,&lock->owner);
> >+
> >  	if (__owner_flags(owner))
> >-		__mutex_unlock_slowpath(lock);
> >+		__mutex_unlock_slowpath(lock, owner);
> >  }
> >  EXPORT_SYMBOL(mutex_unlock);
> 
> I don't think the race condition is fixed when we don't make sure that lock
> handoff only happens from current=>new. The problem is due to the fact that
> the MUTEX_FLAG_HANDOFF check in the unlock fastpath isn't serialized by the
> wait_lock. As a result, it is possible that the owner is NULL while the
> HANDOFF bit is set. Or an optimistic spinner may have stolen the lock in the
> interim.

You're right.. I'll try again tomorrow.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ