]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
fstatat etc.: fix wrong machine code for calls
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 16 Jun 2026 16:45:39 +0000 (09:45 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 16 Jun 2026 16:53:22 +0000 (09:53 -0700)
Without this fix, compilers can generate incorrect machine code
for functions that call to fstatat-like functions, as the
compilers incorrectly assume that the calls’ arguments cannot be
null pointers.  This assumption became false with the release of
Linux kernel 6.11 (2024).
* lib/sys_stat.in.h (fchmodat, fstatat, utimensat):
* lib/unistd.in.h (faccessat, fchownat): Do not mark file args
with _GL_ARG_NONNULL, as the args are allowed to be null pointers
in Linux kernel 6.11+, possibly with glibc 2.41+ involved.

ChangeLog
lib/sys_stat.in.h
lib/unistd.in.h

index 4882598f436880b9be72dfbcb343e39183216d9d..20459c0447d86c90f4a83b5d0fce685d1065b9da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2026-06-16  Paul Eggert  <eggert@cs.ucla.edu>
 
+       fstatat etc.: fix wrong machine code for calls
+       Without this fix, compilers can generate incorrect machine code
+       for functions that call to fstatat-like functions, as the
+       compilers incorrectly assume that the calls’ arguments cannot be
+       null pointers.  This assumption became false with the release of
+       Linux kernel 6.11 (2024).
+       * lib/sys_stat.in.h (fchmodat, fstatat, utimensat):
+       * lib/unistd.in.h (faccessat, fchownat): Do not mark file args
+       with _GL_ARG_NONNULL, as the args are allowed to be null pointers
+       in Linux kernel 6.11+, possibly with glibc 2.41+ involved.
+
        euidaccess-tests: link with test_euidaccess_LDADD
        * modules/euidaccess-tests (test_euidaccess_LDADD):
        New macro.  Needed for Solaris 10.
index deed21cdf394ee2ab0f10656e4d8cf4d324dbf11..567dffa6209a475037a2a50eece0b0f14f19ea82 100644 (file)
@@ -480,18 +480,18 @@ _GL_CXXALIASWARN (chmod);
 #   define fchmodat rpl_fchmodat
 #  endif
 _GL_FUNCDECL_RPL (fchmodat, int,
-                  (int fd, char const *file, mode_t mode, int flag),
-                  _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
+                  (int fd, char const *file, mode_t mode, int flags),
+                  _GL_ATTRIBUTE_NODISCARD);
 _GL_CXXALIAS_RPL (fchmodat, int,
-                  (int fd, char const *file, mode_t mode, int flag));
+                  (int fd, char const *file, mode_t mode, int flags));
 # else
 #  if !@HAVE_FCHMODAT@
 _GL_FUNCDECL_SYS (fchmodat, int,
-                  (int fd, char const *file, mode_t mode, int flag),
-                  _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
+                  (int fd, char const *file, mode_t mode, int flags),
+                  _GL_ATTRIBUTE_NODISCARD);
 #  endif
 _GL_CXXALIAS_SYS (fchmodat, int,
-                  (int fd, char const *file, mode_t mode, int flag));
+                  (int fd, char const *file, mode_t mode, int flags));
 # endif
 _GL_CXXALIASWARN (fchmodat);
 #elif defined GNULIB_POSIXCHECK
@@ -542,7 +542,7 @@ _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
 _GL_FUNCDECL_RPL (fstatat, int,
                   (int fd, char const *restrict name, struct stat *restrict st,
                    int flags),
-                  _GL_ARG_NONNULL ((2, 3)));
+                  _GL_ARG_NONNULL ((3)));
 _GL_CXXALIAS_RPL (fstatat, int,
                   (int fd, char const *restrict name, struct stat *restrict st,
                    int flags));
@@ -551,7 +551,7 @@ _GL_CXXALIAS_RPL (fstatat, int,
 _GL_FUNCDECL_SYS (fstatat, int,
                   (int fd, char const *restrict name, struct stat *restrict st,
                    int flags),
-                  _GL_ARG_NONNULL ((2, 3)));
+                  _GL_ARG_NONNULL ((3)));
 #  endif
 _GL_CXXALIAS_SYS (fstatat, int,
                   (int fd, char const *restrict name, struct stat *restrict st,
@@ -966,18 +966,18 @@ _GL_CXXALIASWARN (umask);
 #   define utimensat rpl_utimensat
 #  endif
 _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag),
-                                  _GL_ARG_NONNULL ((2)));
+                                   struct timespec const times[2], int flags),
+                  );
 _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag));
+                                   struct timespec const times[2], int flags));
 # else
 #  if !@HAVE_UTIMENSAT@
 _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag),
-                                  _GL_ARG_NONNULL ((2)));
+                                   struct timespec const times[2], int flags),
+                  );
 #  endif
 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
-                                   struct timespec const times[2], int flag));
+                                   struct timespec const times[2], int flags));
 # endif
 # if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@
 _GL_CXXALIASWARN (utimensat);
index f7e4450cede5936db9162fd08c2f4701d0b7e444..8f40c19e2a14c7cbadad565153c1136360b57a36 100644 (file)
@@ -930,18 +930,18 @@ _GL_CXXALIASWARN (execvpe);
 #   define faccessat rpl_faccessat
 #  endif
 _GL_FUNCDECL_RPL (faccessat, int,
-                  (int fd, char const *name, int mode, int flag),
-                  _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
+                  (int fd, char const *name, int mode, int flags),
+                  _GL_ATTRIBUTE_NODISCARD);
 _GL_CXXALIAS_RPL (faccessat, int,
-                  (int fd, char const *name, int mode, int flag));
+                  (int fd, char const *name, int mode, int flags));
 # else
 #  if !@HAVE_FACCESSAT@
 _GL_FUNCDECL_SYS (faccessat, int,
-                  (int fd, char const *file, int mode, int flag),
-                  _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
+                  (int fd, char const *file, int mode, int flags),
+                  _GL_ATTRIBUTE_NODISCARD);
 #  endif
 _GL_CXXALIAS_SYS (faccessat, int,
-                  (int fd, char const *file, int mode, int flag));
+                  (int fd, char const *file, int mode, int flags));
 # endif
 # if __GLIBC__ >= 2
 _GL_CXXALIASWARN (faccessat);
@@ -997,18 +997,18 @@ _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
 #   define fchownat rpl_fchownat
 #  endif
 _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
-                                  uid_t owner, gid_t group, int flag),
-                                 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
+                                  uid_t owner, gid_t group, int flags),
+                  _GL_ATTRIBUTE_NODISCARD);
 _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
-                                  uid_t owner, gid_t group, int flag));
+                                  uid_t owner, gid_t group, int flags));
 # else
 #  if !@HAVE_FCHOWNAT@
 _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
-                                  uid_t owner, gid_t group, int flag),
-                                 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
+                                  uid_t owner, gid_t group, int flags),
+                  _GL_ATTRIBUTE_NODISCARD);
 #  endif
 _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
-                                  uid_t owner, gid_t group, int flag));
+                                  uid_t owner, gid_t group, int flags));
 # endif
 _GL_CXXALIASWARN (fchownat);
 #elif defined GNULIB_POSIXCHECK
@@ -1728,21 +1728,21 @@ _GL_WARN_ON_USE (link, "link is unportable - "
 #  endif
 _GL_FUNCDECL_RPL (linkat, int,
                   (int fd1, const char *path1, int fd2, const char *path2,
-                   int flag),
+                   int flags),
                   _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD);
 _GL_CXXALIAS_RPL (linkat, int,
                   (int fd1, const char *path1, int fd2, const char *path2,
-                   int flag));
+                   int flags));
 # else
 #  if !@HAVE_LINKAT@
 _GL_FUNCDECL_SYS (linkat, int,
                   (int fd1, const char *path1, int fd2, const char *path2,
-                   int flag),
+                   int flags),
                   _GL_ARG_NONNULL ((2, 4)) _GL_ATTRIBUTE_NODISCARD);
 #  endif
 _GL_CXXALIAS_SYS (linkat, int,
                   (int fd1, const char *path1, int fd2, const char *path2,
-                   int flag));
+                   int flags));
 # endif
 # if __GLIBC__ >= 2
 _GL_CXXALIASWARN (linkat);