aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-02-28x86: Update _dl_tlsdesc_dynamic to preserve caller-saved registersHEADmasterH.J. Lu
Compiler generates the following instruction sequence for GNU2 dynamic TLS access: leaq tls_var@TLSDESC(%rip), %rax call *tls_var@TLSCALL(%rax) or leal tls_var@TLSDESC(%ebx), %eax call *tls_var@TLSCALL(%eax) CALL instruction is transparent to compiler which assumes all registers, except for EFLAGS and RAX/EAX, are unchanged after CALL. When _dl_tlsdesc_dynamic is called, it calls __tls_get_addr on the slow path. __tls_get_addr is a normal function which doesn't preserve any caller-saved registers. _dl_tlsdesc_dynamic saved and restored integer caller-saved registers, but didn't preserve any other caller-saved registers. Add _dl_tlsdesc_dynamic IFUNC functions for FNSAVE, FXSAVE, XSAVE and XSAVEC to save and restore all caller-saved registers. This fixes BZ #31372. Add GLRO(dl_x86_64_runtime_resolve) with GLRO(dl_x86_tlsdesc_dynamic) to optimize elf_machine_runtime_setup. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2024-02-28sysdeps/unix/sysv/linux/x86_64/Makefile: Add the end markerH.J. Lu
Add the end marker to tests, tests-container and modules-names.
2024-02-28cdefs: Drop access attribute for _FORTIFY_SOURCE=3 (BZ #31383)Siddhesh Poyarekar
When passed a pointer to a zero-sized struct, the access attribute without the third argument misleads -Wstringop-overflow diagnostics to think that a function is writing 1 byte into the zero-sized structs. The attribute doesn't add that much value in this context, so drop it completely for _FORTIFY_SOURCE=3. Resolves: BZ #31383 Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-28s390: Improve static-pie configure testsAdhemerval Zanella
Instead of tying based on the linker name and version, check for the required support: * whether it does not generate dynamic TLS relocations in PIE (binutils PR ld/22263); * if it accepts --no-dynamic-linker (by using -static-pie); * and if it adds a DT_JMPREL pointing to .rela.iplt with static pie. The patch also trims the comments, for binutils one of the tests should already cover it. The kernel ones are not clear which version should have the backport, nor it is something that glibc can do much about it. Finally, the glibc is somewhat confusing, since it refers to commits not related to s390x. Checked with a build for s390x-linux-gnu. Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
2024-02-27x86: Change ENQCMD test to CHECK_FEATURE_PRESENTH.J. Lu
Since ENQCMD is mainly used in kernel, change the ENQCMD test to CHECK_FEATURE_PRESENT. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2024-02-27debug: Improve mqueue.h fortify warnings with clangAdhemerval Zanella
It improve mq_open. The compile and runtime checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27debug: Improve fcntl.h fortify warnings with clangAdhemerval Zanella
It improves open, open64, openat, and openat64. The compile and runtime checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27wcsmbs: Improve fortify with clangAdhemerval Zanella
It improve fortify checks for wmemcpy, wmemmove, wmemset, wcscpy, wcpcpy, wcsncpy, wcpncpy, wcscat, wcsncat, wcslcpy, wcslcat, swprintf, fgetws, fgetws_unlocked, wcrtomb, mbsrtowcs, wcsrtombs, mbsnrtowcs, and wcsnrtombs. The compile and runtime checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27syslog: Improve fortify with clangAdhemerval Zanella
It improve fortify checks for syslog and vsyslog. The compile and runtime hecks have similar coverage as with GCC. The syslog fortify wrapper calls the va_arg version, since clang does not support __va_arg_pack. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27socket: Improve fortify with clangAdhemerval Zanella
It improve fortify checks recv, recvfrom, poll, and ppoll. The compile and runtime hecks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27unistd: Improve fortify with clangAdhemerval Zanella
It improve fortify checks for read, pread, pread64, readlink, readlinkat, getcwd, getwd, confstr, getgroups, ttyname_r, getlogin_r, gethostname, and getdomainname. The compile and runtime checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27stdlib: Improve fortify with clangAdhemerval Zanella
It improve fortify checks for realpath, ptsname_r, wctomb, mbstowcs, and wcstombs. The runtime and compile checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27string: Improve fortify with clangAdhemerval Zanella
It improve fortify checks for strcpy, stpcpy, strncpy, stpncpy, strcat, strncat, strlcpy, and strlcat. The runtime and compile checks have similar coverage as with GCC. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27libio: Improve fortify with clangAdhemerval Zanella
It improve fortify checks for sprintf, vsprintf, vsnsprintf, fprintf, dprintf, asprintf, __asprintf, obstack_printf, gets, fgets, fgets_unlocked, fread, and fread_unlocked. The runtime checks have similar support coverage as with GCC. For function with variadic argument (sprintf, snprintf, fprintf, printf, dprintf, asprintf, __asprintf, obstack_printf) the fortify wrapper calls the va_arg version since clang does not support __va_arg_pack. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27cdefs.h: Add clang fortify directivesAdhemerval Zanella
For instance, the read wrapper is currently expanded as: extern __inline __attribute__((__always_inline__)) __attribute__((__artificial__)) __attribute__((__warn_unused_result__)) ssize_t read (int __fd, void *__buf, size_t __nbytes) { return __glibc_safe_or_unknown_len (__nbytes, sizeof (char), __glibc_objsize0 (__buf)) ? __read_alias (__fd, __buf, __nbytes) : __glibc_unsafe_len (__nbytes, sizeof (char), __glibc_objsize0 (__buf)) ? __read_chk_warn (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0)) : __read_chk (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0)); } The wrapper relies on __builtin_object_size call lowers to a constant at compile-time and many other operations in the wrapper depends on having a single, known value for parameters. Because this is impossible to have for function parameters, the wrapper depends heavily on inlining to work and While this is an entirely viable approach on GCC, it is not fully reliable on clang. This is because by the time llvm gets to inlining and optimizing, there is a minimal reliable source and type-level information available (more information on a more deep explanation on how to fortify wrapper works on clang [1]). To allow the wrapper to work reliably and with the same functionality as with GCC, clang requires a different approach: * __attribute__((diagnose_if(c, “str”, “warning”))) which is a function level attribute; if the compiler can determine that 'c' is true at compile-time, it will emit a warning with the text 'str1'. If it would be better to emit an error, the wrapper can use "error" instead of "warning". * __attribute__((overloadable)) which is also a function-level attribute; and it allows C++-style overloading to occur on C functions. * __attribute__((pass_object_size(n))) which is a parameter-level attribute; and it makes the compiler evaluate __builtin_object_size(param, n) at each call site of the function that has the parameter, and passes it in as a hidden parameter. This attribute has two side-effects that are key to how FORTIFY works: 1. It can overload solely on pass_object_size (e.g. there are two overloads of foo in void foo(char * __attribute__((pass_object_size(0))) c); void foo(char *); (The one with pass_object_size attribute has precende over the default one). 2. A function with at least one pass_object_size parameter can never have its address taken (and overload resolution respects this). Thus the read wrapper can be implemented as follows, without hindering any fortify coverage compile and runtime: extern __inline __attribute__((__always_inline__)) __attribute__((__artificial__)) __attribute__((__overloadable__)) __attribute__((__warn_unused_result__)) ssize_t read (int __fd, void *const __attribute__((pass_object_size (0))) __buf, size_t __nbytes) __attribute__((__diagnose_if__ ((((__builtin_object_size (__buf, 0)) != -1ULL && (__nbytes) > (__builtin_object_size (__buf, 0)) / (1))), "read called with bigger length than size of the destination buffer", "warning"))) { return (__builtin_object_size (__buf, 0) == (size_t) -1) ? __read_alias (__fd, __buf, __nbytes) : __read_chk (__fd, __buf, __nbytes, __builtin_object_size (__buf, 0)); } To avoid changing the current semantic for GCC, a set of macros is defined to enable the clang required attributes, along with some changes on internal macros to avoid the need to issue the symbol_chk symbols (which are done through the __diagnose_if__ attribute for clang). The read wrapper is simplified as: __fortify_function __attribute_overloadable__ __wur ssize_t read (int __fd, __fortify_clang_overload_arg0 (void *, ,__buf), size_t __nbytes) __fortify_clang_warning_only_if_bos0_lt (__nbytes, __buf, "read called with bigger length than " "size of the destination buffer") { return __glibc_fortify (read, __nbytes, sizeof (char), __glibc_objsize0 (__buf), __fd, __buf, __nbytes); } There is no expected semantic or code change when using GCC. Also, clang does not support __va_arg_pack, so variadic functions are expanded to call va_arg implementations. The error function must not have bodies (address takes are expanded to nonfortified calls), and with the __fortify_function compiler might still create a body with the C++ mangling name (due to the overload attribute). In this case, the function is defined with __fortify_function_error_function macro instead. [1] https://docs.google.com/document/d/1DFfZDICTbL7RqS74wJVIJ-YnjQOj1SaoqfhbgddFYSM/edit Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-02-27Update SHARED-FILES and license for Unicode 15.1.0.Carlos O'Donell
In 2018 the license changed to use Unicode-3.0 license. The Unicode License is a permissive MIT type of license. Automation is updated to fetch the correct license file to keep it in sync with the data files. The new license is OSI approved and has an SPDX identifer: https://opensource.org/license/unicode-license-v3 https://spdx.org/licenses/Unicode-3.0.html The FSF and the GNU Project have been contacted to update the license list for this license: https://www.gnu.org/licenses/license-list.html
2024-02-26aarch64/fpu: Sync libmvec routines from 2.39 and before with AORJoe Ramsay
This includes a fix for big-endian in AdvSIMD log, some cosmetic changes, and numerous small optimisations mainly around inlining and using indexed variants of MLA intrinsics. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-26S390: Do not clobber r7 in clone [BZ #31402]Stefan Liebler
Starting with commit e57d8fc97b90127de4ed3e3a9cdf663667580935 "S390: Always use svc 0" clone clobbers the call-saved register r7 in error case: function or stack is NULL. This patch restores the saved registers also in the error case. Furthermore the existing test misc/tst-clone is extended to check all error cases and that clone does not clobber registers in this error case.
2024-02-25x86_64: Exclude SSE, AVX and FMA4 variants in libm multiarchSunil K Pandey
When glibc is built with ISA level 3 or higher by default, the resulting glibc binaries won't run on SSE or FMA4 processors. Exclude SSE, AVX and FMA4 variants in libm multiarch when ISA level 3 or higher is enabled by default. When glibc is built with ISA level 2 enabled by default, only keep SSE4.1 variant. Fixes BZ 31335. NB: elf/tst-valgrind-smoke test fails with ISA level 4, because valgrind doesn't support AVX512 instructions: https://bugs.kde.org/show_bug.cgi?id=383010 Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-02-25hurd: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686. Tested with build-many-glibcs.py for x86_64-gnu.
2024-02-25htl/tests: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. No code generation changes in non-test binary artifacts. No regressions on x86_64 and i686. Tested with build-many-glibcs.py for x86_64-gnu.
2024-02-25htl: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686.
2024-02-25hesiod: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. No code generation changes in non-test binary artifacts. No regressions on x86_64 and i686.
2024-02-25gmon: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686.
2024-02-25dlfcn: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. No code generation changes in non-test binary artifacts. No regressions on x86_64 and i686.
2024-02-25dirent: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686.
2024-02-25ctype: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686.
2024-02-25csu: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. Code generation changes present due to link order changes. No regressions on x86_64 and i686.
2024-02-25conform: Reformat Makefile.Carlos O'Donell
Reflow and sort Makefile. No code changes in generated binary artifacts. No regressions on x86_64 and i686.
2024-02-25Support compiling .S files with additional optionsH.J. Lu
Add $(sysdep-ASFLAGS) $(ASFLAGS-$(<F)) $(ASFLAGS-$(@F)) to compile.S and COMPILE.S to support compiling .S files with additional options.
2024-02-25x86-64: Save APX registers in ld.so trampolineH.J. Lu
Add APX registers to STATE_SAVE_MASK so that APX registers are saved in ld.so trampoline. This fixes BZ #31371. Also update STATE_SAVE_OFFSET and STATE_SAVE_MASK for i386 which will be used by i386 _dl_tlsdesc_dynamic. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2024-02-23benchtests: Add more benchtests for rounding functions.Junxian Zhu
This patch adds more benchtests for rounding functions. The double inputs are copied from trunc-inputs, the float inputs are copied from truncf-inputs. and the rintf is copied from rint-inputs. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-23tests: gracefully handle AppArmor userns containmentSimon Chopin
Recent AppArmor containment allows restricting unprivileged user namespaces, which is enabled by default on recent Ubuntu systems. When this happens, as is common with Linux Security Modules, the syscall will fail with -EACCESS. When that happens, the affected tests will now be considered unsupported rather than simply failing. Further information: * https://gitlab.com/apparmor/apparmor/-/wikis/unprivileged_userns_restriction * https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces * https://manpages.ubuntu.com/manpages/jammy/man5/apparmor.d.5.html (for the return code) V2: * Fix duplicated line in check_unshare_hints * Also handle similar failure in tst-pidfd_getpid V3: * Comment formatting * Aded some more documentation on syscall return value Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
2024-02-23treewide: python-scripts: use `is None` for none-equalityKonstantin Kharlamov
Testing for `None`-ness with `==` operator is frowned upon and causes warnings in at least "LGTM" python linter. Fix that. Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-23powerpc: Remove power7 strstr optimizationAdhemerval Zanella
The optimization is not faster than the generic algorithm, using the bench-strstr the geometric mean running on a POWER10 machine using gcc 13.1.1 is 482.47 while the default __strstr_ppc is 340.97 (which uses the generic implementation). Also, there is no need to redirect the internal str*/mem* call to optimized version, internal ifunc is supported and enabled for internal calls (meaning that the generic implementation will use any asm optimization if available). Checked on powerpc64le-linux-gnu. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2024-02-23arm: Use _dl_find_object on __gnu_Unwind_Find_exidx (BZ 31405)Adhemerval Zanella
Instead of __dl_iterate_phdr. On ARM dlfo_eh_frame/dlfo_eh_count maps to PT_ARM_EXIDX vaddr start / length. On a Neoverse N1 machine with 160 cores, the following program: $ cat test.c #include <stdlib.h> #include <pthread.h> #include <assert.h> enum { niter = 1024, ntimes = 128, }; static void * tf (void *arg) { int a = (int) arg; for (int i = 0; i < niter; i++) { void *p[ntimes]; for (int j = 0; j < ntimes; j++) p[j] = malloc (a * 128); for (int j = 0; j < ntimes; j++) free (p[j]); } return NULL; } int main (int argc, char *argv[]) { enum { nthreads = 16 }; pthread_t t[nthreads]; for (int i = 0; i < nthreads; i ++) assert (pthread_create (&t[i], NULL, tf, (void *) i) == 0); for (int i = 0; i < nthreads; i++) { void *r; assert (pthread_join (t[i], &r) == 0); assert (r == NULL); } return 0; } $ arm-linux-gnueabihf-gcc -fsanitize=address test.c -o test Improves from ~15s to 0.5s. Checked on arm-linux-gnueabihf.
2024-02-22math: Update mips64 ulpsXi Ruoyao
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2024-02-22elf: Add new LoongArch reloc types (110 to 126) into elf.hXi Ruoyao
These reloc types have been added in LoongArch psABI v2.30. Link: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#relocation-types Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-02-21build-many-glibcs.py: Add s390 --disable-multi-arch / multi-arch configurations.Stefan Liebler
This patch adds some --disable-multi-arch variants for s390x. As the used IFUNC variants and __GI symbols depend on the used gcc -march=cpu-level, there are multiple new configurations. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-19sparc: Treat the version field in the FPU control word as reservedDaniel Cederman
The FSR version field is read-only and might be non-zero. This allows math/test-fpucw* to correctly pass when the version is non-zero. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-17Implement setcontext/getcontext/makecontext/swapcontext for Hurd x86_64Flavio Cruz
Tested with the tests provided by glibc plus some other toy examples. Message-ID: <20240217202535.1860803-1-flaviocruz@gmail.com>
2024-02-17Use proc_getchildren_rusage when available in getrusage and times.Flavio Cruz
Message-ID: <20240217164846.1837223-1-flaviocruz@gmail.com>
2024-02-17Linux: Switch back to assembly syscall wrapper for prctl (bug 29770)Florian Weimer
Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for prctl [BZ #25896]") replaced the assembler wrapper with a C function. However, on powerpc64le-linux-gnu, the C variadic function implementation requires extra work in the caller to set up the parameter save area. Calling a function that needs a parameter save area without one (because the prototype used indicates the function is not variadic) corrupts the caller's stack. The Linux manual pages project documents prctl as a non-variadic function. This has resulted in various projects over the years using non-variadic prototypes, including the sanitizer libraries in LLVm and GCC (GCC PR 113728). This commit switches back to the assembler implementation on most targets and only keeps the C implementation for x86-64 x32. Also add the __prctl_time64 alias from commit b39ffab860cd743a82c91946619f1b8158b0b65e ("Linux: Add time64 alias for prctl") to sysdeps/unix/sysv/linux/syscalls.list; it was not yet present in commit ff026950e280bc3e9487b41b460fb31bc5b57721. This restores the old ABI on powerpc64le-linux-gnu, thus fixing bug 29770. Reviewed-By: Simon Chopin <simon.chopin@canonical.com>
2024-02-16i386: Use generic memrchr in libc (bug 31316)Florian Weimer
Before this change, we incorrectly used the SSE2 variant in the implementation, without checking that the system actually supports SSE2. Tested-by: Sam James <sam@gentoo.org>
2024-02-15Apply the Makefile sorting fixH.J. Lu
Apply the Makefile sorting fix generated by sort-makefile-lines.py.
2024-02-15sysdeps/x86_64/Makefile (tests): Add the end markerH.J. Lu
2024-02-15sort-makefile-lines.py: Allow '_' in name and "^# name"H.J. Lu
'_' is used in Makefile variable names and many variables end with "^# name". Relax sort-makefile-lines.py to allow '_' in name and "^# name" as variable end. This fixes BZ #31385.
2024-02-14trivial doc fix: remove weird phrase "syscall takes zero to five arguments"Askar Safin
"number of arguments, from zero to five" is wrong, because on Linux maximal number of arguments is 6, not 5. Also, maximal number of arguments is kernel-dependent, so let's not include it here at all. Moreover, "Each kind of system call has a definite number of arguments" is questionable. Think about SYS_open on Linux, which takes 2 or 3 arguments. Or SYS_clone on Linux x86_64, which takes 2 to 5 arguments. So I propose to fully remove this sentence. Signed-off-by: Askar Safin <safinaskar@zohomail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-02-14mips: Use builtins for ffs and ffsllJunxian Zhu
__builtin_ffs{,ll} basically on __builtin_ctz{,ll} in MIPS GCC compiler. The hardware ctz instructions were available after MIPS{32,64} Release1. By using builtin ctz. It can also reduce code size of ffs/ffsll. Checked on mips o32. mips64. Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
2024-02-13x86: Expand the comment on when REP STOSB is used on memsetAdhemerval Zanella
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>