diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2025-11-01 07:48:31 +0300 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2026-01-13 23:16:43 +0300 |
| commit | 0cf1149673da1153d32eeea67771a002530fda42 (patch) | |
| tree | 9a8dce071e89918092de3b104e5a58b3480ee22c | |
| parent | 24df85ffb9712cd6060588f6e08defcda5986efe (diff) | |
| download | linux-0cf1149673da1153d32eeea67771a002530fda42.tar.xz | |
do_faccessat(): 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>
| -rw-r--r-- | fs/open.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/open.c b/fs/open.c index f328622061c5..f3bacc583ef0 100644 --- a/fs/open.c +++ b/fs/open.c @@ -468,6 +468,7 @@ static int do_faccessat(int dfd, const char __user *filename, int mode, int flag int res; unsigned int lookup_flags = LOOKUP_FOLLOW; const struct cred *old_cred = NULL; + struct filename *name; if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ return -EINVAL; @@ -477,8 +478,6 @@ static int do_faccessat(int dfd, const char __user *filename, int mode, int flag if (flags & AT_SYMLINK_NOFOLLOW) lookup_flags &= ~LOOKUP_FOLLOW; - if (flags & AT_EMPTY_PATH) - lookup_flags |= LOOKUP_EMPTY; if (access_need_override_creds(flags)) { old_cred = access_override_creds(); @@ -486,8 +485,9 @@ static int do_faccessat(int dfd, const char __user *filename, int mode, int flag return -ENOMEM; } + name = getname_uflags(filename, flags); retry: - res = user_path_at(dfd, filename, lookup_flags, &path); + res = filename_lookup(dfd, name, lookup_flags, &path, NULL); if (res) goto out; @@ -527,6 +527,7 @@ out_path_release: goto retry; } out: + putname(name); if (old_cred) put_cred(revert_creds(old_cred)); |
