[PATCH] io: statx, fstatat64: allow using NULL as path

Florian Weimer fweimer@redhat.com
Mon Sep 30 13:29:10 GMT 2024


* Miao Wang via:

> From: Miao Wang <shankerwangmiao@gmail.com>
>
> Since linux 6.11, fstatat and statx syscalls allow using NULL as path
> when AT_EMPTY_PATH is given. We also expose this to glibc users, and
> change path to an empty string when this is not supported by the kernel.
>
> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
> ---
> Since kernel 6.11, statx/fstatat(..., NULL, AT_EMPTH_PATH...) are
> supported for better performance by avoiding copying buffer data from
> userland. Since currently the declaration of statx and fstatat flags
> the path argument as nonull, it prevents users from utilizing this
> kernel feature. I can come up with the following possible solutions:
>
> 1. Directly remove the nonull annotation on the path argument, and
>    pass the parameter given by the user as-is to the kernel, exposing
>    the kernel behavior. This would be confusing since on older kernels,
>    the user would receive EFAULT and need to handle this.
>
> 2. Based on 1, but if the user provides NULL, the handling of EFAULT is
>    integrated in glibc, who implicitly change the parameter to an empty
>    string if EFAULT received.
>
> In either case, I think there is no need to introduce a new ABI version
> of statx() and fstatat(), since we are loosening the restriction on the
> given parameters, and executables linked with previous versions of statx
> and fstatat can still work after this change.

I'm not sure if we should change glibc to add this emulation.  It
prevents probing in the application to figure out if the kernel supports
the shortcut or not.  So it would keep hitting the double-system-call
case.

Thanks,
Florian



More information about the Libc-alpha mailing list