public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] linux: Use stat_overflow to check overflow in fstatat
@ 2021-01-14  8:13 Stafford Horne
  2021-01-14  9:29 ` Andreas Schwab
  2021-01-27 12:40 ` Stafford Horne
  0 siblings, 2 replies; 8+ messages in thread
From: Stafford Horne @ 2021-01-14  8:13 UTC (permalink / raw)
  To: GLIBC patches

After a recent rebase of the OpenRISC port I am working on the build
started to fail with:

    ../sysdeps/unix/sysv/linux/fstatat.c: In function '__fstatat':
    ../sysdeps/unix/sysv/linux/fstatat.c:35:21: error: 'struct stat' has no member named '__st_ino_pad'
       35 |   if (r == 0 && (buf->__st_ino_pad != 0
	  |                     ^~
    ../sysdeps/unix/sysv/linux/fstatat.c:36:24: error: 'struct stat' has no member named '__st_size_pad'
       36 |                  || buf->__st_size_pad != 0
	  |                        ^~
    ../sysdeps/unix/sysv/linux/fstatat.c:37:24: error: 'struct stat' has no member named '__st_blocks_pad'
       37 |                  || buf->__st_blocks_pad != 0))
	  |                        ^~

This seems to be caused by 6073bae64c ("linux: Disentangle fstatat from
fxstatat").  Which introduced the checks for overflow using the
stat->__st_*_pad fields.  These do not exist on all architectures, I
cannot even find any that do exist by grepping code.

The fix is to use the stat_overflow function which only runs the
overflow checks if the pad fields are available.

Note, This is not xstat but I use the xstatover.h header.  I hope that
is not an issue.

Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
 sysdeps/unix/sysv/linux/fstatat.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c
index 59efff615f..5bff931183 100644
--- a/sysdeps/unix/sysv/linux/fstatat.c
+++ b/sysdeps/unix/sysv/linux/fstatat.c
@@ -22,6 +22,7 @@
 
 #if !XSTAT_IS_XSTAT64
 # include <kstat_cp.h>
+# include <xstatover.h>
 
 int
 __fstatat (int fd, const char *file, struct stat *buf, int flag)
@@ -32,10 +33,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
   /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g.
      csky, nios2  */
   r = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, buf, flag);
-  if (r == 0 && (buf->__st_ino_pad != 0
-		 || buf->__st_size_pad != 0
-		 || buf->__st_blocks_pad != 0))
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW);
+  return r ?: stat_overflow (buf);
 # else
 #  ifdef __NR_fstatat64
   /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,
-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-02-01 13:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14  8:13 [PATCH] linux: Use stat_overflow to check overflow in fstatat Stafford Horne
2021-01-14  9:29 ` Andreas Schwab
2021-01-19 21:11   ` Stafford Horne
2021-01-27 12:40 ` Stafford Horne
2021-01-27 13:28   ` Adhemerval Zanella
2021-01-27 23:28     ` Stafford Horne
2021-01-29 22:25     ` Stafford Horne
2021-02-01 13:18       ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).