Commit Graph

37781 Commits

Author SHA1 Message Date
Fangrui Song
33c50ef428 elf: Drop elf/tls-macros.h in favor of __thread and tls_model attributes [BZ #28152] [BZ #28205]
elf/tls-macros.h was added for TLS testing when GCC did not support
__thread. __thread and tls_model attributes are mature now and have been
used by many newer tests.

Also delete tst-tls2.c which tests .tls_common (unused by modern GCC and
unsupported by Clang/LLD). .tls_common and .tbss definition are almost
identical after linking, so the runtime test doesn't add additional
coverage.  Assembler and linker tests should be on the binutils side.

When LLD 13.0.0 is allowed in configure.ac
(https://sourceware.org/pipermail/libc-alpha/2021-August/129866.html),
`make check` result is on par with glibc built with GNU ld on aarch64
and x86_64.

As a future clean-up, TLS_GD/TLS_LD/TLS_IE/TLS_IE macros can be removed from
sysdeps/*/tls-macros.h. We can add optional -mtls-dialect={gnu2,trad}
tests to ensure coverage.

Tested on aarch64-linux-gnu, powerpc64le-linux-gnu, and x86_64-linux-gnu.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2021-08-16 09:59:30 -07:00
Samuel Thibault
cbb2aa337b hurd: Drop fmh kludge
Gnumach's 0650a4ee30e3 implements support for high bits being set in the
mask parameter of vm_map. This allows to remove the fmh kludge that was
masking away the address range by mapping a dumb area there.
2021-08-16 11:20:38 +02:00
Stafford Horne
6e8a0aac2f time: Fix overflow itimer tests on 32-bit systems
On the port of OpenRISC I am working on and it appears the rv32 port
we have sets __TIMESIZE == 64 && __WORDSIZE == 32.  This causes the
size of time_t to be 8 bytes, but the tv_sec in the kernel is still 32-bit
causing truncation.

The truncations are unavoidable on these systems so skip the
testing/failures by guarding with __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64.

Also, futher in the tests and in other parts of code checking for time_t
overflow does not work on 32-bit systems when time_t is 64-bit.  As
suggested by Adhemerval, update the in_time_t_range function to assume
32-bits by using int32_t.

This also brings in the header for stdint.h so we can update other
usages of __int32_t to int32_t as suggested by Adhemerval.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-08-15 07:09:58 +09:00
Xi Ruoyao
0f62fe0532 mips: increase stack alignment in clone to match the ABI
In "mips: align stack in clone [BZ #28223]"
(commit 1f51cd9a86) I made a mistake: I
misbelieved one "word" was 2-byte and "doubleword" should be 4-byte.
But in MIPS ABI one "word" is defined 32-bit (4-byte), so "doubleword" is
8-byte [1], and "quadword" is 16-byte [2].

[1]: "System V Application Binary Interface: MIPS(R) RISC Processor
      Supplement, 3rd edition", page 3-31
[2]: "MIPSpro(TM) 64-Bit Porting and Transition Guide", page 23
2021-08-13 16:01:14 +00:00
Xi Ruoyao
1f51cd9a86 mips: align stack in clone [BZ #28223]
The MIPS O32 ABI requires 4 byte aligned stack, and the MIPS N64 and N32
ABI require 8 byte aligned stack.  Previously if the caller passed an
unaligned stack to clone the the child misbehaved.

Fixes bug 28223.
2021-08-12 20:31:59 +00:00
Nikita Popov
4cc79c2177 librt: add test (bug 28213)
This test implements following logic:
1) Create POSIX message queue.
   Register a notification with mq_notify (using NULL attributes).
   Then immediately unregister the notification with mq_notify.
   Helper thread in a vulnerable version of glibc
   should cause NULL pointer dereference after these steps.
2) Once again, register the same notification.
   Try to send a dummy message.
   Test is considered successfulif the dummy message
   is successfully received by the callback function.

Signed-off-by: Nikita Popov <npv1310@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2021-08-12 16:09:50 +05:30
Siddhesh Poyarekar
dc906e94f7 mtrace: Use a static buffer for printing [BZ #25947]
Use a static buffer for mtrace printing now that it no longer adds to
default libc footprint.

Reviewed-by: DJ Delorie <dj@redhat.com>
2021-08-12 06:38:15 +05:30
Sergey Bugaev
5a5358b749 hurd mmap: Reduce the requested max vmprot
When the memory object is read-only, the kernel would be right in
refusing max vmprot containing VM_PROT_WRITE.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-08-11 18:39:51 +02:00
Sergey Bugaev
08fc6df294 hurd mmap: Factorize MAP_SHARED flag check
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2021-08-11 18:39:51 +02:00
Fangrui Song
43d06ed218 aarch64: Make elf_machine_{load_address,dynamic} robust [BZ #28203]
The AArch64 ABI is largely platform agnostic and does not specify
_GLOBAL_OFFSET_TABLE_[0] ([1]). glibc ld.so turns out to be probably the
only user of _GLOBAL_OFFSET_TABLE_[0] and GNU ld defines the value
to the link-time address _DYNAMIC. [2]

In 2012, __ehdr_start was implemented in GNU ld and gold in binutils
2.23.  Using adrp+add / (-mcmodel=tiny) adr to access
__ehdr_start/_DYNAMIC gives us a robust way to get the load address and
the link-time address of _DYNAMIC.

[1]: From a psABI maintainer, https://bugs.llvm.org/show_bug.cgi?id=49672#c2
[2]: LLD's aarch64 port does not set _GLOBAL_OFFSET_TABLE_[0] to the
link-time address _DYNAMIC.
LLD is widely used on aarch64 Android and ChromeOS devices.  Software
just works without the need for _GLOBAL_OFFSET_TABLE_[0].

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2021-08-11 09:00:38 -07:00
Fangrui Song
302247c891 elf: Unconditionally use __ehdr_start
We can consider __ehdr_start (from binutils 2.23 onwards)
unconditionally supported, since configure.ac requires binutils>=2.25.

The configure.ac check is related to an ia64 bug fixed by binutils 2.24.
See https://sourceware.org/pipermail/libc-alpha/2014-August/053503.html

Tested on x86_64-linux-gnu. Tested build-many-glibcs.py with
aarch64-linux-gnu and s390x-linux-gnu.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2021-08-10 11:04:56 -07:00
Samuel Thibault
13710e7e6a hurd: Add support for AT_NO_AUTOMOUNT 2021-08-10 17:16:54 +02:00
Wilco Dijkstra
a5db6a5cae [5/5] AArch64: Improve A64FX memset medium loops
Simplify the code for memsets smaller than L1. Improve the unroll8 and
L1_prefetch loops.

Reviewed-by: Naohiro Tamura <naohirot@fujitsu.com>
2021-08-10 13:46:20 +01:00
Wilco Dijkstra
e69d9981f8 [4/5] AArch64: Improve A64FX memset by removing unroll32
Remove unroll32 code since it doesn't improve performance.

Reviewed-by: Naohiro Tamura <naohirot@fujitsu.com>
2021-08-10 13:44:27 +01:00
Wilco Dijkstra
186092c6ba [3/5] AArch64: Improve A64FX memset for remaining bytes
Simplify handling of remaining bytes. Avoid lots of taken branches and complex
whilelo computations, instead unconditionally write vectors from the end.

Reviewed-by: Naohiro Tamura <naohirot@fujitsu.com>
2021-08-10 13:42:07 +01:00
Wilco Dijkstra
9bc2ed8f46 [2/5] AArch64: Improve A64FX memset for large sizes
Improve performance of large memsets. Simplify alignment code. For zero memset
use DC ZVA, which almost doubles performance. For non-zero memsets use the
unroll8 loop which is about 10% faster.

Reviewed-by: Naohiro Tamura <naohirot@fujitsu.com>
2021-08-10 13:39:37 +01:00
Wilco Dijkstra
07b427296b [1/5] AArch64: Improve A64FX memset for small sizes
Improve performance of small memsets by reducing instruction counts and
improving code alignment. Bench-memset shows 35-45% performance gain for
small sizes.

Reviewed-by: Naohiro Tamura <naohirot@fujitsu.com>
2021-08-10 13:30:27 +01:00
Joseph Myers
1d7b32ee61 Use binutils 2.37 branch in build-many-glibcs.py
This patch makes build-many-glibcs.py use binutils 2.37 branch.

Tested with build-many-glibcs.py (compilers and glibcs builds).
2021-08-09 17:00:36 +00:00
Joseph Myers
98149b16d6 Add PTRACE_GET_RSEQ_CONFIGURATION from Linux 5.13 to sys/ptrace.h
Linux 5.13 adds a PTRACE_GET_RSEQ_CONFIGURATION constant, with an
associated ptrace_rseq_configuration structure.

Add this constant to the various sys/ptrace.h headers in glibc, with
the structure in bits/ptrace-shared.h (named struct
__ptrace_rseq_configuration in glibc, as with other such structures).

Tested for x86_64, and with build-many-glibcs.py.
2021-08-09 16:51:38 +00:00
Nikita Popov
b805aebd42 librt: fix NULL pointer dereference (bug 28213)
Helper thread frees copied attribute on NOTIFY_REMOVED message
received from the OS kernel.  Unfortunately, it fails to check whether
copied attribute actually exists (data.attr != NULL).  This worked
earlier because free() checks passed pointer before actually
attempting to release corresponding memory.  But
__pthread_attr_destroy assumes pointer is not NULL.

So passing NULL pointer to __pthread_attr_destroy will result in
segmentation fault.  This scenario is possible if
notification->sigev_notify_attributes == NULL (which means default
thread attributes should be used).

Signed-off-by: Nikita Popov <npv1310@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2021-08-09 20:17:34 +05:30
Anton Blanchard
60b4dd2579 powerpc64: Add checks for Altivec and VSX in ifunc selection
We'd like to support processors without Altivec or VSX, so check
the relevant hwcap bits before selecting them.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2021-08-06 16:10:08 -03:00
Anton Blanchard
f2a15dd668 powerpc64: Check cacheline size before using optimised memset routines
A number of optimised memset routines assume the cacheline size is 128B,
so we better check before using them.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2021-08-06 16:09:59 -03:00
Anton Blanchard
e4ca6de1bc powerpc64: Replace some PPC_FEATURE_HAS_VSX with PPC_FEATURE_ARCH_2_06
We use PPC_FEATURE_HAS_VSX to select a number of POWER7 optimised
functions. These functions don't use any VSX instructions, so
PPC_FEATURE_ARCH_2_06 seems like a better fit.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2021-08-06 16:09:52 -03:00
Florian Weimer
c87fcacc50 Linux: Fix fcntl, ioctl, prctl redirects for _TIME_BITS=64 (bug 28182)
__REDIRECT and __THROW are not compatible with C++ due to the ordering of the
__asm__ alias and the throw specifier. __REDIRECT_NTH has to be used
instead.

Fixes commit 8a40aff86b ("io: Add time64 alias
for fcntl"), commit 82c395d91e ("misc: Add
time64 alias for ioctl"), commit b39ffab860
("Linux: Add time64 alias for prctl").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-08-06 09:52:00 +02:00
Joseph Myers
fb89489636 Add INADDR_DUMMY from Linux 5.13 to netinet/in.h
Linux 5.13 adds an INADDR_DUMMY definition; add a corresponding
definition to glibc's netinet/in.h.  (This isn't strictly a new kernel
interface, rather a value defined in RFC 7600.)

Tested for x86_64.
2021-08-05 20:12:56 +00:00
Siddhesh Poyarekar
505a964ae0 tst-mxfast: Don't run with mcheck
The test may not show predictable behaviour with -lmcheck since the
padding won't always guarantee fastbin usage.
2021-08-05 07:36:55 +05:30
Adhemerval Zanella
3d9a539ee6 rt: Set the correct message queue for tst-mqueue10
Checked on x86_64-linux-gnu.
2021-08-04 17:38:38 -03:00
Adhemerval Zanella
c52eb066bc Update sparc libm-test-ulps 2021-08-04 17:38:38 -03:00
Adhemerval Zanella
5b86241a03 linux: Add sparck brk implementation
It turned that the generic implementation of brk() does not work
for sparc, since on failure kernel will just return the previous
input value without setting the conditional register.

This patches adds back a sparc32 and sparc64 implementation removed
by 720480934a.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
2021-08-04 17:38:30 -03:00
DJ Delorie
ac30324c67 test-dlclose-exit-race: avoid hang on pthread_create error
This test depends on the "last" function being called in a
different thread than the "first" function, as "last" posts
a semaphore that "first" is waiting on.  However, if pthread_create
fails - for example, if running in an older container before
the clone3()-in-container-EPERM fixes - exit() is called in the
same thread as everything else, the semaphore never gets posted,
and first hangs.

The fix is to pre-post that semaphore before a single-threaded
exit.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2021-08-04 15:33:21 -04:00
Siddhesh Poyarekar
b17e842a60 gethosts: Remove unused argument _type
The generated code is unchanged.
2021-08-04 02:23:43 +05:30
Samuel Thibault
df183287ff hurd: Avoid spurious warning
Compilers missing some flow analysis may think ss may be used
uninitialized.
2021-08-03 19:38:45 +02:00
Siddhesh Poyarekar
77a34079d8 gaiconf_init: Avoid double-free in label and precedence lists
labellist and precedencelist could get freed a second time if there
are allocation failures, so set them to NULL to avoid a double-free.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2021-08-03 21:11:03 +05:30
Siddhesh Poyarekar
45caed9d67 copy_and_spawn_sgid: Avoid double calls to close()
If close() on infd and outfd succeeded, reset the fd numbers so that
we don't attempt to close them again.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2021-08-03 21:10:53 +05:30
Siddhesh Poyarekar
1e0e6d656d iconv_charmap: Close output file when done
Reviewed-by: Arjun Shankar <arjun@redhat.com>
2021-08-03 21:10:29 +05:30
Siddhesh Poyarekar
5f9b78fe35 gconv_parseconfdir: Fix memory leak
The allocated `conf` would leak if we have to skip over the file due
to the underlying filesystem not supporting dt_type.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2021-08-03 21:10:20 +05:30
Siddhesh Poyarekar
b0234d79e7 ldconfig: avoid leak on empty paths in config file
Reviewed-by: Arjun Shankar <arjun@redhat.com>
2021-08-03 21:10:10 +05:30
Joseph Myers
2ee9b24f47 Fix build of nptl/tst-thread_local1.cc with GCC 12
The test nptl/tst-thread_local1.cc fails to build with GCC mainline
because of changes to what libstdc++ headers implicitly include what
other headers:

tst-thread_local1.cc: In function 'int do_test()':
tst-thread_local1.cc:177:5: error: variable 'std::array<std::pair<const char*, std::function<void(void* (*)(void*))> >, 2> do_thread_X' has initializer but incomplete type
  177 |     do_thread_X
      |     ^~~~~~~~~~~

Fix this by adding an explicit include of <array>.

Tested with build-many-glibcs.py for aarch64-linux-gnu.
2021-08-02 16:33:44 +00:00
Robbie Harwood
6069826312 nis: Fix leak on realloc failure in nis_getnames [BZ #28150]
If pos >= count but realloc fails, tmp will not have been placed in
getnames[pos] yet, and so will not be freed in free_null.  Detected
by Coverity.

Also remove misleading comment from nis_getnames(), since it actually
did properly release getnames when out of memory.

Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-08-02 11:14:20 -04:00
Paul Zimmermann
db737c79c6 Remove obsolete comments/name from several benchtest input files.
These comments refer to slow paths that were removed in
glibc 2.34 or earlier.  The corresponding "names" that yield
separate workload traces for "make bench" are thus obsolete.
We are however keeping the corresponding inputs.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2021-08-02 15:27:16 +02:00
Paul Zimmermann
4165dd2e95 Remove obsolete comments/name from acos-inputs, since slow path was removed. 2021-08-02 15:05:22 +02:00
Carlos O'Donell
a85c93c424 Open master branch for glibc 2.35 development 2021-08-01 21:54:40 -04:00
Carlos O'Donell
ae37d06c7d Update ChangeLog.old/ChangeLog.23. 2021-08-01 21:33:43 -04:00
Carlos O'Donell
cdf4cd5e60 Prepare for glibc 2.34 release.
Update version.h, and include/features.h.
2021-08-01 21:24:04 -04:00
Carlos O'Donell
e39d2b84a2 po/nl.po: Update Dutch translation. 2021-08-01 20:52:28 -04:00
Carlos O'Donell
06eae99ab4 Update install.texi, and regenerate INSTALL. 2021-08-01 16:48:43 -04:00
Carlos O'Donell
e502942eb8 Update translations. 2021-08-01 16:48:43 -04:00
Carlos O'Donell
2e2c08aa4d Update NEWS.
Suggestions by Florian Weimer, Andreas Schwab, and Alexander Monakov.

See:
https://sourceware.org/pipermail/libc-alpha/2021-July/129356.html
https://sourceware.org/pipermail/libc-alpha/2021-July/129357.html
https://sourceware.org/pipermail/libc-alpha/2021-July/129361.html
2021-08-01 16:47:56 -04:00
Mark Harris
cfdaa29f66 NEWS: Fix typos, grammar, and missing words
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-08-01 00:51:22 -04:00
Adhemerval Zanella
3908fa933a elf: Fix audit regression
Commit 03e187a41d added a regression when an audit module does not have
libc as DT_NEEDED (although unusual it is possible).

Checked on x86_64-linux-gnu.
2021-07-30 16:01:44 -03:00