Adhemerval Zanella [Tue, 29 Dec 2020 20:32:25 +0000 (17:32 -0300)]
posix: Sync regex code with gnulib
It sync with gnulib commit
43ee1a6bf. The main change is
9682f18e9.
(which does not have a meaniful description).
Checked on x86_64-linux-gnu.
Siddhesh Poyarekar [Fri, 1 Jan 2021 00:57:11 +0000 (06:27 +0530)]
Move generic nan-pseudo-number.h to ldbl-96
The concept of pseudo number formats only exists in the realm of the
96 bit long double format.
Paul Eggert [Sat, 2 Jan 2021 20:46:25 +0000 (12:46 -0800)]
Sync FDL from https://gnu.org/licenses/fdl-1.3.texi
Paul Eggert [Sat, 2 Jan 2021 20:43:58 +0000 (12:43 -0800)]
Sync move-if-change from Gnulib
This alters move-if-change so that its --version option outputs
the correct copyright date automatically. One less thing
to update by hand.
Paul Eggert [Sat, 2 Jan 2021 19:56:24 +0000 (11:56 -0800)]
Update automatically-generated copyright dates
These were updated simply by running "make" to regen the files.
Paul Eggert [Sat, 2 Jan 2021 19:47:54 +0000 (11:47 -0800)]
Update copyright dates not handled by scripts/update-copyrights.
I've updated copyright dates in glibc for 2021. This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files. As well as the usual annual
updates, mainly dates in --version output (minus csu/version.c which
previously had to be handled manually but is now successfully updated
by update-copyrights), there is a small change to the copyright notice
in NEWS which should let NEWS get updated automatically next year.
Please remember to include 2021 in the dates for any new files added
in future (which means updating any existing uncommitted patches you
have that add new files to use the new copyright dates in them).
Paul Eggert [Sat, 2 Jan 2021 19:32:25 +0000 (11:32 -0800)]
Update copyright dates with scripts/update-copyrights
I used these shell commands:
../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")
and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 6694 files FOO.
I then removed trailing white space from benchtests/bench-pthread-locks.c
and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this
diagnostic from Savannah:
remote: *** pre-commit check failed ...
remote: *** error: lines with trailing whitespace found
remote: error: hook declined to update refs/heads/master
Szabolcs Nagy [Thu, 17 Dec 2020 10:03:05 +0000 (10:03 +0000)]
aarch64: use PTR_ARG and SIZE_ARG instead of DELOUSE
DELOUSE was added to asm code to make them compatible with non-LP64
ABIs, but it is an unfortunate name and the code was not compatible
with ABIs where pointer and size_t are different. Glibc currently
only supports the LP64 ABI so these macros are not really needed or
tested, but for now the name is changed to be more meaningful instead
of removing them completely.
Some DELOUSE macros were dropped: clone, strlen and strnlen used it
unnecessarily.
The out of tree ILP32 patches are currently not maintained and will
likely need a rework to rebase them on top of the time64 changes.
Siddhesh Poyarekar [Tue, 15 Dec 2020 18:20:09 +0000 (23:50 +0530)]
nonstring: Enable __FORTIFY_LEVEL=3
Use __builtin_dynamic_object_size in the remaining functions that
don't have compiler builtins as is the case for string functions.
Siddhesh Poyarekar [Wed, 30 Dec 2020 05:39:58 +0000 (11:09 +0530)]
string: Enable __FORTIFY_LEVEL=3
This change enhances fortified string functions to use
__builtin_dynamic_object_size under _FORTIFY_SOURCE=3 whenever the
compiler supports it.
Siddhesh Poyarekar [Wed, 30 Dec 2020 06:24:00 +0000 (11:54 +0530)]
Introduce _FORTIFY_SOURCE=3
Introduce a new _FORTIFY_SOURCE level of 3 to enable additional
fortifications that may have a noticeable performance impact, allowing
more fortification coverage at the cost of some performance.
With llvm 9.0 or later, this will replace the use of
__builtin_object_size with __builtin_dynamic_object_size.
__builtin_dynamic_object_size
-----------------------------
__builtin_dynamic_object_size is an LLVM builtin that is similar to
__builtin_object_size. In addition to what __builtin_object_size
does, i.e. replace the builtin call with a constant object size,
__builtin_dynamic_object_size will replace the call site with an
expression that evaluates to the object size, thus expanding its
applicability. In practice, __builtin_dynamic_object_size evaluates
these expressions through malloc/calloc calls that it can associate
with the object being evaluated.
A simple motivating example is below; -D_FORTIFY_SOURCE=2 would miss
this and emit memcpy, but -D_FORTIFY_SOURCE=3 with the help of
__builtin_dynamic_object_size is able to emit __memcpy_chk with the
allocation size expression passed into the function:
void *copy_obj (const void *src, size_t alloc, size_t copysize)
{
void *obj = malloc (alloc);
memcpy (obj, src, copysize);
return obj;
}
Limitations
-----------
If the object was allocated elsewhere that the compiler cannot see, or
if it was allocated in the function with a function that the compiler
does not recognize as an allocator then __builtin_dynamic_object_size
also returns -1.
Further, the expression used to compute object size may be non-trivial
and may potentially incur a noticeable performance impact. These
fortifications are hence enabled at a new _FORTIFY_SOURCE level to
allow developers to make a choice on the tradeoff according to their
environment.
Siddhesh Poyarekar [Thu, 10 Dec 2020 11:17:02 +0000 (16:47 +0530)]
Warn on unsupported fortification levels
Make the _FORTIFY_SOURCE macro soup in features.h warn about
unsupported fortification levels. For example, it will warn about
_FORTIFY_SOURCE=3 and over with an indication of which level has been
selected.
Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
Matheus Castanho [Thu, 3 Dec 2020 17:15:28 +0000 (14:15 -0300)]
powerpc: Use scv instruction on clone when available
clone already uses r31 to temporarily save input arguments before doing the
syscall, so we use a different register to read from the TCB. We can also avoid
allocating another stack frame, which is not needed since we can simply extend
the usage of the red zone.
Tested-by: Lucas A. M. Magalhães <lamm@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Matheus Castanho [Thu, 3 Dec 2020 17:15:27 +0000 (14:15 -0300)]
powerpc: Runtime selection between sc and scv for syscalls
Linux kernel v5.9 added support for system calls using the scv
instruction for POWER9 and later. The new codepath provides better
performance (see below) if compared to using sc. For the
foreseeable future, both sc and scv mechanisms will co-exist, so this
patch enables glibc to do a runtime check and use scv when it is
available.
Before issuing the system call to the kernel, we check hwcap2 in the TCB
for PPC_FEATURE2_SCV to see if scv is supported by the kernel. If not,
we fallback to sc and keep the old behavior.
The kernel implements a different error return convention for scv, so
when returning from a system call we need to handle the return value
differently depending on the instruction we used to enter the kernel.
For syscalls implemented in ASM, entry and exit are implemented by
different macros (PSEUDO and PSEUDO_RET, resp.), which may be used in
sequence (e.g. for templated syscalls) or with other instructions in
between (e.g. clone). To avoid accessing the TCB a second time on
PSEUDO_RET to check which instruction we used, the value read from
hwcap2 is cached on a non-volatile register.
This is not needed when using INTERNAL_SYSCALL macro, since entry and
exit are bundled into the same inline asm directive.
The dynamic loader may issue syscalls before the TCB has been setup
so it always uses sc with no extra checks. For the static case, there
is no compile-time way to determine if we are inside startup code,
so we also check the value of the thread pointer before effectively
accessing the TCB. For such situations in which the availability of
scv cannot be determined, sc is always used.
Support for scv in syscalls implemented in their own ASM file (clone and
vfork) will be added later. For now simply use sc as before.
Average performance over 1M calls for each syscall "type":
- stat: C wrapper calling INTERNAL_SYSCALL
- getpid: templated ASM syscall
- syscall: call to gettid using syscall function
Standard:
stat : 1.573445 us / ~3619 cycles
getpid : 0.164986 us / ~379 cycles
syscall : 0.162743 us / ~374 cycles
With scv:
stat : 1.537049 us / ~3535 cycles <~ -84 cycles / -2.32%
getpid : 0.109923 us / ~253 cycles <~ -126 cycles / -33.25%
syscall : 0.116410 us / ~268 cycles <~ -106 cycles / -28.34%
Tested on powerpc, powerpc64, powerpc64le (with and without scv)
Tested-by: Lucas A. M. Magalhães <lamm@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Adhemerval Zanella [Tue, 29 Dec 2020 20:12:21 +0000 (17:12 -0300)]
malloc: preserve errno on mcheck hooks [BZ #17924]
Similar to the fix
69fda43b8d, save and restore errno for the hook
functions used for MALLOC_CHECK_=3.
It fixes the malloc/tst-free-errno-mcheck regression.
Checked on x86_64-linux-gnu.
Siddhesh Poyarekar [Thu, 24 Dec 2020 02:44:20 +0000 (08:14 +0530)]
x86 long double: Add tests for pseudo normal numbers
Add some tests for fpclassify, isnan, isinf and issignaling.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Siddhesh Poyarekar [Thu, 24 Dec 2020 02:27:25 +0000 (07:57 +0530)]
x86 long double: Consider pseudo numbers as signaling
Add support to treat pseudo-numbers specially and implement x86
version to consider all of them as signaling.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Adhemerval Zanella [Mon, 26 Oct 2020 11:58:01 +0000 (08:58 -0300)]
io: Remove xmknod{at} implementations
With xmknod wrapper functions removed (
589260cef8), the mknod functions
are now properly exported, and version is done using symbols versioning
instead of the extra _MKNOD_* argument.
It also allows us to consolidate Linux and Hurd mknod implementation.
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Adhemerval Zanella [Fri, 23 Oct 2020 19:40:06 +0000 (16:40 -0300)]
io: Remove xstat implementations
With xstat wrapper functions removed (
8ed005daf0), the stat functions
are now properly exported, and version is done using symbols versioning
instead of the extra _STAT_* argument.
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Paul Eggert [Tue, 29 Dec 2020 08:45:49 +0000 (00:45 -0800)]
free: preserve errno [BZ#17924]
In the next release of POSIX, free must preserve errno
<https://www.austingroupbugs.net/view.php?id=385>.
Modify __libc_free to save and restore errno, so that
any internal munmap etc. syscalls do not disturb the caller's errno.
Add a test malloc/tst-free-errno.c (almost all by Bruno Haible),
and document that free preserves errno.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Samuel Thibault [Tue, 29 Dec 2020 02:26:12 +0000 (03:26 +0100)]
hurd: Accept including hurd/version.h
We need it to get the RPC API version.
Samuel Thibault [Mon, 28 Dec 2020 22:37:04 +0000 (23:37 +0100)]
hurd: Add WSTOPPED/WCONTINUED/WEXITED/WNOWAIT support [BZ #23091]
The new __proc_waitid RPC now expects WEXITED to be passed, allowing to
properly implement waitid, and thus define the missing W* macros
(according to FreeBSD values).
Samuel Thibault [Mon, 28 Dec 2020 22:05:14 +0000 (23:05 +0100)]
support: Make support_process_state_wait wait less
Tests such as posix/tst-waitid.c make heavy use of
support_process_state_wait, and thus on non-Linux where it falls back
to sleeping, a 2s sleep makes such test time out, while 1s remains
fine enough.
Samuel Thibault [Sat, 26 Dec 2020 16:57:52 +0000 (17:57 +0100)]
hurd: set sigaction for signal preemptors in arch-independent file
Instead of having the arch-specific trampoline setup code detect whether
preemption happened or not, we'd rather pass it the sigaction. In the
future, this may also allow to change sa_flags from post_signal().
Samuel Thibault [Sat, 26 Dec 2020 15:39:40 +0000 (16:39 +0100)]
hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argv
When argv is empty, we need to add the original script to be run on the
shell command line.
Samuel Thibault [Sat, 26 Dec 2020 14:12:04 +0000 (15:12 +0100)]
hurd: Try shell in posix_spawn* only in compat mode
Reported by Bruno Haible <bruno@clisp.org>
H.J. Lu [Thu, 24 Dec 2020 23:43:34 +0000 (15:43 -0800)]
Remove _ISOMAC check from <cpu-features.h>
Remove _ISOMAC check from <cpu-features.h> since it isn't an installer
header file.
H.J. Lu [Thu, 24 Dec 2020 02:34:34 +0000 (18:34 -0800)]
x86: Remove the duplicated CPU_FEATURE_CPU_P
CPU_FEATURE_CPU_P is defined in sysdeps/x86/sys/platform/x86.h. Remove
the duplicated CPU_FEATURE_CPU_P in sysdeps/x86/include/cpu-features.h.
Siddhesh Poyarekar [Tue, 15 Dec 2020 10:36:48 +0000 (16:06 +0530)]
Partially revert
681900d29683722b1cb0a8e565a0585846ec5a61
Do not attempt to fix the significand top bit in long double input
received in printf. The code should never reach here because isnan
should now detect unnormals as NaN. This is already a NOP for glibc
since it uses the gcc __builtin_isnan, which detects unnormals as NaN.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Siddhesh Poyarekar [Wed, 23 Dec 2020 08:32:02 +0000 (14:02 +0530)]
x86 long double: Support pseudo numbers in isnanl
This syncs up isnanl behaviour with gcc. Also move the isnanl
implementation to sysdeps/x86 and remove the sysdeps/x86_64 version.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Siddhesh Poyarekar [Wed, 23 Dec 2020 08:23:34 +0000 (13:53 +0530)]
x86 long double: Support pseudo numbers in fpclassifyl
Also move sysdeps/i386/fpu/s_fpclassifyl.c to
sysdeps/x86/fpu/s_fpclassifyl.c and remove
sysdeps/x86_64/fpu/s_fpclassifyl.c
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Siddhesh Poyarekar [Wed, 23 Dec 2020 02:11:17 +0000 (07:41 +0530)]
MTE: Do not pad size in realloc_check
The MTE patch to add malloc support incorrectly padded the size passed
to _int_realloc by SIZE_SZ when it ought to have sent just the
chunksize. Revert that bit of the change so that realloc works
correctly with MALLOC_CHECK_ set.
This also brings the realloc_check implementation back in sync with
libc_realloc.
Siddhesh Poyarekar [Wed, 23 Dec 2020 07:34:45 +0000 (13:04 +0530)]
tests-mcheck: New variable to run tests with MALLOC_CHECK_=3
This new variable allows various subsystems in glibc to run all or
some of their tests with MALLOC_CHECK_=3. This patch adds
infrastructure support for this variable as well as an implementation
in malloc/Makefile to allow running some of the tests with
MALLOC_CHECK_=3.
At present some tests in malloc/ have been excluded from the mcheck
tests either because they're specifically testing MALLOC_CHECK_ or
they are failing in master even without the Memory Tagging patches
that prompted this work. Some tests were reviewed and found to need
specific error points that MALLOC_CHECK_ defeats by terminating early
but a thorough review of all tests is needed to bring them into mcheck
coverage.
The following failures are seen in current master:
FAIL: malloc/tst-malloc-fork-deadlock-mcheck
FAIL: malloc/tst-malloc-stats-cancellation-mcheck
FAIL: malloc/tst-malloc-thread-fail-mcheck
FAIL: malloc/tst-realloc-mcheck
FAIL: malloc/tst-reallocarray-mcheck
All of these are due to the Memory Tagging patchset and will be fixed
separately.
Florian Weimer [Wed, 23 Dec 2020 11:07:20 +0000 (12:07 +0100)]
elf: Account for glibc-hwcaps/ prefix in _dl_important_hwcaps
Siddhesh Poyarekar [Wed, 23 Dec 2020 01:33:42 +0000 (07:03 +0530)]
misc: Use __ferror_unlocked instead of ferror
The ferror results in an unnecessary PLT reference. Use
__ferror_unlocked instead , which gets inlined.
Florian Weimer [Tue, 22 Dec 2020 18:20:56 +0000 (19:20 +0100)]
s390x: Regenerate ulps
For new inputs added in commit
cad5ad81d2f7f58a7ad0d8afa8c1b710,
as seen on a z13 system.
Florian Weimer [Tue, 22 Dec 2020 18:20:56 +0000 (19:20 +0100)]
powerpc: Regenerate ulps
For new inputs added in commit
cad5ad81d2f7f58a7ad0d8afa8c1b710,
as seen on a POWER8 system.
Siddhesh Poyarekar [Tue, 22 Dec 2020 11:48:12 +0000 (17:18 +0530)]
addmntent: Remove unbounded alloca usage from getmntent [BZ#27083]
The addmntent function replicates elements of struct mnt on stack
using alloca, which is unsafe. Put characters directly into the
stream, escaping them as they're being written out.
Also add a test to check all escaped characters with addmntent and
getmntent.
H.J. Lu [Tue, 22 Dec 2020 03:56:10 +0000 (19:56 -0800)]
<sys/platform/x86.h>: Add Intel LAM support
Add Intel Linear Address Masking (LAM) support to <sys/platform/x86.h>.
HAS_CPU_FEATURE (LAM) can be used to detect if LAM is enabled in CPU.
LAM modifies the checking that is applied to 64-bit linear addresses,
allowing software to use of the untranslated address bits for metadata.
Florian Weimer [Mon, 21 Dec 2020 17:17:54 +0000 (18:17 +0100)]
i386: Regenerate ulps
For new inputs added in commit
cad5ad81d2f7f58a7ad0d8afa8c1b710.
Szabolcs Nagy [Mon, 21 Dec 2020 16:39:20 +0000 (16:39 +0000)]
aarch64: update ulps.
For new test cases in
commit
cad5ad81d2f7f58a7ad0d8afa8c1b7101a0301fb
Richard Earnshaw [Mon, 21 Dec 2020 15:03:03 +0000 (15:03 +0000)]
aarch64: Add aarch64-specific files for memory tagging support
This final patch provides the architecture-specific implementation of
the memory-tagging support hooks for aarch64.
Richard Earnshaw [Mon, 21 Dec 2020 15:03:03 +0000 (15:03 +0000)]
aarch64: Add sysv specific enabling code for memory tagging
Add various defines and stubs for enabling MTE on AArch64 sysv-like
systems such as Linux. The HWCAP feature bit is copied over in the
same way as other feature bits. Similarly we add a new wrapper header
for mman.h to define the PROT_MTE flag that can be used with mmap and
related functions.
We add a new field to struct cpu_features that can be used, for
example, to check whether or not certain ifunc'd routines should be
bound to MTE-safe versions.
Finally, if we detect that MTE should be enabled (ie via the glibc
tunable); we enable MTE during startup as required.
Support in the Linux kernel was added in version 5.10.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Richard Earnshaw [Mon, 21 Dec 2020 15:03:03 +0000 (15:03 +0000)]
linux: Add compatibility definitions to sys/prctl.h for MTE
Older versions of the Linux kernel headers obviously lack support for
memory tagging, but we still want to be able to build in support when
using those (obviously it can't be enabled on such systems).
The linux kernel extensions are made to the platform-independent
header (linux/prctl.h), so this patch takes a similar approach.
Richard Earnshaw [Mon, 21 Dec 2020 15:03:03 +0000 (15:03 +0000)]
malloc: Basic support for memory tagging in the malloc() family
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>
Richard Earnshaw [Mon, 21 Dec 2020 15:03:03 +0000 (15:03 +0000)]
elf: Add a tunable to control use of tagged memory
Add a new glibc tunable: mem.tagging. This is a decimal constant in
the range 0-255 but used as a bit-field.
Bit 0 enables use of tagged memory in the malloc family of functions.
Bit 1 enables precise faulting of tag failure on platforms where this
can be controlled.
Other bits are currently unused, but if set will cause memory tag
checking for the current process to be enabled in the kernel.
Richard Earnshaw [Mon, 21 Dec 2020 15:03:03 +0000 (15:03 +0000)]
config: Allow memory tagging to be enabled when configuring glibc
This patch adds the configuration machinery to allow memory tagging to be
enabled from the command line via the configure option --enable-memory-tagging.
The current default is off, though in time we may change that once the API
is more stable.
Matt Turner [Mon, 21 Dec 2020 12:09:43 +0000 (09:09 -0300)]
alpha: Remove anonymous union in struct stat [BZ #27042]
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.
Paul Zimmermann [Wed, 25 Nov 2020 18:03:33 +0000 (19:03 +0100)]
add inputs to auto-libm-test-in yielding larger errors (binary64, x86_64)
Sergei Trofimovich [Mon, 21 Dec 2020 04:54:34 +0000 (10:24 +0530)]
m68k: fix clobbering a5 in setjmp() [BZ #24202]
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.
liqingqing [Mon, 21 Dec 2020 04:22:38 +0000 (09:52 +0530)]
iconv add iconv_close before the function returned with bad value.
add iconv_close before the function returned with bad value.
liqingqing [Sat, 14 Dec 2019 08:07:22 +0000 (16:07 +0800)]
iconv: use iconv_close after iconv_open
Andreas Schwab [Mon, 21 Dec 2020 03:26:43 +0000 (08:56 +0530)]
Fix buffer overrun in EUC-KR conversion module (bz #24973)
The byte 0xfe as input to the EUC-KR conversion denotes a user-defined
area and is not allowed. The from_euc_kr function used to skip two bytes
when told to skip over the unknown designation, potentially running over
the buffer end.
Samuel Thibault [Mon, 21 Dec 2020 02:15:38 +0000 (03:15 +0100)]
hurd: Make trampoline fill siginfo ss_sp from sc_uesp
Mach actually rather fills the uesp field, not esp.
Richard Braun [Mon, 21 Dec 2020 01:10:16 +0000 (02:10 +0100)]
Hurd: make sigstates hold a reference on thread ports
This change is required in order to correctly release per-thread
resources. Directly reusing the threading library reference isn't
possible since the sigstate is also used early in the main thread,
before threading is initialized.
* hurd/hurd/signal.h (_hurd_self_sigstate): Drop thread reference after
calling _hurd_thread_sigstate.
(_hurd_critical_section_lock): Likewise.
* hurd/hurdsig.c (_hurd_thread_sigstate): Add a reference on the thread.
(_hurd_sigstate_delete): Drop thread reference.
Samuel Thibault [Mon, 21 Dec 2020 01:02:47 +0000 (02:02 +0100)]
profil-counter: Add missing SIGINFO case
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.
Jeremie Koenig [Mon, 21 Dec 2020 00:41:55 +0000 (01:41 +0100)]
hurd: implement SA_SIGINFO signal handlers.
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.
Samuel Thibault [Sun, 20 Dec 2020 00:47:47 +0000 (01:47 +0100)]
hurd: Fix ELF_MACHINE_USER_ADDRESS_MASK value
x86 binaries are linked at 0x08000000, so we need to let them get mapped
there.
Samuel Thibault [Sun, 20 Dec 2020 00:46:11 +0000 (01:46 +0100)]
hurd: Note when the vm_map kernel bug was fixed
dl-sysdep has been wanting to use high bits in the vm_map mask for decades,
but that was only implemented lately.
Samuel Thibault [Sat, 19 Dec 2020 17:57:47 +0000 (18:57 +0100)]
hurd: Also turn KERN_INVALID_ADDRESS to EINVAL
When e.g. mmap is passed an invalid address we would return
KERN_INVALID_ADDRESS, while POSIX applications would expect EINVAL.
Anssi Hannula [Mon, 27 Jan 2020 10:45:11 +0000 (12:45 +0200)]
ieee754: Remove unused __sin32 and __cos32
The __sin32 and __cos32 functions were only used in the now removed slow
path of asin and acos.
Anssi Hannula [Mon, 27 Jan 2020 10:45:10 +0000 (12:45 +0200)]
ieee754: Remove slow paths from asin and acos
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.
Lode Willems [Fri, 18 Dec 2020 06:32:27 +0000 (12:02 +0530)]
getenv: Move call to strlen to the branch it's used in.
The len variable is only used in the else branch.
We don't need the call to strlen if the name is 0 or 1 characters long.
2019-10-02 Lode Willems <Lode.Willems@UGent.be>
* tdlib/getenv.c: Move the call to strlen into the branch it's used.
Joseph Myers [Thu, 17 Dec 2020 16:17:59 +0000 (16:17 +0000)]
Update kernel version to 5.10 in tst-mman-consts.py.
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.
Stefan Liebler [Tue, 15 Dec 2020 14:18:03 +0000 (15:18 +0100)]
s390x: Require GCC 7.1 or later to build glibc.
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)
Florian Weimer [Wed, 16 Dec 2020 14:09:52 +0000 (15:09 +0100)]
malloc: Use __libc_initial to detect an inner libc
The secondary/non-primary/inner libc (loaded via dlmopen, LD_AUDIT,
static dlopen) must not use sbrk to allocate member because that would
interfere with allocations in the outer libc. On Linux, this does not
matter because sbrk itself was changed to fail in secondary libcs.
_dl_addr occasionally shows up in profiles, but had to be used before
because __libc_multiple_libs was unreliable. So this change achieves
a slight reduction in startup time.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Florian Weimer [Wed, 16 Dec 2020 14:09:52 +0000 (15:09 +0100)]
Replace __libc_multiple_libcs with __libc_initial flag
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>
Samuel Thibault [Wed, 16 Dec 2020 13:36:19 +0000 (14:36 +0100)]
{nptl,htl}/semaphoreP.h: clean up
This removes "Contributed by", and uses a C99 flexible array instead of
char name[0];
Samuel Thibault [Sun, 13 Dec 2020 15:20:32 +0000 (15:20 +0000)]
htl: Get sem_open/sem_close/sem_unlink support [BZ #25524]
This just moves the existing nptl implementation to reuse as it is in
htl.
Samuel Thibault [Sun, 13 Dec 2020 15:18:16 +0000 (15:18 +0000)]
pthread: Move semaphore initialization for open to semaphoreP.h
This allows to easily reuse all of the sem_open/sem_close/sem_unlink
implementations in the various ports.
H.J. Lu [Wed, 2 Dec 2020 22:26:28 +0000 (14:26 -0800)]
Mark __libc_freeres_fn as used [BZ #27002]
GCC 11 with
commit
6fbec038f7a7ddf29f074943611b53210d17c40c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Feb 3 11:55:43 2020 -0800
Use SHF_GNU_RETAIN to preserve symbol definitions
places used symbols in SECTION_RETAIN sections if assembler supports it.
Mark __libc_freeres_fn as used to avoid
gconv_dl.c: In function 'free_mem':
gconv_dl.c:191:1: error: 'do_release_all' without 'used' attribute and 'free_mem' with 'used' attribute are placed in a section with the same name [-Werror=attributes]
191 | do_release_all (void *nodep)
| ^~~~~~~~~~~~~~
In file included from <command-line>:
gconv_dl.c:202:18: note: 'free_mem' was declared here
202 | libc_freeres_fn (free_mem)
| ^~~~~~~~
./../include/libc-symbols.h:316:15: note: in definition of macro 'libc_freeres_fn'
316 | static void name (void)
| ^~~~
cc1: all warnings being treated as errors
Joseph Myers [Wed, 16 Dec 2020 02:08:52 +0000 (02:08 +0000)]
Update syscall lists for Linux 5.10.
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.
Samuel Thibault [Sun, 13 Dec 2020 15:14:40 +0000 (15:14 +0000)]
htl: Add pshared semaphore support
The implementation is extremely similar to the nptl implementation, but
with slight differences in the futex interface. This fixes some of BZ
25521.
Samuel Thibault [Sun, 13 Dec 2020 13:31:22 +0000 (13:31 +0000)]
hurd: Add LLL_PRIVATE and LLL_SHARED
Samuel Thibault [Sun, 13 Dec 2020 13:29:25 +0000 (13:29 +0000)]
hurd: Add __libc_open and __libc_close
Needed by libpthread for sem_open and sem_close
Samuel Thibault [Sun, 13 Dec 2020 11:06:27 +0000 (11:06 +0000)]
htl: Add futex-internal.h
That provides futex_supports_pshared
Samuel Thibault [Sun, 13 Dec 2020 11:01:52 +0000 (11:01 +0000)]
hurd: Add __lll_abstimed_wait_intr
For semaphores, we need an interruptible version of low-level locks.
Samuel Thibault [Sun, 13 Dec 2020 10:37:24 +0000 (10:37 +0000)]
hurd: make lll_* take a variable instead of a ptr
To be coherent with other ports, let's make lll_* take a variable, and
rename those that keep taking a ptr into __lll_*.
Samuel Thibault [Sun, 13 Dec 2020 10:16:55 +0000 (10:16 +0000)]
hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZER
To get coherent with other ports.
Joseph Myers [Tue, 15 Dec 2020 23:36:41 +0000 (23:36 +0000)]
Use Linux 5.10 in build-many-glibcs.py.
This patch makes build-many-glibcs.py use Linux 5.10.
Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
Florian Weimer [Tue, 15 Dec 2020 19:56:04 +0000 (20:56 +0100)]
elf: Record libc.so link map when it is the main program (bug 20972)
Otherwise, it will not participate in the dependency sorting.
Fixes commit
9ffa50b26b0cb5d3043adf6d3d0b1ea735acc147
("elf: Include libc.so.6 as main program in dependency sort
(bug 20972)").
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Joseph Myers [Tue, 15 Dec 2020 16:45:49 +0000 (16:45 +0000)]
Use GMP 6.2.1 in build-many-glibcs.py.
This patch makes build-many-glibcs.py use the recent GMP 6.2.1
release.
Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
Szabolcs Nagy [Tue, 15 Dec 2020 10:36:56 +0000 (10:36 +0000)]
aarch64: remove the strlen_asimd symbol
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
Guillaume Gardet [Mon, 14 Dec 2020 15:38:22 +0000 (15:38 +0000)]
aarch64: fix static PIE start code for BTI [BZ #27068]
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.
Szabolcs Nagy [Tue, 24 Nov 2020 12:34:39 +0000 (12:34 +0000)]
elf: Fix failure handling in _dl_map_object_from_fd
The failure paths in _dl_map_object_from_fd did not clean every
potentially allocated resource up.
Handle l_phdr, l_libname and mapped segments in the common failure
handling code.
There are various bits that may not be cleaned properly on failure
(e.g. executable stack, incomplete dl_map_segments) fixing those
need further changes.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Szabolcs Nagy [Tue, 24 Nov 2020 11:08:33 +0000 (11:08 +0000)]
elf: inline lose for error handling
_dl_map_object_from_fd has complex error handling with cleanups.
It was managed by a separate function to avoid code bloat at
every failure case, but since the code was changed to use gotos
there is no longer such code bloat from inlining.
Maintaining a separate error handling function is harder as it
needs to access local state which has to be passed down. And the
same lose function was used in open_verify which is error prone.
The goto labels are changed since there is no longer a call.
The new code generates slightly smaller binary.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Joseph Myers [Mon, 14 Dec 2020 17:51:38 +0000 (17:51 +0000)]
Remove strtoimax, strtoumax, wcstoimax, wcstoumax inlines
inttypes.h has inline implementations of the strtoimax, strtoumax,
wcstoimax and wcstoumax functions, despite the corresponding stdlib.h
and wchar.h inlines having been removed in 2007 (commit
9b2e9577b228350b15d88303b00097dd58e8d29b).
Remove those inlines, thereby eliminating all references to the
corresponding __*_internal functions from installed headers (so they
could be made into compat symbols in future if desired).
Tested for x86_64 and x86.
DJ Delorie [Thu, 10 Dec 2020 02:46:30 +0000 (21:46 -0500)]
nsswitch: handle missing actions properly
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>
H.J. Lu [Sun, 13 Dec 2020 12:56:41 +0000 (04:56 -0800)]
x86: Remove the default REP MOVSB threshold tunable value [BZ #27061]
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>
Mark Wielaard [Fri, 11 Dec 2020 22:58:24 +0000 (23:58 +0100)]
elf.h: Remove SHF_GNU_BUILD_NOTE.
SHF_GNU_BUILD_NOTE was a binutils experiment. And it is no longer
needed. It was also removed from binutils.
Dmitry V. Levin [Sat, 12 Dec 2020 00:30:00 +0000 (00:30 +0000)]
elf.h: fix spelling typos in comments
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
Jonny Grant [Sat, 12 Dec 2020 00:16:22 +0000 (01:16 +0100)]
Fix spelling and grammar in several comments
W. Hashimoto [Fri, 11 Dec 2020 21:59:10 +0000 (16:59 -0500)]
malloc: Detect infinite-loop in _int_free when freeing tcache [BZ#27052]
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>
Szabolcs Nagy [Fri, 11 Dec 2020 17:30:49 +0000 (17:30 +0000)]
elf: Fix dl-load.c
Rebasing broke commit
38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2
it was supposed to move code.
Florian Weimer [Fri, 11 Dec 2020 16:30:03 +0000 (17:30 +0100)]
elf: Include libc.so.6 as main program in dependency sort (bug 20972)
_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>
Florian Weimer [Fri, 11 Dec 2020 16:24:08 +0000 (17:24 +0100)]
support: Add support_slibdir_prefix variable
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Szabolcs Nagy [Tue, 1 Dec 2020 10:13:18 +0000 (10:13 +0000)]
aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]
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>
Szabolcs Nagy [Wed, 28 Oct 2020 15:17:06 +0000 (15:17 +0000)]
elf: Pass the fd to note processing
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>
Szabolcs Nagy [Thu, 29 Oct 2020 13:29:15 +0000 (13:29 +0000)]
elf: Move note processing after l_phdr is updated
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>
Szabolcs Nagy [Tue, 1 Dec 2020 10:12:32 +0000 (10:12 +0000)]
aarch64: align address for BTI protection [BZ #26988]
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>