aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Add HWCAP2_AFP, HWCAP2_RPRES from Linux 5.17 to AArch64 bits/hwcap.hJoseph Myers2022-05-141-0/+2
| | | | | | | | Add the new HWCAP2_AFP and HWCAP2_RPRES constants from Linux 5.17. Tested with build-many-glibcs.py for aarch64-linux-gnu. (cherry picked from commit 866c599182e87f116440b5d854f9e99533c48eb3) (cherry picked from commit 97cb8227b864b8ea0d99a4a50e4163baad3e1c72)
* aarch64: Add HWCAP2_ECV from Linux 5.16Szabolcs Nagy2022-05-141-0/+1
| | | | | | | | | Indicates the availability of enhanced counter virtualization extension of armv8.6-a with self-synchronized virtual counter CNTVCTSS_EL0 usable in userspace. (cherry picked from commit 5a1be8ebdf6f02d4efec6e5f12ad06db17511f90) (cherry picked from commit c108e87026d61d6744e3e55704e0bea937243f5a)
* Add SOL_MPTCP, SOL_MCTP from Linux 5.16 to bits/socket.hJoseph Myers2022-05-141-0/+2
| | | | | | | | | | Linux 5.16 adds constants SOL_MPTCP and SOL_MCTP to the getsockopt / setsockopt levels; add these constants to bits/socket.h. Tested for x86_64. (cherry picked from commit fdc1ae67fef27eea1445bab4bdfe2f0fb3bc7aa1) (cherry picked from commit f858bc309315a03ff6b1a048f59405c159d23430)
* Update kernel version to 5.17 in tst-mman-consts.pyJoseph Myers2022-05-141-1/+1
| | | | | | | | | | | This patch updates the kernel version in the test tst-mman-consts.py to 5.17. (There are no new MAP_* constants covered by this test in 5.17 that need any other header changes.) Tested with build-many-glibcs.py. (cherry picked from commit 23808a422e6036accaba7236fd3b9a0d7ab7e8ee) (cherry picked from commit 0499c3a95fb864284fef36d3e9c5a54f6646b2db)
* Update kernel version to 5.16 in tst-mman-consts.pyJoseph Myers2022-05-141-1/+1
| | | | | | | | | | | This patch updates the kernel version in the test tst-mman-consts.py to 5.16. (There are no new MAP_* constants covered by this test in 5.16 that need any other header changes.) Tested with build-many-glibcs.py. (cherry picked from commit 790a607e234aa10d4b977a1b80aebe8a2acac970) (cherry picked from commit 81181ba5d916fc49bd737f603e28a3c2dc8430b4)
* Update syscall lists for Linux 5.17Joseph Myers2022-05-1426-2/+28
| | | | | | | | | | | Linux 5.17 has one new syscall, set_mempolicy_home_node. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py. (cherry picked from commit 8ef9196b26793830515402ea95aca2629f7721ec) (cherry picked from commit 6af165658d0999ac2c4e9ce88bee020fbc2ee49f)
* Add ARPHRD_CAN, ARPHRD_MCTP to net/if_arp.hJoseph Myers2022-05-141-0/+2
| | | | | | | | | | | | Add the constant ARPHRD_MCTP, from Linux 5.15, to net/if_arp.h, along with ARPHRD_CAN which was added to Linux in version 2.6.25 (commit cd05acfe65ed2cf2db683fa9a6adb8d35635263b, "[CAN]: Allocate protocol numbers for PF_CAN") but apparently missed for glibc at the time. Tested for x86_64. (cherry picked from commit a94d9659cd69dbc70d3494b1cbbbb5a1551675c5) (cherry picked from commit 5146b73d72ced9bab125e986aa99ef5fe2f88475)
* Update kernel version to 5.15 in tst-mman-consts.pyJoseph Myers2022-05-141-1/+1
| | | | | | | | | | | This patch updates the kernel version in the test tst-mman-consts.py to 5.15. (There are no new MAP_* constants covered by this test in 5.15 that need any other header changes.) Tested with build-many-glibcs.py. (cherry picked from commit 5c3ece451d46a7d8721311609bfcb6faafacb39e) (cherry picked from commit fd5dbfd1cd98cb2f12f9e9f7004a4d25ab0c977f)
* Add PF_MCTP, AF_MCTP from Linux 5.15 to bits/socket.hJoseph Myers2022-05-141-1/+3
| | | | | | | | | | Linux 5.15 adds a new address / protocol family PF_MCTP / AF_MCTP; add these constants to bits/socket.h. Tested for x86_64. (cherry picked from commit bdeb7a8fa9989d18dab6310753d04d908125dc1d) (cherry picked from commit bc6fba3c8048b11c9f73db03339c97a2fec3f0cf)
* posix/glob.c: update from gnulibDJ Delorie2022-05-141-0/+1
| | | | | | | | | | Copied from gnulib/lib/glob.c in order to fix rhbz 1982608 Also fixes swbz 25659 Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com> (cherry picked from commit 7c477b57a31487eda516db02b9e04f22d1a6e6af) (cherry picked from commit c66c92181ddbd82306537a608e8c0282587131de)
* linux: Fix fchmodat with AT_SYMLINK_NOFOLLOW for 64 bit time_t (BZ#29097)Adhemerval Zanella2022-05-141-2/+2
| | | | | | | | | | | The AT_SYMLINK_NOFOLLOW emulation ues the default 32 bit stat internal calls, which fails with EOVERFLOW if the file constains timestamps beyond 2038. Checked on i686-linux-gnu. (cherry picked from commit 118a2aee07f64d605b6668cbe195c1f44eac6be6) (cherry picked from commit 88a8637cb4658cd91a002659db05867716b88b36)
* linux: Fix missing internal 64 bit time_t stat usageAdhemerval Zanella2022-05-142-4/+4
| | | | | | | | | These are two missing spots initially done by 52a5fe70a2c77935. Checked on i686-linux-gnu. (cherry picked from commit 834ddd0432f68d6dc85b6aac95065721af0d86e9) (cherry picked from commit 9681691402052b727e01ae3375c73e0f76566593)
* Default to --with-default-link=no (bug 25812)Florian Weimer2022-04-221-0/+6
| | | | | | | | | | | | This is necessary to place the libio vtables into the RELRO segment. New tests elf/tst-relro-ldso and elf/tst-relro-libc are added to verify that this is what actually happens. The new tests fail on ia64 due to lack of (default) RELRO support inbutils, so they are XFAILed there. (cherry picked from commit 198abcbb94618730dae1b3f4393efaa49e0ec8c7) (cherry picked from commit f0c71b34f96c816292c49122d50da3a511b67bf2)
* mips: Fix mips64n32 64 bit time_t stat support (BZ#29069)=Joshua Kinard2022-04-181-15/+23
| | | | | | | | Add missing support initially added by 4e8521333bea6e89fcef1020 (which missed n32 stat). (cherry picked from commit 78fb88827362fbd2cc8aa32892ae5b015106e25c) (cherry picked from commit b87b697f15d6bf7e576a2eeadc1f740172f9d013)
* elf: Fix dynamic-link.h usage on rtld.cAdhemerval Zanella2022-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 4af6982e4c fix does not fully handle RTLD_BOOTSTRAP usage on rtld.c due two issues: 1. RTLD_BOOTSTRAP is also used on dl-machine.h on various architectures and it changes the semantics of various machine relocation functions. 2. The elf_get_dynamic_info() change was done sideways, previously to 490e6c62aa get-dynamic-info.h was included by the first dynamic-link.h include *without* RTLD_BOOTSTRAP being defined. It means that the code within elf_get_dynamic_info() that uses RTLD_BOOTSTRAP is in fact unused. To fix 1. this patch now includes dynamic-link.h only once with RTLD_BOOTSTRAP defined. The ELF_DYNAMIC_RELOCATE call will now have the relocation fnctions with the expected semantics for the loader. And to fix 2. part of 4af6982e4c is reverted (the check argument elf_get_dynamic_info() is not required) and the RTLD_BOOTSTRAP pieces are removed. To reorganize the includes the static TLS definition is moved to its own header to avoid a circular dependency (it is defined on dynamic-link.h and dl-machine.h requires it at same time other dynamic-link.h definition requires dl-machine.h defitions). Also ELF_MACHINE_NO_REL, ELF_MACHINE_NO_RELA, and ELF_MACHINE_PLT_REL are moved to its own header. Only ancient ABIs need special values (arm, i386, and mips), so a generic one is used as default. The powerpc Elf64_FuncDesc is also moved to its own header, since csu code required its definition (which would require either include elf/ folder or add a full path with elf/). Checked on x86_64, i686, aarch64, armhf, powerpc64, powerpc32, and powerpc64le. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com> (cherry picked from commit d6d89608ac8cf2b37c75debad1fff653f6939f90) Resolved conflicts: elf/rtld.c (cherry picked from commit b868b45f6763a4adc4aa93248be9f84480768fcf)
* Revert "Revert "clone-internal.c: make clone3 syscall optional""gentoo/glibc-2.34-16Andreas K. Hüttel2022-03-311-1/+1
| | | | | | Was still needed after all. For zoom of all things ... This reverts commit c69573d32ce399d03446b6b4b76b18848203718f.
* hppa: Use END instead of PSEUDO_END in swapcontext.SJohn David Anglin2022-03-261-1/+1
| | | | | (cherry picked from commit 7a5c440102d4ec7fafd9bbd98eca9bd90ecaaafd) (cherry picked from commit d53b9cc391c72a1011ea8fe7a9f70dc5060a0db2)
* hppa: Implement swapcontext in assembler (bug 28960)John David Anglin2022-03-262-83/+72
| | | | | | | | | When swapcontext.c is compiled without -g, the following error occurs: Error: CFI instruction used without previous .cfi_startproc Fix by converting swapcontext routine to assembler. (cherry picked from commit 738ee53f0ce5e39b9b7a6777f5d3057afbaac498)
* Revert "clone-internal.c: make clone3 syscall optional"Andreas K. Hüttel2022-03-261-1/+1
| | | | This reverts commit 1f714c474eb248b3fa2c84f3b0f22cc509c0e6c9.
* hppa: Revise gettext trampoline designJohn David Anglin2022-03-073-31/+35
| | | | | | | | | | | | | | | | | | | | | | The current getcontext return trampoline is overly complex and it unnecessarily clobbers several registers. By saving the context pointer (r26) in the context, __getcontext_ret can restore any registers not restored by setcontext. This allows getcontext to save and restore the entire register context present when getcontext is entered. We use the unused oR0 context slot for the return from __getcontext_ret. While this is not directly useful in C, it can be exploited in assembly code. Registers r20, r23, r24 and r25 are not clobbered in the call path to getcontext. This allows a small simplification of swapcontext. It also allows saving and restoring the 6-bit SAR register in the LSB of the oSAR context slot. The getcontext flag value can be stored in the MSB of the oSAR slot. (cherry picked from commit 9e7e5fda38471e00d1190479ea91d7b08ae3e304) (cherry picked from commit f610d2935f041c5f41ddcb96924ea42ca2fb5ea5)
* hppa: Fix swapcontextJohn David Anglin2022-03-073-7/+58
| | | | | | | | | | | | | | | | | | | | This change fixes the failure of stdlib/tst-setcontext2 and stdlib/tst-setcontext7 on hppa. The implementation of swapcontext in C is broken. C saves the return pointer (rp) and any non call-clobbered registers (in this case r3, r4 and r5) on the stack. However, the setcontext call in swapcontext pops the stack and subsequent calls clobber the saved registers. When the context in oucp is restored, both tests fault. Here we rewrite swapcontext in assembly code to avoid using the stack for register values that need to be used after restoration. The getcontext and setcontext routines are revised to save and restore register ret1 for normal returns. We copy the oucp pointer to ret1. This allows access to the old context after calling getcontext and setcontext. (cherry picked from commit 71b108d7eb33b2bf3e61d5e92d2a47f74c1f7d96) (cherry picked from commit c6f9085ee4e913a0b8260340ac7b75c426b780ce)
* linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]Dmitry V. Levin2022-02-171-31/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_nprocs() and get_nprocs_conf() use various methods to obtain an accurate number of processors. Re-introduce __get_nprocs_sched() as a source of information, and fix the order in which these methods are used to return the most accurate information. The primary source of information used in both functions remains unchanged. This also changes __get_nprocs_sched() error return value from 2 to 0, but all its users are already prepared to handle that. Old fallback order: get_nprocs: /sys/devices/system/cpu/online -> /proc/stat -> 2 get_nprocs_conf: /sys/devices/system/cpu/ -> /proc/stat -> 2 New fallback order: get_nprocs: /sys/devices/system/cpu/online -> /proc/stat -> sched_getaffinity -> 2 get_nprocs_conf: /sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2 Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc") Closes: BZ #28865 Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit e1d32b836410767270a3adf1f82b1a47e6e4cd51) (cherry picked from commit 007e054d786be340699c634e3a3b30ab1fde1a7a)
* linux: Fix missing __convert_scm_timestamps (BZ #28860)Adhemerval Zanella2022-02-041-2/+3
| | | | | | | | | | | | | Commit 948ce73b31 made recvmsg/recvmmsg to always call __convert_scm_timestamps for 64 bit time_t symbol, so adjust it to always build it for __TIMESIZE != 64. It fixes build for architecture with 32 bit time_t support when configured with minimum kernel of 5.1. (cherry-picked from 798d716df71fb23dc89d1d5dba1fc26a1b5c0024) (cherry picked from commit 0351c75c5f94134fcec0e778e8cf86d149f8bbfb)
* Linux: Simplify __opensock and fix race condition [BZ #28353]Florian Weimer2022-02-042-116/+0
| | | | | | | | | | | | | | | AF_NETLINK support is not quite optional on modern Linux systems anymore, so it is likely that the first attempt will always succeed. Consequently, there is no need to cache the result. Keep AF_UNIX and the Internet address families as a fallback, for the rare case that AF_NETLINK is missing. The other address families previously probed are totally obsolete be now, so remove them. Use this simplified version as the generic implementation, disabling Netlink support as needed. (cherry picked from commit 5bf07e1b3a74232bfb8332275110be1a5da50f83) (cherry picked from commit ad615b59c78d6d37fee921fb2b2ae6b72c930625)
* linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]Gleb Fotengauer-Malinovskiy2022-02-041-1/+1
| | | | | | | | | | Pass the actual number of bytes returned by the kernel. Fixes: 33099d72e41c ("linux: Simplify get_nprocs") Reviewed-by: Dmitry V. Levin <ldv@altlinux.org> (cherry picked from commit 97ba273b505763325efd802dc3a9562dbba79579) (cherry picked from commit 05c83ccaf50aef2dd30d92cbb814383f6bddea2c)
* tst-socket-timestamp-compat.c: Check __TIMESIZE [BZ #28837]H.J. Lu2022-02-041-1/+1
| | | | | | | | | time_t size is defined by __TIMESIZE, not __WORDSIZE. Check __TIMESIZE, instead of __WORDSIZE, for time_t size. This fixes BZ #28837. (cherry pick from commit 77a602ebb0769e7ccc5f9f8e06f7fffe66f69dfc) (cherry picked from commit 008003dc6e83439c5e04a744b7fd8197df19096e)
* Linux: Only generate 64 bit timestamps for 64 bit time_t recvmsg/recvmmsgAdhemerval Zanella2022-02-045-24/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | The timestamps created by __convert_scm_timestamps only make sense for 64 bit time_t programs, 32 bit time_t programs will ignore 64 bit time_t timestamps since SO_TIMESTAMP will be defined to old values (either by glibc or kernel headers). Worse, if the buffer is not suffice MSG_CTRUNC is set to indicate it (which breaks some programs [1]). This patch makes only 64 bit time_t recvmsg and recvmmsg to call __convert_scm_timestamps. Also, the assumption to called it is changed from __ASSUME_TIME64_SYSCALLS to __TIMESIZE != 64 since the setsockopt might be called by libraries built without __TIME_BITS=64. The MSG_CTRUNC is only set for the 64 bit symbols, it should happen only if 64 bit time_t programs run older kernels. Checked on x86_64-linux-gnu and i686-linux-gnu. [1] https://github.com/systemd/systemd/pull/20567 Reviewed-by: Florian Weimer <fweimer@redhat.com> (cherry picked from commit 948ce73b31fdb0860bcec4b8e62b14e88234f98a) (cherry picked from commit 489d0b8b32548bc569cd3067aebf98b030720753)
* linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ#28350)Adhemerval Zanella2022-02-044-6/+348
| | | | | | | | | | | | | | | | | | | | | | | The __convert_scm_timestamps only updates the control message last pointer for SOL_SOCKET type, so if the message control buffer contains multiple ancillary message types the converted timestamp one might overwrite a valid message. The test checks if the extra ancillary space is correctly handled by recvmsg/recvmmsg, where if there is no extra space for the 64-bit time_t converted message the control buffer should be marked with MSG_TRUNC. It also check if recvmsg/recvmmsg handle correctly multiple ancillary data. Checked on x86_64-linux and on i686-linux-gnu on both 5.11 and 4.15 kernel. Co-authored-by: Fabian Vogt <fvogt@suse.de> Reviewed-by: Florian Weimer <fweimer@redhat.com> (cherry picked from commit 8fba672472ae0055387e9315fc2eddfa6775ca79) (cherry picked from commit e098446037da532d4a250efac9a813bc22f3669f)
* Fix glibc 2.34 ABI omission (missing GLIBC_2.34 in dynamic loader)Florian Weimer2022-01-3129-0/+29
| | | | | | | | | | | | | | | The glibc 2.34 release really should have added a GLIBC_2.34 symbol to the dynamic loader. With it, we could move functions such as dlopen or pthread_key_create that work on process-global state into the dynamic loader (once we have fixed a longstanding issue with static linking). Without the GLIBC_2.34 symbol, yet another new symbol version would be needed because old glibc will fail to load binaries due to the missing symbol version in ld.so that newly linked programs will require. Reviewed-by: H.J. Lu <hjl.tools@gmail.com> (cherry picked from commit af121ae3e7cd12628c91ecfc46a9d65313a6e972) (cherry picked from commit 948ebc098ed3cd928ea10997f990115e7770bda3)
* Linux: Detect user namespace support in io/tst-getcwd-smallbuffgentoo/glibc-2.34-12Florian Weimer2022-01-241-0/+18
| | | | | | | | Otherwise the test fails with certain container runtimes. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> (cherry picked from commit 5b8e7980c5dabd9aaefeba4f0208baa8cf7653ee) (cherry picked from commit 3438bbca90895d32825a52e31a77dc44d273c1c1)
* getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999)Siddhesh Poyarekar2022-01-242-1/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No valid path returned by getcwd would fit into 1 byte, so reject the size early and return NULL with errno set to ERANGE. This change is prompted by CVE-2021-3999, which describes a single byte buffer underflow and overflow when all of the following conditions are met: - The buffer size (i.e. the second argument of getcwd) is 1 byte - The current working directory is too long - '/' is also mounted on the current working directory Sequence of events: - In sysdeps/unix/sysv/linux/getcwd.c, the syscall returns ENAMETOOLONG because the linux kernel checks for name length before it checks buffer size - The code falls back to the generic getcwd in sysdeps/posix - In the generic func, the buf[0] is set to '\0' on line 250 - this while loop on line 262 is bypassed: while (!(thisdev == rootdev && thisino == rootino)) since the rootfs (/) is bind mounted onto the directory and the flow goes on to line 449, where it puts a '/' in the byte before the buffer. - Finally on line 458, it moves 2 bytes (the underflowed byte and the '\0') to the buf[0] and buf[1], resulting in a 1 byte buffer overflow. - buf is returned on line 469 and errno is not set. This resolves BZ #28769. Reviewed-by: Andreas Schwab <schwab@linux-m68k.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Qualys Security Advisory <qsa@qualys.com> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> (cherry picked from commit 23e0e8f5f1fb5ed150253d986ecccdc90c2dcd5e) (cherry picked from commit 472e799a5f2102bc0c3206dbd5a801765fceb39c)
* Update syscall lists for Linux 5.16Joseph Myers2022-01-2426-2/+28
| | | | | | | | | | | Linux 5.16 has one new syscall, futex_waitv. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py. (cherry picked from commit 4997a533ae4b51ef66a6b68862b7578a7acb82df) (cherry picked from commit 705f1e4606aa78f4e861b4e3346725bf5f083a56)
* i386: Remove broken CAN_USE_REGISTER_ASM_EBP (bug 28771)Florian Weimer2022-01-133-251/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The configure check for CAN_USE_REGISTER_ASM_EBP tried to compile a simple function that uses %ebp as an inline assembly operand. If compilation failed, CAN_USE_REGISTER_ASM_EBP was set 0, which eventually had these consequences: (1) %ebx was avoided as an inline assembly operand, with an assembler macro hack to avoid unnecessary register moves. (2) %ebp was avoided as an inline assembly operand, using an out-of-line syscall function for 6-argument system calls. (1) is no longer needed for any GCC version that is supported for building glibc. %ebx can be used directly as a register operand. Therefore, this commit removes the %ebx avoidance completely. This avoids the assembler macro hack, which turns out to be incompatible with the current Systemtap probe macros (which switch to .altmacro unconditionally). (2) is still needed in many build configurations. The existing configure check cannot really capture that because the simple function succeeds to compile, while the full glibc build still fails. Therefore, this commit removes the check, the CAN_USE_REGISTER_ASM_EBP macro, and uses the out-of-line syscall function for 6-argument system calls unconditionally. Reviewed-by: H.J. Lu <hjl.tools@gmail.com> (cherry picked from commit a78e6a10d0b50d0ca80309775980fc99944b1727) (cherry picked from commit 2fe2af88abd13ae5636881da2e26f461ecb7dfb5)
* Update syscall lists for Linux 5.15Joseph Myers2022-01-1328-4/+31
| | | | | | | | | | | | | | | | | Linux 5.15 has one new syscall, process_mrelease (and also enables the clone3 syscall for RV32). It also has a macro __NR_SYSCALL_MASK for Arm, which is not a syscall but matches the pattern used for syscall macro names. Add __NR_SYSCALL_MASK to the names filtered out in the code dealing with syscall lists, update syscall-names.list for the new syscall and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py. (cherry picked from commit 3387c40a8bbad5faf85b1feb56429cb20feaa640) (cherry picked from commit 73558ffe841cf4c60ccb4c71cf6dcebf84f2b736)
* Bring onto exact state as azanella's revised patchsetgentoo/glibc-2.34-11Andreas K. Hüttel2022-01-121-2/+3
| | | | Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
* dirent: Deprecate getdirentriesgentoo/glibc-2.34-9Adhemerval Zanella2022-01-041-0/+3
| | | | | | | | | | | | | | | | The interface has some issues: 1. It is build on top getdents on Linux and requires handling non-LFS call using LFS getdents. 2. It is not wildly used and the non-LFS support is as problematic as non-LFS readdir. glibc only exports the LFS getdents. 3. It is not a direct replacement over BSD since on some plataform its signature has changed (FreeBSD 11, for instance, used to set the offset as a 'long' and changed to 'off_t' on version 12). The idea is to eventually move the symbols to compat ones.
* linux: Use getdents64 on readdir64 compat implementationAdhemerval Zanella2022-01-044-135/+79
| | | | | | | | | | It uses a similar strategy from the non-LFS readdir that also uses getdents64 internally and uses a translation buffer to return the compat readdir64 entry. It allows to remove __old_getdents64. Checked on i686-linux-gnu.
* linux: Add __old_readdir64_unlockedAdhemerval Zanella2022-01-043-67/+35
| | | | | | And use it __old_readdir64_r. Checked on i686-linux-gnu.
* linux: Add __readdir64_unlockedAdhemerval Zanella2022-01-042-68/+32
| | | | | | And use it on readdir_r implementation. Checked on i686-linux-gnu.
* linux: Set internal DIR filepos as off64_t [BZ #23960, BZ #24050]Adhemerval Zanella2022-01-048-8/+158
| | | | | | | | | | | | | | | | | | | | | | It allows to obtain the expected entry offset on telldir and set it correctly on seekdir on platforms where long int is smaller than off64_t. On such cases telldir will mantain an internal list that maps the DIR object off64_t offsets to the returned long int (the function return value). The seekdir will then set the correct offset from the internal list using the telldir as the list key. It also removes the overflow check on readdir and the returned value will be truncated by the non-LFS off_t size. As Joseph has noted in BZ #23960 comment #22, d_off is an opaque value and since telldir/seekdir works regardless of the returned dirent d_off value. Finally it removed the requirement to check for overflow values on telldir (BZ #24050). Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu, and arm-linux-gnueabihf.
* linux: Use getdents64 on non-LFS readdirAdhemerval Zanella2022-01-044-26/+101
| | | | | | | | | | | The opendir allocates a translation buffer to be used to return the non-LFS readdir entry. The obtained dirent64 struct is translated to the temporary buffer on each readdir call. Entries that overflow d_off/d_ino and the buffer reallocation failure (in case of large d_name) are ignored. Checked on x86_64-linux-gnu and i686-linux-gnu.
* linux: Do not skip entries with zero d_ino values [BZ #12165]Adhemerval Zanella2022-01-042-74/+44
| | | | | | | | | | | According to Linux commit 2adc376c55194 (vfs: avoid creation of inode number 0 in get_next_ino) Linux did not treat d_ino == 0 as a special case (it is a valid inode number). This patch fixes readdir{64} by not ignoring entried with d_ino being 0. Checked on x86_64-linux-gnu and i686-linux-gnu.
* Linux: Fix 32-bit vDSO for clock_gettime on powerpc32maminjie2022-01-021-1/+1
| | | | | | | | | | | | | | | | | When the clock_id is CLOCK_PROCESS_CPUTIME_ID or CLOCK_THREAD_CPUTIME_ID, on the 5.10 kernel powerpc 32-bit, the 32-bit vDSO is executed successfully ( because the __kernel_clock_gettime in arch/powerpc/kernel/vdso32/gettimeofday.S does not support these two IDs, the 32-bit time_t syscall will be used), but tp32.tv_sec is equal to 0, causing the 64-bit time_t syscall to continue to be used, resulting in two system calls. Fix commit 72e84d1db22203e01a43268de71ea8669eca2863. Signed-off-by: maminjie <maminjie2@huawei.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit e0fc721ce600038dd390e77cfe52440707ef574d) (cherry picked from commit 8ad6d6d8ed33631bd2ca5d1112e6da2f92731432)
* linux: Add sparck brk implementationAdhemerval Zanella2022-01-021-0/+58
| | | | | | | | | | | | | | It turned that the generic implementation of brk() does not work for sparc, since on failure kernel will just return the previous input value without setting the conditional register. This patches adds back a sparc32 and sparc64 implementation removed by 720480934ab9107. Checked on sparc64-linux-gnu and sparcv9-linux-gnu. (cherry picked from commit 5b86241a032c50462988bdd1439e078384690d34) (cherry picked from commit 1d9764aba8c00754fbf8299e48afbe222245ee3e)
* riscv: align stack in clone [BZ #28702]Aurelien Jarno2022-01-021-0/+3
| | | | | | | | | | | | | | | The RISC-V ABI [1] mandates that "the stack pointer shall be aligned to a 128-bit boundary upon procedure entry". This as not the case in clone. This fixes the misc/tst-misalign-clone-internal and misc/tst-misalign-clone tests. Fixes bug 28702. [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc (cherry picked from commit d2e594d71509faf36cf851a69370db34a4f5fa65) (cherry picked from commit 9de8011c328021f10588a8acb418daf5121d5f3d)
* powerpc64[le]: Allocate extra stack frame on syscall.SMatheus Castanho2022-01-021-0/+4
| | | | | | | | | | | | | | | | The syscall function does not allocate the extra stack frame for scv like other assembly syscalls using DO_CALL_SCV. So after commit d120fb9941 changed the offset that is used to save LR, syscall ended up using an invalid offset, causing regressions on powerpc64. So make sure the extra stack frame is allocated in syscall.S as well to make it consistent with other uses of DO_CALL_SCV and avoid similar issues in the future. Tested on powerpc, powerpc64, and powerpc64le (with and without scv) Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com> (cherry picked from commit ae91d3df24a4a1b1f264d101a71a298bff310d14) (cherry picked from commit 5daf13b1e637eec0f7a2de05b177cb0d76479aa2)
* arm: Guard ucontext _rtld_global_ro access by SHARED, not PIC macroFlorian Weimer2022-01-022-4/+4
| | | | | | | | | | | | | | | | | | Due to PIE-by-default, PIC is now defined in more cases. libc.a does not have _rtld_global_ro, and statically linking setcontext fails. SHARED is the right condition to use, so that libc.a references _dl_hwcap instead of _rtld_global_ro. For static PIE support, the !SHARED case would still have to be made PIC. This patch does not achieve that. Fixes commit 23645707f12f2dd9d80b51effb2d9618a7b65565 ("Replace --enable-static-pie with --disable-default-pie"). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com> (cherry picked from commit ce1e5b11229f19820b86f8b19d651f16009552b0) (cherry picked from commit 93aabf891e96e93f100081ee07989c23d7107d17)
* mips: increase stack alignment in clone to match the ABIXi Ruoyao2022-01-021-3/+3
| | | | | | | | | | | | | | | In "mips: align stack in clone [BZ #28223]" (commit 1f51cd9a860ee45eee8a56fb2ba925267a2a7bfe) I made a mistake: I misbelieved one "word" was 2-byte and "doubleword" should be 4-byte. But in MIPS ABI one "word" is defined 32-bit (4-byte), so "doubleword" is 8-byte [1], and "quadword" is 16-byte [2]. [1]: "System V Application Binary Interface: MIPS(R) RISC Processor Supplement, 3rd edition", page 3-31 [2]: "MIPSpro(TM) 64-Bit Porting and Transition Guide", page 23 (cherry picked from commit 0f62fe053273ff6c62ac95c59b7687c964737b00) (cherry picked from commit 4db172a54d43f9b7fd17e66fc44a34efb3cab1e1)
* mips: align stack in clone [BZ #28223]Xi Ruoyao2022-01-021-0/+7
| | | | | | | | | | | The MIPS O32 ABI requires 4 byte aligned stack, and the MIPS N64 and N32 ABI require 8 byte aligned stack. Previously if the caller passed an unaligned stack to clone the the child misbehaved. Fixes bug 28223. (cherry picked from commit 1f51cd9a860ee45eee8a56fb2ba925267a2a7bfe) (cherry picked from commit 7af07fe795f43e53d31be1c6f9adba7e05f87b0b)
* clone-internal.c: make clone3 syscall optionalgentoo/glibc-2.34-7Sam James2021-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We're disabling clone3 for now _CONDITIONALLY_ (not by default) to allow compatibility with applications using older Electron. Use -DGENTOO_USE_CLONE3 to enable clone3 for now. In future, we will revert back to always using clone3. This was impacting e.g. Discord and Skype. This patch stops glibc from using clone3 internally (which is the only real use of it) and falls back to the old behaviour. Specifically, we want https://github.com/electron/electron/pull/31091 to work its way downstream to various Electron applications. https://bugs.gentoo.org/819045 https://bugs.gentoo.org/827386 https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/glibc/plain/debian/patches/ubuntu/disable-clone3.patch This is the same as the patch that was considered but ultimately rejected for 2.34 because Docker got sorted out in time: https://patchwork.ozlabs.org/project/glibc/patch/87eebkf8ph.fsf@oldenburg.str.redhat.com/. Signed-off-by: Sam James <sam@gentoo.org>