From: Al Viro Date: Sat, 1 Nov 2025 04:48:31 +0000 (-0400) Subject: chroot(2): import pathname only once X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3fa2b7cf5dda5a73480361303441db4ba7f0e6a;p=thirdparty%2Fkernel%2Flinux.git chroot(2): 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. In this case we never pass LOOKUP_EMPTY, so getname_flags() is equivalent to plain getname(). 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 --- diff --git a/fs/open.c b/fs/open.c index 67c114bdeac5c..6f48fa9c756a3 100644 --- a/fs/open.c +++ b/fs/open.c @@ -600,8 +600,9 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename) struct path path; int error; unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY; + struct filename *name = getname(filename); retry: - error = user_path_at(AT_FDCWD, filename, lookup_flags, &path); + error = filename_lookup(AT_FDCWD, name, lookup_flags, &path, NULL); if (error) goto out; @@ -625,6 +626,7 @@ dput_and_out: goto retry; } out: + putname(name); return error; }