@@ -3745,29 +3745,26 @@ static int may_mknod(umode_t mode)
}
}
-static int do_mknodat(int dfd, struct filename *name, umode_t mode,
- unsigned int dev)
+static int try_mknodat(int dfd, struct filename *name, umode_t mode,
+ unsigned int dev, unsigned int lookup_flags)
{
struct user_namespace *mnt_userns;
struct dentry *dentry;
struct path path;
int error;
- unsigned int lookup_flags = 0;
-retry:
error = may_mknod(mode);
if (error)
- goto out1;
+ return error;
dentry = __filename_create(dfd, name, &path, lookup_flags);
- error = PTR_ERR(dentry);
if (IS_ERR(dentry))
- goto out1;
+ return PTR_ERR(dentry);
if (!IS_POSIXACL(path.dentry->d_inode))
mode &= ~current_umask();
error = security_path_mknod(&path, dentry, mode, dev);
if (error)
- goto out2;
+ goto out;
mnt_userns = mnt_user_ns(path.mnt);
switch (mode & S_IFMT) {
@@ -3786,13 +3783,20 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode,
dentry, mode, 0);
break;
}
-out2:
+out:
done_path_create(&path, dentry);
-out1:
- if (unlikely(retry_estale(error, lookup_flags))) {
- lookup_flags |= LOOKUP_REVAL;
- goto retry;
- }
+ return error;
+}
+
+static int do_mknodat(int dfd, struct filename *name, umode_t mode,
+ unsigned int dev)
+{
+ int error;
+
+ error = try_mknodat(dfd, name, mode, dev, 0);
+ if (unlikely(retry_estale(error, 0)))
+ error = try_mknodat(dfd, name, mode, dev, LOOKUP_REVAL);
+
putname(name);
return error;
}
No functional changes, just move the main logic to a helper function to make the whole thing easier to follow. Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <christian.brauner@ubuntu.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/io-uring/CAHk-=wiG+sN+2zSoAOggKCGue2kOJvw3rQySvQXsZstRQFTN+g@mail.gmail.com/ Signed-off-by: Dmitry Kadashev <dkadashev@gmail.com> --- fs/namei.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)