Frédéric Bérat [Wed, 14 Jun 2023 08:52:07 +0000 (10:52 +0200)]
tests: replace system by xsystem
With fortification enabled, system calls return result needs to be checked,
has it gets the __wur macro enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Wed, 14 Jun 2023 08:52:06 +0000 (10:52 +0200)]
tests: replace read by xread
With fortification enabled, read calls return result needs to be checked,
has it gets the __wur macro enabled.
Note on read call removal from sysdeps/pthread/tst-cancel20.c and
sysdeps/pthread/tst-cancel21.c:
It is assumed that this second read call was there to overcome the race
condition between pipe closure and thread cancellation that could happen
in the original code. Since this race condition got fixed by
d0e3ffb7a58854248f1d5e737610d50cd0a60f46 the second call seems
superfluous. Hence, instead of checking for the return value of read, it
looks reasonable to simply remove it.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Joe Simmons-Talbott [Thu, 8 Jun 2023 15:58:43 +0000 (11:58 -0400)]
hurd: writev: Get rid of alloca
Use a scratch_buffer rather than alloca to avoid potential stack
overflows.
Checked on i686-gnu and x86_64-linux-gnu
Message-Id: <
20230608155844.976554-1-josimmon@redhat.com>
Joe Simmons-Talbott [Tue, 13 Jun 2023 19:16:31 +0000 (15:16 -0400)]
grantpt: Get rid of alloca
Replace alloca with a scratch_buffer to avoid potential stack overflows.
Message-Id: <
20230613191631.1080455-1-josimmon@redhat.com>
Florian Weimer [Thu, 15 Jun 2023 10:08:22 +0000 (12:08 +0200)]
string: strerror must not return NULL (bug 30555)
For strerror, this fixes commit
28aff047818eb1726394296d27b ("string:
Implement strerror in terms of strerror_l"). This commit avoids
returning NULL for strerror_l as well, although POSIX allows this
behavior for strerror_l.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
Florian Weimer [Thu, 15 Jun 2023 08:05:25 +0000 (10:05 +0200)]
hurd: Add strlcpy, strlcat, wcslcpy, wcslcat to libc.abilist
Paul Eggert [Wed, 14 Jun 2023 16:10:27 +0000 (18:10 +0200)]
manual: Manual update for strlcat, strlcpy, wcslcat, wclscpy
Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Florian Weimer [Wed, 14 Jun 2023 16:10:24 +0000 (18:10 +0200)]
Add the wcslcpy, wcslcat functions
These functions are about to be added to POSIX, under Austin Group
issue 986.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Florian Weimer [Wed, 14 Jun 2023 16:10:08 +0000 (18:10 +0200)]
Implement strlcpy and strlcat [BZ #178]
These functions are about to be added to POSIX, under Austin Group
issue 986.
The fortified strlcat implementation does not raise SIGABRT if the
destination buffer does not contain a null terminator, it just
inherits the non-failing regular strlcat behavior.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frederic Berat [Mon, 12 Jun 2023 15:18:21 +0000 (17:18 +0200)]
tests: replace fgets by xfgets
With fortification enabled, fgets calls return result needs to be checked,
has it gets the __wur macro enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frederic Berat [Mon, 12 Jun 2023 15:18:20 +0000 (17:18 +0200)]
tests: replace fread by xfread
With fortification enabled, fread calls return result needs to be checked,
has it gets the __wur macro enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Dridi Boukelmoune [Tue, 13 Jun 2023 10:08:28 +0000 (12:08 +0200)]
posix: Add test case for gai_strerror()
Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
Dridi Boukelmoune [Tue, 13 Jun 2023 10:08:27 +0000 (12:08 +0200)]
posix: Handle success in gai_strerror()
Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
caiyinyu [Mon, 20 Mar 2023 01:25:36 +0000 (09:25 +0800)]
LoongArch: Add support for dl_runtime_profile
This commit can fix the FAIL item: elf/tst-sprof-basic.
Adhemerval Zanella Netto [Wed, 7 Jun 2023 17:39:55 +0000 (14:39 -0300)]
malloc: Decrease resource usage for malloc tests
The tst-mallocfork2 and tst-mallocfork3 create large number of
subprocesss, around 11k for former and 20k for latter, to check
for malloc async-signal-safeness on both fork and _Fork. However
they do not really exercise allocation patterns different than
other tests fro malloc itself, and the spawned process just exit
without any extra computation.
The tst-malloc-tcache-leak is similar, but creates 100k threads
and already checks the resulting with mallinfo.
These tests are also very sensitive to system load (since they
estresss heavy the kernel resource allocation), and adding them
on THP tunable and mcheck tests increase the pressure even more.
For THP the fork tests do not add any more coverage than other
tests. The mcheck is also not enable for tst-malloc-tcache-leak.
Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella Netto [Thu, 1 Jun 2023 15:59:19 +0000 (12:59 -0300)]
stdlib: Tune down fork arc4random tests
There is no fork detection on current arc4random implementation, so
use lower subprocess on fork tests. The tests now run on 0.1s
instead of 8s on a Ryzen9 5900X.
Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Joe Simmons-Talbott [Mon, 12 Jun 2023 15:39:00 +0000 (11:39 -0400)]
tst-getdate: Improve testcase flexibility and add test.
The getdate testcases all expect successful results. Add support for
negative testcases and testcases where a full date and time are not
supplied by skipping the tm checks in the test. Add a testcase that
would catch a use-after-free that was recently found.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
Noah Goldstein [Wed, 7 Jun 2023 18:18:03 +0000 (13:18 -0500)]
x86: Make the divisor in setting `non_temporal_threshold` cpu specific
Different systems prefer a different divisors.
From benchmarks[1] so far the following divisors have been found:
ICX : 2
SKX : 2
BWD : 8
For Intel, we are generalizing that BWD and older prefers 8 as a
divisor, and SKL and newer prefers 2. This number can be further tuned
as benchmarks are run.
[1]: https://github.com/goldsteinn/memcpy-nt-benchmarks
Reviewed-by: DJ Delorie <dj@redhat.com>
Noah Goldstein [Wed, 7 Jun 2023 18:18:02 +0000 (13:18 -0500)]
x86: Refactor Intel `init_cpu_features`
This patch should have no affect on existing functionality.
The current code, which has a single switch for model detection and
setting prefered features, is difficult to follow/extend. The cases
use magic numbers and many microarchitectures are missing. This makes
it difficult to reason about what is implemented so far and/or
how/where to add support for new features.
This patch splits the model detection and preference setting stages so
that CPU preferences can be set based on a complete list of available
microarchitectures, rather than based on model magic numbers.
Reviewed-by: DJ Delorie <dj@redhat.com>
Noah Goldstein [Wed, 7 Jun 2023 18:18:01 +0000 (13:18 -0500)]
x86: Increase `non_temporal_threshold` to roughly `sizeof_L3 / 4`
Current `non_temporal_threshold` set to roughly '3/4 * sizeof_L3 /
ncores_per_socket'. This patch updates that value to roughly
'sizeof_L3 / 4`
The original value (specifically dividing the `ncores_per_socket`) was
done to limit the amount of other threads' data a `memcpy`/`memset`
could evict.
Dividing by 'ncores_per_socket', however leads to exceedingly low
non-temporal thresholds and leads to using non-temporal stores in
cases where REP MOVSB is multiple times faster.
Furthermore, non-temporal stores are written directly to main memory
so using it at a size much smaller than L3 can place soon to be
accessed data much further away than it otherwise could be. As well,
modern machines are able to detect streaming patterns (especially if
REP MOVSB is used) and provide LRU hints to the memory subsystem. This
in affect caps the total amount of eviction at 1/cache_associativity,
far below meaningfully thrashing the entire cache.
As best I can tell, the benchmarks that lead this small threshold
where done comparing non-temporal stores versus standard cacheable
stores. A better comparison (linked below) is to be REP MOVSB which,
on the measure systems, is nearly 2x faster than non-temporal stores
at the low-end of the previous threshold, and within 10% for over
100MB copies (well past even the current threshold). In cases with a
low number of threads competing for bandwidth, REP MOVSB is ~2x faster
up to `sizeof_L3`.
The divisor of `4` is a somewhat arbitrary value. From benchmarks it
seems Skylake and Icelake both prefer a divisor of `2`, but older CPUs
such as Broadwell prefer something closer to `8`. This patch is meant
to be followed up by another one to make the divisor cpu-specific, but
in the meantime (and for easier backporting), this patch settles on
`4` as a middle-ground.
Benchmarks comparing non-temporal stores, REP MOVSB, and cacheable
stores where done using:
https://github.com/goldsteinn/memcpy-nt-benchmarks
Sheets results (also available in pdf on the github):
https://docs.google.com/spreadsheets/d/e/2PACX-1vS183r0rW_jRX6tG_E90m9qVuFiMbRIJvi5VAE8yYOvEOIEEc3aSNuEsrFbuXw5c3nGboxMmrupZD7K/pubhtml
Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Martin Coufal [Fri, 9 Jun 2023 11:58:04 +0000 (13:58 +0200)]
Remove unused DATEMSK file for tst-getdate
tst-getdate used to rely on an in-tree datemsk file that was
subsequently replaced by a file created during test execution. This
commit removes the unused file and corresponding env-var and uses a more
appropriate name for the temp file.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Andreas Schwab [Wed, 7 Jun 2023 09:21:48 +0000 (11:21 +0200)]
resolv_conf: release lock on allocation failure (bug 30527)
When the initial allocation of global fails, the local lock is left
locked.
Reported by Steffen Lammel of SAP HANA development.
Arjun Shankar [Tue, 6 Jun 2023 17:20:31 +0000 (19:20 +0200)]
time: Fix use-after-free in getdate
getdate would free the buffer pointed to by the result of its call to
strptime, then reference the same buffer later on -- leading to a
use-after-free. This commit fixes that.
Reported-by: Martin Coufal <mcoufal@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Frédéric Bérat [Fri, 2 Jun 2023 15:28:12 +0000 (17:28 +0200)]
Move {read,write}_all functions to a dedicated header
Since these functions are used in both catgets/gencat.c and
malloc/memusage{,stat}.c, it make sense to move them into a dedicated
header where they can be inlined.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Fri, 2 Jun 2023 15:28:11 +0000 (17:28 +0200)]
tests: Replace various function calls with their x variant
With fortification enabled, few function calls return result need to be
checked, has they get the __wur macro enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Fri, 2 Jun 2023 15:28:06 +0000 (17:28 +0200)]
tests: fix warn unused result on asprintf calls
When enabling _FORTIFY_SOURCE, some functions now lead to warnings when
their result is not checked.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Florian Weimer [Tue, 6 Jun 2023 09:39:06 +0000 (11:39 +0200)]
pthreads: Use _exit to terminate the tst-stdio1 test
Previously, the exit function was used, but this causes the test to
block (until the timeout) once exit is changed to lock stdio streams
during flush.
Florian Weimer [Tue, 6 Jun 2023 09:37:30 +0000 (11:37 +0200)]
support: Add delayed__exit (with two underscores)
It calls _exit instead of exit once the timeout expires.
Adhemerval Zanella [Fri, 2 Jun 2023 17:02:09 +0000 (14:02 -0300)]
time: Also check for EPERM while trying to clock_settime
Container management default seccomp filter [1] only accepts
clock_settime if process has also CAP_SYS_TIME. So also handle
EPERM as well.
Also adapt the test to libsupport and add a proper Copyright header.
Checked on aarch64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Fri, 2 Jun 2023 13:19:48 +0000 (10:19 -0300)]
linux: Fail as unsupported if personality call is filtered
Container management default seccomp filter [1] only accepts
personality(2) with PER_LINUX, (0x0), UNAME26 (0x20000),
PER_LINUX32 (0x8), UNAME26 | PER_LINUX32, and 0xffffffff (to query
current personality)
Although the documentation only state it is blocked to prevent
'enabling BSD emulation' (PER_BSD, not implemented by Linux), checking
on repository log the real reason is to block ASLR disable flag
(ADDR_NO_RANDOMIZE) and other poorly support emulations.
So handle EPERM and fail as UNSUPPORTED if we can really check for
BZ#19408.
Checked on aarch64-linux-gnu.
[1] https://github.com/moby/moby/blob/master/profiles/seccomp/default.json
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Joseph Myers [Mon, 5 Jun 2023 14:35:25 +0000 (14:35 +0000)]
Remove MAP_VARIABLE from hppa bits/mman.h
As suggested in
<https://sourceware.org/pipermail/libc-alpha/2023-February/145890.html>,
remove the MAP_VARIABLE define from the hppa bits/mman.h, for
consistency with Linux 6.2 which removed the define there.
Tested with build-many-glibcs.py for hppa-linux-gnu.
Sergey Bugaev [Sun, 4 Jun 2023 17:05:51 +0000 (19:05 +0200)]
hurd: Fix x86_64 sigreturn restoring bogus reply_port
Since the area of the user's stack we use for the registers dump (and
otherwise as __sigreturn2's stack) can and does overlap the sigcontext,
we have to be very careful about the order of loads and stores that we
do. In particular we have to load sc_reply_port before we start
clobbering the sigcontext.
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Carlos O'Donell [Thu, 18 May 2023 20:18:22 +0000 (16:18 -0400)]
Add lint-makefiles Makefile linting test.
We add a 'make check' test that lints all Makefiles in the source
directory of the glibc build. This linting test ensures that the
lines in all Makefiles will be sorted correctly as developers
creates patches. It is added to 'make check' because it is
light-weight and supports the existing developer workflow
The test adds ~3s to a 'make check' execution.
No regressions on x86_64 and i686.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Carlos O'Donell [Tue, 30 May 2023 12:01:27 +0000 (08:01 -0400)]
elf: Sort Makefile variables.
Sort Makefile variables using scrips/sort-makefile-lines.py.
No code generation changes observed in non-test binary artifacts.
No regressions on x86_64 and i686.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Paul Pluzhnikov [Fri, 2 Jun 2023 03:40:12 +0000 (03:40 +0000)]
Fix a few more typos I missed in previous round -- BZ 25337
Paul Pluzhnikov [Sat, 20 May 2023 13:37:47 +0000 (13:37 +0000)]
Fix all the remaining misspellings -- BZ 25337
Alejandro Colomar [Mon, 22 May 2023 22:01:21 +0000 (00:01 +0200)]
Use __nonnull for the epoll_wait(2) family of syscalls
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Alejandro Colomar [Wed, 31 May 2023 20:44:22 +0000 (22:44 +0200)]
Fix invalid use of NULL in epoll_pwait2(2) test
epoll_pwait2(2)'s second argument should be nonnull. We're going to add
__nonnull to the prototype, so let's fix the test accordingly. We can
use a dummy variable to avoid passing NULL.
Reported-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Joe Simmons-Talbott [Tue, 30 May 2023 18:32:55 +0000 (14:32 -0400)]
getipv4sourcefilter: Get rid of alloca
Use a scratch_buffer rather than alloca to avoid potential stack
overflows.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Joe Simmons-Talbott [Tue, 30 May 2023 18:13:40 +0000 (14:13 -0400)]
getsourcefilter: Get rid of alloca.
Use a scratch_buffer rather than alloca to avoid potential stack
overflows.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Frédéric Bérat [Thu, 1 Jun 2023 14:27:47 +0000 (16:27 +0200)]
tests: fix warn unused results
With fortification enabled, few function calls return result need to be
checked, has they get the __wur macro enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Thu, 1 Jun 2023 14:27:44 +0000 (16:27 +0200)]
nptl_db/thread_dbP.h: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Thu, 1 Jun 2023 14:27:43 +0000 (16:27 +0200)]
malloc/{memusage.c, memusagestat.c}: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Thu, 1 Jun 2023 14:27:42 +0000 (16:27 +0200)]
catgets/gencat.c: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Fri, 28 Apr 2023 12:21:39 +0000 (14:21 +0200)]
tests: replace ftruncate by xftruncate
With fortification enabled, ftruncate calls return result needs to be
checked, has it gets the __wur macro enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Thu, 1 Jun 2023 16:40:05 +0000 (12:40 -0400)]
tests: replace write by xwrite
Using write without cheks leads to warn unused result when __wur is
enabled.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
H.J. Lu [Thu, 1 Jun 2023 15:53:35 +0000 (08:53 -0700)]
x86-64: Use YMM registers in memcmpeq-evex.S
Since the assembly source file with -evex suffix should use YMM registers,
not ZMM registers, include x86-evex256-vecs.h by default to use YMM
registers in memcmpeq-evex.S
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Siddhesh Poyarekar [Thu, 1 Jun 2023 11:23:15 +0000 (07:23 -0400)]
support: Don't fail on fchown when spawning sgid processes
In some cases (e.g. when podman creates user containers), the only other
group assigned to the executing user is nobody and fchown fails with it
because the group is not mapped. Do not fail the test in this case,
instead exit as unsupported.
Reported-by: Frédéric Bérat <fberat@redhat.com>
Tested-by: Frédéric Bérat <fberat@redhat.com>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Tue, 30 May 2023 19:40:38 +0000 (16:40 -0300)]
io: Fix F_GETLK, F_SETLK, and F_SETLKW for powerpc64
Different than other 64 bit architectures, powerpc64 defines the
LFS POSIX lock constants with values similar to 32 ABI, which
are meant to be used with fcntl64 syscall. Since powerpc64 kABI
does not have fcntl, the constants are adjusted with the
FCNTL_ADJUST_CMD macro.
The
4d0fe291aed3a476a changed the logic of generic constants
LFS value are equal to the default values; which is now wrong
for powerpc64.
Fix the value by explicit define the previous glibc constants
(powerpc64 does not need to use the 32 kABI value, but it simplifies
the FCNTL_ADJUST_CMD which should be kept as compatibility).
Checked on powerpc64-linux-gnu and powerpc-linux-gnu.
Florian Weimer [Wed, 31 May 2023 05:35:07 +0000 (07:35 +0200)]
elf: Remove spurios SHARED conditional from elf/rtld.c
elf/rtld.c is only ever built in SHARED mode.
Paul Pluzhnikov [Tue, 30 May 2023 23:02:29 +0000 (23:02 +0000)]
Fix misspellings in sysdeps/ -- BZ 25337
Adhemerval Zanella [Wed, 24 May 2023 19:24:19 +0000 (16:24 -0300)]
io: Fix record locking contants on 32 bit arch with 64 bit default time_t (BZ#30477)
For architecture with default 64 bit time_t support, the kernel
does not provide LFS and non-LFS values for F_GETLK, F_GETLK, and
F_GETLK (the default value used for 64 bit architecture are used).
This is might be considered an ABI break, but the currenct exported
values is bogus anyway.
The POSIX lockf is not affected since it is aliased to lockf64,
which already uses the LFS values.
Checked on i686-linux-gnu and the new tests on a riscv32.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Wed, 24 May 2023 18:09:26 +0000 (15:09 -0300)]
io: Re-flow and sort multiline Makefile definitions
Florian Weimer [Tue, 30 May 2023 11:25:50 +0000 (13:25 +0200)]
elf: Make more functions available for binding during dlclose (bug 30425)
Previously, after destructors for a DSO have been invoked, ld.so refused
to bind against that DSO in all cases. Relax this restriction somewhat
if the referencing object is itself a DSO that is being unloaded. This
assumes that the symbol reference is not going to be stored anywhere.
The situation in the test case can arise fairly easily with C++ and
objects that are built with different optimization levels and therefore
define different functions with vague linkage.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
caiyinyu [Thu, 25 May 2023 09:01:11 +0000 (17:01 +0800)]
LoongArch: Fix inconsistency in SHMLBA macro values between glibc and kernel
The LoongArch glibc was using the value of the SHMLBA macro from common code,
which is __getpagesize() (16k), but this was inconsistent with the value of
the SHMLBA macro in the kernel, which is SZ_64K (64k). This caused several
shmat-related tests in LTP (Linux Test Project) to fail. This commit fixes
the issue by ensuring that the glibc's SHMLBA macro value matches the value
used in the kernel like other architectures.
Paul Pluzhnikov [Sat, 27 May 2023 20:47:46 +0000 (20:47 +0000)]
Fix misspellings in elf/ -- BZ 25337
Applying this commit results in bit-identical libc.so.6.
The elf/ld-linux-x86-64.so.2 does change, but only in .note.gnu.build-id
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Wed, 28 Sep 2022 02:49:24 +0000 (23:49 -0300)]
riscv: Add the clone3 wrapper
It follows the internal signature:
extern int clone3 (struct clone_args *__cl_args, size_t __size,
int (*__func) (void *__arg), void *__arg);
Checked on riscv64-linux-gnu-rv64imafdc-lp64d.
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Dridi Boukelmoune [Thu, 25 May 2023 12:45:03 +0000 (14:45 +0200)]
posix: Add error message for EAI_OVERFLOW
Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
Joe Simmons-Talbott [Tue, 16 May 2023 13:45:49 +0000 (09:45 -0400)]
setsourcefilter: Replace alloca with a scratch_buffer.
Use a scratch_buffer rather than either alloca or malloc to reduce the
possibility of a stack overflow.
Suggested-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Joe Simmons-Talbott [Tue, 23 May 2023 19:41:29 +0000 (15:41 -0400)]
time: strftime_l: Avoid an unbounded alloca.
Avoid possible stack overflow by removing alloca() and converting to
wide characters within the buffer.
Suggested-by: Paul Eggert <eggert@cs.ucla.edu>
Noah Goldstein [Tue, 9 May 2023 03:10:20 +0000 (22:10 -0500)]
x86: Use 64MB as nt-store threshold if no cacheinfo [BZ #30429]
If `non_temporal_threshold` is below `minimum_non_temporal_threshold`,
it almost certainly means we failed to read the systems cache info.
In this case, rather than defaulting the minimum correct value, we
should default to a value that gets at least reasonable
performance. 64MB is chosen conservatively to be at the very high
end. This should never cause non-temporal stores when, if we had read
cache info, we wouldn't have otherwise.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Samuel Thibault [Sat, 27 May 2023 22:29:14 +0000 (00:29 +0200)]
hurd: Fix setting up signal thread stack alignment
x86_64 needs special alignment when calling functions, so we have to use
MACHINE_THREAD_STATE_SETUP_CALL for the signal thread when forking.
Samuel Thibault [Sat, 27 May 2023 21:06:00 +0000 (23:06 +0200)]
mach: Fix startup with stack protector
thread_set_state() is used to set up TLS, so stack protection can not be
used yet.
Paul Pluzhnikov [Sat, 27 May 2023 16:41:44 +0000 (16:41 +0000)]
Fix misspellings in manual/ -- BZ 25337
Paul Pluzhnikov [Sat, 27 May 2023 06:48:33 +0000 (06:48 +0000)]
Fix misspellings in iconv/ and iconvdata/ -- BZ 25337
All the changes are in comments or '#error' messages.
Applying this commit results in bit-identical rebuild of iconvdata/*.so
Reviewed-by: Florian Weimer <fw@deneb.enyo.de>
Joseph Myers [Fri, 26 May 2023 15:04:51 +0000 (15:04 +0000)]
Add MFD_NOEXEC_SEAL, MFD_EXEC from Linux 6.3 to bits/mman-shared.h
Linux 6.3 adds new constants MFD_NOEXEC_SEAL and MFD_EXEC. Add these
to bits/mman-shared.h (conditional on MFD_NOEXEC_SEAL not already
being defined, similar to the existing conditional on the older MFD_*
macros).
Tested for x86_64.
Joseph Myers [Fri, 26 May 2023 15:04:13 +0000 (15:04 +0000)]
Add IP_LOCAL_PORT_RANGE from Linux 6.3 to bits/in.h
Linux 6.3 adds a new constant IP_LOCAL_PORT_RANGE. Add it to the
corresponding bits/in.h in glibc.
Tested for x86_64.
Joseph Myers [Fri, 26 May 2023 15:03:31 +0000 (15:03 +0000)]
Add AT_RSEQ_* from Linux 6.3 to elf.h
Linux 6.3 adds constants AT_RSEQ_FEATURE_SIZE and AT_RSEQ_ALIGN; add
them to glibc's elf.h. (Recall that, although elf.h is a
system-independent header, so far we've put AT_* constants there even
if Linux-specific, as discussed in bug 15794. So rather than making
any attempt to fix that issue, the new constants are just added there
alongside the existing ones.)
Tested for x86_64.
Joe Simmons-Talbott [Fri, 26 May 2023 13:58:27 +0000 (09:58 -0400)]
setipv4sourcefilter: Avoid using alloca.
Use a scratch_buffer rather than alloca/malloc to avoid potential stack
overflow.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Adhemerval Zanella [Mon, 23 Jan 2023 16:59:31 +0000 (13:59 -0300)]
wchar: Define va_list for POSIX (BZ #30035)
This was uncovered by a recent clang change [1]. Different than ISO C,
POSIX states that va_list should be exported by wchar.h [2].
Checked on x86_64-linux-gnu and aarch64-linux-gnu.
[1] https://reviews.llvm.org/D137268
[2] https://pubs.opengroup.org/onlinepubs/
9699919799.2018edition/basedefs/wchar.h.html
Roy Eldar [Thu, 25 May 2023 14:41:59 +0000 (17:41 +0300)]
elf: add test for dl-printf
This patch checks _dl_debug_vdprintf, by passing various inputs to
_dl_dprintf and comparing the output with invocations of snprintf.
Signed-off-by: Roy Eldar <royeldar0@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Roy Eldar [Thu, 25 May 2023 14:41:58 +0000 (17:41 +0300)]
elf: fix handling of negative numbers in dl-printf
_dl_debug_vdprintf is a bare-bones printf implementation; currently
printing a signed integer (using "%d" format specifier) behaves
incorrectly when the number is negative, as it just prints the
corresponding unsigned integer, preceeded by a minus sign.
For example, _dl_printf("%d", -1) would print '-
4294967295'.
Signed-off-by: Roy Eldar <royeldar0@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Siddhesh Poyarekar [Thu, 25 May 2023 15:15:54 +0000 (11:15 -0400)]
elf: Update comment in open_path
f55727ca53308a206cf00d0442f8c57c73761899 updated open_path to use the
r_search_path_struct struct but failed to update the comment.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Qixing ksyx Xue [Thu, 25 May 2023 15:10:54 +0000 (11:10 -0400)]
elf: Add test for locating libraries in root dir (bug 30435)
When dlopen is being called, efforts have been made to improve
future lookup performance. This includes marking a search path
as non-existent using `stat`. However, if the root directory
is given as a search path, there exists a bug which erroneously
marks it as non-existing.
The bug is reproduced under the following sequence:
1. dlopen is called to open a shared library, with at least:
1) a dependency 'A.so' not directly under the '/' directory
(e.g. /lib/A.so), and
2) another dependency 'B.so' resides in '/'.
2. for this bug to reproduce, 'A.so' should be searched *before* 'B.so'.
3. it first tries to find 'A.so' in /, (e.g. /A.so):
- this will (obviously) fail,
- since it's the first time we have seen the '/' directory,
its 'status' is 'unknown'.
4. `buf[buflen - namelen - 1] = '\0'` is executed:
- it intends to remove the leaf and its final slash,
- because of the speciality of '/', its buflen == namelen + 1,
- it erroneously clears the entire buffer.
6. it then calls 'stat' with the empty buffer:
- which will result in an error.
7. so it marks '/' as 'nonexisting', future lookups will not consider
this path.
8. while /B.so *does* exist, failure to look it up in the '/'
directory leads to a 'cannot open shared object file' error.
This patch fixes the bug by preventing 'buflen', an index to put '\0',
from being set to 0, so that the root '/' is always kept.
Relative search paths are always considered as 'existing' so this
wont be affected.
Writeup by Moody Liu <mooodyhunter@outlook.com>
Suggested-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Qixing ksyx Xue <qixingxue@outlook.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Adhemerval Zanella [Wed, 24 May 2023 18:09:26 +0000 (15:09 -0300)]
io: Re-flow and sort multiline Makefile definitions
Adhemerval Zanella [Thu, 25 May 2023 11:14:37 +0000 (08:14 -0300)]
Fix special case for C2x strtol binary constant handling (BZ# 30371)
When the base is 0 or 2 and the first two characters are '0' and 'b',
but the rest are no binary digits. In this case this is no error,
and strtol must return 0 and ENDPTR points to the 'x' or 'b'.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Andreas Schwab [Tue, 16 May 2023 12:41:46 +0000 (14:41 +0200)]
rtld: properly handle root directory in load path (bug 30435)
Don't strip the trailing slash when checking for existence of a load path
element to handle the special case of the root directory.
Frédéric Bérat [Fri, 28 Apr 2023 12:21:33 +0000 (14:21 +0200)]
sysdeps/pthread/eintr.c: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Fri, 28 Apr 2023 12:21:32 +0000 (14:21 +0200)]
sunrpc/netname.c: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Frédéric Bérat [Fri, 28 Apr 2023 12:21:29 +0000 (14:21 +0200)]
locale/programs/locarchive.c: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Carlos O'Donell [Tue, 23 May 2023 12:34:56 +0000 (08:34 -0400)]
support: Reformat Makefile.
Add list end markers.
Sort text using scripts/sort-makefile-lines.py.
No code generation changes observed in non-test binary artifacts.
No regressions on x86_64 and i686.
Paul Pluzhnikov [Tue, 23 May 2023 16:21:29 +0000 (16:21 +0000)]
Regenerate configure fragment -- BZ 25337.
In commit
0b25c28e028b63c95108c442d8112811107e4c13 I updated congure.ac
but neglected to regenerate updated configure.
Fix this here.
Paul Pluzhnikov [Tue, 23 May 2023 12:11:30 +0000 (12:11 +0000)]
Fix misspellings in sysdeps/powerpc -- BZ 25337
All fixes are in comments, so the binaries should be identical
before/after this commit, but I can't verify this.
Reviewed-by: Rajalakshmi Srinivasaraghavan <rajis@linux.ibm.com>
Paul Pluzhnikov [Tue, 23 May 2023 10:50:31 +0000 (10:50 +0000)]
Fix misspellings in sysdeps/unix -- BZ 25337
Applying this commit results in bit-identical rebuild of
libc.so.6 math/libm.so.6 elf/ld-linux-x86-64.so.2 mathvec/libmvec.so.1
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Paul Pluzhnikov [Tue, 23 May 2023 03:57:01 +0000 (03:57 +0000)]
Fix misspellings in sysdeps/x86_64 -- BZ 25337.
Applying this commit results in bit-identical rebuild of libc.so.6
math/libm.so.6 elf/ld-linux-x86-64.so.2 mathvec/libmvec.so.1
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Samuel Thibault [Tue, 23 May 2023 07:36:22 +0000 (09:36 +0200)]
mach: Fix accessing mach_i386.h
Fixes:
196358ae26aa ("mach: Fix installing mach_i386.h")
Paul Pluzhnikov [Mon, 22 May 2023 03:40:33 +0000 (03:40 +0000)]
Fix misspellings in sysdeps/x86_64/fpu/multiarch -- BZ 25337.
Applying this commit results in a bit-identical rebuild of
mathvec/libmvec.so.1 (which is the only binary that gets rebuilt).
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Samuel Thibault [Mon, 22 May 2023 23:44:43 +0000 (01:44 +0200)]
mach: Fix installing mach_i386.h
We do not want mach_i386.h to get installed into machine/, but into
i386/ or x86_64/ depending where mach_i386.defs was found, i.e.
according to 32/64 bitness.
Samuel Thibault [Mon, 22 May 2023 22:31:31 +0000 (00:31 +0200)]
hurd: Fix making ld.so run static binaries with retry
We need O_EXEC for __rtld_execve
Ronan Pigott [Mon, 22 May 2023 20:13:41 +0000 (22:13 +0200)]
Add voice-admit DSCP code point from RFC-5865
Samuel Thibault [Mon, 22 May 2023 17:47:49 +0000 (17:47 +0000)]
mach: Fix mach_setup_thread_impl with NULL stack_base
This is notably necessary for running the gmon thread.
Andreas Schwab [Mon, 8 May 2023 13:40:46 +0000 (15:40 +0200)]
Remove last remnants of have-protected
Stefan Liebler [Fri, 12 May 2023 10:44:49 +0000 (12:44 +0200)]
S390: Use compile-only instead of also link-tests in configure.
Some of the s390-specific configure checks are using compile and
link configure tests. Now use only compile tests as the link
tests fails when e.g. bootstrapping a cross-toolchain due to
missing crt-files/libc.so. This is achieved by using
AC_COMPILE_IFELSE in configure.ac file.
This is observable e.g. when using buildroot which builds glibc
only once or the build-many-glibcs.py script. Note that the latter
one is building glibc twice in the compilers-step (configure-checks
fails) and in the glibcs-step (configure-checks succeed).
Note, that the s390 specific configure tests for static PIE have to
link an executable to test binutils support. Thus we can't fix
those tests.
Flavio Cruz [Mon, 22 May 2023 05:16:50 +0000 (01:16 -0400)]
Fix build for hurd/thread-self.c for i386.
We need to include hurd.h for libc_hidden_proto (__hurd_thread_self),
introduced in
b44c1e12524b ("hurd: Fix using interposable
hurd_thread_self")
This the error log:
In file included from <command-line>:
./../include/libc-symbols.h:472:33: error: '__EI___hurd_thread_self' aliased to undefined symbol '__GI___hurd_thread_self'
472 | extern thread __typeof (name) __EI_##name \
| ^~~~~
./../include/libc-symbols.h:468:3: note: in expansion of macro '__hidden_ver2'
468 | __hidden_ver2 (, local, internal, name)
| ^~~~~~~~~~~~~
./../include/libc-symbols.h:476:41: note: in expansion of macro '__hidden_ver1'
476 | # define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
| ^~~~~~~~~~~~~
./../include/libc-symbols.h:557:32: note: in expansion of macro 'hidden_def'
557 | # define libc_hidden_def(name) hidden_def (name)
| ^~~~~~~~~~
thread-self.c:27:1: note: in expansion of macro 'libc_hidden_def'
27 | libc_hidden_def (__hurd_thread_self)
| ^~~~~~~~~~~~~~~
Message-Id: <ZGr6wj2UOxg3F0qH@jupiter.tail36e24.ts.net>
Sergey Bugaev [Sat, 20 May 2023 11:55:31 +0000 (14:55 +0300)]
io: Fix a typo
Fixes
85f7554cd97e7f03d8dc66278653045ef63a2221
"Add test case for O_TMPFILE handling in open, openat"
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <
20230520115531.3911877-3-bugaevc@gmail.com>
Sergey Bugaev [Sat, 20 May 2023 11:55:30 +0000 (14:55 +0300)]
htl: Use __hurd_fail () instead of assigning errno
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <
20230520115531.3911877-2-bugaevc@gmail.com>
Sergey Bugaev [Sat, 20 May 2023 11:55:29 +0000 (14:55 +0300)]
hurd: Use __hurd_fail () instead of assigning errno
The __hurd_fail () inline function is the dedicated, idiomatic way of
reporting errors in the Hurd part of glibc. Not only is it more concise
than '{ errno = err; return -1; }', it is since commit
6639cc10029e24e06b34e169712b21c31b8cf213
"hurd: Mark error functions as __COLD" marked with the cold attribute,
telling the compiler that this codepath is unlikely to be executed.
In one case, use __hurd_dfail () over the plain __hurd_fail ().
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <
20230520115531.3911877-1-bugaevc@gmail.com>
Mahesh Bodapati [Fri, 12 May 2023 10:22:59 +0000 (05:22 -0500)]
powerpc:GCC(<10) doesn't allow -mlong-double-64 after -mabi=ieeelongdouble
Removed -mabi=ieeelongdouble on failing tests. It resolves the error.
error: ‘-mabi=ieeelongdouble’ requires ‘-mlong-double-128’
Sergey Bugaev [Fri, 19 May 2023 14:47:24 +0000 (17:47 +0300)]
hurd: Fix using interposable hurd_thread_self
Create a private hidden __hurd_thread_self alias, and use that one.
Fixes
2f8ecb58a59eb82c43214d000842d99644a662d1
"hurd: Fix x86_64 _hurd_tls_fork" and
c7fcce38c83a2bb665ef5dc4981bf20c7e586123
"hurd: Make sure to not use tcb->self"
Reported-by: Joseph Myers <joseph@codesourcery.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Samuel Thibault [Fri, 19 May 2023 18:44:01 +0000 (20:44 +0200)]
hurd 64bit: Re-introduce gai_suspend symbol
4d3f846b88d3 ("hurd: Fix __TIMESIZE on x86_64") incidentaly dropped it
because it fixed hurd 64bit into setting __TIMESIZE to 64, and that case
was not having gai_suspend defined yet.