aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
AgeCommit message (Collapse)Author
2020-12-21malloc: Basic support for memory tagging in the malloc() familyRichard Earnshaw
This patch adds the basic support for memory tagging. Various flavours are supported, particularly being able to turn on tagged memory at run-time: this allows the same code to be used on systems where memory tagging support is not present without neededing a separate build of glibc. Also, depending on whether the kernel supports it, the code will use mmap for the default arena if morecore does not, or cannot support tagged memory (on AArch64 it is not available). All the hooks use function pointers to allow this to work without needing ifuncs. Reviewed-by: DJ Delorie <dj@redhat.com>
2020-12-21alpha: Remove anonymous union in struct stat [BZ #27042]Matt Turner
This is clever, but it confuses downstream detection in at least zstd and GNOME's glib. zstd has preprocessor tests for the 'st_mtime' macro, which is not provided by the path using the anonymous union; glib checks for the presence of 'st_mtimensec' in struct stat but then tries to access that field in struct statx (which might be a bug on its own). Checked with a build for alpha-linux-gnu.
2020-12-21add inputs to auto-libm-test-in yielding larger errors (binary64, x86_64)Paul Zimmermann
2020-12-21m68k: fix clobbering a5 in setjmp() [BZ #24202]Sergei Trofimovich
setjmp() uses C code to store current registers into jmp_buf environment. -fstack-protector-all places canary into setjmp() prologue and clobbers 'a5' before it gets saved. The change inhibits stack canary injection to avoid clobber.
2020-12-21hurd: Make trampoline fill siginfo ss_sp from sc_uespSamuel Thibault
Mach actually rather fills the uesp field, not esp.
2020-12-21profil-counter: Add missing SIGINFO caseSamuel Thibault
When SA_SIGINFO is available, sysdeps/posix/s?profil.c use it, so we have to fix the __profil_counter function accordingly, using sigcontextinfo.h's sigcontext_get_pc.
2020-12-21hurd: implement SA_SIGINFO signal handlers.Jeremie Koenig
SA_SIGINFO is actually just another way of expressing what we were already passing over with struct sigcontext. This just introduces the SIGINFO interface and fixes the posix values when that interface is requested by the application.
2020-12-20hurd: Fix ELF_MACHINE_USER_ADDRESS_MASK valueSamuel Thibault
x86 binaries are linked at 0x08000000, so we need to let them get mapped there.
2020-12-20hurd: Note when the vm_map kernel bug was fixedSamuel Thibault
dl-sysdep has been wanting to use high bits in the vm_map mask for decades, but that was only implemented lately.
2020-12-18ieee754: Remove unused __sin32 and __cos32Anssi Hannula
The __sin32 and __cos32 functions were only used in the now removed slow path of asin and acos.
2020-12-18ieee754: Remove slow paths from asin and acosAnssi Hannula
asin and acos have slow paths for rounding the last bit that cause some calls to be 500-1500x slower than average calls. These slow paths are rare, a test of a trillion (1.000.000.000.000) random inputs between -1 and 1 showed 32870 slow calls for acos and 4473 for asin, with most occurrences between -1.0 .. -0.9 and 0.9 .. 1.0. The slow paths claim correct rounding and use __sin32() and __cos32() (which compare two result candidates and return the closest one) as the final step, with the second result candidate (res1) having a small offset applied from res. This suggests that res and res1 are intended to be 1 ULP apart (which makes sense for rounding), barring bugs, allowing us to pick either one and still remain within 1 ULP of the exact result. Remove the slow paths as the accuracy is better than 1 ULP even without them, which is enough for glibc. Also remove code comments claiming correctly rounded results. After slow path removal, checking the accuracy of 14.400.000.000 random asin() and acos() inputs showed only three incorrectly rounded (error > 0.5 ULP) results: - asin(-0x1.ee2b43286db75p-1) (0.500002 ULP, same as before) - asin(-0x1.f692ba202abcp-4) (0.500003 ULP, same as before) - asin(-0x1.9915e876fc062p-1) (0.50000000001 ULP, previously exact) The first two had the same error even before this commit, and they did not use the slow path at all. Checking 4934 known randomly found previously-slow-path asin inputs shows 25 calls with incorrectly rounded results, with a maximum error of 0.500000002 ULP (for 0x1.fcd5742999ab8p-1). The previous slow-path code rounded all these inputs correctly (error < 0.5 ULP). The observed average speed increase was 130x. Checking 36240 known randomly found previously-slow-path acos inputs shows 42 calls with incorrectly rounded results, with a maximum error of 0.500000008 ULP (for 0x1.f63845056f35ep-1). The previous "exact" slow-path code showed 34 calls with incorrectly rounded results, with the same maximum error of 0.500000008 ULP (for 0x1.f63845056f35ep-1). The observed average speed increase was 130x. The functions could likely be trimmed more while keeping acceptable accuracy, but this at least gets rid of the egregiously slow cases. Tested on x86_64.
2020-12-17Update kernel version to 5.10 in tst-mman-consts.py.Joseph Myers
This patch updates the kernel version in the test tst-mman-consts.py to 5.10. (There are no new MAP_* constants covered by this test in 5.10 that need any other header changes.) Tested with build-many-glibcs.py.
2020-12-17s390x: Require GCC 7.1 or later to build glibc.Stefan Liebler
GCC 6.5 fails to correctly build ldconfig with recent ld.so.cache commits, e.g.: 785969a047ad2f23f758901c6816422573544453 elf: Implement a string table for ldconfig, with tail merging If glibc is build with gcc 6.5.0: __builtin_add_overflow is used in <glibc>/elf/stringtable.c:stringtable_finalize() which leads to ldconfig failing with "String table is too large". This is also recognizable in following tests: FAIL: elf/tst-glibc-hwcaps-cache FAIL: elf/tst-glibc-hwcaps-prepend-cache FAIL: elf/tst-ldconfig-X FAIL: elf/tst-ldconfig-bad-aux-cache FAIL: elf/tst-ldconfig-ld_so_conf-update FAIL: elf/tst-stringtable See gcc "Bug 98269 - gcc 6.5.0 __builtin_add_overflow() with small uint32_t values incorrectly detects overflow" (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269)
2020-12-16Replace __libc_multiple_libcs with __libc_initial flagFlorian Weimer
Change sbrk to fail for !__libc_initial (in the generic implementation). As a result, sbrk is (relatively) safe to use for the __libc_initial case (from the main libc). It is therefore no longer necessary to avoid using it in that case (or updating the brk cache), and the __libc_initial flag does not need to be updated as part of dlmopen or static dlopen. As before, direct brk system calls on Linux may lead to memory corruption. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-16htl: Get sem_open/sem_close/sem_unlink support [BZ #25524]Samuel Thibault
This just moves the existing nptl implementation to reuse as it is in htl.
2020-12-16Update syscall lists for Linux 5.10.Joseph Myers
Linux 5.10 has one new syscall, process_madvise. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
2020-12-16htl: Add pshared semaphore supportSamuel Thibault
The implementation is extremely similar to the nptl implementation, but with slight differences in the futex interface. This fixes some of BZ 25521.
2020-12-16hurd: Add __libc_open and __libc_closeSamuel Thibault
Needed by libpthread for sem_open and sem_close
2020-12-16htl: Add futex-internal.hSamuel Thibault
That provides futex_supports_pshared
2020-12-16hurd: make lll_* take a variable instead of a ptrSamuel Thibault
To be coherent with other ports, let's make lll_* take a variable, and rename those that keep taking a ptr into __lll_*.
2020-12-16hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZERSamuel Thibault
To get coherent with other ports.
2020-12-15aarch64: remove the strlen_asimd symbolSzabolcs Nagy
This symbol is not in the implementation reserved namespace for static linking and it was never used: it seems it was mistakenly added in the orignal strlen_asimd commit 436e4d5b965abe592d26150cb518accf9ded8fe4
2020-12-15aarch64: fix static PIE start code for BTI [BZ #27068]Guillaume Gardet
A bti c was missing from rcrt1.o which made all -static-pie binaries fail at program startup on BTI enabled systems. Fixes bug 27068.
2020-12-14x86: Remove the default REP MOVSB threshold tunable value [BZ #27061]H.J. Lu
Since we can't tell if the tunable value is set by user or not: https://sourceware.org/bugzilla/show_bug.cgi?id=27069 remove the default REP MOVSB threshold tunable value so that the correct default value will be set correctly by init_cacheinfo (). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-12-12Fix spelling and grammar in several commentsJonny Grant
2020-12-11aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]Szabolcs Nagy
Re-mmap executable segments if possible instead of using mprotect to add PROT_BTI. This allows using BTI protection with security policies that prevent mprotect with PROT_EXEC. If the fd of the ELF module is not available because it was kernel mapped then mprotect is used and failures are ignored. To protect the main executable even when mprotect is filtered the linux kernel will have to be changed to add PROT_BTI to it. The delayed failure reporting is mainly needed because currently _dl_process_gnu_properties does not propagate failures such that the required cleanups happen. Using the link_map_machine struct for error propagation is not ideal, but this seemed to be the least intrusive solution. Fixes bug 26831. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-11elf: Pass the fd to note processingSzabolcs Nagy
To handle GNU property notes on aarch64 some segments need to be mmaped again, so the fd of the loaded ELF module is needed. When the fd is not available (kernel loaded modules), then -1 is passed. The fd is passed to both _dl_process_pt_gnu_property and _dl_process_pt_note for consistency. Target specific note processing functions are updated accordingly. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-11aarch64: align address for BTI protection [BZ #26988]Szabolcs Nagy
Handle unaligned executable load segments (the bfd linker is not expected to produce such binaries, but other linkers may). Computing the mapping bounds follows _dl_map_object_from_fd more closely now. Fixes bug 26988. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-11aarch64: Fix missing BTI protection from dependencies [BZ #26926]Szabolcs Nagy
The _dl_open_check and _rtld_main_check hooks are not called on the dependencies of a loaded module, so BTI protection was missed on every module other than the main executable and directly dlopened libraries. The fix just iterates over dependencies to enable BTI. Fixes bug 26926.
2020-12-10linux: Consolidate brk implementationAdhemerval Zanella
It removes all the arch-specific assembly implementation. The outliers are alpha, where its kernel ABI explict return -ENOMEM in case of failure; and i686, where it can't use "call *%gs:SYSINFO_OFFSET" during statup in static PIE. Also some ABIs exports an additional ___brk_addr symbol and to handle it an internal HAVE_INTERNAL_BRK_ADDR_SYMBOL is added. Checked on x86_64-linux-gnu, i686-linux-gnu, adn with builsd for the affected ABIs. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-12-10s390x: Add glibc-hwcaps supportFlorian Weimer
Subdirectories z13, z14, z15 can be selected, mostly based on the level of support for vector instructions. Co-Authored-By: Stefan Liebler <stli@linux.ibm.com>
2020-12-09S390: Derive float_t from FLT_EVAL_METHODMarius Hillenbrand
float_t supposedly represents the type that is used to evaluate float expressions internally. While the isa supports single-precision float operations, the port of glibc to s390 incorrectly deferred to the generic definitions which, back then, tied float_t to double. gcc by default evaluates float in single precision, so that scenario violates the C standard (sections 5.2.4.2.2 and 7.12 in C11/C17). With -fexcess-precision=standard, gcc evaluates float in double precision, which aligns with the standard yet at the cost of added conversion instructions. With this patch, we drop the s390-specific definition of float_t and defer to the default behavior, which aligns float_t with the compiler-defined FLT_EVAL_METHOD in a standard-compliant way. Checked on s390x-linux-gnu with 31-bit and 64-bit builds.
2020-12-09Fix parsing of /sys/devices/system/cpu/online (bug 25859)Andreas Schwab
The file contains comma-separated ranges, not spaces.
2020-12-08Make strtoimax, strtoumax, wcstoimax, wcstoumax into aliasesJoseph Myers
The functions strtoimax, strtoumax, wcstoimax, wcstoumax currently have three implementations each (wordsize-32, wordsize-64 and dummy implementation in stdlib/ using #error), defining the functions as thin wrappers round corresponding *_internal functions. Simplify the code by changing them into aliases of functions such as strtol and wcstoull. This is more consistent with how e.g. imaxdiv is handled. Tested for x86_64 and x86.
2020-12-06x86: Rename readelflib.cH.J. Lu
Rename linux/i386/readelflib.c to linux/x86/readelflib.c and remove x86_64/readelflib.c.
2020-12-04nsswitch: use new internal API (callers)DJ Delorie
Stitch new ABI and types throughout all NSS callers. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2020-12-04nss: Implement <nss_database.h>Florian Weimer
This code manages the mappings of the available databases in NSS (i.e. passwd, hosts, netgroup, etc) with the actions that should be taken to do a query on those databases. This is the main API between query functions scattered throughout glibc and the underlying code (actions, modules, etc). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2020-12-04powerpc64le: Add glibc-hwcaps supportFlorian Weimer
The "power10" and "power9" subdirectories are selected in a way that matches the -mcpu=power10 and -mcpu=power9 options of GCC.
2020-12-04x86: Adjust tst-cpu-features-supports.c for GCC 11H.J. Lu
Check HAS_CPU_FEATURE instead of CPU_FEATURE_USABLE for FSGSBASE, IBT, LM, SHSTK and XSAVES since FSGSBASE requires kernel support, IBT/SHSTK/LM require OS support and XSAVES is supervisor-mode only.
2020-12-04x86: Set RDRAND usable if CPU supports RDRANDH.J. Lu
Set RDRAND usable if CPU supports RDRAND.
2020-12-04lowlevellock-futex: Remove not used macrosLukasz Majewski
Following macros: lll_futex_timed_lock_pi, lll_futex_clock_wait_bitset, lll_futex_wait_requeue_pi, lll_futex_timed_wait_requeue_pi are not used anymore so are eligible for removal. Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-12-04futex: Remove not used futex_reltimed_wait{_cancelable}Lukasz Majewski
After gai_suspend and aio_suspend conversion to support 64 bit time and hence rewriting the code to use only absolute variants of futex wait functions (i.e. __futex_abstimed_wait64 and __futex_abstimed_wait_cancelable64) futex_reltimed_wait{_cancelable} are not needed anymore and can be removed. Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-12-04y2038: Convert gai_suspend to support 64 bit timeLukasz Majewski
This change uses (in gai_misc.h): - __futex_abstimed_wait64 (instead of futex_reltimed_wait) - __futex_abstimed_wait_cancellable64 (instead of futex_reltimed_wait_cancellable) from ./sysdeps/nptl/futex-helpers.h The gai_suspend() accepts relative timeout, which then is converted to absolute one. The i686-gnu port (HURD) do not define DONT_NEED_GAI_MISC_COND and as it doesn't (yet) support 64 bit time it uses not converted pthread_cond_timedwait(). The __gai_suspend() is supposed to be run on ports with __TIMESIZE !=64 and __WORDSIZE==32. It internally utilizes __gai_suspend_time64() and hence the conversion from 32 bit struct timespec to 64 bit one is required. For ports supporting 64 bit time the __gai_suspend_time64() will be used either via alias (to __gai_suspend when __TIMESIZE==64) or redirection (when -D_TIME_BITS=64 is passed). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-12-04x86_64: Add glibc-hwcaps supportFlorian Weimer
The subdirectories match those in the x86-64 psABI: https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9a6b9396884b67c7c Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Process glibc-hwcaps subdirectories in ldconfigFlorian Weimer
Libraries from these subdirectories are added to the cache with a special hwcap bit DL_CACHE_HWCAP_EXTENSION, so that they are ignored by older dynamic loaders. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add extension mechanism to ld.so.cacheFlorian Weimer
A previously unused new-format header field is used to record the address of an extension directory. This change adds a demo extension which records the version of ldconfig which builds a file. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add endianness markup to ld.so.cache (bug 27008)Florian Weimer
Use a reserved byte in the new format cache header to indicate whether the file is in little endian or big endian format. Eventually, this information could be used to provide a unified cache for qemu-user and similiar scenarios. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add glibc-hwcaps support for LD_LIBRARY_PATHFlorian Weimer
This hacks non-power-set processing into _dl_important_hwcaps. Once the legacy hwcaps handling goes away, the subdirectory handling needs to be reworked, but it is premature to do this while both approaches are still supported. ld.so supports two new arguments, --glibc-hwcaps-prepend and --glibc-hwcaps-mask. Each accepts a colon-separated list of glibc-hwcaps subdirectory names. The prepend option adds additional subdirectories that are searched first, in the specified order. The mask option restricts the automatically selected subdirectories to those listed in the option argument. For example, on systems where /usr/lib64 is on the library search path, --glibc-hwcaps-prepend=valgrind:debug causes the dynamic loader to search the directories /usr/lib64/glibc-hwcaps/valgrind and /usr/lib64/glibc-hwcaps/debug just before /usr/lib64 is searched. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-03x86: Fix THREAD_SELF definition to avoid ld.so crash (bug 27004)Jakub Jelinek
The previous definition of THREAD_SELF did not tell the compiler that %fs (or %gs) usage is invalid for the !DL_LOOKUP_GSCOPE_LOCK case in _dl_lookup_symbol_x. As a result, ld.so could try to use the TCB before it was initialized. As the comment in tls.h explains, asm volatile is undesirable here. Using the __seg_fs (or __seg_gs) namespace does not interfere with optimization, and expresses that THREAD_SELF is potentially trapping.
2020-12-03htl: Add hidden def for __pthread_create/detachSamuel Thibault
to avoid a PLT.