glibc/sysdeps/unix
Adhemerval Zanella 42d6270439 linux: mips: Fix getdents64 fallback on mips64-n32
GCC mainline shows the following error:

../sysdeps/unix/sysv/linux/mips/mips64/getdents64.c: In function '__getdents64':
../sysdeps/unix/sysv/linux/mips/mips64/getdents64.c:121:7: error: 'memcpy' forming offset [4, 7] is out of the bounds [0, 4] [-Werror=array-bounds]
  121 |       memcpy (((char *) dp + offsetof (struct dirent64, d_ino)),
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122 |               KDP_MEMBER (kdp, d_ino), sizeof ((struct dirent64){0}.d_ino));
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/mips/mips64/getdents64.c:123:7: error: 'memcpy' forming offset [4, 7] is out of the bounds [0, 4] [-Werror=array-bounds]
  123 |       memcpy (((char *) dp + offsetof (struct dirent64, d_off)),
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124 |               KDP_MEMBER (kdp, d_off), sizeof ((struct dirent64){0}.d_off));
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The issue is due both d_ino and d_off fields for mips64-n32
kernel_dirent are 32-bits, while this is using memcpy to copy 64 bits
from it into the glibc dirent64.

The fix is to use a temporary buffer to read the correct type
from kernel_dirent.

Checked with a build-many-glibcs.py for mips64el-linux-gnu and I
also checked the tst-getdents64 on mips64el 4.1.4 kernel with
and without fallback enabled (by manually setting the
getdents64_supported).
2021-01-22 15:44:41 -03:00
..
alpha Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
arm Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
bsd Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
i386 Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
inet Remove obsolete, never-implemented XSI STREAMS declarations 2019-03-14 15:44:15 +01:00
mips Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
powerpc Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sh Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sysv/linux linux: mips: Fix getdents64 fallback on mips64-n32 2021-01-22 15:44:41 -03:00
x86_64 Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
confstr.h
get_child_max.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
getlogin_r.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
getlogin.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
getpagesize.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
grantpt.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
ifreq.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
Implies
make-syscalls.sh Add SYSCALL_ULONG_ARG_[12] to pass long to syscall [BZ #25810] 2020-04-29 05:35:34 -07:00
Makefile Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
pt-fcntl.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
s-proto-cancel.S * sysdeps/unix/Makefile: Include $(common-objpfx)s-proto-cancel.d. 2002-12-30 00:12:56 +00:00
s-proto.S
setxid.h Update. 2004-11-12 01:27:04 +00:00
sockatmark.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
syscall-template.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
syscall.S Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
syscalls.list Mark unsigned long arguments with U in more syscalls [BZ #25810] 2020-04-29 08:10:01 -07:00
sysdep.h Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00