[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGudoHHdccL5Lh8zAO-0swqqRCW4GXMSXhq4jQGoVj=UdBK-Lg@mail.gmail.com>
Date: Tue, 8 Oct 2024 05:57:00 +0200
From: Mateusz Guzik <mjguzik@...il.com>
To: Xi Ruoyao <xry111@...111.site>
Cc: Christian Brauner <brauner@...nel.org>, Miao Wang <shankerwangmiao@...il.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH 2/2] vfs: Make sure {statx,fstatat}(..., AT_EMPTY_PATH |
..., NULL, ...) behave as (..., AT_EMPTY_PATH | ..., "", ...)
On Mon, Oct 7, 2024 at 3:08 PM Xi Ruoyao <xry111@...111.site> wrote:
>
> We've supported {statx,fstatat}(real_fd, NULL, AT_EMPTY_PATH, ...) since
> Linux 6.11 for better performance. However there are other cases, for
> example using AT_FDCWD as the fd or having AT_SYMLINK_NOFOLLOW in flags,
> not covered by the fast path. While it may be impossible, too
> difficult, or not very beneficial to optimize these cases, we should
> still turn NULL into "" for them in the slow path to make the API easier
> to be documented and used.
>
> Fixes: 0ef625bba6fb ("vfs: support statx(..., NULL, AT_EMPTY_PATH, ...)")
> Cc: stable@...r.kernel.org
> Signed-off-by: Xi Ruoyao <xry111@...111.site>
> ---
> fs/stat.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/stat.c b/fs/stat.c
> index ed9d4fd8ba2c..5d1b51c23c62 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -337,8 +337,11 @@ int vfs_fstatat(int dfd, const char __user *filename,
> flags &= ~AT_NO_AUTOMOUNT;
> if (flags == AT_EMPTY_PATH && vfs_empty_path(dfd, filename))
> return vfs_fstat(dfd, stat);
> + else if ((flags & AT_EMPTY_PATH) && !filename)
> + name = getname_kernel("");
> + else
> + name = getname_flags(filename, getname_statx_lookup_flags(statx_flags));
>
> - name = getname_flags(filename, getname_statx_lookup_flags(statx_flags));
> ret = vfs_statx(dfd, name, statx_flags, stat, STATX_BASIC_STATS);
> putname(name);
>
> @@ -791,8 +794,11 @@ SYSCALL_DEFINE5(statx,
> lflags = flags & ~(AT_NO_AUTOMOUNT | AT_STATX_SYNC_TYPE);
> if (lflags == AT_EMPTY_PATH && vfs_empty_path(dfd, filename))
> return do_statx_fd(dfd, flags & ~AT_NO_AUTOMOUNT, mask, buffer);
> + else if ((lflags & AT_EMPTY_PATH) && !filename)
> + name = getname_kernel("");
> + else
> + name = getname_flags(filename, getname_statx_lookup_flags(flags));
>
> - name = getname_flags(filename, getname_statx_lookup_flags(flags));
> ret = do_statx(dfd, name, flags, mask, buffer);
> putname(name);
>
I thought you are going to patch up the 2 callsites of
vfs_empty_path() or add the flags argument to said routine so that it
can do the branching internally.
Either way I don't think implementing AT_FDCWD + NULL + AT_EMPTY_PATH
with getname_kernel("") is necessary.
--
Mateusz Guzik <mjguzik gmail.com>
Powered by blists - more mailing lists