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: <20160622065128.GB28443@insomnia>
Date:	Wed, 22 Jun 2016 14:51:28 +0800
From:	Boqun Feng <boqun.feng@...il.com>
To:	Wei Fang <fangwei1@...wei.com>
Cc:	viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
	akpm@...ux-foundation.org, jack@...e.com, axboe@...nel.dk,
	tj@...nel.org, linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] fs/dcache.c: avoid soft-lockup in dput()

Hi Wei Fang,

On Wed, Jun 22, 2016 at 11:01:15AM +0800, Wei Fang wrote:
> We triggered soft-lockup under stress test which
> open/access/write/close one file concurrently on more than
> five different CPUs:
> 
> WARN: soft lockup - CPU#0 stuck for 11s! [who:30631]
> ...
> [<ffffffc0003986f8>] dput+0x100/0x298
> [<ffffffc00038c2dc>] terminate_walk+0x4c/0x60
> [<ffffffc00038f56c>] path_lookupat+0x5cc/0x7a8
> [<ffffffc00038f780>] filename_lookup+0x38/0xf0
> [<ffffffc000391180>] user_path_at_empty+0x78/0xd0
> [<ffffffc0003911f4>] user_path_at+0x1c/0x28
> [<ffffffc00037d4fc>] SyS_faccessat+0xb4/0x230
> 
> ->d_lock trylock may failed many times because of concurrently
> operations, and dput() may execute a long time.
> 
> Fix this by replacing cpu_relax() with cond_resched().
> dput() used to be sleepable, so make it sleepable again
> should be safe.
> 
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Wei Fang <fangwei1@...wei.com>
> ---
> Changes v1->v2:
> - add might_sleep() to annotate that dput() can sleep
> 
>  fs/dcache.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/dcache.c b/fs/dcache.c
> index d5ecc6e..074fc1c 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -578,7 +578,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
>  
>  failed:
>  	spin_unlock(&dentry->d_lock);
> -	cpu_relax();
> +	cond_resched();

Is it better to put the cond_resched() in the caller(i.e. dput()), right
before "goto repeat"? Because it's obviously a loop there, which makes
the purpose of cond_resched() more straightforward.

Regards,
Boqun

>  	return dentry; /* try again with same dentry */
>  }
>  
> @@ -752,6 +752,8 @@ void dput(struct dentry *dentry)
>  		return;
>  
>  repeat:
> +	might_sleep();
> +
>  	rcu_read_lock();
>  	if (likely(fast_dput(dentry))) {
>  		rcu_read_unlock();
> -- 
> 1.7.1
> 

Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ