aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-04-03x86: Set FSGSBASE to active if enabled by kernelH.J. Lu4-0/+58
Linux kernel uses AT_HWCAP2 to indicate if FSGSBASE instructions are enabled. If the HWCAP2_FSGSBASE bit in AT_HWCAP2 is set, FSGSBASE instructions can be used in user space. Define dl_check_hwcap2 to set the FSGSBASE feature to active on Linux when the HWCAP2_FSGSBASE bit is set. Add a test to verify that FSGSBASE is active on current kernels. NB: This test will fail if the kernel doesn't set the HWCAP2_FSGSBASE bit in AT_HWCAP2 while fsgsbase shows up in /proc/cpuinfo. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2023-04-03x86_64: Fix asm constraints in feraiseexcept (bug 30305)Florian Weimer1-2/+2
The divss instruction clobbers its first argument, and the constraints need to reflect that. Fortunately, with GCC 12, generated code does not actually change, so there is no externally visible bug. Suggested-by: Jakub Jelinek <jakub@redhat.com> Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-04-03manual: Document __wur usage under _FORTIFY_SOURCESiddhesh Poyarekar1-0/+3
The __warn_unused_result__ attribute is only enabled when fortification is enabled. Mention that in the document. The rationale for this is essentially to mitigate against CWE-252: [1] https://cwe.mitre.org/data/definitions/252.html Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2023-04-03hurd: Microoptimize _hurd_self_sigstate ()Sergey Bugaev1-3/+5
When THREAD_GETMEM is defined with inline assembly, the compiler may not optimize away the two reads of _hurd_sigstate. Help it out a little bit by only reading it once. This also makes for a slightly cleaner code. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-32-bugaevc@gmail.com>
2023-04-03hurd: Add vm_param.h for x86_64Sergey Bugaev1-0/+24
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-30-bugaevc@gmail.com>
2023-04-03hurd: Implement _hurd_longjmp_thread_state for x86_64Sergey Bugaev1-0/+41
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-29-bugaevc@gmail.com>
2023-04-03htl: Implement thread_set_pcsptp for x86_64Sergey Bugaev1-0/+73
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-23-bugaevc@gmail.com>
2023-04-03x86_64: Add rtld-stpncpy & rtld-strncpySergey Bugaev2-0/+36
Just like the other existing rtld-str* files, this provides rtld with usable versions of stpncpy and strncpy. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-22-bugaevc@gmail.com>
2023-04-03htl: Add tcb-offsets.sym for x86_64Sergey Bugaev2-0/+28
The source code is the same as sysdeps/i386/htl/tcb-offsets.sym, but of course the produced tcb-offsets.h will be different. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-21-bugaevc@gmail.com>
2023-04-03hurd: Move a couple of signal-related files to x86Sergey Bugaev2-0/+0
These do not need any changes to be used on x86_64. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-20-bugaevc@gmail.com>
2023-04-03hurd: Use uintptr_t for register values in trampoline.cSergey Bugaev1-7/+6
This is more correct, if only because these fields are defined as having the type unsigned int in the Mach headers, so casting them to a signed int and then back is suboptimal. Also, remove an extra reassignment of uesp -- this is another remnant of the ecx kludge. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-16-bugaevc@gmail.com>
2023-04-03hurd: Move rtld-strncpy-c.c out of mach/hurd/Sergey Bugaev1-0/+0
There's nothing Mach- or Hurd-specific about it; any port that ends up with rtld pulling in strncpy will need this. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-15-bugaevc@gmail.com>
2023-04-03hurd: More 64-bit integer casting fixesSergey Bugaev2-4/+4
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-13-bugaevc@gmail.com>
2023-04-03mach, hurd: Drop __libc_lock_self0Sergey Bugaev3-8/+3
This was used for the value of libc-lock's owner when TLS is not yet set up, so THREAD_SELF can not be used. Since the value need not be anything specific -- it just has to be non-NULL -- we can just use a plain constant, such as (void *) 1, for this. This avoids accessing the symbol through GOT, and exporting it from libc.so in the first place. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-12-bugaevc@gmail.com>
2023-04-03stdio-common: Fix building when !IS_IN (libc)Sergey Bugaev1-0/+2
In this case, _itoa_word () is already defined inline in the header (see sysdeps/generic/_itoa.h), and the second definition causes an error. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-11-bugaevc@gmail.com>
2023-04-03hurd: Fix _hurd_setup_sighandler () signatureSergey Bugaev1-5/+5
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-10-bugaevc@gmail.com>
2023-04-03hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtldSergey Bugaev1-2/+5
hurd/lookup-retry.c is compiled into rtld, the dynamic linker/loader. To avoid pulling in file_set_size, file_utimens, tty/ctty stuff, more string/memory code (memmove, strncpy, strcpy), and more strtoul/itoa code, compile out support for O_TRUNC and FS_RETRY_MAGICAL when building hurd/lookup-retry.c for rtld. None of that functionality is useful to rtld during startup anyway. Keep support for FS_RETRY_MAGICAL("/"), since that does not pull in much, and is required for following absolute symlinks. The large number of extra code being pulled into rtld was noticed by reviewing librtld.map & elf/librtld.os.map in the build tree. It is worth noting that once libc.so is loaded, the real __open, __stat, etc. replace the minimal versions used initially by rtld -- this is especially important in the Hurd port, where the minimal rtld versions do not use the dtable and just pass real Mach port names as fds. Thus, once libc.so is loaded, rtld will gain access to the full __hurd_file_name_lookup_retry () version, complete with FS_RETRY_MAGICAL support, which is important in case the program decides to dlopen ("/proc/self/fd/...") or some such. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-9-bugaevc@gmail.com>
2023-04-03hurd: Fix file name in #errorSergey Bugaev1-1/+1
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-8-bugaevc@gmail.com>
2023-04-03hurd: Swap around two function callsSergey Bugaev1-4/+4
...to keep `sigexc' port initialization in one place, and match what the comments say. No functional change. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-7-bugaevc@gmail.com>
2023-04-03hurd: Remove __hurd_threadvar_stack_{offset,mask}Sergey Bugaev6-46/+2
Noone is or should be using __hurd_threadvar_stack_{offset,mask}, we have proper TLS now. These two remaining variables are never set to anything other than zero, so any code that would try to use them as described would just dereference a zero pointer and crash. So remove them entirely. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-6-bugaevc@gmail.com>
2023-04-03hurd: Make exception subcode a longSergey Bugaev3-4/+5
On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory address, so it needs to be (at least) pointer-sized. Thus, make it into a long. This matches the corresponding change in GNU Mach. Message-Id: <20230319151017.531737-5-bugaevc@gmail.com>
2023-03-31time: Fix strftime(3) API regarding nullabilityAlejandro Colomar1-1/+2
strftime(3) doesn't accept null pointers in any of the parameters. Cc: Paul Eggert <eggert@cs.ucla.edu> Signed-off-by: Alejandro Colomar <alx@kernel.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-30Update arm libm-tests-ulpsAdhemerval Zanella1-0/+1
For the next test from cf7ffdd8a5f6da55397e10b3860062944312824c.
2023-03-30getlogin_r: fix missing fallback if loginuid is unset (bug 30235)Andreas Schwab1-4/+1
When /proc/self/loginuid is not set, we should still fall back to using the traditional utmp lookup, instead of failing right away.
2023-03-29memalign: Support scanning for aligned chunks.DJ Delorie3-28/+390
This patch adds a chunk scanning algorithm to the _int_memalign code path that reduces heap fragmentation by reusing already aligned chunks instead of always looking for chunks of larger sizes and splitting them. The tcache macros are extended to allow removing a chunk from the middle of the list. The goal is to fix the pathological use cases where heaps grow continuously in workloads that are heavy users of memalign. Note that tst-memalign-2 checks for tcache operation, which malloc-check bypasses. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-29malloc: Use C11 atomics on memusageAdhemerval Zanella1-82/+111
Checked on x86_64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
2023-03-29Remove --enable-tunables configure optionAdhemerval Zanella Netto48-513/+75
And make always supported. The configure option was added on glibc 2.25 and some features require it (such as hwcap mask, huge pages support, and lock elisition tuning). It also simplifies the build permutations. Changes from v1: * Remove glibc.rtld.dynamic_sort changes, it is orthogonal and needs more discussion. * Cleanup more code. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-03-29Remove --disable-experimental-malloc optionAdhemerval Zanella8-39/+4
It is the default since 2.26 and it has bitrotten over the years, By using it multiple malloc tests fails: FAIL: malloc/tst-memalign-2 FAIL: malloc/tst-memalign-2-malloc-hugetlb1 FAIL: malloc/tst-memalign-2-malloc-hugetlb2 FAIL: malloc/tst-memalign-2-mcheck FAIL: malloc/tst-mxfast-malloc-hugetlb1 FAIL: malloc/tst-mxfast-malloc-hugetlb2 FAIL: malloc/tst-tcfree2 FAIL: malloc/tst-tcfree2-malloc-hugetlb1 FAIL: malloc/tst-tcfree2-malloc-hugetlb2 Checked on x86_64-linux-gnu. Reviewed-by: DJ Delorie <dj@redhat.com>
2023-03-28Allow building with --disable-nscd againFlavio Cruz1-0/+6
The change 88677348b4de breaks the build with undefiend references to the NSCD functions.
2023-03-28system: Add "--" after "-c" for sh (BZ #28519)Joe Simmons-Talbott4-2/+22
Prevent sh from interpreting a user string as shell options if it starts with '-' or '+'. Since the version of /bin/sh used for testing system() is different from the full-fledged system /bin/sh add support to it for handling "--" after "-c". Add a testcase to ensure the expected behavior. Signed-off-by: Joe Simmons-Talbott <josimmon@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-28posix: Fix some crashes in wordexp [BZ #18096]Julian Squires2-7/+8
Without these fixes, the first three included tests segfault (on a NULL dereference); the fourth aborts on an assertion, which is itself unnecessary. Signed-off-by: Julian Squires <julian@cipht.net> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-28LoongArch: ldconfig: Add comments for using EF_LARCH_OBJABI_V1caiyinyu1-0/+6
We added Adhemerval Zanella's comment to explain the reason for using EF_LARCH_OBJABI_V1.
2023-03-27elf: Take into account ${sysconfdir} in elf/tst-ldconfig-p.shRomain Geissler2-6/+7
Take into account ${sysconfdir} in elf/tst-ldconfig-p.sh. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-27Fix tst-glibc-hwcaps-prepend-cache with custom configure prefix valueRomain Geissler1-3/+7
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-27Fix tst-ldconfig-ld_so_conf-update with custom configure prefix valueRomain Geissler1-5/+8
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-27support: introduce support_sysconfdir_prefixRomain Geissler3-1/+11
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-03-27Remove set-hooks.h from generic includesAdhemerval Zanella Netto1-0/+0
The hooks mechanism uses symbol sets for running lists of functions, which requires either extra linker directives to provide any hardening (such as RELRO) or additional code (such as pointer obfuscation via mangling with random value). Currently only hurd uses set-hooks.h so we remove it from the generic includes. The generic implementation uses direct function calls which provide hardening and good code generation, observability and debugging without the need for extra linking options or special code handling. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27Remove --with-default-link configure optionAdhemerval Zanella Netto8-51/+7
Now that there is no need to use a special linker script to hardening internal data structures, remove the --with-default-link configure option and associated definitions. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27libio: Remove the usage of __libc_IO_vtablesAdhemerval Zanella Netto22-513/+637
Instead of using a special ELF section along with a linker script directive to put the IO vtables within the RELRO section, the libio vtables are all moved to an array marked as data.relro (so linker will place in the RELRO segment without the need of extra directives). To avoid static linking namespace issues and including all vtable referenced objects, all required function pointers are set to weak alias. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27libio: Do not autogenerate stdio_lim.hAdhemerval Zanella Netto6-69/+43
Instead define the required fields in system dependend files. The only system dependent definition is FILENAME_MAX, which should match POSIX PATH_MAX, and it is obtained from either kernel UAPI or mach headers. Currently set pre-defined value from current kernels. It avoids a circular dependendy when including stdio.h in gen-as-const-headers files. Checked on x86_64-linux-gnu and i686-linux-gnu Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functionsAdhemerval Zanella Netto90-243/+584
They are both used by __libc_freeres to free all library malloc allocated resources to help tooling like mtrace or valgrind with memory leak tracking. The current scheme uses assembly markers and linker script entries to consolidate the free routine function pointers in the RELRO segment and to be freed buffers in BSS. This patch changes it to use specific free functions for libc_freeres_ptrs buffers and call the function pointer array directly with call_function_static_weak. It allows the removal of both the internal macros and the linker script sections. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-03-27benchtests: Move libmvec benchtest inputs to benchtests directoryJoe Ramsay53-1/+1
This allows other targets to use the same inputs for their own libmvec microbenchmarks without having to duplicate them in their own subdirectory. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2023-03-27stdio-common: tests: don't double-define _FORTIFY_SOURCESam James1-1/+1
Exactly the same as 35bcb08eaa953c9b8bef6ab2486dc4361e1f26c0. If using -D_FORITFY_SOURCE=3 (in my case, I've patched GCC to add =3 instead of =2 (we've done =2 for years in Gentoo)), building glibc tests will fail on tst-bz11319-fortify2 like: ``` <command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror] <built-in>: note: this is the location of the previous definition cc1: all warnings being treated as errors ``` It's just because we're always setting -D_FORTIFY_SOURCE=2 rather than unsetting it first. If F_S is already 2, it's harmless, but if it's another value (say, 1, or 3), the compiler will bawk. (I'm not aware of a reason this couldn't be tested with =3, but the toolchain support is limited for that (too new), and we want to run the tests everywhere possible.) As Siddhesh noted previously, we could implement some fallback logic to determine the maximal F_S value supported by the toolchain, which is a bit easier now that autoconf-archive has been updated for F_S=3 (https://github.com/autoconf-archive/autoconf-archive/pull/269), but let's revisit this if it continues to crop up. Signed-off-by: Sam James <sam@gentoo.org> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-03-27LoongArch: ldconfig: Ignore EF_LARCH_OBJABI_V1 in shared objectsXi Ruoyao1-1/+1
Binutils 2.40 sets EF_LARCH_OBJABI_V1 for shared objects: $ ld --version | head -n1 GNU ld (GNU Binutils) 2.40 $ echo 'int dummy;' > dummy.c $ cc dummy.c -shared $ readelf -h a.out | grep Flags Flags: 0x43, DOUBLE-FLOAT, OBJ-v1 We need to ignore it in ldconfig or ldconfig will consider all shared objects linked by Binutils 2.40 "unsupported". Maybe we should stop setting EF_LARCH_OBJABI_V1 for shared objects, but Binutils 2.40 is already released and we cannot change it.
2023-03-27_dl_map_object_from_fd: Remove unnecessary debugger notification in error pathAndreas Schwab1-11/+1
After commit ed3ce71f5c ("elf: Move la_activity (LA_ACT_ADD) after _dl_add_to_namespace_list() (BZ #28062)") it is no longer necessary to reset the debugger state in the error case, since the debugger notification only happens after no more errors can occur.
2023-03-26hppa: Drop 16-byte pthread lock alignmentJohn David Anglin2-3/+9
Linux threads were removed about 12 years ago and the current nptl implementation only requires 4-byte alignment for pthread locks. The 16-byte alignment causes various issues. For example in building ignition-msgs, we have: /usr/include/google/protobuf/map.h:124:37: error: static assertion failed 124 | static_assert(alignof(value_type) <= 8, ""); | ~~~~~~~~~~~~~~~~~~~~^~~~ This is caused by the 16-byte pthread lock alignment. Signed-off-by: John David Anglin <dave.anglin@bell.net>
2023-03-26Minor: don't call _dl_debug_update (which can have side effects) inside assertPaul Pluzhnikov1-2/+6
2023-03-21x86: Don't check PREFETCHWT1 in tst-cpu-features-cpuinfo.cDJ Delorie1-0/+3
Don't check PREFETCHWT1 against /proc/cpuinfo since kernel doesn't report PREFETCHWT1 in /proc/cpuinfo. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-03-14Declare wcstofN, wcstofNx for C2xJoseph Myers1-14/+16
WG14 accepted the changes in N3105 to define wcstofN and wcstofNx functions for C2x. Thus enable those for C2x (given also __GLIBC_USE (IEC_60559_TYPES_EXT) and support for the relevant _FloatN / _FloatNx type) rather than only for __USE_GNU. Tested for x86_64.
2023-03-14Update printf %b/%B C2x supportJoseph Myers4-1/+95
WG14 recently accepted two additions to the printf/scanf %b/%B support: there are now PRIb* and SCNb* macros in <inttypes.h>, and printf %B is now an optional feature defined in normative text, instead of recommended practice, with corresponding PRIB* macros that can also be used to test whether that optional feature is supported. See N3072 items 14 and 15 for details (those changes were accepted, some other changes in that paper weren't). Add the corresponding PRI* macros to glibc and update one place in the manual referring to %B as recommended. (SCNb* should naturally be added at the same time as the corresponding scanf %b support.) Tested for x86_64 and x86.