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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YR6gUaz2QMeNkPXp@hirez.programming.kicks-ass.net>
Date:   Thu, 19 Aug 2021 20:17:53 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        LKML <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Will Deacon <will@...nel.org>,
        Waiman Long <longman@...hat.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Davidlohr Bueso <dave@...olabs.net>,
        Mike Galbraith <efault@....de>,
        Guenter Roeck <linux@...ck-us.net>
Subject: Re: [patch V5 41/72] locking/ww_mutex: Gather mutex_waiter
 initialization

On Thu, Aug 19, 2021 at 07:51:10PM +0200, Sebastian Andrzej Siewior wrote:
> On 2021-08-15 23:28:39 [+0200], Thomas Gleixner wrote:
> > --- a/kernel/locking/mutex-debug.c
> > +++ b/kernel/locking/mutex-debug.c
> > @@ -30,6 +30,7 @@ void debug_mutex_lock_common(struct mute
> >  	memset(waiter, MUTEX_DEBUG_INIT, sizeof(*waiter));
> >  	waiter->magic = waiter;
> >  	INIT_LIST_HEAD(&waiter->list);
> > +	waiter->ww_ctx = MUTEX_POISON_WW_CTX;
> >  }
> >  
> >  void debug_mutex_wake_waiter(struct mutex *lock, struct mutex_waiter *waiter)
> > --- a/kernel/locking/mutex.c
> > +++ b/kernel/locking/mutex.c
> > @@ -980,17 +980,15 @@ static __always_inline int __sched
> >  	}
> >  
> >  	debug_mutex_lock_common(lock, &waiter);
> > +	waiter.task = current;
> > +	if (ww_ctx)
> > +		waiter.ww_ctx = ww_ctx;
> >  
> >  	lock_contended(&lock->dep_map, ip);
> >  
> >  	if (!use_ww_ctx) {
> >  		/* add waiting tasks to the end of the waitqueue (FIFO): */
> >  		__mutex_add_waiter(lock, &waiter, &lock->wait_list);
> > -
> > -
> > -#ifdef CONFIG_DEBUG_MUTEXES
> > -		waiter.ww_ctx = MUTEX_POISON_WW_CTX;
> > -#endif
> 
> The crash, Guenter Roeck reported, is because now waiter.ww_ctx is
> always initialized to poisen.
> Previously in the ww-mutex case without a context it was set to NULL
> in the next hunk.
> Keeping the ww_ctx assigment in the next hunk seems to work.

You mean the 'use_ww_ctx && !ww_ctx' case?

Would not the below also help with that?

diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 3a65bf4bacfd..d456579d0952 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -618,7 +618,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
 
 	debug_mutex_lock_common(lock, &waiter);
 	waiter.task = current;
-	if (ww_ctx)
+	if (use_ww_ctx)
 		waiter.ww_ctx = ww_ctx;
 
 	lock_contended(&lock->dep_map, ip);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ