Samuel Thibault [Mon, 22 Aug 2022 20:34:31 +0000 (22:34 +0200)]
hurd: Fix starting static binaries with stack protection enabled
gcc introduces gs:0x14 accesses in most functions, so we need some tcbhead
to be ready very early during initialization. This configures a static area
which can be referenced by various protected functions, until proper TLS is
set up.
Samuel Thibault [Mon, 22 Aug 2022 20:27:24 +0000 (22:27 +0200)]
htl: Make pthread*_cond_timedwait register wref before releasing mutex
Otherwise another thread could be rightly trying to destroy the condition,
see e.g. tst-cond20.
Samuel Thibault [Mon, 22 Aug 2022 20:25:27 +0000 (22:25 +0200)]
htl: make __pthread_hurd_cond_timedwait_internal check mutex is held
Like __pthread_cond_timedwait_internal already does.
Joseph Myers [Mon, 22 Aug 2022 14:59:39 +0000 (14:59 +0000)]
Add AArch64 HWCAP2_* constants from Linux 5.19
Linux 5.19 adds more HWCAP2_* values for AArch64; add these to its
bits/hwcap.h header in glibc.
Tested with build-many-glibcs.py for aarch64-linux-gnu.
Joseph Myers [Mon, 22 Aug 2022 14:16:57 +0000 (14:16 +0000)]
Add AGROUP from Linux 5.19 to sys/acct.h, remove Alpha version (bug 29502)
Linux 5.19 adds a new accounting flag AGROUP; add it to the
enumeration in sys/acct.h.
This shows up that the Alpha-specific variant of this header has a
different set of constants and struct acct, which appear to be the
constants and structure layout from Linux 2.0. These were changed
some time between Linux 2.0 and Linux 2.2; I see no evidence of an
Alpha-specific layout or set of constants, but haven't checked the
detailed Linux kernel history between those versions. Rather, it
looks like tha Alpha-specific header was originally needed because of
the use of types in the kernel structure (such as uid_t and gid_t)
that had different sizes on Alpha, and when glibc was updated for
changes to the structure and constants in the kernel
1998-10-02 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/unix/sysv/linux/sys/acct.h: Bring in sync with current
linux 2.1 version.
that simply omitted to do anything about the Alpha version.
Thus, remove the Alpha version in order to get the updated definitions
into use on Alpha, as I don't think the interfaces are actually
different for Alpha with any kernel version supported by glibc.
Tested for x86_64, and with build-many-glibcs.py for alpha-linux-gnu.
Florian Weimer [Mon, 22 Aug 2022 09:04:47 +0000 (11:04 +0200)]
alpha: Fix generic brk system call emulation in __brk_call (bug 29490)
The kernel special-cases the zero argument for alpha brk, and we can
use that to restore the generic Linux error handling behavior.
Fixes commit
b57ab258c1140bc45464b4b9908713e3e0ee35aa ("Linux:
Introduce __brk_call for invoking the brk system call").
Samuel Thibault [Fri, 19 Aug 2022 00:16:54 +0000 (02:16 +0200)]
hurd: Assume non-suid during bootstrap
We do not have a hurd data block only when bootstrapping the system, in
which case we don't have a notion of suid yet anyway.
This is needed, otherwise init_standard_fds would check that standard
file descriptors are allocated, which is meaningless during bootstrap.
Joseph Myers [Thu, 18 Aug 2022 13:16:56 +0000 (13:16 +0000)]
Use binutils 2.39 branch in build-many-glibcs.py
This patch makes build-many-glibcs.py use binutils 2.39 branch.
Tested with build-many-glibcs.py (compilers and glibcs builds). Note:
binutils 2.39 shows the same failures for i686-linux-gnu-no-pie,
x86_64-linux-gnu-no-pie and x86_64-linux-gnu-x32-no-pie building the
glibc testsuite as binutils mainline does.
Stefan Liebler [Thu, 18 Aug 2022 07:10:48 +0000 (09:10 +0200)]
S390: Fix werror=unused-variable in ifunc-impl-list.c.
If the architecture level set is high enough, no IFUNCs are used at
all and the variable i would be unused. Then the build fails with:
../sysdeps/s390/multiarch/ifunc-impl-list.c: In function ‘__libc_ifunc_impl_list’:
../sysdeps/s390/multiarch/ifunc-impl-list.c:76:10: error: unused variable ‘i’ [-Werror=unused-variable]
76 | size_t i = max;
| ^
cc1: all warnings being treated as errors
Michael Hudson-Doyle [Thu, 11 Aug 2022 23:29:31 +0000 (11:29 +1200)]
Ensure calculations happen with desired rounding mode in y1lf128
math/test-float128-y1 fails on x86_64 and ppc64el with gcc 12 and -O3,
because code inside a block guarded by SET_RESTORE_ROUNDL is being moved
after the rounding mode has been restored. Use math_force_eval to
prevent this (and insert some math_opt_barrier calls to prevent code
from being moved before the rounding mode is set).
Fixes #29463
Reviewed-By: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Florian Weimer [Wed, 17 Aug 2022 07:10:20 +0000 (09:10 +0200)]
localedata: Convert French language locales (fr_*) to UTF-8
Florian Weimer [Tue, 16 Aug 2022 07:25:23 +0000 (09:25 +0200)]
Linux: Fix enum fsconfig_command detection in <sys/mount.h>
The #ifdef FSOPEN_CLOEXEC check did not work because the macro
was always defined in this header prior to the check, so that
the <linux/mount.h> contents did not matter.
Fixes commit
774058d72942249f71d74e7f2b639f77184160a6
("linux: Fix sys/mount.h usage with kernel headers").
Florian Weimer [Tue, 16 Aug 2022 06:27:50 +0000 (08:27 +0200)]
elf: Run tst-audit-tlsdesc, tst-audit-tlsdesc-dlopen everywhere
The test is valid for all TLS models, but we want to make a reasonable
effort to test the GNU2 model specifically. For example, aarch64
defaults to GNU2, but does not have -mtls-dialect=gnu2, and the test
was not run there.
Suggested-by: Martin Coufal <mcoufal@redhat.com>
Samuel Thibault [Sat, 13 Aug 2022 21:02:51 +0000 (23:02 +0200)]
Move ip_mreqn structure from Linux to generic
I.e. from sysdeps/unix/sysv/linux/bits/in.h to netinet/in.h
It is following both the BSD and Linux definitions.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Mon, 15 Aug 2022 14:45:40 +0000 (16:45 +0200)]
malloc: Do not use MAP_NORESERVE to allocate heap segments
Address space for heap segments is reserved in a mmap call with
MAP_ANONYMOUS | MAP_PRIVATE and protection flags PROT_NONE. This
reservation does not count against the RSS limit of the process or
system. Backing memory is allocated using mprotect in alloc_new_heap
and grow_heap, and at this point, the allocator expects the kernel
to provide memory (subject to memory overcommit).
The SIGSEGV that might generate due to MAP_NORESERVE (according to
the mmap manual page) does not seem to occur in practice, it's always
SIGKILL from the OOM killer. Even if there is a way that SIGSEGV
could be generated, it is confusing to applications that this only
happens for secondary heaps, not for large mmap-based allocations,
and not for the main arena.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Florian Weimer [Mon, 15 Aug 2022 14:43:59 +0000 (16:43 +0200)]
Linux: Terminate subprocess on late failure in tst-pidfd (bug 29485)
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Samuel Thibault [Mon, 15 Aug 2022 09:25:55 +0000 (11:25 +0200)]
non-linux: bits/in.h: Add more RFC options
Adhemerval Zanella [Tue, 26 Jul 2022 13:34:01 +0000 (10:34 -0300)]
arm: Remove nested functionf rom relocate_pc24
Checked on arm-linux-gnueabihf.
Adhemerval Zanella [Wed, 10 Aug 2022 17:24:47 +0000 (14:24 -0300)]
linux: Fix sys/mount.h usage with kernel headers
Now that kernel exports linux/mount.h and includes it on linux/fs.h,
its definitions might clash with glibc exports sys/mount.h. To avoid
the need to rearrange the Linux header to be always after glibc one,
the glibc sys/mount.h is changed to:
1. Undefine the macros also used as enum constants. This covers prior
inclusion of <linux/mount.h> (for instance MS_RDONLY).
2. Include <linux/mount.h> based on the usual __has_include check
(needs to use __has_include ("linux/mount.h") to paper over GCC
bugs.
3. Define enum fsconfig_command only if FSOPEN_CLOEXEC is not defined.
(FSOPEN_CLOEXEC should be a very close proxy.)
4. Define struct mount_attr if MOUNT_ATTR_SIZE_VER0 is not defined.
(Added in the same commit on the Linux side.)
This patch also adds some tests to check if including linux/fs.h and
linux/mount.h after and before sys/mount.h does work.
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Wed, 10 Aug 2022 17:24:46 +0000 (14:24 -0300)]
linux: Use compile_c_snippet to check linux/mount.h availability
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Wed, 10 Aug 2022 17:24:45 +0000 (14:24 -0300)]
linux: Mimic kernel defition for BLOCK_SIZE
To avoid possible warnings if the kernel header is included before
sys/mount.h.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Wed, 10 Aug 2022 17:24:44 +0000 (14:24 -0300)]
linux: Use compile_c_snippet to check linux/pidfd.h availability
Instead of tying to a specific kernel version.
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Wed, 10 Aug 2022 19:24:06 +0000 (16:24 -0300)]
glibcextract.py: Add compile_c_snippet
It might be used on tests to check if a snippet build with the provided
compiler and flags.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
caiyinyu [Wed, 10 Aug 2022 02:21:46 +0000 (10:21 +0800)]
LoongArch: Add pointer mangling support.
Wilco Dijkstra [Thu, 11 Aug 2022 16:52:00 +0000 (17:52 +0100)]
AArch64: Fix typo in sve configure check (BZ# 29394)
Fix a typo in the SVE configure check. This fixes [BZ# 29394].
Wilco Dijkstra [Thu, 11 Aug 2022 15:47:45 +0000 (16:47 +0100)]
libio: Improve performance of IO locks
Improve performance of recursive IO locks by adding a fast path for
the single-threaded case. To reduce the number of memory accesses for
locking/unlocking, only increment the recursion counter if the lock
is already taken.
On Neoverse V1, a microbenchmark with many small freads improved by
2.9x. Multithreaded performance improved by 2%.
Reviewed-by: Cristian Rodríguez <crrodriguez@opensuse.org>
Stefan Liebler [Thu, 11 Aug 2022 07:47:46 +0000 (09:47 +0200)]
tst-process_madvise: Check process_madvise-syscall support.
So far this test checks if pidfd_open-syscall is supported,
which was introduced with linux 5.3.
The process_madvise-syscall was introduced with linux 5.10.
Thus you'll get FAILs if you are running a kernel in between.
This patch adds a check if the first process_madvise-syscall
returns ENOSYS and in this case will fail with UNSUPPORTED.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Fangrui Song [Thu, 11 Aug 2022 04:46:09 +0000 (21:46 -0700)]
elf.h: Add ELFCOMPRESS_ZSTD
From the approved generic ABI proposal
https://groups.google.com/g/generic-abi/c/satyPkuMisk
("Add new ch_type value: ELFCOMPRESS_ZSTD").
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Wed, 10 Aug 2022 06:35:41 +0000 (08:35 +0200)]
inet: Turn __ivaliduser into a compatibility symbol
It is not declared in a header file, and as the comment indicates,
it is not expected to be used.
Noah Goldstein [Mon, 8 Aug 2022 03:26:21 +0000 (11:26 +0800)]
x86: Fix `#define STRCPY` guard in strcpy-sse2.S
`#ifndef STPCPY` is incorrect for checking if `STRCPY` is already
defined. It doesn't end up mattering as the whole check is
guarded by `#if IS_IN (libc)` but is incorrect none the less.
Noah Goldstein [Mon, 8 Aug 2022 03:26:22 +0000 (11:26 +0800)]
elf: Replace `strcpy` call with `memcpy` [BZ #29454]
GCC normally does this optimization for us in
strlen_pass::handle_builtin_strcpy but only for optimized
build. To avoid needing to include strcpy.S in the rtld build to
support the debug build, just do the optimization by hand.
Kito Cheng [Tue, 5 Jul 2022 09:46:31 +0000 (17:46 +0800)]
soft-fp: Add fixhf[uns][di|si] and float[uns][di|si]hf
Add more IEEE half conversion routines:
- Convert 32-bit/64-bit integer to IEEE half.
- Convert IEEE half to 32-bit/64-bit integer.
They are required by RISC-V _Float16 support, tested with RISC-V GCC.
Adhemerval Zanella [Tue, 26 Jul 2022 11:44:37 +0000 (08:44 -0300)]
i386: Use cmpl instead of cmp
Clang cannot assemble cmp in the AT&T dialect mode.
Adhemerval Zanella [Tue, 26 Jul 2022 11:42:50 +0000 (08:42 -0300)]
i386: Use fldt instead of fld on e_logl.S
Clang cannot assemble fldt in the AT&T dialect mode.
Fangrui Song [Thu, 4 Aug 2022 21:06:50 +0000 (14:06 -0700)]
i386: Replace movzx with movzbl
Similar to
6720d36b6623c5e48c070d86acf61198b33e144e for x86-64.
Clang cannot assemble movzx in the AT&T dialect mode. Change movzx to
movzbl, which follows the AT&T dialect and is used elsewhere in the
file.
Florian Weimer [Thu, 4 Aug 2022 15:54:48 +0000 (17:54 +0200)]
dlfcn: Pass caller pointer to static dlopen implementation (bug 29446)
Fixes commit
0c1c3a771eceec46e66ce1183cf988e2303bd373 ("dlfcn: Move
dlopen into libc").
Florian Weimer [Thu, 4 Aug 2022 08:24:47 +0000 (10:24 +0200)]
malloc: Correct the documentation of the top_pad default
DEFAULT_TOP_PAD is defined as 131072 in
sysdeps/generic/malloc-machine.h.
Adhemerval Zanella [Tue, 26 Jul 2022 11:40:52 +0000 (08:40 -0300)]
i386: Remove RELA support
Now that prelink is not support, there is no need to keep supporting
rela for non bootstrap.
Adhemerval Zanella [Tue, 26 Jul 2022 11:39:20 +0000 (08:39 -0300)]
arm: Remove RELA support
Now that prelink is not support, there is no need to keep supporting
rela for non bootstrap.
Adhemerval Zanella [Tue, 2 Aug 2022 14:29:22 +0000 (11:29 -0300)]
Remove ldd libc4 support
The older libc versions are obsolete for over twenty years now.
Lucas A. M. Magalhaes [Thu, 14 Jul 2022 17:37:22 +0000 (14:37 -0300)]
Assume only FLAG_ELF_LIBC6 suport
The older libc versions are obsolete for over twenty years now.
This patch removes the special flags for libc5 and libc4 and assumes
that all libraries cached are libc6 compatible and use FLAG_ELF_LIBC6.
Checked with a build for all affected architectures.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Adhemerval Zanella [Tue, 2 Aug 2022 13:08:57 +0000 (10:08 -0300)]
Remove left over LD_LIBRARY_VERSION usages
The environment variable was removed by
d2db60d8d830ef68c8d20a77ac3572d610aa40b1.
Florian Weimer [Thu, 4 Aug 2022 04:17:50 +0000 (06:17 +0200)]
Linux: Remove exit system call from _exit
exit only terminates the current thread, not the whole process, so it
is the wrong fallback system call in this context. All supported
Linux versions implement the exit_group system call anyway.
caiyinyu [Thu, 14 Jul 2022 00:54:04 +0000 (08:54 +0800)]
LoongArch: Add vdso support for gettimeofday.
Joseph Myers [Wed, 3 Aug 2022 16:31:58 +0000 (16:31 +0000)]
Update kernel version to 5.19 in header constant tests
This patch updates the kernel version in the tests tst-mman-consts.py,
tst-mount-consts.py and tst-pidfd-consts.py to 5.18. (There are no
new constants covered by these tests in 5.19, or in 5.17 or 5.18 in
the case of tst-mount-consts.py that previously used version 5.16,
that need any other header changes.)
Tested with build-many-glibcs.py.
Florian Weimer [Wed, 3 Aug 2022 09:41:53 +0000 (11:41 +0200)]
assert: Do not use stderr in libc-internal assert
Redirect internal assertion failures to __libc_assert_fail, based on
based on __libc_message, which writes directly to STDERR_FILENO
and calls abort. Also disable message translation and reword the
error message slightly (adjusting stdlib/tst-bz20544 accordingly).
As a result of these changes, malloc no longer needs its own
redefinition of __assert_fail.
__libc_assert_fail needs to be stubbed out during rtld dependency
analysis because the rtld rebuilds turn __libc_assert_fail into
__assert_fail, which is unconditionally provided by elf/dl-minimal.c.
This change is not possible for the public assert macro and its
__assert_fail function because POSIX requires that the diagnostic
is written to stderr.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Florian Weimer [Wed, 3 Aug 2022 09:41:53 +0000 (11:41 +0200)]
nptl: Remove uses of assert_perror
__pthread_sigmask cannot actually fail with valid pointer arguments
(it would need a really broken seccomp filter), and we do not check
for errors elsewhere.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Florian Weimer [Wed, 3 Aug 2022 09:41:53 +0000 (11:41 +0200)]
stdio: Clean up __libc_message after unconditional abort
Since commit
ec2c1fcefb200c6cb7e09553f3c6af8815013d83 ("malloc:
Abort on heap corruption, without a backtrace [BZ #21754]"),
__libc_message always terminates the process. Since commit
a289ea09ea843ced6e5277c2f2e63c357bc7f9a3 ("Do not print backtraces
on fatal glibc errors"), the backtrace facility has been removed.
Therefore, remove enum __libc_message_action and the action
argument of __libc_message, and mark __libc_message as _No_return.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Joseph Myers [Tue, 2 Aug 2022 21:05:07 +0000 (21:05 +0000)]
Update syscall lists for Linux 5.19
Linux 5.19 has no new syscalls, but enables memfd_secret in the uapi
headers for RISC-V. Update the version number in syscall-names.list
to reflect that it is still current for 5.19 and regenerate the
arch-syscall.h headers with build-many-glibcs.py update-syscalls.
Tested with build-many-glibcs.py.
Joseph Myers [Tue, 2 Aug 2022 14:09:24 +0000 (14:09 +0000)]
Use Linux 5.19 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 5.19.
Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
Arjun Shankar [Tue, 2 Aug 2022 09:10:25 +0000 (11:10 +0200)]
socket: Check lengths before advancing pointer in CMSG_NXTHDR
The inline and library functions that the CMSG_NXTHDR macro may expand
to increment the pointer to the header before checking the stride of
the increment against available space. Since C only allows incrementing
pointers to one past the end of an array, the increment must be done
after a length check. This commit fixes that and includes a regression
test for CMSG_FIRSTHDR and CMSG_NXTHDR.
The Linux, Hurd, and generic headers are all changed.
Tested on Linux on armv7hl, i686, x86_64, aarch64, ppc64le, and s390x.
[BZ #28846]
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Andreas Schwab [Mon, 1 Aug 2022 14:30:15 +0000 (16:30 +0200)]
Don't use unsupported format string in ld.so (bug 29427)
The dynamic loader does not support printf format strings that contain a
literal field width or precision, they have to be specified indirectly.
Samuel Thibault [Thu, 28 Jul 2022 20:01:49 +0000 (22:01 +0200)]
htl: Let pthread_self and cancellability called early
When applications redirect some functions they might get called before
libpthread is fully initialized. They may still expected pthread_self
and cancellable functions to work, so cope with such calls in that
situation.
Adhemerval Zanella [Thu, 28 Jul 2022 12:18:01 +0000 (09:18 -0300)]
stdlib: Simplify arc4random_uniform
It uses the bitmask with rejection [1], which calculates a mask
being the lowest power of two bounding the request upper bound,
successively queries new random values, and rejects values
outside the requested range.
Performance-wise, there is no much gain in trying to conserve
bits since arc4random is wrapper on getrandom syscall. It should
be cheaper to just query a uint32_t value. The algorithm also
avoids modulo and divide operations, which might be costly
depending of the architecture.
[1] https://www.pcg-random.org/posts/bounded-rands.html
Reviewed-by: Yann Droneaud <ydroneaud@opteya.com>
Florian Weimer [Mon, 1 Aug 2022 13:49:07 +0000 (15:49 +0200)]
malloc: Use __getrandom_nocancel during tcache initiailization
Cancellation currently cannot happen at this point because dlopen
as used by the unwind link always performs additional allocations
for libgcc_s.so.1, even if it has been loaded already as a dependency
of the main executable. But it seems prudent not to rely on this
quirk.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Florian Weimer [Mon, 1 Aug 2022 13:49:07 +0000 (15:49 +0200)]
Remove spurious references to _dl_open_hook
_dl_open_hook was removed in commit
466c1ea15f461edb8e3ffaf5d86d708
("dlfcn: Rework static dlopen hooks").
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
H.J. Lu [Fri, 29 Jul 2022 17:50:56 +0000 (10:50 -0700)]
wcsmbs: Add missing test-c8rtomb/test-mbrtoc8 dependency
Make test-c8rtomb.out and test-mbrtoc8.out depend on $(gen-locales) for
xsetlocale (LC_ALL, "de_DE.UTF-8");
xsetlocale (LC_ALL, "zh_HK.BIG5-HKSCS");
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tom Honermann [Sun, 24 Jul 2022 05:11:43 +0000 (01:11 -0400)]
stdlib: Suppress gcc diagnostic that char8_t is a keyword in C++20 in uchar.h.
gcc 13 issues the following diagnostic for the uchar.h header when the
-Wc++20-compat option is enabled in C++ modes that do not enable char8_t
as a builtin type (C++17 and earlier by default; subject to _GNU_SOURCE
and the gcc -f[no-]char8_t option).
warning: identifier ‘char8_t’ is a keyword in C++20 [-Wc++20-compat]
This change modifies the uchar.h header to suppress the diagnostic through
the use of '#pragma GCC diagnostic' directives for gcc 10 and later (the
-Wc++20-compat option was added in gcc version 10). Unfortunately, a bug
in gcc currently prevents those directives from having the intended effect
as reported at https://gcc.gnu.org/PR106423. A patch for that issue has
been submitted and is available in the email thread archive linked below.
https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598736.html
Carlos O'Donell [Sat, 30 Jul 2022 19:34:11 +0000 (15:34 -0400)]
Open master branch for glibc 2.37 development
Carlos O'Donell [Fri, 29 Jul 2022 22:03:09 +0000 (18:03 -0400)]
Create ChangeLog.old/ChangeLog.25.
Carlos O'Donell [Fri, 29 Jul 2022 21:59:01 +0000 (17:59 -0400)]
Prepare for glibc 2.36 release.
Update version.h, and include/features.h.
Carlos O'Donell [Fri, 29 Jul 2022 21:51:16 +0000 (17:51 -0400)]
Update install.texi, and regenerate INSTALL.
Carlos O'Donell [Fri, 29 Jul 2022 21:49:20 +0000 (17:49 -0400)]
Update NEWS bug list.
Carlos O'Donell [Fri, 29 Jul 2022 17:01:35 +0000 (13:01 -0400)]
Update libc.pot for 2.36 release.
Mark Wielaard [Sun, 26 Jun 2022 20:17:17 +0000 (22:17 +0200)]
tst-pidfd.c: UNSUPPORTED if we get EPERM on valid pidfd_getfd call
pidfd_getfd can fail for a valid pidfd with errno EPERM for various
reasons in a restricted environment. Use FAIL_UNSUPPORTED in that case.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Wed, 27 Jul 2022 11:59:15 +0000 (08:59 -0300)]
stdlib: Tuned down tst-arc4random-thread internal parameters
With new arc4random implementation, the internal parameters might
require a lot of runtime and/or trigger some contention on older
kernels (which might trigger spurious timeout failures).
Also, since we are now testing getrandom entropy instead of an
userspace RNG, there is no much need to extensive testing.
With this change the tst-arc4random-thread goes from about 1m to
5s on a Ryzen 9 with 5.15.0-41-generic.
Checked on x86_64-linux-gnu.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
caiyinyu [Wed, 27 Jul 2022 19:25:40 +0000 (03:25 +0800)]
LoongArch: Add greg_t and gregset_t.
caiyinyu [Wed, 27 Jul 2022 18:36:52 +0000 (02:36 +0800)]
LoongArch: Fix VDSO_HASH and VDSO_NAME.
Darius Rad [Tue, 26 Jul 2022 12:54:55 +0000 (08:54 -0400)]
riscv: Update rv64 libm test ulps
Generated on a Microsemi Polarfire Icicle Kit running Linux version
5.15.32. Same ULPs were also produced on QEMU 5.2.0 running Linux
5.18.0.
Darius Rad [Tue, 26 Jul 2022 12:54:38 +0000 (08:54 -0400)]
riscv: Update nofpu libm test ulps
Jason A. Donenfeld [Tue, 26 Jul 2022 19:58:22 +0000 (21:58 +0200)]
arc4random: simplify design for better safety
Rather than buffering 16 MiB of entropy in userspace (by way of
chacha20), simply call getrandom() every time.
This approach is doubtlessly slower, for now, but trying to prematurely
optimize arc4random appears to be leading toward all sorts of nasty
properties and gotchas. Instead, this patch takes a much more
conservative approach. The interface is added as a basic loop wrapper
around getrandom(), and then later, the kernel and libc together can
work together on optimizing that.
This prevents numerous issues in which userspace is unaware of when it
really must throw away its buffer, since we avoid buffering all
together. Future improvements may include userspace learning more from
the kernel about when to do that, which might make these sorts of
chacha20-based optimizations more possible. The current heuristic of 16
MiB is meaningless garbage that doesn't correspond to anything the
kernel might know about. So for now, let's just do something
conservative that we know is correct and won't lead to cryptographic
issues for users of this function.
This patch might be considered along the lines of, "optimization is the
root of all evil," in that the much more complex implementation it
replaces moves too fast without considering security implications,
whereas the incremental approach done here is a much safer way of going
about things. Once this lands, we can take our time in optimizing this
properly using new interplay between the kernel and userspace.
getrandom(0) is used, since that's the one that ensures the bytes
returned are cryptographically secure. But on systems without it, we
fallback to using /dev/urandom. This is unfortunate because it means
opening a file descriptor, but there's not much of a choice. Secondly,
as part of the fallback, in order to get more or less the same
properties of getrandom(0), we poll on /dev/random, and if the poll
succeeds at least once, then we assume the RNG is initialized. This is a
rough approximation, as the ancient "non-blocking pool" initialized
after the "blocking pool", not before, and it may not port back to all
ancient kernels, though it does to all kernels supported by glibc
(≥3.2), so generally it's the best approximation we can do.
The motivation for including arc4random, in the first place, is to have
source-level compatibility with existing code. That means this patch
doesn't attempt to litigate the interface itself. It does, however,
choose a conservative approach for implementing it.
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Cristian Rodríguez <crrodriguez@opensuse.org>
Cc: Paul Eggert <eggert@cs.ucla.edu>
Cc: Mark Harris <mark.hsj@gmail.com>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
caiyinyu [Tue, 19 Jul 2022 01:22:10 +0000 (09:22 +0800)]
LoongArch: Update NEWS and README for the LoongArch port.
caiyinyu [Tue, 19 Jul 2022 01:22:09 +0000 (09:22 +0800)]
LoongArch: Update build-many-glibcs.py for the LoongArch Port.
caiyinyu [Tue, 19 Jul 2022 01:22:08 +0000 (09:22 +0800)]
LoongArch: Hard Float Support
caiyinyu [Tue, 19 Jul 2022 01:22:07 +0000 (09:22 +0800)]
LoongArch: Build Infrastructure
caiyinyu [Tue, 19 Jul 2022 01:22:06 +0000 (09:22 +0800)]
LoongArch: Add ABI Lists
caiyinyu [Tue, 19 Jul 2022 01:20:51 +0000 (09:20 +0800)]
LoongArch: Linux ABI
caiyinyu [Tue, 19 Jul 2022 01:20:50 +0000 (09:20 +0800)]
LoongArch: Linux Syscall Interface
caiyinyu [Tue, 19 Jul 2022 01:20:49 +0000 (09:20 +0800)]
LoongArch: Atomic and Locking Routines
caiyinyu [Tue, 19 Jul 2022 01:20:48 +0000 (09:20 +0800)]
LoongArch: Generic <math.h> and soft-fp Routines
caiyinyu [Tue, 19 Jul 2022 01:20:47 +0000 (09:20 +0800)]
LoongArch: Thread-Local Storage Support
caiyinyu [Tue, 19 Jul 2022 01:20:46 +0000 (09:20 +0800)]
LoongArch: ABI Implementation
caiyinyu [Tue, 19 Jul 2022 01:20:45 +0000 (09:20 +0800)]
LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py
caiyinyu [Tue, 19 Jul 2022 01:20:44 +0000 (09:20 +0800)]
LoongArch: Add LoongArch entries to config.h.in
Arnout Vandecappelle (Essensium/Mind) [Mon, 25 Jul 2022 09:25:15 +0000 (11:25 +0200)]
struct stat is not posix conformant on microblaze with __USE_FILE_OFFSET64
Commit
a06b40cdf5ba0d2ab4f9b4c77d21e45ff284fac7 updated stat.h to use
__USE_XOPEN2K8 instead of __USE_MISC to add the st_atim, st_mtim and
st_ctim members to struct stat. However, for microblaze, there are two
definitions of struct stat, depending on the __USE_FILE_OFFSET64 macro.
The second one was not updated.
Change __USE_MISC to __USE_XOPEN2K8 in the __USE_FILE_OFFSET64 version
of struct stat for microblaze.
Florian Weimer [Mon, 25 Jul 2022 07:39:22 +0000 (09:39 +0200)]
Linux: dirent/tst-readdir64-compat needs to use TEST_COMPAT (bug 27654)
The hppa port starts libc at GLIBC_2.2, but has earlier symbol
versions in other shared objects. This means that the compat
symbol for readdir64 is not actually present in libc even though
have-GLIBC_2.1.3 is defined as yes at the make level.
Fixes commit
15e50e6c966fa0f26612602a95f0129543d9f9d5 ("Linux:
dirent/tst-readdir64-compat can be a regular test") by mostly
reverting it.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:07 +0000 (10:05 -0300)]
manual: Add documentation for arc4random functions
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:06 +0000 (10:05 -0300)]
s390x: Add optimized chacha20
It adds vectorized ChaCha20 implementation based on libgcrypt
cipher/chacha20-s390x.S. The final state register clearing is
omitted.
On a z15 it shows the following improvements (using formatted
bench-arc4random data):
GENERIC MB/s
-----------------------------------------------
arc4random [single-thread] 198.92
arc4random_buf(16) [single-thread] 244.49
arc4random_buf(32) [single-thread] 282.73
arc4random_buf(48) [single-thread] 286.64
arc4random_buf(64) [single-thread] 320.06
arc4random_buf(80) [single-thread] 297.43
arc4random_buf(96) [single-thread] 310.96
arc4random_buf(112) [single-thread] 308.10
arc4random_buf(128) [single-thread] 309.90
-----------------------------------------------
VX. MB/s
-----------------------------------------------
arc4random [single-thread] 430.26
arc4random_buf(16) [single-thread] 735.14
arc4random_buf(32) [single-thread] 1029.99
arc4random_buf(48) [single-thread] 1206.76
arc4random_buf(64) [single-thread] 1311.92
arc4random_buf(80) [single-thread] 1378.74
arc4random_buf(96) [single-thread] 1445.06
arc4random_buf(112) [single-thread] 1484.32
arc4random_buf(128) [single-thread] 1517.30
-----------------------------------------------
Checked on s390x-linux-gnu.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:05 +0000 (10:05 -0300)]
powerpc64: Add optimized chacha20
It adds vectorized ChaCha20 implementation based on libgcrypt
cipher/chacha20-ppc.c. It targets POWER8 and it is used on default
for LE.
On a POWER8 it shows the following improvements (using formatted
bench-arc4random data):
POWER8
GENERIC MB/s
-----------------------------------------------
arc4random [single-thread] 138.77
arc4random_buf(16) [single-thread] 174.36
arc4random_buf(32) [single-thread] 228.11
arc4random_buf(48) [single-thread] 252.31
arc4random_buf(64) [single-thread] 270.11
arc4random_buf(80) [single-thread] 278.97
arc4random_buf(96) [single-thread] 287.78
arc4random_buf(112) [single-thread] 291.92
arc4random_buf(128) [single-thread] 295.25
POWER8 MB/s
-----------------------------------------------
arc4random [single-thread] 198.06
arc4random_buf(16) [single-thread] 278.79
arc4random_buf(32) [single-thread] 448.89
arc4random_buf(48) [single-thread] 551.09
arc4random_buf(64) [single-thread] 646.12
arc4random_buf(80) [single-thread] 698.04
arc4random_buf(96) [single-thread] 756.06
arc4random_buf(112) [single-thread] 784.12
arc4random_buf(128) [single-thread] 808.04
-----------------------------------------------
Checked on powerpc64-linux-gnu and powerpc64le-linux-gnu.
Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:04 +0000 (10:05 -0300)]
x86: Add AVX2 optimized chacha20
It adds vectorized ChaCha20 implementation based on libgcrypt
cipher/chacha20-amd64-avx2.S. It is used only if AVX2 is supported
and enabled by the architecture.
As for generic implementation, the last step that XOR with the
input is omited. The final state register clearing is also
omitted.
On a Ryzen 9 5900X it shows the following improvements (using
formatted bench-arc4random data):
SSE MB/s
-----------------------------------------------
arc4random [single-thread] 704.25
arc4random_buf(16) [single-thread] 1018.17
arc4random_buf(32) [single-thread] 1315.27
arc4random_buf(48) [single-thread] 1449.36
arc4random_buf(64) [single-thread] 1511.16
arc4random_buf(80) [single-thread] 1539.48
arc4random_buf(96) [single-thread] 1571.06
arc4random_buf(112) [single-thread] 1596.16
arc4random_buf(128) [single-thread] 1613.48
-----------------------------------------------
AVX2 MB/s
-----------------------------------------------
arc4random [single-thread] 922.61
arc4random_buf(16) [single-thread] 1478.70
arc4random_buf(32) [single-thread] 2241.80
arc4random_buf(48) [single-thread] 2681.28
arc4random_buf(64) [single-thread] 2913.43
arc4random_buf(80) [single-thread] 3009.73
arc4random_buf(96) [single-thread] 3141.16
arc4random_buf(112) [single-thread] 3254.46
arc4random_buf(128) [single-thread] 3305.02
-----------------------------------------------
Checked on x86_64-linux-gnu.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:03 +0000 (10:05 -0300)]
x86: Add SSE2 optimized chacha20
It adds vectorized ChaCha20 implementation based on libgcrypt
cipher/chacha20-amd64-ssse3.S. It replaces the ROTATE_SHUF_2 (which
uses pshufb) by ROTATE2 and thus making the original implementation
SSE2.
As for generic implementation, the last step that XOR with the
input is omited. The final state register clearing is also
omitted.
On a Ryzen 9 5900X it shows the following improvements (using
formatted bench-arc4random data):
GENERIC MB/s
-----------------------------------------------
arc4random [single-thread] 443.11
arc4random_buf(16) [single-thread] 552.27
arc4random_buf(32) [single-thread] 626.86
arc4random_buf(48) [single-thread] 649.81
arc4random_buf(64) [single-thread] 663.95
arc4random_buf(80) [single-thread] 674.78
arc4random_buf(96) [single-thread] 675.17
arc4random_buf(112) [single-thread] 680.69
arc4random_buf(128) [single-thread] 683.20
-----------------------------------------------
SSE MB/s
-----------------------------------------------
arc4random [single-thread] 704.25
arc4random_buf(16) [single-thread] 1018.17
arc4random_buf(32) [single-thread] 1315.27
arc4random_buf(48) [single-thread] 1449.36
arc4random_buf(64) [single-thread] 1511.16
arc4random_buf(80) [single-thread] 1539.48
arc4random_buf(96) [single-thread] 1571.06
arc4random_buf(112) [single-thread] 1596.16
arc4random_buf(128) [single-thread] 1613.48
-----------------------------------------------
Checked on x86_64-linux-gnu.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:02 +0000 (10:05 -0300)]
aarch64: Add optimized chacha20
It adds vectorized ChaCha20 implementation based on libgcrypt
cipher/chacha20-aarch64.S. It is used as default and only
little-endian is supported (BE uses generic code).
As for generic implementation, the last step that XOR with the
input is omited. The final state register clearing is also
omitted.
On a virtualized Linux on Apple M1 it shows the following
improvements (using formatted bench-arc4random data):
GENERIC MB/s
-----------------------------------------------
arc4random [single-thread] 380.89
arc4random_buf(16) [single-thread] 500.73
arc4random_buf(32) [single-thread] 552.61
arc4random_buf(48) [single-thread] 566.82
arc4random_buf(64) [single-thread] 574.01
arc4random_buf(80) [single-thread] 581.02
arc4random_buf(96) [single-thread] 591.19
arc4random_buf(112) [single-thread] 592.29
arc4random_buf(128) [single-thread] 596.43
-----------------------------------------------
OPTIMIZED MB/s
-----------------------------------------------
arc4random [single-thread] 569.60
arc4random_buf(16) [single-thread] 825.78
arc4random_buf(32) [single-thread] 987.03
arc4random_buf(48) [single-thread] 1042.39
arc4random_buf(64) [single-thread] 1075.50
arc4random_buf(80) [single-thread] 1094.68
arc4random_buf(96) [single-thread] 1130.16
arc4random_buf(112) [single-thread] 1129.58
arc4random_buf(128) [single-thread] 1137.91
-----------------------------------------------
Checked on aarch64-linux-gnu.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:01 +0000 (10:05 -0300)]
benchtests: Add arc4random benchtest
It shows both throughput (total bytes obtained in the test duration)
and latecy for both arc4random and arc4random_buf with different
sizes.
Checked on x86_64-linux-gnu, aarch64-linux, and powerpc64le-linux-gnu.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:05:00 +0000 (10:05 -0300)]
stdlib: Add arc4random tests
The basic tst-arc4random-chacha20.c checks if the output of ChaCha20
implementation matches the reference test vectors from RFC8439.
The tst-arc4random-fork.c check if subprocesses generate distinct
streams of randomness (if fork handling is done correctly).
The tst-arc4random-stats.c is a statistical test to the randomness of
arc4random, arc4random_buf, and arc4random_uniform.
The tst-arc4random-thread.c check if threads generate distinct streams
of randomness (if function are thread-safe).
Checked on x86_64-linux-gnu, aarch64-linux, and powerpc64le-linux-gnu.
Co-authored-by: Florian Weimer <fweimer@redhat.com>
Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Adhemerval Zanella Netto [Thu, 21 Jul 2022 13:04:59 +0000 (10:04 -0300)]
stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417)
The implementation is based on scalar Chacha20 with per-thread cache.
It uses getrandom or /dev/urandom as fallback to get the initial entropy,
and reseeds the internal state on every 16MB of consumed buffer.
To improve performance and lower memory consumption the per-thread cache
is allocated lazily on first arc4random functions call, and if the
memory allocation fails getentropy or /dev/urandom is used as fallback.
The cache is also cleared on thread exit iff it was initialized (so if
arc4random is not called it is not touched).
Although it is lock-free, arc4random is still not async-signal-safe
(the per thread state is not updated atomically).
The ChaCha20 implementation is based on RFC8439 [1], omitting the final
XOR of the keystream with the plaintext because the plaintext is a
stream of zeros. This strategy is similar to what OpenBSD arc4random
does.
The arc4random_uniform is based on previous work by Florian Weimer,
where the algorithm is based on Jérémie Lumbroso paper Optimal Discrete
Uniform Generation from Coin Flips, and Applications (2013) [2], who
credits Donald E. Knuth and Andrew C. Yao, The complexity of nonuniform
random number generation (1976), for solving the general case.
The main advantage of this method is the that the unit of randomness is not
the uniform random variable (uint32_t), but a random bit. It optimizes the
internal buffer sampling by initially consuming a 32-bit random variable
and then sampling byte per byte. Depending of the upper bound requested,
it might lead to better CPU utilization.
Checked on x86_64-linux-gnu, aarch64-linux, and powerpc64le-linux-gnu.
Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Yann Droneaud <ydroneaud@opteya.com>
[1] https://datatracker.ietf.org/doc/html/rfc8439
[2] https://arxiv.org/pdf/1304.1916.pdf
Adhemerval Zanella [Tue, 19 Jul 2022 13:30:34 +0000 (10:30 -0300)]
locale: Optimize tst-localedef-path-norm
The locale generation are issues in parallel to try speed locale
generation. The maximum number of jobs are limited to the online
CPU (in hope to not overcommit on environments with lower cores
than tests).
On a Ryzen 9, the test execution improves from ~6.7s to ~1.4s.
Tested-by: Mark Wielaard <mark@klomp.org>
Florian Weimer [Thu, 21 Jul 2022 10:12:08 +0000 (12:12 +0200)]
malloc: Simplify implementation of __malloc_assert
It is prudent not to run too much code after detecting heap
corruption, and __fxprintf is really complex. The line number
and file name do not carry much information, so it is not included
in the error message. (__libc_message only supports %s formatting.)
The function name and assertion should provide some context.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Adhemerval Zanella [Fri, 8 Jul 2022 01:14:24 +0000 (01:14 +0000)]
Update scripts/config.* files from upstream GNU config version
This patch updates various miscellaneous files from their upstream
sources (version 2022-05-25).
It is required for loongarch support.
Checked on aarch64-linux-gnu.
Michael Hudson-Doyle [Sun, 17 Jul 2022 23:16:57 +0000 (11:16 +1200)]
linux: return UNSUPPORTED from tst-mount if entering mount namespace fails
Before this the test fails if run in a chroot by a non-root user:
warning: could not become root outside namespace (Operation not permitted)
../sysdeps/unix/sysv/linux/tst-mount.c:36: numeric comparison failure
left: 1 (0x1); from: errno
right: 19 (0x13); from: ENODEV
error: ../sysdeps/unix/sysv/linux/tst-mount.c:39: not true: fd != -1
error: ../sysdeps/unix/sysv/linux/tst-mount.c:46: not true: r != -1
error: ../sysdeps/unix/sysv/linux/tst-mount.c:48: not true: r != -1
../sysdeps/unix/sysv/linux/tst-mount.c:52: numeric comparison failure
left: 1 (0x1); from: errno
right: 9 (0x9); from: EBADF
error: ../sysdeps/unix/sysv/linux/tst-mount.c:55: not true: mfd != -1
../sysdeps/unix/sysv/linux/tst-mount.c:58: numeric comparison failure
left: 1 (0x1); from: errno
right: 2 (0x2); from: ENOENT
error: ../sysdeps/unix/sysv/linux/tst-mount.c:61: not true: r != -1
../sysdeps/unix/sysv/linux/tst-mount.c:65: numeric comparison failure
left: 1 (0x1); from: errno
right: 2 (0x2); from: ENOENT
error: ../sysdeps/unix/sysv/linux/tst-mount.c:68: not true: pfd != -1
error: ../sysdeps/unix/sysv/linux/tst-mount.c:75: not true: fd_tree != -1
../sysdeps/unix/sysv/linux/tst-mount.c:88: numeric comparison failure
left: 1 (0x1); from: errno
right: 38 (0x26); from: ENOSYS
error: 12 test failures
Checking that the test can enter a new mount namespace is more correct
than just checking the return value of support_become_root() as the test
code changes the mount namespace it runs in so running it as root on a
system that does not support mount namespaces should still skip.
Also change the test to remove the unnecessary fork.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Noah Goldstein [Wed, 13 Jul 2022 23:33:01 +0000 (16:33 -0700)]
x86: Add support to build st{p|r}{n}{cpy|cat} with explicit ISA level
1. Add default ISA level selection in non-multiarch/rtld
implementations.
2. Add ISA level build guards to different implementations.
- I.e strcpy-avx2.S which is ISA level 3 will only build if
compiled ISA level <= 3. Otherwise there is no reason to
include it as we will always use one of the ISA level 4
implementations (strcpy-evex.S).
3. Refactor the ifunc selector and ifunc implementation list to use
the ISA level aware wrapper macros that allow functions below the
compiled ISA level (with a guranteed replacement) to be skipped.
Tested with and without multiarch on x86_64 for ISA levels:
{generic, x86-64-v2, x86-64-v3, x86-64-v4}
And m32 with and without multiarch.