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: <20180222052906.GM30522@ZenIV.linux.org.uk>
Date:   Thu, 22 Feb 2018 05:29:06 +0000
From:   Al Viro <viro@...IV.linux.org.uk>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        linux-fsdevel <linux-fsdevel@...r.kernel.org>,
        Christoph Hellwig <hch@....de>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill()

On Tue, Feb 20, 2018 at 12:34:57AM +0100, John Ogness wrote:


> Implementation 3: The same as implementation 2 but using if's to
> support branch prediction. This approach is probably the most
> complicated to understand but will be the fastest.
> 
>  		/*
>  		 * Lock the inode. Might drop dentry->d_lock temporarily
>  		 * which allows inode to change. Start over if that happens.
>  		 */
>                 int ret = dentry_lock_inode(dentry);
>                 if (unlikely(ret != LOCK_FAST)) {
>                         if (ret == LOCK_FAILED)
>                                 goto again;
>                         /*
>                          * Recheck refcount as it might have been
>                          * incremented while d_lock was dropped.
>                          */
>                         if (dentry->d_lockref.count != 1)
>                                 goto drop_ref;
>                 }

Implementation 4: screw the tristate, move the loop inside dentry_lock_inode().

> If lock_parent() returns a non-NULL, it is returning
> dentry->d_parent. So the return value is really just a boolean and the
> locked parent is the parent of the dentry. The function is a little bit
> tricky because it could return NULL (lock failed) even if the dentry has
> a non-NULL d_parent. So any caller using a tristate return variation of
> lock_parent() must rely on the return value instead of a non-NULL
> dentry->d_parent.

dentry always has non-NULL ->d_parent; it might point to dentry itself, but
it's never NULL.

>  		if (!dentry->d_lockref.count) {
> -			struct dentry *parent = lock_parent(dentry);
> +			int ret = lock_parent(dentry);
> +			parent = dentry->d_parent;
>  			if (likely(!dentry->d_lockref.count)) {
>  				__dentry_kill(dentry);
>  				dput(parent);

Broken.  In IS_ROOT case you'll hit an extra dput() on dentry itself.
dput(NULL) is no-op; this, OTOH, isn't.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ