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-next>] [day] [month] [year] [list]
Message-ID: <87fwa7ha5w.fsf@tucsk.pomaz.szeredi.hu>
Date:	Thu, 07 Jun 2012 09:07:55 +0200
From:	Miklos Szeredi <miklos@...redi.hu>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
CC:	Dave Jones <davej@...hat.com>, Al Viro <viro@...iv.linux.org.uk>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Miklos Szeredi <mszeredi@...e.cz>, Jan Kara <jack@...e.cz>
Subject: Re: processes hung after sys_renameat, and 'missing' processes

> They do change some other things, though. In particular, I mislike the
> last patch in that series ("vfs: retry last component if opening stale
> dentry"), which does the whole "save_parent" thing. There's a few
> things that look odd there, and I don't like this code, for example:
> 
> +               save_parent.dentry = nd->path.dentry;
> +               save_parent.mnt = mntget(path->mnt);
> +               nd->path.dentry = path->dentry;
> ...
> +               path_put(&save_parent);
> 
> whete there isn't a dget() on the dentry (but path_put() will do a
> dput() on it). I'm guessing it's because we lose a refcount to it when
> we overwrite nd->path.dentry, but why isn't there a dget() on *that*
> one? The patch just makes me nervous. Miklos, can you explain more?
> The interactions with "path_put_conditional()" makes me extra nervous.

Yeah, see the comment in below patch for how it's supposed to work.  I
*think* it's correct.

Thanks,
Miklos


Subject: vfs: add comment to save_parent
From: Miklos Szeredi <mszeredi@...e.cz>

Reported-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Miklos Szeredi <mszeredi@...e.cz>
---
 fs/namei.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c	2012-06-05 19:29:39.000000000 +0200
+++ linux-2.6/fs/namei.c	2012-06-07 08:41:55.000000000 +0200
@@ -2355,6 +2355,16 @@ static struct file *do_last(struct namei
 	if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) {
 		path_to_nameidata(path, nd);
 	} else {
+		/*
+		 * We are not in RCU mode and nd->path.mnt == path->mnt.
+		 * In that case path_to_nameidata() would just do
+		 *
+		 * 	dput(nd->path.dentry)
+		 *	nd->path.dentry = path->dentry;
+		 *
+		 * So here we can save a dget/dput pair by just transferring the
+		 * ref to save_parent.dentry.
+		 */
 		save_parent.dentry = nd->path.dentry;
 		save_parent.mnt = mntget(path->mnt);
 		nd->path.dentry = path->dentry;
--
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