]> sourceware.org Git - glibc.git/log
glibc.git
3 years agonptl: Move internal symbol __mutex_aconf into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move internal symbol __mutex_aconf into libc

This is in preparation of moving the mutex code into libc.

__pthread_tunables_init is now called via __pthread_early_init.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agopthread: Introduce __pthread_early_init
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
pthread: Introduce __pthread_early_init

This function is called from __libc_early_init to initialize the
pthread subsystem.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move the internal thread priority protection symbols into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move the internal thread priority protection symbols into libc

This is a prerequisite for moving the mutex implementation.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move rwlock functions with forwarders into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move rwlock functions with forwarders into libc

The forwarders were only used internally, so new symbol versions
are needed.  All symbols are moved at once because the forwarders
are no-ops if libpthread is not loaded, leading to inconsistencies
in case of a partial migration.

The symbols __pthread_rwlock_rdlock, __pthread_rwlock_unlock,
__pthread_rwlock_wrlock, pthread_rwlock_rdlock,
pthread_rwlock_unlock, pthread_rwlock_wrlock have been moved using
scripts/move-symbol-to-libc.py.

The __ symbol variants are turned into compat symbols, which is why they
do not receive a GLIBC_2.34 version.

3 years agonptl: Move pthread_key_delete into libc.
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move pthread_key_delete into libc.

The symbol was moved using scripts/move-symbol-to-libc.py.

tss_delete (still in libpthread) uses the __pthread_key_create
alias, so that is now exported under GLIBC_PRIVATE.

3 years agonptl: Move pthread_setspecific, __pthread_setspecific into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move pthread_setspecific, __pthread_setspecific into libc

The symbols have been moved using scripts/move-symbol-to-libc.py.

3 years agonptl: Move pthread_getspecific, __pthread_getspecific into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move pthread_getspecific, __pthread_getspecific into libc

The symbols have been moved using scripts/move-symbol-to-libc.py.

3 years agonptl: Move pthread_key_create, __pthread_key_create into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move pthread_key_create, __pthread_key_create into libc

The symbols have been moved using scripts/move-symbol-to-libc.py.

3 years agonptl: Move part of TCB initialization from libpthread to __tls_init_tp
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Move part of TCB initialization from libpthread to __tls_init_tp

This initalization should only happen once for the main thread's TCB.
At present, auditors can achieve this by not linking against
libpthread.  If libpthread becomes part of libc, doing this
initialization in libc would happen for every audit namespace,
or too late (if it happens from the main libc only).  That's why
moving this code into ld.so seems the right thing to do, right after
the TCB initialization.

For !__ASSUME_SET_ROBUST_LIST ports, this also moves the symbol
__set_robust_list_avail into ld.so, as __nptl_set_robust_list_avail.
It also turned into a proper boolean flag.

Inline the __pthread_initialize_pids function because it seems no
longer useful as a separate function.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Introduce __tls_init_tp for second-phase TCB initialization
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
elf: Introduce __tls_init_tp for second-phase TCB initialization

TLS_INIT_TP is processor-specific, so it is not a good place to
put thread library initialization code (it would have to be repeated
for all CPUs).  Introduce __tls_init_tp as a separate function,
to be called immediately after TLS_INIT_TP.  Move the existing
stack list setup code for NPTL to this function.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoRemove pthread_key_create-related internals from libc-lock.h
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
Remove pthread_key_create-related internals from libc-lock.h

And libc-lockP.h.  This is no longer used because all internal
TLS use goes directly to the thread descriptor/TCB or uses ELF TLS.

3 years agodlfcn: dlerror needs to call free from the base namespace [BZ #24773]
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
dlfcn: dlerror needs to call free from the base namespace [BZ #24773]

Calling free directly may end up freeing a pointer allocated by the
dynamic loader using malloc from libc.so in the base namespace using
the allocator from libc.so in a secondary namespace, which results in
crashes.

This commit redirects the free call through GLRO and the dynamic
linker, to reach the correct namespace.  It also cleans up the dlerror
handling along the way, so that pthread_setspecific is no longer
needed (which avoids triggering bug 24774).

3 years agodlfcn: Failures after dlmopen should not terminate process [BZ #24772]
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
dlfcn: Failures after dlmopen should not terminate process [BZ #24772]

Commit 9e78f6f6e7134a5f299cc8de77370218f8019237 ("Implement
_dl_catch_error, _dl_signal_error in libc.so [BZ #16628]") has the
side effect that distinct namespaces, as created by dlmopen, now have
separate implementations of the rtld exception mechanism.  This means
that the call to _dl_catch_error from libdl in a secondary namespace
does not actually install an exception handler because the
thread-local variable catch_hook in the libc.so copy in the secondary
namespace is distinct from that of the base namepace.  As a result, a
dlsym/dlopen/... failure in a secondary namespace terminates the process
with a dynamic linker error because it looks to the exception handler
mechanism as if no handler has been installed.

This commit restores GLRO (dl_catch_error) and uses it to set the
handler in the base namespace.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Invoke the set_robust_list system call directly in fork
Florian Weimer [Wed, 21 Apr 2021 17:49:51 +0000 (19:49 +0200)]
nptl: Invoke the set_robust_list system call directly in fork

This removes one of the pthread forwarder functions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_setcanceltype into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move pthread_setcanceltype into libc

No new symbol version is required because there was a forwarder.

The symbol has been moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_setcancelstate into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move pthread_setcancelstate into libc

No new symbol version is required because there was a forwarder.

The symbol has been moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_exit into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move pthread_exit into libc

The pthread_exit symbol was moved using
scripts/move-symbol-to-libc.py.  No new symbol version is needed
because there was a forwarder.

The new tests nptl/tst-pthread_exit-nothreads and
nptl/tst-pthread_exit-nothreads-static exercise the scenario
that pthread_exit is called without libpthread having been linked in.
This is not possible for the generic code, so these tests do not
live in sysdeps/pthread for now.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __nptl_deallocate_tsd into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move __nptl_deallocate_tsd into libc

This prepares moving pthread_exit, and later the pthread_key_create
infrastructure.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __pthread_keys global variable into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move __pthread_keys global variable into libc

This prepares moving pthread_exit, and later the pthread_key_create
infrastructure.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl_db: Introduce DB_MAIN_ARRAY_VARIABLE
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl_db: Introduce DB_MAIN_ARRAY_VARIABLE

And document the reason for DB_ARRAY_VARIABLE.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move internal __nptl_nthreads variable into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move internal __nptl_nthreads variable into libc

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agocsu: Move calling main out of __libc_start_main_impl
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
csu: Move calling main out of __libc_start_main_impl

This code depends on whether glibc has unwinding support for
a particular port.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __pthread_unwind_next into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move __pthread_unwind_next into libc

It's necessary to stub out __libc_disable_asynccancel and
__libc_enable_asynccancel via rtld-stubbed-symbols because the new
direct references to the unwinder result in symbol conflicts when the
rtld exception handling from libc is linked in during the construction
of librtld.map.

unwind-forcedunwind.c is merged into unwind-resume.c.  libc now needs
the functions that were previously only used in libpthread.

The GLIBC_PRIVATE exports of __libc_longjmp and __libc_siglongjmp are
no longer needed, so switch them to hidden symbols.

The symbol __pthread_unwind_next has been moved using
scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_once and __pthread_once into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move pthread_once and __pthread_once into libc

And also the fork generation counter, __fork_generation.  This
eliminates the need for __fork_generation_pointer.

call_once remains in libpthread and calls the exported __pthread_once
symbol.

pthread_once and __pthread_once have been moved using
scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __pthread_cleanup_upto into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move __pthread_cleanup_upto into libc

This internal symbol is used as part of the longjmp implementation.
Rename the file from nptl/pt-cleanup.c to nptl/pthread_cleanup_upto.c
so that the pt-* files remain restricted to libpthread.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agox86: Restore compile-time check for shadow stack pointer in longjmp
Adhemerval Zanella [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
x86: Restore compile-time check for shadow stack pointer in longjmp

3 years agonptl: Remove longjmp, siglongjmp from libpthread
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Remove longjmp, siglongjmp from libpthread

The definitions in libc are sufficient, the forwarders are no longer
needed.

The symbols have been moved using scripts/move-symbol-to-libc.py.
s390-linux-gnu and s390x-linux-gnu need a new version placeholder
to keep the GLIBC_2.19 symbol version in libpthread.

Tested on i386-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu,
x86_64-linux-gnu.  Built with build-many-glibcs.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move legacy cancelation handling into libc as compat symbols
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move legacy cancelation handling into libc as compat symbols

This affects _pthread_cleanup_pop, _pthread_cleanup_pop_restore,
_pthread_cleanup_push, _pthread_cleanup_push_defer.  The symbols
have been moved using scripts/move-symbol-to-libc.py.

No new symbol versions are added because the symbols are turned into
compatibility symbols at the same time.

__pthread_cleanup_pop and __pthread_cleanup_push are added as
GLIBC_PRIVATE symbols because they are also used internally, for
glibc's own cancellation handling.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move legacy unwinding implementation into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move legacy unwinding implementation into libc

It is still used internally.  Since unwinding is now available
unconditionally, avoid indirect calls through function pointers loaded
from the stack by inlining the non-cancellation cleanup code.  This
avoids a regression in security hardening.

The out-of-line  __libc_cleanup_routine implementation is no longer
needed because the inline definition is now static __always_inline.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __pthread_cleanup_routine into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move __pthread_cleanup_routine into libc

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_mutex_consistent into libc
Florian Weimer [Wed, 21 Apr 2021 17:49:50 +0000 (19:49 +0200)]
nptl: Move pthread_mutex_consistent into libc

And deprecated pthread_mutex_consistent_np, its old name.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Remove lazy tlsdesc relocation related code
Szabolcs Nagy [Thu, 11 Feb 2021 13:24:47 +0000 (13:24 +0000)]
elf: Remove lazy tlsdesc relocation related code

Remove generic tlsdesc code related to lazy tlsdesc processing since
lazy tlsdesc relocation is no longer supported.  This includes removing
GL(dl_load_lock) from _dl_make_tlsdesc_dynamic which is only called at
load time when that lock is already held.

Added a documentation comment too.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoFix argv overrun in getconf (bug 27761)
Andreas Schwab [Wed, 21 Apr 2021 12:27:21 +0000 (14:27 +0200)]
Fix argv overrun in getconf (bug 27761)

Correct argument counter accounting when processing the -v option with the
argument directly attached.

3 years agonptl_db: Support different libpthread/ld.so load orders (bug 27744)
Florian Weimer [Wed, 21 Apr 2021 09:50:43 +0000 (11:50 +0200)]
nptl_db: Support different libpthread/ld.so load orders (bug 27744)

libthread_db is loaded once GDB encounters libpthread, and at this
point, ld.so may not have been processed by GDB yet. As a result,
_rtld_global cannot be accessed by regular means from libthread_db.
To make this work until GDB can be fixed, acess _rtld_global through
a pointer stored in libpthread.

The new test does not reproduce bug 27744 with
--disable-hardcoded-path-in-tests, but is still a valid smoke test.
With --enable-hardcoded-path-in-tests, it is necessary to avoid
add-symbol-file because this can tickle a GDB bug.

Fixes commit 1daccf403b1bd86370eb94edca794dc106d02039 ("nptl: Move
stack list variables into _rtld_global").

Tested-by: Emil Velikov <emil.velikov@collabora.com>
3 years agox86: Optimize strlen-avx2.S
Noah Goldstein [Mon, 19 Apr 2021 23:36:07 +0000 (19:36 -0400)]
x86: Optimize strlen-avx2.S

No bug. This commit optimizes strlen-avx2.S. The optimizations are
mostly small things but they add up to roughly 10-30% performance
improvement for strlen. The results for strnlen are bit more
ambiguous. test-strlen, test-strnlen, test-wcslen, and test-wcsnlen
are all passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agox86: Optimize strlen-evex.S
Noah Goldstein [Mon, 19 Apr 2021 23:36:06 +0000 (19:36 -0400)]
x86: Optimize strlen-evex.S

No bug. This commit optimizes strlen-evex.S. The
optimizations are mostly small things but they add up to roughly
10-30% performance improvement for strlen. The results for strnlen are
bit more ambiguous. test-strlen, test-strnlen, test-wcslen, and
test-wcsnlen are all passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agoReindent string/test-memmove.c
H.J. Lu [Tue, 20 Apr 2021 00:46:05 +0000 (17:46 -0700)]
Reindent string/test-memmove.c

3 years agox86: Expand test-memset.c and bench-memset.c
Noah Goldstein [Mon, 19 Apr 2021 21:48:11 +0000 (17:48 -0400)]
x86: Expand test-memset.c and bench-memset.c

No bug. This commit adds tests cases and benchmarks for page cross and
for memset to the end of the page without crossing. As well in
test-memset.c this commit adds sentinel on start/end of tstbuf to test
for overwrites

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agox86: Optimize less_vec evex and avx512 memset-vec-unaligned-erms.S
Noah Goldstein [Mon, 19 Apr 2021 21:48:10 +0000 (17:48 -0400)]
x86: Optimize less_vec evex and avx512 memset-vec-unaligned-erms.S

No bug. This commit adds optimized cased for less_vec memset case that
uses the avx512vl/avx512bw mask store avoiding the excessive
branches. test-memset and test-wmemset are passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agox86-64: Require BMI2 for strchr-avx2.S
H.J. Lu [Mon, 19 Apr 2021 17:45:07 +0000 (10:45 -0700)]
x86-64: Require BMI2 for strchr-avx2.S

Since strchr-avx2.S updated by

commit 1f745ecc2109890886b161d4791e1406fdfc29b8
Author: noah <goldstein.w.n@gmail.com>
Date:   Wed Feb 3 00:38:59 2021 -0500

    x86-64: Refactor and improve performance of strchr-avx2.S

uses sarx:

c4 e2 72 f7 c0        sarx   %ecx,%eax,%eax

for strchr-avx2 family functions, require BMI2 in ifunc-impl-list.c and
ifunc-avx2.h.

3 years agox86-64: Require BMI2 for __strlen_evex and __strnlen_evex
H.J. Lu [Mon, 19 Apr 2021 14:07:21 +0000 (07:07 -0700)]
x86-64: Require BMI2 for __strlen_evex and __strnlen_evex

Since __strlen_evex and __strnlen_evex added by

commit 1fd8c163a83d96ace1ff78fa6bac7aee084f6f77
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Mar 5 06:24:52 2021 -0800

    x86-64: Add ifunc-avx2.h functions with 256-bit EVEX

use sarx:

c4 e2 6a f7 c0        sarx   %edx,%eax,%eax

require BMI2 for __strlen_evex and __strnlen_evex in ifunc-impl-list.c.
ifunc-avx2.h already requires BMI2 for EVEX implementation.

3 years agobenchtests: Fix name of exp10f benchmark variant
Siddhesh Poyarekar [Sun, 18 Apr 2021 07:09:12 +0000 (12:39 +0530)]
benchtests: Fix name of exp10f benchmark variant

Variant names don't accept brackets.

3 years agobenchtests: Fix pthread-locks test to produce valid json
Siddhesh Poyarekar [Sun, 18 Apr 2021 07:19:54 +0000 (12:49 +0530)]
benchtests: Fix pthread-locks test to produce valid json

The benchtests json allows {function {variant}} categorization of
results whereas the pthread-locks tests had {function {variant
{subvariant}}}, which broke validation.  Fix that by serializing the
subvariants as variant-subvariant.  Also update the schema to
recognize the new benchmark attributes after fixing the naming
conventions.

3 years agox86: Expanding test-memmove.c, test-memcpy.c, bench-memcpy-large.c
noah [Sat, 3 Apr 2021 08:12:16 +0000 (04:12 -0400)]
x86: Expanding test-memmove.c, test-memcpy.c, bench-memcpy-large.c

No Bug. This commit expanding the range of tests / benchmarks for
memmove and memcpy. The test expansion is mostly in the vein of
increasing the maximum size, increasing the number of unique
alignments tested, and testing both source < destination and vice
versa. The benchmark expansaion is just to increase the number of
unique alignments. test-memcpy, test-memccpy, test-mempcpy,
test-memmove, and tst-memmove-overflow all pass.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agoSet the retain attribute on _elf_set_element if CC supports [BZ #27492]
Fangrui Song [Fri, 16 Apr 2021 18:26:39 +0000 (11:26 -0700)]
Set the retain attribute on _elf_set_element if CC supports [BZ #27492]

So that text_set_element/data_set_element/bss_set_element defined
variables will be retained by the linker.

Note: 'used' and 'retain' are orthogonal: 'used' makes sure the variable
will not be optimized out; 'retain' prevents section garbage collection
if the linker support SHF_GNU_RETAIN.

GNU ld 2.37 and LLD 13 will support -z start-stop-gc which allow C
identifier name sections to be GCed even if there are live
__start_/__stop_ references.

Without the change, there are some static linking problems, e.g.
_IO_cleanup (libio/genops.c) may be discarded by ld --gc-sections, so
stdout is not flushed on exit.

Note: GCC may warning 'retain' attribute ignored while __has_attribute(retain)
is 1 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587).

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86: Update large memcpy case in memmove-vec-unaligned-erms.S
noah [Sat, 3 Apr 2021 08:12:15 +0000 (04:12 -0400)]
x86: Update large memcpy case in memmove-vec-unaligned-erms.S

No Bug. This commit updates the large memcpy case (no overlap). The
update is to perform memcpy on either 2 or 4 contiguous pages at
once. This 1) helps to alleviate the affects of false memory aliasing
when destination and source have a close 4k alignment and 2) In most
cases and for most DRAM units is a modestly more efficient access
pattern. These changes are a clear performance improvement for
VEC_SIZE =16/32, though more ambiguous for VEC_SIZE=64. test-memcpy,
test-memccpy, test-mempcpy, test-memmove, and tst-memmove-overflow all
pass.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agopowerpc: Add missing registers to clobbers list for syscalls [BZ #27623]
Matheus Castanho [Wed, 17 Mar 2021 13:14:15 +0000 (10:14 -0300)]
powerpc: Add missing registers to clobbers list for syscalls [BZ #27623]

Some registers that can be clobbered by the kernel during a syscall are not
listed on the clobbers list in sysdeps/unix/sysv/linux/powerpc/sysdep.h.

For syscalls using sc:
    - XER is zeroed by the kernel on exit

For syscalls using scv:
    - XER is zeroed by the kernel on exit
    - Different from the sc case, most CR fields can be clobbered (according to
      the ELF ABI and the Linux kernel's syscall ABI for powerpc
      (linux/Documentation/powerpc/syscall64-abi.rst)

The same should apply to vsyscalls, which effectively execute a function call
but are not currently adding these registers as clobbers either.

These are likely not causing issues today, but they should be added to the
clobbers list just in case things change on the kernel side in the future.

Reported-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
3 years agomisc: syslog: Use static const for AF_UNIX address
Adhemerval Zanella [Sun, 11 Apr 2021 02:42:12 +0000 (23:42 -0300)]
misc: syslog: Use static const for AF_UNIX address

Checked on x86_64-linux-gnu.

3 years agomisc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145)
Adhemerval Zanella [Sun, 11 Apr 2021 02:29:40 +0000 (23:29 -0300)]
misc: syslog: Use CLOC_EXEC with _PATH_CONSOLE (BZ #17145)

The syslog open the '/dev/console' for LOG_CONS without O_CLOEXEC,
which might leak in multithread programs that call fork.

Checked on x86_64-linux-gnu.

3 years agomisc: syslog: Assume MSG_NOSIGNAL support (BZ #17144)
Adhemerval Zanella [Fri, 9 Apr 2021 18:53:04 +0000 (15:53 -0300)]
misc: syslog: Assume MSG_NOSIGNAL support (BZ #17144)

MSG_NOSIGNAL was added on POSIX 2008 and Hurd seems to support it.
The SIGPIPE handling also makes the implementation not thread-safe
(due the sigaction usage).

Checked on x86_64-linux-gnu.

3 years agomisc: syslog: Use bool for connected
Adhemerval Zanella [Fri, 9 Apr 2021 18:40:20 +0000 (15:40 -0300)]
misc: syslog: Use bool for connected

Checked on x86_64-linux-gnu.

3 years agoposix: Add wait3 tests
Adhemerval Zanella [Mon, 1 Mar 2021 17:05:31 +0000 (14:05 -0300)]
posix: Add wait3 tests

The tst-wait4 is moved to common file and used for wait3
tests.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agotime: Add 64 bit tests for getdate / getdate_r
Adhemerval Zanella [Mon, 1 Mar 2021 20:10:26 +0000 (17:10 -0300)]
time: Add 64 bit tests for getdate / getdate_r

The test is also converted to use libsupport.

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agotime: Add basic timespec_get tests
Adhemerval Zanella [Mon, 1 Mar 2021 16:14:03 +0000 (13:14 -0300)]
time: Add basic timespec_get tests

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agotime: Add timegm/timelocal basic tests
Adhemerval Zanella [Mon, 1 Mar 2021 14:36:56 +0000 (11:36 -0300)]
time: Add timegm/timelocal basic tests

Checked i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agotime: Add gmtime/gmtime_r tests
Adhemerval Zanella [Mon, 1 Mar 2021 14:14:45 +0000 (11:14 -0300)]
time: Add gmtime/gmtime_r tests

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agotime: Add getitimer and setitimer basic tests
Adhemerval Zanella [Sun, 28 Feb 2021 20:31:25 +0000 (17:31 -0300)]
time: Add getitimer and setitimer basic tests

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoio: Use temporary directory and file for ftwtest-sh
Adhemerval Zanella [Wed, 3 Mar 2021 16:24:24 +0000 (13:24 -0300)]
io: Use temporary directory and file for ftwtest-sh

It allows run it in parallel.

Checked on x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoio: Add basic tests for utimensat
Adhemerval Zanella [Mon, 22 Mar 2021 17:55:22 +0000 (14:55 -0300)]
io: Add basic tests for utimensat

Checked on x86_64-linux-gnu and i686-linux-gnu

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agolinux: Add lutimes test
Adhemerval Zanella [Mon, 22 Mar 2021 17:23:45 +0000 (14:23 -0300)]
linux: Add lutimes test

It uses stat to compare against the values set by lutimes.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agolinux: Add futimes test
Adhemerval Zanella [Mon, 22 Mar 2021 17:16:01 +0000 (14:16 -0300)]
linux: Add futimes test

It uses stat to compare against the values set by futimes.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoio: Move file timestamps tests out of Linux
Adhemerval Zanella [Mon, 22 Mar 2021 18:10:23 +0000 (15:10 -0300)]
io: Move file timestamps tests out of Linux

Now that libsupport abstract Linux possible missing support (either
due FS limitation that can't handle 64 bit timestamp or architectures
that do not handle values larger than unsigned 32 bit values) the
tests can be turned generic.

Checked on x86_64-linux-gnu and i686-linux-gnu.  I also built the
tests for i686-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoelf: Fix missing include in test case [BZ #27136]
Szabolcs Nagy [Thu, 15 Apr 2021 08:57:10 +0000 (09:57 +0100)]
elf: Fix missing include in test case [BZ #27136]

Broken test was introduced in

  commit 8f85075a2e9c26ff7486d4bbaf358999807d215c
  elf: Add a DTV setup test [BZ #27136]

3 years agos390: Update ulps
Stefan Liebler [Thu, 15 Apr 2021 09:05:43 +0000 (11:05 +0200)]
s390: Update ulps

Required after 9acda61d94acc "Fix the inaccuracy of j0f/j1f/y0f/y1f
[BZ #14469, #14470, #14471, #14472]".

3 years agoi386: Remove lazy tlsdesc relocation related code
Szabolcs Nagy [Thu, 11 Feb 2021 11:58:20 +0000 (11:58 +0000)]
i386: Remove lazy tlsdesc relocation related code

Like in commit e75711ebfa976d5468ec292282566a18b07e4d67 for x86_64,
remove unused lazy tlsdesc relocation processing code:

  _dl_tlsdesc_resolve_abs_plus_addend
  _dl_tlsdesc_resolve_rel
  _dl_tlsdesc_resolve_rela
  _dl_tlsdesc_resolve_hold

3 years agox86_64: Remove lazy tlsdesc relocation related code
Szabolcs Nagy [Thu, 11 Feb 2021 11:52:24 +0000 (11:52 +0000)]
x86_64: Remove lazy tlsdesc relocation related code

_dl_tlsdesc_resolve_rela and _dl_tlsdesc_resolve_hold are only used for
lazy tlsdesc relocation processing which is no longer supported.

3 years agoi386: Avoid lazy relocation of tlsdesc [BZ #27137]
Szabolcs Nagy [Thu, 11 Feb 2021 11:40:11 +0000 (11:40 +0000)]
i386: Avoid lazy relocation of tlsdesc [BZ #27137]

Lazy tlsdesc relocation is racy because the static tls optimization and
tlsdesc management operations are done without holding the dlopen lock.

This similar to the commit b7cf203b5c17dd6d9878537d41e0c7cc3d270a67
for aarch64, but it fixes a different race: bug 27137.

On i386 the code is a bit more complicated than on x86_64 because both
rel and rela relocs are supported.

3 years agox86_64: Avoid lazy relocation of tlsdesc [BZ #27137]
Szabolcs Nagy [Thu, 11 Feb 2021 11:29:23 +0000 (11:29 +0000)]
x86_64: Avoid lazy relocation of tlsdesc [BZ #27137]

Lazy tlsdesc relocation is racy because the static tls optimization and
tlsdesc management operations are done without holding the dlopen lock.

This similar to the commit b7cf203b5c17dd6d9878537d41e0c7cc3d270a67
for aarch64, but it fixes a different race: bug 27137.

Another issue is that ld auditing ignores DT_BIND_NOW and thus tries to
relocate tlsdesc lazily, but that does not work in a BIND_NOW module
due to missing DT_TLSDESC_PLT. Unconditionally relocating tlsdesc at
load time fixes this bug 27721 too.

3 years agoelf: Refactor _dl_update_slotinfo to avoid use after free
Szabolcs Nagy [Wed, 30 Dec 2020 21:52:38 +0000 (21:52 +0000)]
elf: Refactor _dl_update_slotinfo to avoid use after free

map is not valid to access here because it can be freed by a concurrent
dlclose: during tls access (via __tls_get_addr) _dl_update_slotinfo is
called without holding dlopen locks. So don't check the modid of map.

The map == 0 and map != 0 code paths can be shared (avoiding the dtv
resize in case of map == 0 is just an optimization: larger dtv than
necessary would be fine too).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Fix comments and logic in _dl_add_to_slotinfo
Szabolcs Nagy [Wed, 30 Nov 2016 11:44:25 +0000 (11:44 +0000)]
elf: Fix comments and logic in _dl_add_to_slotinfo

Since

  commit a509eb117fac1d764b15eba64993f4bdb63d7f3c
  Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112]

the generation counter update is not needed in the failure path.
That commit ensures allocation in _dl_add_to_slotinfo happens before
the demarcation point in dlopen (it is called twice, first time is for
allocation only where dlopen can still be reverted on failure, then
second time actual dtv updates are done which then cannot fail).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add a DTV setup test [BZ #27136]
Szabolcs Nagy [Thu, 31 Dec 2020 12:24:38 +0000 (12:24 +0000)]
elf: Add a DTV setup test [BZ #27136]

The test dlopens a large number of modules with TLS, they are reused
from an existing test.

The test relies on the reuse of slotinfo entries after dlclose, without
bug 27135 fixed this needs a failing dlopen. With a slotinfo list that
has non-monotone increasing generation counters, bug 27136 can trigger.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Fix a DTV setup issue [BZ #27136]
Szabolcs Nagy [Wed, 30 Dec 2020 23:40:14 +0000 (23:40 +0000)]
elf: Fix a DTV setup issue [BZ #27136]

The max modid is a valid index in the dtv, it should not be skipped.

The bug is observable if the last module has modid == 64 and its
generation is same or less than the max generation of the previous
modules.  Then dtv[0].counter implies dtv[64] is initialized but
it isn't. Fixes bug 27136.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoARC: Update ulps
Vineet Gupta [Tue, 13 Apr 2021 02:59:17 +0000 (19:59 -0700)]
ARC: Update ulps

Needed after 43576de04afc6

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
3 years agoRemove PR_TAGGED_ADDR_ENABLE from sys/prctl.h
Szabolcs Nagy [Tue, 2 Feb 2021 15:02:09 +0000 (15:02 +0000)]
Remove PR_TAGGED_ADDR_ENABLE from sys/prctl.h

The value of PR_TAGGED_ADDR_ENABLE was incorrect in the installed
headers and the prctl command macros were missing that are needed
for it to be useful (PR_SET_TAGGED_ADDR_CTRL).  Linux headers have
the definitions since 5.4 so it's widely available, we don't need
to repeat these definitions.  The remaining definitions are from
Linux 5.10.

To build glibc with --enable-memory-tagging, Linux 5.4 headers and
binutils 2.33.1 or newer is needed.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agolinux: sysconf: Use a more explicit maximum_ARG_MAX
Adhemerval Zanella [Tue, 13 Apr 2021 20:45:14 +0000 (17:45 -0300)]
linux: sysconf: Use a more explicit maximum_ARG_MAX

3 years agolinux: sysconf: limit _SC_MAX_ARG to 6 MiB (BZ #25305)
Michal Nazarewicz [Wed, 7 Apr 2021 15:10:58 +0000 (17:10 +0200)]
linux: sysconf: limit _SC_MAX_ARG to 6 MiB (BZ #25305)

Since Linux 4.13, kernel limits the maximum command line arguments
length to 6 MiB [1].  Normally the limit is still quarter of the maximum
stack size but if that limit exceeds 6 MiB it's clamped down.

glibc's __sysconf implementation for Linux platform is not aware of
this limitation and for stack sizes of over 24 MiB it returns higher
ARG_MAX than Linux will actually accept.  This can be verified by
executing the following application on Linux 4.13 or newer:

    #include <stdio.h>
    #include <string.h>
    #include <sys/resource.h>
    #include <sys/time.h>
    #include <unistd.h>

    int main(void) {
            const struct rlimit rlim = { 40 * 1024 * 1024,
                                         40 * 1024 * 1024 };
            if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
                    perror("setrlimit: RLIMIT_STACK");
                    return 1;
            }

            printf("ARG_MAX     : %8ld\n", sysconf(_SC_ARG_MAX));
            printf("63 * 100 KiB: %8ld\n", 63L * 100 * 1024);
            printf("6 MiB       : %8ld\n", 6L * 1024 * 1024);

            char str[100 * 1024], *argv[64], *envp[1];
            memset(&str, 'A', sizeof str);
            str[sizeof str - 1] = '\0';
            for (size_t i = 0; i < sizeof argv / sizeof *argv - 1; ++i) {
                    argv[i] = str;
            }
            argv[sizeof argv / sizeof *argv - 1] = envp[0] = 0;

            execve("/bin/true", argv, envp);
            perror("execve");
            return 1;
    }

On affected systems the program will report ARG_MAX as 10 MiB but
despite that executing /bin/true with a bit over 6 MiB of command line
arguments will fail with E2BIG error.  Expected result is that ARG_MAX
is reported as 6 MiB.

Update the __sysconf function to clamp ARG_MAX value to 6 MiB if it
would otherwise exceed it.  This resolves bug #25305 which was market
WONTFIX as suggested solution was to cap ARG_MAX at 128 KiB.

As an aside and point of comparison, bionic (a libc implementation for
Android systems) decided to resolve this issue by always returning 128
KiB ignoring any potential xargs regressions [2].

On older kernels this results in returning overly conservative value
but that's a safer option than being aggressive and returning invalid
value on recent systems.  It's also worth noting that at this point
all supported Linux releases have the 6 MiB barrier so only someone
running an unsupported kernel version would get incorrectly truncated
result.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[1] See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=da029c11e6b12f321f36dac8771e833b65cec962
[2] See https://android.googlesource.com/platform/bionic/+/baed51ee3a13dae4b87b11870bdf7f10bdc9efc1

3 years agomisc: syslog: Fix calls to openlog() with LOG_KERN facility (BZ #3604)
Dan Raymond [Tue, 13 Apr 2021 13:26:12 +0000 (10:26 -0300)]
misc: syslog: Fix calls to openlog() with LOG_KERN facility (BZ #3604)

POSIX states for syslog [1]:

  "Values of the priority argument are formed by OR'ing together a
  severity-level value and an optional facility value. If no
  facility value is specified, the current default facility value is
  used."

So the patch fixes an existing violation of the openlog interface contract
where it is ignoring the facility argument when the value is zero

It allows the use LOG_KERN by calling openlog prior syslog usage.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html

3 years agos390: Update ulps
Adhemerval Zanella [Tue, 13 Apr 2021 14:51:07 +0000 (11:51 -0300)]
s390: Update ulps

Required after 43576de04afc6 "Improve the accuracy of tgamma
(BZ #26983)"

3 years agoi386: Update ulps
Adhemerval Zanella [Tue, 13 Apr 2021 14:48:24 +0000 (11:48 -0300)]
i386: Update ulps

Required after 43576de04afc6 "Improve the accuracy of tgamma
(BZ #26983)"

3 years agoImprove documentation for malloc etc. (BZ#27719)
Paul Eggert [Mon, 12 Apr 2021 02:06:00 +0000 (19:06 -0700)]
Improve documentation for malloc etc. (BZ#27719)

Cover key corner cases (e.g., whether errno is set) that are well
settled in glibc, fix some examples to avoid integer overflow, and
update some other dated examples (code needed for K&R C, e.g.).
* manual/charset.texi (Non-reentrant String Conversion):
* manual/filesys.texi (Symbolic Links):
* manual/memory.texi (Allocating Cleared Space):
* manual/socket.texi (Host Names):
* manual/string.texi (Concatenating Strings):
* manual/users.texi (Setting Groups):
Use reallocarray instead of realloc, to avoid integer overflow issues.
* manual/filesys.texi (Scanning Directory Content):
* manual/memory.texi (The GNU Allocator, Hooks for Malloc):
* manual/tunables.texi:
Use code font for 'malloc' instead of roman font.
(Symbolic Links): Don't assume readlink return value fits in 'int'.
* manual/memory.texi (Memory Allocation and C, Basic Allocation)
(Malloc Examples, Alloca Example):
* manual/stdio.texi (Formatted Output Functions):
* manual/string.texi (Concatenating Strings, Collation Functions):
Omit pointer casts that are needed only in ancient K&R C.
* manual/memory.texi (Basic Allocation):
Say that malloc sets errno on failure.
Say "convert" rather than "cast", since casts are no longer needed.
* manual/memory.texi (Basic Allocation):
* manual/string.texi (Concatenating Strings):
In examples, use C99 declarations after statements for brevity.
* manual/memory.texi (Malloc Examples): Add portability notes for
malloc (0), errno setting, and PTRDIFF_MAX.
(Changing Block Size): Say that realloc (p, 0) acts like
(p ? (free (p), NULL) : malloc (0)).
Add xreallocarray example, since other examples can use it.
Add portability notes for realloc (0, 0), realloc (p, 0),
PTRDIFF_MAX, and improve notes for reallocating to the same size.
(Allocating Cleared Space): Reword now-confusing discussion
about replacement, and xref "Replacing malloc".
* manual/stdio.texi (Formatted Output Functions):
Don't assume message size fits in 'int'.
* manual/string.texi (Concatenating Strings):
Fix undefined behavior involving arithmetic on a freed pointer.

3 years agolinux: always update select timeout (BZ #27706)
Adhemerval Zanella [Thu, 8 Apr 2021 10:39:32 +0000 (07:39 -0300)]
linux: always update select timeout (BZ #27706)

The timeout should be updated even on failure for time64 support.

Checked on i686-linux-gnu.

3 years agolinux: Normalize and return timeout on select (BZ #27651)
Adhemerval Zanella [Wed, 31 Mar 2021 16:53:34 +0000 (13:53 -0300)]
linux: Normalize and return timeout on select (BZ #27651)

The commit 2433d39b697, which added time64 support to select, changed
the function to use __NR_pselect6 (or __NR_pelect6_time64) on all
architectures.  However, on architectures where the symbol was
implemented with __NR_select the kernel normalizes the passed timeout
instead of return EINVAL.  For instance, the input timeval
{ 0, 5000000 } is interpreted as { 5, 0 }.

And as indicated by BZ #27651, this semantic seems to be expected
and changing it results in some performance issues (most likely
the program does not check the return code and keeps issuing
select with unormalized tv_usec argument).

To avoid a different semantic depending whether which syscall the
architecture used to issue, select now always normalize the timeout
input.  This is a slight change for some ABIs (for instance aarch64).

Checked on x86_64-linux-gnu and i686-linux-gnu.

3 years agolibsupport: Add support_select_normalizes_timeout
Adhemerval Zanella [Fri, 9 Apr 2021 13:05:13 +0000 (10:05 -0300)]
libsupport: Add support_select_normalizes_timeout

It will be used on a select() test.

3 years agolibsupport: Add support_select_modifies_timeout
Adhemerval Zanella [Fri, 9 Apr 2021 13:02:30 +0000 (10:02 -0300)]
libsupport: Add support_select_modifies_timeout

It will be used on a select() test.

3 years agoFix SXID_ERASE behavior in setuid programs (BZ #27471)
Siddhesh Poyarekar [Tue, 16 Mar 2021 07:07:55 +0000 (12:37 +0530)]
Fix SXID_ERASE behavior in setuid programs (BZ #27471)

When parse_tunables tries to erase a tunable marked as SXID_ERASE for
setuid programs, it ends up setting the envvar string iterator
incorrectly, because of which it may parse the next tunable
incorrectly.  Given that currently the implementation allows malformed
and unrecognized tunables pass through, it may even allow SXID_ERASE
tunables to go through.

This change revamps the SXID_ERASE implementation so that:

- Only valid tunables are written back to the tunestr string, because
  of which children of SXID programs will only inherit a clean list of
  identified tunables that are not SXID_ERASE.

- Unrecognized tunables get scrubbed off from the environment and
  subsequently from the child environment.

- This has the side-effect that a tunable that is not identified by
  the setxid binary, will not be passed on to a non-setxid child even
  if the child could have identified that tunable.  This may break
  applications that expect this behaviour but expecting such tunables
  to cross the SXID boundary is wrong.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoEnhance setuid-tunables test
Siddhesh Poyarekar [Tue, 16 Mar 2021 07:07:54 +0000 (12:37 +0530)]
Enhance setuid-tunables test

Instead of passing GLIBC_TUNABLES via the environment, pass the
environment variable from parent to child.  This allows us to test
multiple variables to ensure better coverage.

The test list currently only includes the case that's already being
tested.  More tests will be added later.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agotst-env-setuid: Use support_capture_subprogram_self_sgid
Siddhesh Poyarekar [Tue, 16 Mar 2021 07:07:53 +0000 (12:37 +0530)]
tst-env-setuid: Use support_capture_subprogram_self_sgid

Use the support_capture_subprogram_self_sgid to spawn an sgid child.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agosupport: Add capability to fork an sgid child
Siddhesh Poyarekar [Fri, 9 Apr 2021 15:25:45 +0000 (20:55 +0530)]
support: Add capability to fork an sgid child

Add a new function support_capture_subprogram_self_sgid that spawns an
sgid child of the running program with its own image and returns the
exit code of the child process.  This functionality is used by at
least three tests in the testsuite at the moment, so it makes sense to
consolidate.

There is also a new function support_subprogram_wait which should
provide simple system() like functionality that does not set up file
actions.  This is useful in cases where only the return code of the
spawned subprocess is interesting.

This patch also ports tst-secure-getenv to this new function.  A
subsequent patch will port other tests.  This also brings an important
change to tst-secure-getenv behaviour.  Now instead of succeeding, the
test fails as UNSUPPORTED if it is unable to spawn a setgid child,
which is how it should have been in the first place.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoarm: Fix an incorrect check in ____longjmp_chk [BZ #27709]
Szabolcs Nagy [Wed, 7 Apr 2021 11:45:53 +0000 (12:45 +0100)]
arm: Fix an incorrect check in ____longjmp_chk [BZ #27709]

An incorrect check in __longjmp_chk could fail on valid code causing

FAIL: debug/tst-longjmp_chk2

The original check was

  altstack_sp + altstack_size - setjmp_sp > altstack_size

i.e. sp at setjmp was outside of the altstack range. Here we know that
longjmp is called from a signal handler on the altstack (SS_ONSTACK),
and that it jumps in the wrong direction (sp decreases), so the check
wants to ensure the jump goes to another stack.

The check is wrong when altstack_sp == setjmp_sp which can happen
when the altstack is a local buffer in the function that calls setjmp,
so the patch allows == too. This fixes bug 27709.

Note that the generic __longjmp_chk check seems to be different.
(it checks if longjmp was on the altstack but does not check setjmp,
so it would not catch incorrect longjmp use within the signal handler).

3 years agoFurther fixes for REALLOC_ZERO_BYTES_FREES comment
Paul Eggert [Mon, 12 Apr 2021 07:33:15 +0000 (00:33 -0700)]
Further fixes for REALLOC_ZERO_BYTES_FREES comment

* malloc/malloc.c (REALLOC_ZERO_BYTES_FREES): Improve comment further.

3 years agohurd: Export _hurd_libc_proc_init
Samuel Thibault [Sun, 11 Apr 2021 21:11:47 +0000 (23:11 +0200)]
hurd: Export _hurd_libc_proc_init

hurd's libdiskfs needs to be able to call _hurd_init + _hurd_libc_proc_init
for bootstrap initialization.

3 years agoFix REALLOC_ZERO_BYTES_FREES comment to match C17
Paul Eggert [Sun, 11 Apr 2021 21:39:20 +0000 (14:39 -0700)]
Fix REALLOC_ZERO_BYTES_FREES comment to match C17

* malloc/malloc.c (REALLOC_ZERO_BYTES_FREES):
Update comment to match current C standard.

3 years agopowerpc: Update libm test ulps
Tulio Magno Quites Machado Filho [Fri, 9 Apr 2021 20:41:22 +0000 (17:41 -0300)]
powerpc: Update libm test ulps

Update after commit 43576de04afc6a0896a3ecc094e1581069a0652a.

3 years agoarm: update libm test ulps
Szabolcs Nagy [Wed, 7 Apr 2021 11:45:42 +0000 (12:45 +0100)]
arm: update libm test ulps

Updated after commits 9acda61d94acc5348c2330f2519a14d1a4a37e73
and 43576de04afc6a0896a3ecc094e1581069a0652a.

3 years agoaarch64: update libm test ulps
Szabolcs Nagy [Thu, 8 Apr 2021 07:22:39 +0000 (08:22 +0100)]
aarch64: update libm test ulps

Update after commit 43576de04afc6a0896a3ecc094e1581069a0652a.

3 years agoImprove the accuracy of tgamma (BZ #26983)
Paul Zimmermann [Fri, 2 Apr 2021 06:21:06 +0000 (08:21 +0200)]
Improve the accuracy of tgamma (BZ #26983)

With this patch, the maximal known error for tgamma is now reduced to 9 ulps
for dbl-64, for all rounding modes. Since exhaustive testing is not possible
for dbl-64, it might be that there are still cases with an error larger than
9 ulps, but all known cases are fixed (intensive tests were done to find cases
with large errors).

Tested on x86_64 and powerpc (and by Adhemerval Zanella on aarch64, arm,
s390x, sparc, and i686).
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotunables: Fix comparison of tunable values
Siddhesh Poyarekar [Tue, 16 Mar 2021 13:01:02 +0000 (18:31 +0530)]
tunables: Fix comparison of tunable values

The simplification of tunable_set interfaces took care of
signed/unsigned conversions while setting values, but comparison with
bounds ended up being incorrect; comparing TUNABLE_SIZE_T values for
example will fail because SIZE_MAX is seen as -1.

Add comparison helpers that take tunable types into account and use
them to do comparison instead.

3 years agosys: Fixes possible typo in comment: statfs -> statvfs
Hugo Gabriel Eyherabide [Mon, 5 Apr 2021 19:08:19 +0000 (22:08 +0300)]
sys: Fixes possible typo in comment: statfs -> statvfs

3 years agomalloc: Run tst-malloc-stats-cancellation via test-driver.c
Arjun Shankar [Tue, 6 Apr 2021 22:30:11 +0000 (00:30 +0200)]
malloc: Run tst-malloc-stats-cancellation via test-driver.c

This allows the test to time out in case it hangs.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoUpdate hppa libm-test-ulps
John David Anglin [Tue, 6 Apr 2021 18:55:58 +0000 (18:55 +0000)]
Update hppa libm-test-ulps

This page took 0.086322 seconds and 5 git commands to generate.