Commit Graph

39135 Commits

Author SHA1 Message Date
Szabolcs Nagy
93c5545300 cheri: headers: Define {u}intptr_t and {u}intcap_t for CHERI
The CHERI pure capability programming model for C requires special
definition of {u}intptr_t.

Only the pure capability model is supported for hosted compilation,
but for freestanding compilation there is limited support for other
(hybrid capability) programming models too, which require new
{u}intcap_t type definitions.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
77777d453d aarch64: morello: use separate c++-types.data
The c++ mangling ABI for intptr_t and pthread_t are different on
morello.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
78cc285037 aarch64: morello: use separate localplt data for morello
There is no longer PLT reference to matherr in libm.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
ccec84f408 aarch64: morello: Add separate lp64 and morello linux abilists
The base symbol version is 2.36.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
9e6811dafb aarch64: morello: Add purecap abi-variants on linux 2022-08-05 19:45:19 +01:00
Szabolcs Nagy
18fb025070 aarch64: morello: configure change for purecap abi
Detect default-abi and add aarch64-purecap make variable.

Purecap abi sets HIDDEN_VAR_NEEDS_DYNAMIC_RELOC and unsets
SUPPORT_STATIC_PIE.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
4fc4072240 aarch64: morello: Use separate lp64 and morello sysdep directories
Provide separate directories for lp64 and purecap abi related sysdep
functionality.

purecap may be better name than morello, but we started with morello
and that is more future compatible with alternative cheri-like
extensions on top of aarch64.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
570f6858b7 aarch64: morello: add purecap support to build-many-glibcs.py
aarch64-linux-gnu compiler is a lp64,purecap multilib gcc and
supported glibc variants:

  aarch64-linux-gnu
  aarch64-linux-gnu-purecap
  aarch64-linux-gnu-purecap-nopie

aarch64-linux-gnu_purecap compiler is a default purecap gcc, with
supported glibc variants:

  aarch64-linux-gnu_purecap
  aarch64-linux-gnu_purecap-nopie

purecap libgomp and libitm builds fail so disabled for now.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
084ac620b1 aarch64: Use fewer ifdefs in bits/fcntl.h
This simplifies adding the Morello purecap abi target.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
2adfa58c4f aarch64: cleanup MOVL definition in sysdep.h
PTR_REG is for ILP32, there is no point using it under __LP64__.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
f8335dc69a libio: adjust _IO_FILE / _IO_FILE_complete for 128 bit pointers
The size of the reserved space has to be adjusted because it underflows
with 16 byte pointers.  With the new value there should be enough space
for 2 more pointers in the struct on CHERI targets.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
1cb2ecf162 cheri: Fix elf/tst-dlmodcount test
switch statement does not work for intptr_t, use a large int type
that's guaranteed to work.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
a87b3fcbb3 Fix the symbolic link of multilib dirs
If dir contains several / then 'ln -s . $dir' does not link it to the
current directory. Use the existing rellns.sh script to compute the
correct relative path to .
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
30719666f8 cheri: Fix pointer alignment in fts
ALIGN has to work on pointers and the code assumed unsigned long can
always represent pointers.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
1943345fa3 cheri: Fix invalid pointer deref in wcpcpy_chk
Accessing src via the dest pointer is invalid.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
dec33ea23f cheri: Fix invalid pointer deref in wcscpy_chk
The src pointer is const, accessing dest via it fails on CHERI targets.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
db674b0d98 Fix string/tester alignment code
The code assumed pointers can be converted to unsigned long without
loss of information.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
d8ecbea3fc Fix resource/bug-ulimit1 test
ulimit is a variadic function and the second argument must have type
long (or unsigned long).
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
14c8e3a355 Fix stdlib/test-dlclose-exit-race to not hang 2022-08-05 19:45:19 +01:00
Szabolcs Nagy
2f90599f89 aarch64: fix extension header write in getcontext and swapcontext
The extension header is two 32bit words and in the last header both
should be 0. There is plenty space in the __reserved area, but it's
better not to write more than we mean to.
2022-08-05 19:45:19 +01:00
Szabolcs Nagy
9ed39f584e aarch64: don't build wordcopy
Use an empty wordcopy.c to avoid building the generic one.
It does not seem to be used anywhere.
2022-08-05 19:45:09 +01:00
Szabolcs Nagy
9f22387b95 scripts: Use bool in tunables initializer 2022-08-05 15:28:42 +01:00
Florian Weimer
c74bb93cfd dlfcn: Pass caller pointer to static dlopen implementation (bug 29446)
Fixes commit 0c1c3a771e ("dlfcn: Move
dlopen into libc").

(cherry picked from commit ed0185e412)
2022-08-04 17:57:11 +02:00
H.J. Lu
33f1b4c145 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>
(cherry picked from commit e03f5ccd6c)
2022-08-01 10:02:06 -03:00
Tom Honermann
c3fda489cf 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

(cherry picked from commit 825f84f133)
2022-08-01 10:02:00 -03:00
Carlos O'Donell
c804cd1c00 Create ChangeLog.old/ChangeLog.25. 2022-07-29 18:03:09 -04:00
Carlos O'Donell
f94b70bd3a Prepare for glibc 2.36 release.
Update version.h, and include/features.h.
2022-07-29 17:59:01 -04:00
Carlos O'Donell
7a52dfab02 Update install.texi, and regenerate INSTALL. 2022-07-29 17:51:16 -04:00
Carlos O'Donell
90d8f0dc29 Update NEWS bug list. 2022-07-29 17:49:20 -04:00
Carlos O'Donell
da3b9f4451 Update libc.pot for 2.36 release. 2022-07-29 16:41:57 -04:00
Mark Wielaard
325ba824b0 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>
2022-07-29 18:52:12 +02:00
Adhemerval Zanella
35363b53ce 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>
2022-07-29 09:19:00 -03:00
caiyinyu
bce0218d9a LoongArch: Add greg_t and gregset_t. 2022-07-29 09:15:21 +08:00
caiyinyu
033e76ea9c LoongArch: Fix VDSO_HASH and VDSO_NAME. 2022-07-29 09:15:21 +08:00
Darius Rad
7c5db7931f 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.
2022-07-27 10:50:20 -03:00
Darius Rad
5b6d8a650d riscv: Update nofpu libm test ulps 2022-07-27 10:50:10 -03:00
Jason A. Donenfeld
eaad4f9e8f 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>
2022-07-27 08:58:27 -03:00
caiyinyu
3a38045820 LoongArch: Update NEWS and README for the LoongArch port. 2022-07-26 12:35:12 -03:00
caiyinyu
3be5fc00ad LoongArch: Update build-many-glibcs.py for the LoongArch Port. 2022-07-26 12:35:12 -03:00
caiyinyu
68d61026d5 LoongArch: Hard Float Support 2022-07-26 12:35:12 -03:00
caiyinyu
3d87c89815 LoongArch: Build Infrastructure 2022-07-26 12:35:12 -03:00
caiyinyu
0d4a891a7c LoongArch: Add ABI Lists 2022-07-26 12:35:12 -03:00
caiyinyu
f2037efbb3 LoongArch: Linux ABI 2022-07-26 12:35:12 -03:00
caiyinyu
45955fe618 LoongArch: Linux Syscall Interface 2022-07-26 12:35:12 -03:00
caiyinyu
3275882261 LoongArch: Atomic and Locking Routines 2022-07-26 12:35:12 -03:00
caiyinyu
c742795dce LoongArch: Generic <math.h> and soft-fp Routines 2022-07-26 12:35:12 -03:00
caiyinyu
619bfc6770 LoongArch: Thread-Local Storage Support 2022-07-26 12:35:12 -03:00
caiyinyu
a133942025 LoongArch: ABI Implementation 2022-07-26 12:35:12 -03:00
caiyinyu
2d83247d90 LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py 2022-07-26 12:35:12 -03:00
caiyinyu
4c2c2142d6 LoongArch: Add LoongArch entries to config.h.in 2022-07-26 12:35:12 -03:00