about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* nsswitch: handle missing actions properlyDJ Delorie2020-12-1412-4/+110
| | | | | | | | | | | | | Some internal functions need to know if a database has a nonzero list of actions; success getting the database does not guarantee that. Add checks for such as needed. Skip the ":" in each nsswitch.conf line so as not to add a dummy action libnss_:.so See also https://bugzilla.redhat.com/show_bug.cgi?id=1906066 Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* x86: Remove the default REP MOVSB threshold tunable value [BZ #27061]H.J. Lu2020-12-141-2/+4
| | | | | | | | | | | 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>
* elf.h: Remove SHF_GNU_BUILD_NOTE.Mark Wielaard2020-12-121-1/+0
| | | | | SHF_GNU_BUILD_NOTE was a binutils experiment. And it is no longer needed. It was also removed from binutils.
* elf.h: fix spelling typos in commentsDmitry V. Levin2020-12-121-3/+3
| | | | | | | | | | | Since elf.h is a public header file copied to other projects, try to make it free from spelling typos. This change fixes the following spelling typos in comments of elf.h: Auxialiary -> Auxiliary tenatively -> tentatively compatability -> compatibility
* Fix spelling and grammar in several commentsJonny Grant2020-12-125-12/+11
|
* malloc: Detect infinite-loop in _int_free when freeing tcache [BZ#27052]W. Hashimoto2020-12-111-1/+4
| | | | | | | | | | | If linked-list of tcache contains a loop, it invokes infinite loop in _int_free when freeing tcache. The PoC which invokes such infinite loop is on the Bugzilla(#27052). This loop should terminate when the loop exceeds mp_.tcache_count and the program should abort. The affected glibc version is 2.29 or later. Reviewed-by: DJ Delorie <dj@redhat.com>
* elf: Fix dl-load.cSzabolcs Nagy2020-12-111-15/+0
| | | | | Rebasing broke commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2 it was supposed to move code.
* elf: Include libc.so.6 as main program in dependency sort (bug 20972)Florian Weimer2020-12-113-2/+43
| | | | | | | | | | | | | | | | | _dl_map_object_deps always sorts the initially loaded object first during dependency sorting. This means it is relocated last in dl_open_worker. This results in crashes in IFUNC resolvers without lazy bindings if libraries are preloaded that refer to IFUNCs in libc.so.6: the resolvers are called when libc.so.6 has not been relocated yet, so references to _rtld_global_ro etc. crash. The fix is to check against the libc.so.6 link map recorded by the __libc_early_init framework, and let it participate in the dependency sort. This fixes bug 20972. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add support_slibdir_prefix variableFlorian Weimer2020-12-113-0/+10
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]Szabolcs Nagy2020-12-113-19/+43
| | | | | | | | | | | | | | | | | | | | | 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>
* elf: Pass the fd to note processingSzabolcs Nagy2020-12-116-18/+21
| | | | | | | | | | | | | | 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>
* elf: Move note processing after l_phdr is updatedSzabolcs Nagy2020-12-111-0/+15
| | | | | | | | | | | | | Program headers are processed in two pass: after the first pass load segments are mmapped so in the second pass target specific note processing logic can access the notes. The second pass is moved later so various link_map fields are set up that may be useful for note processing such as l_phdr. The second pass should be before the fd is closed so that is available. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* aarch64: align address for BTI protection [BZ #26988]Szabolcs Nagy2020-12-111-6/+8
| | | | | | | | | | | | 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>
* aarch64: Fix missing BTI protection from dependencies [BZ #26926]Szabolcs Nagy2020-12-111-2/+15
| | | | | | | | | | | 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.
* Fix linknamespace errors in nss_database.c if build with -Os.Stefan Liebler2020-12-111-2/+2
| | | | | | | | | | | | | | | | | | | Starting with recent commits, I get 43 conform/.../linknamespace FAILs: - nss: Introduce <nss_module.h> - <nss_action.h>: New abstraction for combining NSS modules and NSS actions - nss: Implement <nss_database.h> (see nss/nss_database.c) - nsswitch: use new internal API (core) - nsswitch: user new internal API (tests) - nsswitch: use new internal API (callers) e.g. conform/XPG42/wordexp.h/linknamespace.out [initial] wordexp -> [libc.a(wordexp.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_database_get -> [libc.a(nss_database.o)] feof_unlocked [initial] wordexp -> [libc.a(wordexp.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_database_get -> [libc.a(nss_database.o)] ferror_unlocked This patch is just using __ferror_unlocked and __feof_unlocked instead of the non "__" prefixed ones. Reviewed-by: DJ Delorie <dj@redhat.com>
* treewide: fix incorrect spelling of indices in commentsDmitry V. Levin2020-12-1110-13/+13
| | | | | | Replace 'indeces' with 'indices', the most annoying of these typos were those found in elf.h which is a public header file copied to other projects.
* linux: Consolidate brk implementationAdhemerval Zanella2020-12-1036-745/+60
| | | | | | | | | | | | | | | 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>
* elf: Include <sys/param.h> in cache.cFlorian Weimer2020-12-101-0/+1
| | | | | The roundup macro is defined there. Relying on an indirect definition is brittle.
* s390x: Add glibc-hwcaps supportFlorian Weimer2020-12-105-1/+186
| | | | | | | 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>
* elf: Fix run-time dependencies of tst-dlopen-fail-2Florian Weimer2020-12-101-1/+1
| | | | | | | | The misattributed dependencies can cause failures in parallel testing if the dependencies have not been built yet. Fixes commit a332bd1518af518c984fad73eba6f46dc5b2b2d4 ("elf: Add elf/tst-dlopenfail-2 [BZ #25396]").
* Handle out-of-memory case in svc_tcp.c/svc_unix.c:rendezvous_request.Stefan Liebler2020-12-104-2/+25
| | | | | | | | | | | | | | | | | | | | | If glibc is build with -O3 on at least 390 (-m31) or x86 (-m32), gcc 11 dumps this warning: svc_tcp.c: In function 'rendezvous_request': svc_tcp.c:274:3: error: 'memcpy' offset [0, 15] is out of the bounds [0, 0] [-Werror=array-bounds] 274 | memcpy (&xprt->xp_raddr, &addr, sizeof (addr)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors In out-of-memory case, if one of the mallocs in makefd_xprt function returns NULL, a message is dumped, makefd_xprt returns NULL and the subsequent memcpy would copy to NULL. Instead of a segfaulting, we delay a bit (see also __svc_accept_failed and Bug 14889 (CVE-2011-4609) - svc_run() produces high cpu usage when accept() fails with EMFILE (CVE-2011-4609). The same applies to svc_unix.c. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix incorrect comparison in sort_priorities_by_nameFlorian Weimer2020-12-091-1/+1
| | | | Reported-By: Stefan Liebler <stli@linux.ibm.com>
* S390: Derive float_t from FLT_EVAL_METHODMarius Hillenbrand2020-12-092-24/+7
| | | | | | | | | | | | | | | | | | 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.
* Fix parsing of /sys/devices/system/cpu/online (bug 25859)Andreas Schwab2020-12-091-2/+3
| | | | The file contains comma-separated ranges, not spaces.
* Make strtoimax, strtoumax, wcstoimax, wcstoumax into aliasesJoseph Myers2020-12-0822-230/+8
| | | | | | | | | | | 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.
* Fixed typos in "NEWS for version 2.32"Paul Zimmermann2020-12-081-10/+10
|
* Add NEWS entry for CVE-2020-29562 (BZ #26923)Siddhesh Poyarekar2020-12-081-0/+3
| | | | BZ #26923 now has a CVE entry, so add a NEWS entry for it.
* iconv: Fix incorrect UCS4 inner loop bounds (BZ#26923)Michael Colavita2020-12-073-13/+55
| | | | | | | | | | | | | | Previously, in UCS4 conversion routines we limit the number of characters we examine to the minimum of the number of characters in the input and the number of characters in the output. This is not the correct behavior when __GCONV_IGNORE_ERRORS is set, as we do not consume an output character when we skip a code unit. Instead, track the input and output pointers and terminate the loop when either reaches its limit. This resolves assertion failures when resetting the input buffer in a step of iconv, which assumes that the input will be fully consumed given sufficient output space.
* x86: Rename readelflib.cH.J. Lu2020-12-062-4/+2
| | | | | Rename linux/i386/readelflib.c to linux/x86/readelflib.c and remove x86_64/readelflib.c.
* nsswitch: use new internal API (callers)DJ Delorie2020-12-0426-262/+88
| | | | | | Stitch new ABI and types throughout all NSS callers. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nsswitch: user new internal API (tests)DJ Delorie2020-12-047-1/+524
| | | | | | Testsuite support and new test for new API. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nsswitch: use new internal API (core)DJ Delorie2020-12-048-845/+168
| | | | | | Core changes to switch the NSS internals to use the new API. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss: Implement <nss_database.h>Florian Weimer2020-12-045-1/+539
| | | | | | | | | | | 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>
* <nss_action.h>: New abstraction for combining NSS modules and NSS actionsFlorian Weimer2020-12-044-1/+423
| | | | | | | | | | nss_action manages a set of lists of actions; these are the portions of the lines in nsswitch.conf to the right of the colons, like "dns [!UNAVAIL=return] files". Each permutation of actions and conditionals is cached for reuse, which limits memory growth, and refers to the static list of modules managed by nss_modules. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss: Introduce <nss_module.h>Florian Weimer2020-12-045-61/+467
| | | | | | | | | | | | | | | | This provides the struct nss_module type, which combines the old struct service_library type with the known_function tree, by statically allocating space for all function pointers. struct nss_module is fairly large (536 bytes), but it will be shared across NSS databases. The old known_function handling had non-some per-function overhead (at least 32 bytes per looked-up function, but more for long function anmes), so overall, this is not too bad. Resolving all functions at load time simplifies locking, and the repeated lookups should be fast because the caches are hot at this point. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Add scripts/move-symbol-to-libc.pyFlorian Weimer2020-12-041-0/+217
| | | | | This helper script can be used to move symbols to libc.abilist across all architectures, while preserving their symbol version.
* powerpc64le: Add glibc-hwcaps supportFlorian Weimer2020-12-045-1/+135
| | | | | The "power10" and "power9" subdirectories are selected in a way that matches the -mcpu=power10 and -mcpu=power9 options of GCC.
* x86: Adjust tst-cpu-features-supports.c for GCC 11H.J. Lu2020-12-041-5/+10
| | | | | | 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.
* x86: Set RDRAND usable if CPU supports RDRANDH.J. Lu2020-12-041-0/+1
| | | | Set RDRAND usable if CPU supports RDRAND.
* elf: Add missing <stddef.h> header to elf/dl-hwcaps.hMatheus Castanho2020-12-041-0/+1
| | | | | The lack of this header makes size_t unavailable on builds configured with --disable-tunables, causing compilation errors.
* lowlevellock-futex: Remove not used macrosLukasz Majewski2020-12-041-43/+0
| | | | | | | | | | | | 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>
* futex: Remove not used futex_reltimed_wait{_cancelable}Lukasz Majewski2020-12-041-61/+0
| | | | | | | | | | | | | 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>
* y2038: Convert gai_suspend to support 64 bit timeLukasz Majewski2020-12-043-29/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* symbols: Add defines for libanl's libanl_hidden_{def|proto}Lukasz Majewski2020-12-041-0/+8
| | | | | | | | | The __gai_suspend_time64, which supports 64 bit time on ports with __WORDSIZE == 32 && __TIMESIZE != 64, shall be exported from libanl (the same library from which original gai_suspend is exported). Up till now there were no defines for this library. This commit adds them.
* x86_64: Add glibc-hwcaps supportFlorian Weimer2020-12-045-1/+192
| | | | | | | | 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>
* elf: Add glibc-hwcaps subdirectory support to ld.so cache processingFlorian Weimer2020-12-0410-3/+508
| | | | | | | | | | | | | | This recognizes the DL_CACHE_HWCAP_EXTENSION flag in cache entries, and picks the supported cache entry with the highest priority. The elf/tst-glibc-hwcaps-prepend-cache test documents a non-desired aspect of the current cache implementation: If the cache selects a DSO that does not exist on disk, _dl_map_object falls back to open_path, which may or may not find an alternative implementation. This is an existing limitation that also applies to the legacy hwcaps processing for ld.so.cache. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Process glibc-hwcaps subdirectories in ldconfigFlorian Weimer2020-12-044-53/+427
| | | | | | | | 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>
* elf: Implement tail merging of strings in ldconfigFlorian Weimer2020-12-042-39/+40
| | | | | | | | | | | | | This simplifies the string table construction in elf/cache.c because there is no more need to keep track of offsets explicitly; the string table implementation does this internally. This change slightly reduces the size of the cache on disk. The file format does not change as a result. The strings are null-terminated, without explicit length, so tail merging is transparent to readers. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Implement a string table for ldconfig, with tail mergingFlorian Weimer2020-12-045-1/+488
| | | | | | | | | | | | | | | | This will be used in ldconfig to reduce the ld.so.cache size slightly. Tail merging is an optimization where a pointer points into another string if the first string is a suffix of the second string. The hash function FNV-1a was chosen because it is simple and achieves good dispersion even for short strings (so that the hash table bucket count can be a power of two). It is clearly superior to the hsearch hash and the ELF hash in this regard. The hash table uses chaining for collision resolution. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Add extension mechanism to ld.so.cacheFlorian Weimer2020-12-042-1/+211
| | | | | | | | | | 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>