Florian Weimer wrote:
The fstat/fstat64 system call does not exist on arc and riscv/rv32.
glibc tries to consolidate the implementations as far as possible, so if
the kernel deprecates a system call and the replacement is already
supported by all architectures, glibc uses that, rather than maintaing
architecture-specific code to call the earliest possible implemented
system call.
That explains it. So my patch calling the fstat64 syscall (fstat on 64-bit
platforms) in the fstatat handler should be fine on those platforms that
support the fstat(64) syscall.
But the thing is, fstatat is not really a newer version of fstat, it
unfortunately has very different security properties. fstat allows
retrieving the stat metadata only of already open files (if you know or
guess the fd). On the other hand, fstatat allows retrieving the stat
metadata of ANY file on the file system. It even accepts an absolute path as
the relative pathspec, in which case the fd is ignored entirely. (And I
guess it also allows directory traversal using "..", but that does not
matter anyway since it also accepts absolute paths to begin with.) And the
only way to distinguish the fstat case ("" pathspec) from the stat case
(absolute pathspec) is to actually look at the string, which cannot be done
in BPF.
Kevin Kofler