Florian Weimer [Fri, 11 Feb 2022 18:03:04 +0000 (19:03 +0100)]
Linux: Include <dl-auxv.h> in dl-sysdep.c only for SHARED
Otherwise, <dl-auxv.h> on POWER ends up being included twice,
once in dl-sysdep.c, once in dl-support.c. That leads to a linker
failure due to multiple definitions of _dl_cache_line_size.
The revert is necessary because the reverted commit introduced an
early memset call on aarch64, which leads to crash due to lack of TCB
initialization.
malloc: Remove LD_TRACE_PRELINKING usage from mtrace
The fix for BZ#22716 replacde LD_TRACE_LOADED_OBJECTS with
LD_TRACE_PRELINKING so mtrace could record executable address
position.
To provide the same information, LD_TRACE_LOADED_OBJECTS is
extended where a value or '2' also prints the executable address
as well. It avoid adding another loader environment variable
to be used solely for mtrace. The vDSO will be printed as
a default library (with '=>' pointing the same name), which is
ok since both mtrace and ldd already handles it.
The mtrace script is changed to also parse the new format. To
correctly support PIE and non-PIE executables, both the default
mtrace address and the one calculated as used (it fixes mtrace
for non-PIE exectuable as for BZ#22716 for PIE).
Prelinked binaries and libraries still work, the dynamic tags
DT_GNU_PRELINKED, DT_GNU_LIBLIST, DT_GNU_CONFLICT just ignored
(meaning the process is reallocated as default).
The loader environment variable TRACE_PRELINKING is also removed,
since it used solely on prelink.
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
On hppa, a function pointer returned by la_symbind is actually a function
descriptor has the plabel bit set (bit 30). This must be cleared to get
the actual address of the descriptor. If the descriptor has been bound,
the first word of the descriptor is the physical address of theA function,
otherwise, the first word of the descriptor points to a trampoline in the
PLT.
This patch also adds a workaround on tests because on hppa (and it seems
to be the only ABI I have see it), some shared library adds a dynamic PLT
relocation to am empty symbol name:
$ readelf -r elf/tst-audit25mod1.so
[...]
Relocation section '.rela.plt' at offset 0x464 contains 6 entries:
Offset Info Type Sym.Value Sym. Name + Addend 0000200800000081 R_PARISC_IPLT 508
[...]
It breaks some assumptions on the test, where a symbol with an empty
name ("") is passed on la_symbind.
Dmitry V. Levin [Sat, 5 Feb 2022 08:00:00 +0000 (08:00 +0000)]
linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]
get_nprocs() and get_nprocs_conf() use various methods to obtain an
accurate number of processors. Re-introduce __get_nprocs_sched() as
a source of information, and fix the order in which these methods are
used to return the most accurate information. The primary source of
information used in both functions remains unchanged.
This also changes __get_nprocs_sched() error return value from 2 to 0,
but all its users are already prepared to handle that.
Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc") Closes: BZ #28865 Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Noah Goldstein [Sun, 6 Feb 2022 05:51:07 +0000 (23:51 -0600)]
Benchtests: Add length zero benchmark for memset in bench-memset.c
Zero is a relevant size for some workloads (roughly 5% of uses for
GCC) so we should be testing it's performance as well. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Noah Goldstein [Sun, 6 Feb 2022 06:54:18 +0000 (00:54 -0600)]
x86: Improve vec generation in memset-vec-unaligned-erms.S
No bug.
Split vec generation into multiple steps. This allows the
broadcast in AVX2 to use 'xmm' registers for the L(less_vec)
case. This saves an expensive lane-cross instruction and removes
the need for 'vzeroupper'.
For SSE2 replace 2x 'punpck' instructions with zero-idiom 'pxor' for
byte broadcast.
Results for memset-avx2 small (geomean of N = 20 benchset runs).
size, New Time, Old Time, New / Old
0, 4.100, 3.831, 0.934
1, 5.074, 4.399, 0.867
2, 4.433, 4.411, 0.995
4, 4.487, 4.415, 0.984
8, 4.454, 4.396, 0.987
16, 4.502, 4.443, 0.987
All relevant string/wcsmbs tests are passing. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Sunil K Pandey [Thu, 30 Dec 2021 19:35:48 +0000 (11:35 -0800)]
x86-64: Add vector tan/tanf to libmvec microbenchmark
Add vector tan/tanf and input files to libmvec microbenchmark.
libmvec-tan-inputs:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 5.0
10% uniform random distribution in range (-1000.0, 1000.0)
libmvec-tanf-inputs:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 5.0f
10% uniform random distribution in range (-1000.0f, 1000.0f)
Sunil K Pandey [Thu, 30 Dec 2021 19:30:58 +0000 (11:30 -0800)]
x86-64: Add vector erfc/erfcf to libmvec microbenchmark
Add vector erfc/erfcf and input files to libmvec microbenchmark.
libmvec-erfc-inputs:
90% Normal random distribution
range: (-6.0, 6.0)
mean: 0.0
sigma: 1.0
10% uniform random distribution in range (-5.9, 5.9)
libmvec-erfcf-inputs:
90% Normal random distribution
range: (-4.0f, 4.0f)
mean: 0.0f
sigma: 1.0f
10% uniform random distribution in range (-3.9f, 3.9f)
Sunil K Pandey [Thu, 30 Dec 2021 19:26:16 +0000 (11:26 -0800)]
x86-64: Add vector asinh/asinhf to libmvec microbenchmark
Add vector asinh/asinhf and input files to libmvec microbenchmark.
libmvec-asinh-inputs:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 2.0
10% uniform random distribution in range (-1.0e6, 1.0e6)
libmvec-asinhf-inputs:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 2.0f
10% uniform random distribution in range (-1.0e6f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 19:21:36 +0000 (11:21 -0800)]
x86-64: Add vector tanh/tanhf to libmvec microbenchmark
Add vector tanh/tanhf and input files to libmvec microbenchmark.
libmvec-tanh-inputs:
90% Normal random distribution
range: (-19.0, 19.0)
mean: 0.0
sigma: 2.0
10% uniform random distribution in range (-16.0, 16.0)
libmvec-tanhf-inputs:
90% Normal random distribution
range: (-10.0f, 10.0f)
mean: 0.0f
sigma: 2.0f
10% uniform random distribution in range (-8.0f, 8.0f)
Sunil K Pandey [Thu, 30 Dec 2021 19:12:23 +0000 (11:12 -0800)]
x86-64: Add vector acosh/acoshf to libmvec microbenchmark
Add vector acosh/acoshf and input files to libmvec microbenchmark.
libmvec-acosh-inputs:
90% Normal random distribution
range: (1.0, DBL_MAX)
mean: 1.0
sigma: 8.0
10% uniform random distribution in range (1.0, 1.0e6)
libmvec-acoshf-inputs:
90% Normal random distribution
range: (1.0f, FLT_MAX)
mean: 1.0f
sigma: 4.0f
10% uniform random distribution in range (1.0f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 19:07:55 +0000 (11:07 -0800)]
x86-64: Add vector atanh/atanhf to libmvec microbenchmark
Add vector atanh/atanhf and input files to libmvec microbenchmark.
libmvec-atanh-inputs:
90% Normal random distribution
range: (-1.0, 1.0)
mean: 0.0
sigma: 1.0
10% uniform random distribution in range (-1.0, 1.0)
libmvec-atanhf-inputs:
90% Normal random distribution
range: (-1.0f, 1.0f)
mean: 0.0f
sigma: 1.0f
10% uniform random distribution in range (-1.0f, 1.0f)
Sunil K Pandey [Thu, 30 Dec 2021 19:03:28 +0000 (11:03 -0800)]
x86-64: Add vector log1p/log1pf to libmvec microbenchmark
Add vector log1p/log1pf and input files to libmvec microbenchmark.
libmvec-log1p-inputs:
70% Normal random distribution
range: (-1.0, DBL_MAX)
mean: 0.0
sigma: 50.0
30% uniform random distribution in range (-1.0, 1.0e6)
libmvec-log1pf-inputs:
70% Normal random distribution
range: (-1.0f, FLT_MAX)
mean: 0.0f
sigma: 50.0f
30% uniform random distribution in range (-1.0f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 18:59:06 +0000 (10:59 -0800)]
x86-64: Add vector log2/log2f to libmvec microbenchmark
Add vector log2/log2f and input files to libmvec microbenchmark.
libmvec-log2-inputs:
70% Normal random distribution
range: (0.0, DBL_MAX)
mean: 1.0
sigma: 50.0
30% uniform random distribution in range (0.0, 1.0e6)
libmvec-log2f-inputs:
70% Normal random distribution
range: (0.0f, FLT_MAX)
mean: 1.0f
sigma: 50.0f
30% uniform random distribution in range (0.0f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 18:54:49 +0000 (10:54 -0800)]
x86-64: Add vector log10/log10f to libmvec microbenchmark
Add vector log10/log10f and input files to libmvec microbenchmark.
libmvec-log10-inputs:
70% Normal random distribution
range: (0.0, DBL_MAX)
mean: 1.0
sigma: 50.0
30% uniform random distribution in range (0.0, 1.0e6)
libmvec-log10f-inputs:
70% Normal random distribution
range: (0.0f, FLT_MAX)
mean: 1.0f
sigma: 50.0f
30% uniform random distribution in range (0.0f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 18:50:35 +0000 (10:50 -0800)]
x86-64: Add vector atan2/atan2f to libmvec microbenchmark
Add vector atan2/atan2f and input files to libmvec microbenchmark.
libmvec-atan2-inputs:
arg1:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 4.0
10% uniform random distribution in range (-1.0e6, 1.0e6)
arg2:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 4.0
10% uniform random distribution in range (-1.0e6, 1.0e6)
libmvec-atan2f-inputs:
arg1:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 4.0f
10% uniform random distribution in range (-1.0e6f, 1.0e6f)
arg2:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 4.0f
10% uniform random distribution in range (-1.0e6f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 18:46:23 +0000 (10:46 -0800)]
x86-64: Add vector cbrt/cbrtf to libmvec microbenchmark
Add vector cbrt/cbrtf and input files to libmvec microbenchmark.
libmvec-cbrt-inputs:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 10.0
10% uniform random distribution in range (-1000.0, 1000.0)
libmvec-cbrtf-inputs:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 10.0f
10% uniform random distribution in range (-1000.0f, 1000.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:42:16 +0000 (10:42 -0800)]
x86-64: Add vector sinh/sinhf to libmvec microbenchmark
Add vector sinh/sinhf and input files to libmvec microbenchmark.
libmvec-sinh-inputs:
90% Normal random distribution
range: (-710.0, 710.0)
mean: 0.0
sigma: 32.0
10% uniform random distribution in range (-500.0, 500.0)
libmvec-sinhf-inputs:
90% Normal random distribution
range: (-89.0f, 89.0f)
mean: 0.0f
sigma: 16.0f
10% uniform random distribution in range (-50.0f, 50.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:38:12 +0000 (10:38 -0800)]
x86-64: Add vector expm1/expm1f to libmvec microbenchmark
Add vector expm1/expm1f and input files to libmvec microbenchmark.
libmvec-expm1-inputs:
90% Normal random distribution
range: (-708.0, 709.0)
mean: 0.0
sigma: 16.0
10% uniform random distribution in range (-500.0, 500.0)
libmvec-expm1f-inputs:
90% Normal random distribution
range: (-87.0f, 88.0f)
mean: 0.0f
sigma: 8.0f
10% uniform random distribution in range (-50.0f, 50.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:34:12 +0000 (10:34 -0800)]
x86-64: Add vector cosh/coshf to libmvec microbenchmark
Add vector cosh/coshf and input files to libmvec microbenchmark.
libmvec-cosh-inputs:
90% Normal random distribution
range: (-710.0, 710.0)
mean: 0.0
sigma: 32.0
10% uniform random distribution in range (-500.0, 500.0)
libmvec-coshf-inputs:
90% Normal random distribution
range: (-89.0f, 89.0f)
mean: 0.0f
sigma: 16.0f
10% uniform random distribution in range (-50.0f, 50.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:30:16 +0000 (10:30 -0800)]
x86-64: Add vector exp10/exp10f to libmvec microbenchmark
Add vector exp10/exp10f and input files to libmvec microbenchmark.
libmvec-exp10-inputs:
90% Normal random distribution
range: (-307.0, 308.0)
mean: 0.0
sigma: 16.0
10% uniform random distribution in range (-250.0, 250.0)
libmvec-exp10f-inputs:
90% Normal random distribution
range: (-37.0f, 38.0f)
mean: 0.0f
sigma: 8.0f
10% uniform random distribution in range (-25.0f, 25.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:26:23 +0000 (10:26 -0800)]
x86-64: Add vector exp2/exp2f to libmvec microbenchmark
Add vector exp2/exp2f and input files to libmvec microbenchmark.
libmvec-exp2-inputs:
90% Normal random distribution
range: (-1022.0, 1024.0)
mean: 0.0
sigma: 16.0
10% uniform random distribution in range (-1000.0, 1000.0)
libmvec-exp2f-inputs:
90% Normal random distribution
range: (-126.0f, 128.0f)
mean: 0.0f
sigma: 8.0f
10% uniform random distribution in range (-100.0f, 100.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:22:34 +0000 (10:22 -0800)]
x86-64: Add vector hypot/hypotf to libmvec microbenchmark
Add vector hypot/hypotf and input files to libmvec microbenchmark.
libmvec-hypot-inputs:
arg1:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 10.0
10% uniform random distribution in range (-1000.0, 1000.0)
arg1:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 10.0
10% uniform random distribution in range (-1000.0, 1000.0)
libmvec-hypotf-inputs:
arg1:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 10.0f
10% uniform random distribution in range (-1000.0f, 1000.0f)
arg2:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 10.0f
10% uniform random distribution in range (-1000.0f, 1000.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:18:48 +0000 (10:18 -0800)]
x86-64: Add vector asin/asinf to libmvec microbenchmark
Add vector asin/asinf and input files to libmvec microbenchmark.
libmvec-asin-inputs:
90% Normal random distribution
range: (-1.0, 1.0)
mean: 0.0
sigma: 1.0
10% uniform random distribution in range (-1.0, 1.0)
libmvec-asinf-inputs:
90% Normal random distribution
range: (-1.0f, 1.0f)
mean: 0.0f
sigma: 1.0f
10% uniform random distribution in range (-1.0f, 1.0f)
Sunil K Pandey [Thu, 30 Dec 2021 18:15:03 +0000 (10:15 -0800)]
x86-64: Add vector atan/atanf to libmvec microbenchmark
Add vector atan/atanf and input files to libmvec microbenchmark.
libmvec-atan-inputs:
arg1:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 4.0
10% uniform random distribution in range (-1.0e6, 1.0e6)
arg2:
90% Normal random distribution
range: (-DBL_MAX, DBL_MAX)
mean: 0.0
sigma: 4.0
10% uniform random distribution in range (-1.0e6, 1.0e6)
libmvec-atanf-inputs:
arg1:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 4.0f
10% uniform random distribution in range (-1.0e6f, 1.0e6f)
arg2:
90% Normal random distribution
range: (-FLT_MAX, FLT_MAX)
mean: 0.0f
sigma: 4.0f
10% uniform random distribution in range (-1.0e6f, 1.0e6f)
Sunil K Pandey [Thu, 30 Dec 2021 18:11:23 +0000 (10:11 -0800)]
x86-64: Add vector acos/acosf to libmvec microbenchmark
Add vector acos/acosf and input files to libmvec microbenchmark.
libmvec-acos-inputs:
90% Normal random distribution
range: (-1.0, 1.0)
mean: 0.0
sigma: 1.0
10% uniform random distribution in range (-1.0, 1.0)
libmvec-acosf-inputs:
90% Normal random distribution
range: (-1.0f, 1.0f)
mean: 0.0f
sigma: 1.0f
10% uniform random distribution in range (-1.0f, 1.0f)
Noah Goldstein [Mon, 10 Jan 2022 21:35:40 +0000 (15:35 -0600)]
benchtests: Add more coverage for strcmp and strncmp benchmarks
Add more small and medium sized tests for strcmp and strncmp.
As well for strcmp add option for more direct control of
alignment. Previously alignment was being pushed to the end of the
page. While this is the most difficult case to implement, it is far
from the common case and so shouldn't be the only benchmark.
Noah Goldstein [Mon, 10 Jan 2022 21:35:39 +0000 (15:35 -0600)]
x86: Optimize strcmp-evex.S
Optimization are primarily to the loop logic and how the page cross
logic interacts with the loop.
The page cross logic is at times more expensive for short strings near
the end of a page but not crossing the page. This is done to retest
the page cross conditions with a non-faulty check and to improve the
logic for entering the loop afterwards. This is only particular cases,
however, and is general made up for by more than 10x improvements on
the transition from the page cross -> loop case.
The non-page cross cases as well are nearly universally improved.
test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass.
Noah Goldstein [Mon, 10 Jan 2022 21:35:38 +0000 (15:35 -0600)]
x86: Optimize strcmp-avx2.S
Optimization are primarily to the loop logic and how the page cross
logic interacts with the loop.
The page cross logic is at times more expensive for short strings near
the end of a page but not crossing the page. This is done to retest
the page cross conditions with a non-faulty check and to improve the
logic for entering the loop afterwards. This is only particular cases,
however, and is general made up for by more than 10x improvements on
the transition from the page cross -> loop case.
The non-page cross cases are improved most for smaller sizes [0, 128]
and go about even for (128, 4096]. The loop page cross logic is
improved so some more significant speedup is seen there as well.
test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass.
Commit 948ce73b31 made recvmsg/recvmmsg to always call
__convert_scm_timestamps for 64 bit time_t symbol, so adjust it to
always build it for __TIMESIZE != 64.
It fixes build for architecture with 32 bit time_t support when
configured with minimum kernel of 5.1.
The test changes the current foreground process group, which might
break testing depending of how the make check is issued. For instance:
nohup make -j1 test t=posix/tst-spawn6 | less
Will set 'make' and 'less' to be in the foreground process group in
the current session. When tst-spawn6 new child takes over it becomes
the foreground process and 'less' is stopped and backgrounded which
interrupts the 'make check' command.
To fix it a pseudo-terminal is allocated, the test starts in new
session (so there is no controlling terminal associated), and the
pseudo-terminal is set as the controlling one (similar to what
login_tty does).
Checked on x86_64-linux-gnu.
Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Carlos O'Donell [Thu, 3 Feb 2022 04:46:19 +0000 (23:46 -0500)]
Update NEWS.
Moved LD_AUDIT notes into requirements section since the LAV_CURRENT
bump is a requirements change that impacts loading old audit modules
or new audit modules on older loaders.
posix: Replace posix_spawnattr_tc{get,set}pgrp_np with posix_spawn_file_actions_addtcsetpgrp_np
The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
controlling terminal), so it would make more sense to actually fit
it on the file actions API.
Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
implicit by the presence of tcsetpgrp file action.
The posix/tst-spawn6.c is also fixed when TTY can is not present.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
Stafford Horne [Fri, 28 Jan 2022 23:20:40 +0000 (08:20 +0900)]
or1k: Define PI_STATIC_AND_HIDDEN
PI_STATIC_AND_HIDDEN means that references to static functions, data
and symbols with hidden visibility do not need any run-time relocations
after the final link, with the build flags used by glibc.
OpenRISC follows this so enabled PI_STATIC_AND_HIDDEN by adding
configure.ac and generating configure.
Ben Woodard [Mon, 24 Jan 2022 13:46:18 +0000 (10:46 -0300)]
elf: Fix runtime linker auditing on aarch64 (BZ #26643)
The rtld audit support show two problems on aarch64:
1. _dl_runtime_resolve does not preserve x8, the indirect result
location register, which might generate wrong result calls
depending of the function signature.
2. The NEON Q registers pushed onto the stack by _dl_runtime_resolve
were twice the size of D registers extracted from the stack frame by
_dl_runtime_profile.
While 2. might result in wrong information passed on the PLT tracing,
1. generates wrong runtime behaviour.
The aarch64 rtld audit support is changed to:
* Both La_aarch64_regs and La_aarch64_retval are expanded to include
both x8 and the full sized NEON V registers, as defined by the
ABI.
* dl_runtime_profile needed to extract registers saved by
_dl_runtime_resolve and put them into the new correctly sized
La_aarch64_regs structure.
* The LAV_CURRENT check is change to only accept new audit modules
to avoid the undefined behavior of not save/restore x8.
* Different than other architectures, audit modules older than
LAV_CURRENT are rejected (both La_aarch64_regs and La_aarch64_retval
changed their layout and there are no requirements to support multiple
audit interface with the inherent aarch64 issues).
* A new field is also reserved on both La_aarch64_regs and
La_aarch64_retval to support variant pcs symbols.
Similar to x86, a new La_aarch64_vector type to represent the NEON
register is added on the La_aarch64_regs (so each type can be accessed
directly).
Since LAV_CURRENT was already bumped to support bind-now, there is
no need to increase it again.
Checked on aarch64-linux-gnu.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
The audit symbind callback is not called for binaries built with
-Wl,-z,now or when LD_BIND_NOW=1 is used, nor the PLT tracking callbacks
(plt_enter and plt_exit) since this would change the expected
program semantics (where no PLT is expected) and would have performance
implications (such as for BZ#15533).
LAV_CURRENT is also bumped to indicate the audit ABI change (where
la_symbind flags are set by the loader to indicate no possible PLT
trace).
To handle powerpc64 ELFv1 function descriptor, _dl_audit_symbind
requires to know whether bind-now is used so the symbol value is
updated to function text segment instead of the OPD (for lazy binding
this is done by PPC64_LOAD_FUNCPTR on _dl_runtime_resolve).
Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
powerpc64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
elf: Fix initial-exec TLS access on audit modules (BZ #28096)
For audit modules and dependencies with initial-exec TLS, we can not
set the initial TLS image on default loader initialization because it
would already be set by the audit setup. However, subsequent thread
creation would need to follow the default behaviour.
This patch fixes it by setting l_auditing link_map field not only
for the audit modules, but also for all its dependencies. This is
used on _dl_allocate_tls_init to avoid the static TLS initialization
at load time.
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
Carlos O'Donell [Mon, 31 Jan 2022 05:34:42 +0000 (00:34 -0500)]
localedata: Adjust C.UTF-8 to align with C/POSIX.
We have had one downstream report from Canonical [1] that
an rrdtool test was broken by the differences in LC_TIME
that we had in the non-builtin C locale (C.UTF-8). If one
application has an issue there are going to be others, and
so with this commit we review and fix all the issues that
cause the builtin C locale to be different from C.UTF-8,
which includes:
* mon_decimal_point should be empty e.g. ""
- Depends on mon_decimal_point_wc fix.
* negative_sign should be empty e.g. ""
* week should be aligned with the builtin C/POSIX locale
* d_fmt corrected with escaped slashes e.g. "%m//%d//%y"
* yesstr and nostr should be empty e.g. ""
* country_ab2 and country_ab3 should be empty e.g. ""
We bump LC_IDENTIFICATION version and adjust the date to
indicate the change in the locale.
A new tst-c-utf8-consistency test is added to ensure
consistency between C/POSIX and C.UTF-8.
Carlos O'Donell [Mon, 31 Jan 2022 05:34:41 +0000 (00:34 -0500)]
localedef: Fix handling of empty mon_decimal_point (Bug 28847)
The handling of mon_decimal_point is incorrect when it comes to
handling the empty "" value. The existing parser in monetary_read()
will correctly handle setting the non-wide-character value and the
wide-character value e.g. STR_ELEM_WC(mon_decimal_point) if they are
set in the locale definition. However, in monetary_finish() we have
conflicting TEST_ELEM() which sets a default value (if the locale
definition doesn't include one), and subsequent code which looks for
mon_decimal_point to be NULL to issue a specific error message and set
the defaults. The latter is unused because TEST_ELEM() always sets a
default. The simplest solution is to remove the TEST_ELEM() check,
and allow the existing check to look to see if mon_decimal_point is
NULL and set an appropriate default. The final fix is to move the
setting of mon_decimal_point_wc so it occurs only when
mon_decimal_point is being set to a default, keeping both values
consistent. There is no way to tell the difference between
mon_decimal_point_wc having been set to the empty string and not
having been defined at all, for that distinction we must use
mon_decimal_point being NULL or "", and so we must logically set
the default together with mon_decimal_point.
Lastly, there are more fixes similar to this that could be made to
ld-monetary.c, but we avoid that in order to fix just the code
required for mon_decimal_point, which impacts the ability for C.UTF-8
to set mon_decimal_point to "", since without this fix we end up with
an inconsistent setting of mon_decimal_point set to "", but
mon_decimal_point_wc set to "." which is incorrect.
Tested on x86_64 and i686 without regression. Reviewed-by: Florian Weimer <fweimer@redhat.com>
H.J. Lu [Sat, 29 Jan 2022 18:56:45 +0000 (10:56 -0800)]
elf: Add <dl-r_debug.h>
Add <dl-r_debug.h> to get the adddress of the r_debug structure after
relocation and its offset before relocation from the PT_DYNAMIC segment
to support DT_DEBUG, DT_MIPS_RLD_MAP_REL and DT_MIPS_RLD_MAP.
Co-developed-by: Xi Ruoyao <xry111@mengyan1223.wang>
Carlos O'Donell [Fri, 28 Jan 2022 20:14:29 +0000 (15:14 -0500)]
malloc: Fix -Wuse-after-free warning in tst-mallocalign1 [BZ #26779]
The test leaks bits from the freed pointer via the return value
in ret, and the compiler correctly identifies this issue.
We switch the test to use TEST_VERIFY and terminate the test
if any of the pointers return an unexpected alignment.
This fixes another -Wuse-after-free error when compiling glibc
with gcc 12.
Linux: Only generate 64 bit timestamps for 64 bit time_t recvmsg/recvmmsg
The timestamps created by __convert_scm_timestamps only make sense for
64 bit time_t programs, 32 bit time_t programs will ignore 64 bit time_t
timestamps since SO_TIMESTAMP will be defined to old values (either by
glibc or kernel headers).
Worse, if the buffer is not suffice MSG_CTRUNC is set to indicate it
(which breaks some programs [1]).
This patch makes only 64 bit time_t recvmsg and recvmmsg to call
__convert_scm_timestamps. Also, the assumption to called it is changed
from __ASSUME_TIME64_SYSCALLS to __TIMESIZE != 64 since the setsockopt
might be called by libraries built without __TIME_BITS=64. The
MSG_CTRUNC is only set for the 64 bit symbols, it should happen only
if 64 bit time_t programs run older kernels.
linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ#28350)
The __convert_scm_timestamps only updates the control message last
pointer for SOL_SOCKET type, so if the message control buffer contains
multiple ancillary message types the converted timestamp one might
overwrite a valid message.
The test checks if the extra ancillary space is correctly handled
by recvmsg/recvmmsg, where if there is no extra space for the 64-bit
time_t converted message the control buffer should be marked with
MSG_TRUNC. It also check if recvmsg/recvmmsg handle correctly multiple
ancillary data.
Checked on x86_64-linux and on i686-linux-gnu on both 5.11 and
4.15 kernel.
Check if the socket support 64-bit network packages timestamps
(SO_TIMESTAMP and SO_TIMESTAMPNS). This will be used on recvmsg
and recvmmsg tests to check if the timestamp should be generated.
Florian Weimer [Thu, 27 Jan 2022 15:03:58 +0000 (16:03 +0100)]
Fix glibc 2.34 ABI omission (missing GLIBC_2.34 in dynamic loader)
The glibc 2.34 release really should have added a GLIBC_2.34
symbol to the dynamic loader. With it, we could move functions such
as dlopen or pthread_key_create that work on process-global state
into the dynamic loader (once we have fixed a longstanding issue
with static linking). Without the GLIBC_2.34 symbol, yet another
new symbol version would be needed because old glibc will fail to
load binaries due to the missing symbol version in ld.so that newly
linked programs will require.
posix: Add terminal control setting support for posix_spawn
Currently there is no proper way to set the controlling terminal through
posix_spawn in race free manner [1]. This forces shell implementations
to keep using fork+exec when launching background process groups,
even when using posix_spawn yields better performance.
This patch adds a new GNU extension so the creating process can
configure the created process terminal group. This is done with a new
flag, POSIX_SPAWN_TCSETPGROUP, along with two new attribute functions:
posix_spawnattr_tcsetpgrp_np, and posix_spawnattr_tcgetpgrp_np.
The function sets a new attribute, spawn-tcgroupfd, that references to
the controlling terminal.
The controlling terminal is set after the spawn-pgroup attribute, and
uses the spawn-tcgroupfd along with current creating process group
(so it is composable with POSIX_SPAWN_SETPGROUP).
To create a process and set the controlling terminal, one can use the
following sequence:
The controlling terminal file descriptor is ignored if the new flag is
not set.
This interface is slight different than the one provided by QNX [2],
which only provides the POSIX_SPAWN_TCSETPGROUP flag. The QNX
documentation does not specify how the controlling terminal is obtained
nor how it iteracts with POSIX_SPAWN_SETPGROUP. Since a glibc
implementation is library based, it is more straightforward and avoid
requires additional file descriptor operations to request the caller
to setup the controlling terminal file descriptor (and it also allows
a bit less error handling by posix_spawn).
Andreas Schwab [Tue, 18 Jan 2022 15:31:39 +0000 (16:31 +0100)]
Fix handling of unterminated bracket expressions in fnmatch (bug 28792)
When fnmatch processes a bracket expression, and eventually finds it to be
unterminated, it should rescan it, treating the starting bracket as a
normal character. That didn't happen when a matching character was found
while scanning the bracket expression.