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: <20200301215240.873899-45-viro@ZenIV.linux.org.uk>
Date:   Sun,  1 Mar 2020 21:52:30 +0000
From:   Al Viro <viro@...IV.linux.org.uk>
To:     linux-fsdevel@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: [RFC][PATCH v3 45/55] handle_dots(): return ERR_PTR/NULL instead of -E.../0

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

all callers prefer such calling conventions

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

diff --git a/fs/namei.c b/fs/namei.c
index 3f15b18af991..20a2fc27dd87 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1785,7 +1785,7 @@ static const char *step_into(struct nameidata *nd, int flags,
 	return pick_link(nd, &path, inode, seq, flags);
 }
 
-static int handle_dots(struct nameidata *nd, int type, int flags)
+static const char *handle_dots(struct nameidata *nd, int type, int flags)
 {
 	if (type == LAST_DOTDOT) {
 		int error = 0;
@@ -1793,14 +1793,14 @@ static int handle_dots(struct nameidata *nd, int type, int flags)
 		if (!nd->root.mnt) {
 			error = set_root(nd);
 			if (error)
-				return error;
+				return ERR_PTR(error);
 		}
 		if (nd->flags & LOOKUP_RCU)
 			error = follow_dotdot_rcu(nd);
 		else
 			error = follow_dotdot(nd);
 		if (error)
-			return error;
+			return ERR_PTR(error);
 
 		if (unlikely(nd->flags & LOOKUP_IS_SCOPED)) {
 			/*
@@ -1811,14 +1811,14 @@ static int handle_dots(struct nameidata *nd, int type, int flags)
 			 */
 			smp_rmb();
 			if (unlikely(__read_seqcount_retry(&mount_lock.seqcount, nd->m_seq)))
-				return -EAGAIN;
+				return ERR_PTR(-EAGAIN);
 			if (unlikely(__read_seqcount_retry(&rename_lock.seqcount, nd->r_seq)))
-				return -EAGAIN;
+				return ERR_PTR(-EAGAIN);
 		}
 	}
 	if (!(flags & WALK_MORE) && nd->depth)
 		put_link(nd);
-	return 0;
+	return NULL;
 }
 
 static const char *walk_component(struct nameidata *nd, int flags)
@@ -1826,16 +1826,13 @@ static const char *walk_component(struct nameidata *nd, int flags)
 	struct dentry *dentry;
 	struct inode *inode;
 	unsigned seq;
-	int err;
 	/*
 	 * "." and ".." are special - ".." especially so because it has
 	 * to be able to know about the current root directory and
 	 * parent relationships.
 	 */
-	if (unlikely(nd->last_type != LAST_NORM)) {
-		err = handle_dots(nd, nd->last_type, flags);
-		return ERR_PTR(err);
-	}
+	if (unlikely(nd->last_type != LAST_NORM))
+		return handle_dots(nd, nd->last_type, flags);
 	dentry = lookup_fast(nd, &inode, &seq);
 	if (IS_ERR(dentry))
 		return ERR_CAST(dentry);
@@ -3135,17 +3132,17 @@ static const char *open_last_lookups(struct nameidata *nd,
 	unsigned seq;
 	struct inode *inode;
 	struct dentry *dentry;
-	const char *link;
+	const char *res;
 	int error;
 
 	nd->flags &= ~LOOKUP_PARENT;
 	nd->flags |= op->intent;
 
 	if (nd->last_type != LAST_NORM) {
-		error = handle_dots(nd, nd->last_type, WALK_TRAILING);
-		if (likely(!error))
-			error = complete_walk(nd);
-		return ERR_PTR(error);
+		res = handle_dots(nd, nd->last_type, WALK_TRAILING);
+		if (likely(!res))
+			res = ERR_PTR(complete_walk(nd));
+		return res;
 	}
 
 	if (!(open_flag & O_CREAT)) {
@@ -3209,11 +3206,11 @@ static const char *open_last_lookups(struct nameidata *nd,
 	}
 
 finish_lookup:
-	link = step_into(nd, WALK_TRAILING, dentry, inode, seq);
-	if (unlikely(link)) {
+	res = step_into(nd, WALK_TRAILING, dentry, inode, seq);
+	if (unlikely(res)) {
 		nd->flags |= LOOKUP_PARENT;
 		nd->flags &= ~(LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_EXCL);
-		return link;
+		return res;
 	}
 
 	if (unlikely((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT))) {
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ