summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2025-11-01 07:48:31 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2026-01-13 23:16:44 +0300
commit67591df968f4ceb12c1f5d7f9caebc668200856b (patch)
tree9e6763814d30247af9c8d492725c6a844d0d9f3c /fs
parent0cf1149673da1153d32eeea67771a002530fda42 (diff)
downloadlinux-67591df968f4ceb12c1f5d7f9caebc668200856b.tar.xz
do_fchmodat(): import pathname only once
Convert the user_path_at() call inside a retry loop into getname_flags() + filename_lookup() + putname() and leave only filename_lookup() inside the loop. Since we have the default logics for use of LOOKUP_EMPTY (passed iff AT_EMPTY_PATH is present in flags), just use getname_uflags() and don't bother with setting LOOKUP_EMPTY in lookup_flags - getname_uflags() will pass the right thing to getname_flags() and filename_lookup() doesn't care about LOOKUP_EMPTY at all. The things could be further simplified by use of cleanup.h stuff, but let's not clutter the patch with that. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/open.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/open.c b/fs/open.c
index f3bacc583ef0..82bfa06dbfa5 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -679,6 +679,7 @@ static int do_fchmodat(int dfd, const char __user *filename, umode_t mode,
unsigned int flags)
{
struct path path;
+ struct filename *name;
int error;
unsigned int lookup_flags;
@@ -686,11 +687,9 @@ static int do_fchmodat(int dfd, const char __user *filename, umode_t mode,
return -EINVAL;
lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
- if (flags & AT_EMPTY_PATH)
- lookup_flags |= LOOKUP_EMPTY;
-
+ name = getname_uflags(filename, flags);
retry:
- error = user_path_at(dfd, filename, lookup_flags, &path);
+ error = filename_lookup(dfd, name, lookup_flags, &path, NULL);
if (!error) {
error = chmod_common(&path, mode);
path_put(&path);
@@ -699,6 +698,7 @@ retry:
goto retry;
}
}
+ putname(name);
return error;
}