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]
Date:	Thu, 3 Nov 2011 10:17:36 +0300
From:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To:	Yong Zhang <yong.zhang0@...il.com>
Cc:	David Rientjes <rientjes@...gle.com>, Tejun Heo <tj@...nel.org>,
	Ingo Molnar <mingo@...e.hu>, Borislav Petkov <bp@...en8.de>,
	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: WARNING: at kernel/lockdep.c:690 __lock_acquire+0x168/0x164b()

On (10/21/11 17:45), Yong Zhang wrote:
> On Fri, Oct 21, 2011 at 02:14:34AM -0700, David Rientjes wrote:
> > How does it mask the race condition?  Before the memset(), the ->name 
> > field was never _cleared_ in lockdep_init_map() like it is now, it was 
> > only stored.
> 
> A typcal race condition will like this:
> 
> 	CPU A					CPU B
> lock_set_subclass(lockA);
>   lock_set_class(lockA);
>     lockdep_init_map(lockA);
>       /* lockA->name is cleared */
>       memset(lockA);
> 					__lock_acquire(lockA);
> 					  /* lockA->class_cache[] is cleared */
> 					  register_lock_class(lockA);
> 					    look_up_lock_class(lockA);
> 					      WARN_ON_ONCE(class->name !=
> 							lock->name);
> 
>       lock->name = name;
> 
> And a untested patch is below:
> BTW, now the patch could cure (I guess) the very issue reported
> in this thread.
> But it don't cover the case which change the key and the relevant
> lock_class has existed, I don't think out a way how to fix it yet :)
> But the fact is we have no such caller yet, the only call site of
> lock_set_subclass() is double_unlock_balance().
> 

Hello,
Any news on this patch? Do you like it or hate it? With recent kernels
I'm able to hit this problem more often (several time a day) so if any
testing is required I'm willing to help.


	Sergey

> 
> ---
> From: Yong Zhang <yong.zhang0@...il.com>
> Subject: [PATCH] lockdep: On-demand initialization for lock_set_class()
> 
> Since commit f59de89 [lockdep: Clear whole lockdep_map on initialization],
> lockdep_init_map() will clear all the struct. But it will break
> lock_set_class()/lock_set_subclass(). A typical race condition
> is like below:
> 
> 	CPU A					CPU B
> lock_set_subclass(lockA);
>   lock_set_class(lockA);
>     lockdep_init_map(lockA);
>       /* lockA->name is cleared */
>       memset(lockA);
> 					__lock_acquire(lockA);
> 					  /* lockA->class_cache[] is cleared */
> 					  register_lock_class(lockA);
> 					    look_up_lock_class(lockA);
> 					      WARN_ON_ONCE(class->name !=
> 							lock->name);
> 
>       lock->name = name;
> 
> Reported-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
> Reported-by: Borislav Petkov <bp@...en8.de>
> Signed-off-by: Yong Zhang <yong.zhang0@...il.com>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: David Rientjes <rientjes@...gle.com>
> Cc: Ingo Molnar <mingo@...e.hu>
> Cc: Peter Zijlstra <peterz@...radead.org>
> ---
>  kernel/lockdep.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/lockdep.c b/kernel/lockdep.c
> index 91d67ce..bc7dd1e 100644
> --- a/kernel/lockdep.c
> +++ b/kernel/lockdep.c
> @@ -3160,7 +3160,10 @@ __lock_set_class(struct lockdep_map *lock, const char *name,
>  	return print_unlock_inbalance_bug(curr, lock, ip);
>  
>  found_it:
> -	lockdep_init_map(lock, name, key, 0);
> +	/* only changing lock->name make no sense */
> +	WARN_ON(lock->key == key && lock->name != name);
> +	if (lock->key != key)
> +		lockdep_init_map(lock, name, key, 0);
>  	class = register_lock_class(lock, subclass, 0);
>  	hlock->class_idx = class - lock_classes + 1;
>  
> -- 
> 1.7.5.4
> 
> 
--
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