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]
Date:	Tue,  5 May 2015 06:22:52 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Neil Brown <neilb@...e.de>, Christoph Hellwig <hch@...radead.org>,
	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [PATCH 78/79] namei: new helper - is_stale()

From: Al Viro <viro@...iv.linux.org.uk>

we have a lot of places where we open-code the check that dentry->d_seq
matches nameidata...

Signed-off-by: Al Viro <viro@...iv.linux.org.uk>
---
 fs/namei.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index eb3f7d9..cf8f2de 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -575,6 +575,11 @@ static inline int nd_alloc_stack(struct nameidata *nd)
  * to restart the path walk from the beginning in ref-walk mode.
  */
 
+static inline bool is_stale(struct nameidata *nd, struct dentry *dentry)
+{
+	return read_seqcount_retry(&dentry->d_seq, nd->seq);
+}
+
 /**
  * unlazy_walk - try to switch to ref-walk mode.
  * @nd: nameidata pathwalk data
@@ -621,13 +626,13 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
 	 * be valid if the child sequence number is still valid.
 	 */
 	if (!dentry) {
-		if (read_seqcount_retry(&parent->d_seq, nd->seq))
+		if (is_stale(nd, parent))
 			goto out;
 		BUG_ON(nd->inode != parent->d_inode);
 	} else {
 		if (!lockref_get_not_dead(&dentry->d_lockref))
 			goto out;
-		if (read_seqcount_retry(&dentry->d_seq, nd->seq))
+		if (is_stale(nd, dentry))
 			goto drop_dentry;
 	}
 
@@ -694,7 +699,7 @@ static int complete_walk(struct nameidata *nd)
 			mntput(nd->path.mnt);
 			return -ECHILD;
 		}
-		if (read_seqcount_retry(&dentry->d_seq, nd->seq)) {
+		if (is_stale(nd, dentry)) {
 			rcu_read_unlock();
 			dput(dentry);
 			mntput(nd->path.mnt);
@@ -1218,7 +1223,7 @@ static int follow_dotdot_rcu(struct nameidata *nd)
 
 			inode = parent->d_inode;
 			seq = read_seqcount_begin(&parent->d_seq);
-			if (read_seqcount_retry(&old->d_seq, nd->seq))
+			if (is_stale(nd, old))
 				goto failed;
 			nd->path.dentry = parent;
 			nd->seq = seq;
@@ -1980,7 +1985,7 @@ static int path_init(int dfd, const struct filename *name, unsigned int flags,
 	nd->inode = nd->path.dentry->d_inode;
 	if (!(flags & LOOKUP_RCU))
 		goto done;
-	if (likely(!read_seqcount_retry(&nd->path.dentry->d_seq, nd->seq)))
+	if (likely(!is_stale(nd, nd->path.dentry)))
 		goto done;
 	if (!(nd->flags & LOOKUP_ROOT))
 		nd->root.mnt = NULL;
-- 
2.1.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