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: <20201221062653.GO3579531@ZenIV.linux.org.uk>
Date:   Mon, 21 Dec 2020 06:26:53 +0000
From:   Al Viro <viro@...iv.linux.org.uk>
To:     Liangyan <liangyan.peng@...ux.alibaba.com>
Cc:     Miklos Szeredi <miklos@...redi.hu>, linux-unionfs@...r.kernel.org,
        linux-kernel@...r.kernel.org, joseph.qi@...ux.alibaba.com
Subject: Re: [PATCH v2] ovl: fix  dentry leak in ovl_get_redirect

On Sun, Dec 20, 2020 at 08:09:27PM +0800, Liangyan wrote:

> +++ b/fs/overlayfs/dir.c
> @@ -973,6 +973,7 @@ static char *ovl_get_redirect(struct dentry *dentry, bool abs_redirect)
>  	for (d = dget(dentry); !IS_ROOT(d);) {
>  		const char *name;
>  		int thislen;
> +		struct dentry *parent = NULL;
>  
>  		spin_lock(&d->d_lock);
>  		name = ovl_dentry_get_redirect(d);
> @@ -992,7 +993,22 @@ static char *ovl_get_redirect(struct dentry *dentry, bool abs_redirect)
>  
>  		buflen -= thislen;
>  		memcpy(&buf[buflen], name, thislen);
> -		tmp = dget_dlock(d->d_parent);
> +		parent = d->d_parent;
> +		if (unlikely(!spin_trylock(&parent->d_lock))) {
> +			rcu_read_lock();
> +			spin_unlock(&d->d_lock);
> +again:
> +			parent = READ_ONCE(d->d_parent);
> +			spin_lock(&parent->d_lock);
> +			if (unlikely(parent != d->d_parent)) {
> +				spin_unlock(&parent->d_lock);
> +				goto again;
> +			}
> +			rcu_read_unlock();
> +			spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
> +		}
> +		tmp = dget_dlock(parent);
> +		spin_unlock(&parent->d_lock);
>  		spin_unlock(&d->d_lock);

Yecchhhh....  What's wrong with just doing
		spin_unlock(&d->d_lock);
		parent = dget_parent(d);
		dput(d);
		d = parent;
instead of that?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ