]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
3 years agogetenv: Move call to strlen to the branch it's used in.
Lode Willems [Fri, 18 Dec 2020 06:32:27 +0000 (12:02 +0530)] 
getenv: Move call to strlen to the branch it's used in.

The len variable is only used in the else branch.
We don't need the call to strlen if the name is 0 or 1 characters long.

2019-10-02  Lode Willems  <Lode.Willems@UGent.be>

* tdlib/getenv.c: Move the call to strlen into the branch it's used.

3 years agoUpdate kernel version to 5.10 in tst-mman-consts.py.
Joseph Myers [Thu, 17 Dec 2020 16:17:59 +0000 (16:17 +0000)] 
Update kernel version to 5.10 in tst-mman-consts.py.

This patch updates the kernel version in the test tst-mman-consts.py
to 5.10.  (There are no new MAP_* constants covered by this test in
5.10 that need any other header changes.)

Tested with build-many-glibcs.py.

3 years agos390x: Require GCC 7.1 or later to build glibc.
Stefan Liebler [Tue, 15 Dec 2020 14:18:03 +0000 (15:18 +0100)] 
s390x: Require GCC 7.1 or later to build glibc.

GCC 6.5 fails to correctly build ldconfig with recent ld.so.cache
commits, e.g.:
785969a047ad2f23f758901c6816422573544453
elf: Implement a string table for ldconfig, with tail merging

If glibc is build with gcc 6.5.0:
__builtin_add_overflow is used in
<glibc>/elf/stringtable.c:stringtable_finalize()
which leads to ldconfig failing with "String table is too large".
This is also recognizable in following tests:
FAIL: elf/tst-glibc-hwcaps-cache
FAIL: elf/tst-glibc-hwcaps-prepend-cache
FAIL: elf/tst-ldconfig-X
FAIL: elf/tst-ldconfig-bad-aux-cache
FAIL: elf/tst-ldconfig-ld_so_conf-update
FAIL: elf/tst-stringtable

See gcc "Bug 98269 - gcc 6.5.0 __builtin_add_overflow() with small
uint32_t values incorrectly detects overflow"
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269)

3 years agomalloc: Use __libc_initial to detect an inner libc
Florian Weimer [Wed, 16 Dec 2020 14:09:52 +0000 (15:09 +0100)] 
malloc: Use __libc_initial to detect an inner libc

The secondary/non-primary/inner libc (loaded via dlmopen, LD_AUDIT,
static dlopen) must not use sbrk to allocate member because that would
interfere with allocations in the outer libc.  On Linux, this does not
matter because sbrk itself was changed to fail in secondary libcs.

 _dl_addr occasionally shows up in profiles, but had to be used before
because __libc_multiple_libs was unreliable.  So this change achieves
a slight reduction in startup time.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoReplace __libc_multiple_libcs with __libc_initial flag
Florian Weimer [Wed, 16 Dec 2020 14:09:52 +0000 (15:09 +0100)] 
Replace __libc_multiple_libcs with __libc_initial flag

Change sbrk to fail for !__libc_initial (in the generic
implementation).  As a result, sbrk is (relatively) safe to use
for the __libc_initial case (from the main libc).  It is therefore
no longer necessary to avoid using it in that case (or updating the
brk cache), and the __libc_initial flag does not need to be updated
as part of dlmopen or static dlopen.

As before, direct brk system calls on Linux may lead to memory
corruption.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years ago{nptl,htl}/semaphoreP.h: clean up
Samuel Thibault [Wed, 16 Dec 2020 13:36:19 +0000 (14:36 +0100)] 
{nptl,htl}/semaphoreP.h: clean up

This removes "Contributed by", and uses a C99 flexible array instead of
char name[0];

3 years agohtl: Get sem_open/sem_close/sem_unlink support [BZ #25524]
Samuel Thibault [Sun, 13 Dec 2020 15:20:32 +0000 (15:20 +0000)] 
htl: Get sem_open/sem_close/sem_unlink support [BZ #25524]

This just moves the existing nptl implementation to reuse as it is in
htl.

3 years agopthread: Move semaphore initialization for open to semaphoreP.h
Samuel Thibault [Sun, 13 Dec 2020 15:18:16 +0000 (15:18 +0000)] 
pthread: Move semaphore initialization for open to semaphoreP.h

This allows to easily reuse all of the sem_open/sem_close/sem_unlink
implementations in the various ports.

3 years agoMark __libc_freeres_fn as used [BZ #27002]
H.J. Lu [Wed, 2 Dec 2020 22:26:28 +0000 (14:26 -0800)] 
Mark __libc_freeres_fn as used [BZ #27002]

GCC 11 with

commit 6fbec038f7a7ddf29f074943611b53210d17c40c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Feb 3 11:55:43 2020 -0800

    Use SHF_GNU_RETAIN to preserve symbol definitions

places used symbols in SECTION_RETAIN sections if assembler supports it.
Mark __libc_freeres_fn as used to avoid

gconv_dl.c: In function 'free_mem':
gconv_dl.c:191:1: error: 'do_release_all' without 'used' attribute and 'free_mem' with 'used' attribute are placed in a section with the same name [-Werror=attributes]
  191 | do_release_all (void *nodep)
      | ^~~~~~~~~~~~~~
In file included from <command-line>:
gconv_dl.c:202:18: note: 'free_mem' was declared here
  202 | libc_freeres_fn (free_mem)
      |                  ^~~~~~~~
./../include/libc-symbols.h:316:15: note: in definition of macro 'libc_freeres_fn'
  316 |   static void name (void)
      |               ^~~~
cc1: all warnings being treated as errors

3 years agoUpdate syscall lists for Linux 5.10.
Joseph Myers [Wed, 16 Dec 2020 02:08:52 +0000 (02:08 +0000)] 
Update syscall lists for Linux 5.10.

Linux 5.10 has one new syscall, process_madvise.  Update
syscall-names.list and regenerate the arch-syscall.h headers with
build-many-glibcs.py update-syscalls.

Tested with build-many-glibcs.py.

3 years agohtl: Add pshared semaphore support
Samuel Thibault [Sun, 13 Dec 2020 15:14:40 +0000 (15:14 +0000)] 
htl: Add pshared semaphore support

The implementation is extremely similar to the nptl implementation, but
with slight differences in the futex interface. This fixes some of BZ
25521.

3 years agohurd: Add LLL_PRIVATE and LLL_SHARED
Samuel Thibault [Sun, 13 Dec 2020 13:31:22 +0000 (13:31 +0000)] 
hurd: Add LLL_PRIVATE and LLL_SHARED

3 years agohurd: Add __libc_open and __libc_close
Samuel Thibault [Sun, 13 Dec 2020 13:29:25 +0000 (13:29 +0000)] 
hurd: Add __libc_open and __libc_close

Needed by libpthread for sem_open and sem_close

3 years agohtl: Add futex-internal.h
Samuel Thibault [Sun, 13 Dec 2020 11:06:27 +0000 (11:06 +0000)] 
htl: Add futex-internal.h

That provides futex_supports_pshared

3 years agohurd: Add __lll_abstimed_wait_intr
Samuel Thibault [Sun, 13 Dec 2020 11:01:52 +0000 (11:01 +0000)] 
hurd: Add __lll_abstimed_wait_intr

For semaphores, we need an interruptible version of low-level locks.

3 years agohurd: make lll_* take a variable instead of a ptr
Samuel Thibault [Sun, 13 Dec 2020 10:37:24 +0000 (10:37 +0000)] 
hurd: make lll_* take a variable instead of a ptr

To be coherent with other ports, let's make lll_* take a variable, and
rename those that keep taking a ptr into __lll_*.

3 years agohurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZER
Samuel Thibault [Sun, 13 Dec 2020 10:16:55 +0000 (10:16 +0000)] 
hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZER

To get coherent with other ports.

3 years agoUse Linux 5.10 in build-many-glibcs.py.
Joseph Myers [Tue, 15 Dec 2020 23:36:41 +0000 (23:36 +0000)] 
Use Linux 5.10 in build-many-glibcs.py.

This patch makes build-many-glibcs.py use Linux 5.10.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

3 years agoelf: Record libc.so link map when it is the main program (bug 20972)
Florian Weimer [Tue, 15 Dec 2020 19:56:04 +0000 (20:56 +0100)] 
elf: Record libc.so link map when it is the main program (bug 20972)

Otherwise, it will not participate in the dependency sorting.

Fixes commit 9ffa50b26b0cb5d3043adf6d3d0b1ea735acc147
("elf: Include libc.so.6 as main program in dependency sort
(bug 20972)").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoUse GMP 6.2.1 in build-many-glibcs.py.
Joseph Myers [Tue, 15 Dec 2020 16:45:49 +0000 (16:45 +0000)] 
Use GMP 6.2.1 in build-many-glibcs.py.

This patch makes build-many-glibcs.py use the recent GMP 6.2.1
release.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

3 years agoaarch64: remove the strlen_asimd symbol
Szabolcs Nagy [Tue, 15 Dec 2020 10:36:56 +0000 (10:36 +0000)] 
aarch64: remove the strlen_asimd symbol

This symbol is not in the implementation reserved namespace for static
linking and it was never used: it seems it was mistakenly added in the
orignal strlen_asimd commit 436e4d5b965abe592d26150cb518accf9ded8fe4

3 years agoaarch64: fix static PIE start code for BTI [BZ #27068]
Guillaume Gardet [Mon, 14 Dec 2020 15:38:22 +0000 (15:38 +0000)] 
aarch64: fix static PIE start code for BTI [BZ #27068]

A bti c was missing from rcrt1.o which made all -static-pie
binaries fail at program startup on BTI enabled systems.

Fixes bug 27068.

3 years agoelf: Fix failure handling in _dl_map_object_from_fd
Szabolcs Nagy [Tue, 24 Nov 2020 12:34:39 +0000 (12:34 +0000)] 
elf: Fix failure handling in _dl_map_object_from_fd

The failure paths in _dl_map_object_from_fd did not clean every
potentially allocated resource up.

Handle l_phdr, l_libname and mapped segments in the common failure
handling code.

There are various bits that may not be cleaned properly on failure
(e.g. executable stack, incomplete dl_map_segments) fixing those
need further changes.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: inline lose for error handling
Szabolcs Nagy [Tue, 24 Nov 2020 11:08:33 +0000 (11:08 +0000)] 
elf: inline lose for error handling

_dl_map_object_from_fd has complex error handling with cleanups.
It was managed by a separate function to avoid code bloat at
every failure case, but since the code was changed to use gotos
there is no longer such code bloat from inlining.

Maintaining a separate error handling function is harder as it
needs to access local state which has to be passed down. And the
same lose function was used in open_verify which is error prone.

The goto labels are changed since there is no longer a call.
The new code generates slightly smaller binary.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoRemove strtoimax, strtoumax, wcstoimax, wcstoumax inlines
Joseph Myers [Mon, 14 Dec 2020 17:51:38 +0000 (17:51 +0000)] 
Remove strtoimax, strtoumax, wcstoimax, wcstoumax inlines

inttypes.h has inline implementations of the strtoimax, strtoumax,
wcstoimax and wcstoumax functions, despite the corresponding stdlib.h
and wchar.h inlines having been removed in 2007 (commit
9b2e9577b228350b15d88303b00097dd58e8d29b).

Remove those inlines, thereby eliminating all references to the
corresponding __*_internal functions from installed headers (so they
could be made into compat symbols in future if desired).

Tested for x86_64 and x86.

3 years agonsswitch: handle missing actions properly
DJ Delorie [Thu, 10 Dec 2020 02:46:30 +0000 (21:46 -0500)] 
nsswitch: handle missing actions properly

Some internal functions need to know if a database has a nonzero
list of actions; success getting the database does not guarantee
that.  Add checks for such as needed.

Skip the ":" in each nsswitch.conf line so as not to add a dummy
action libnss_:.so

See also https://bugzilla.redhat.com/show_bug.cgi?id=1906066

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agox86: Remove the default REP MOVSB threshold tunable value [BZ #27061]
H.J. Lu [Sun, 13 Dec 2020 12:56:41 +0000 (04:56 -0800)] 
x86: Remove the default REP MOVSB threshold tunable value [BZ #27061]

Since we can't tell if the tunable value is set by user or not:

https://sourceware.org/bugzilla/show_bug.cgi?id=27069

remove the default REP MOVSB threshold tunable value so that the correct
default value will be set correctly by init_cacheinfo ().

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoelf.h: Remove SHF_GNU_BUILD_NOTE.
Mark Wielaard [Fri, 11 Dec 2020 22:58:24 +0000 (23:58 +0100)] 
elf.h: Remove SHF_GNU_BUILD_NOTE.

SHF_GNU_BUILD_NOTE was a binutils experiment.  And it is no longer
needed. It was also removed from binutils.

3 years agoelf.h: fix spelling typos in comments
Dmitry V. Levin [Sat, 12 Dec 2020 00:30:00 +0000 (00:30 +0000)] 
elf.h: fix spelling typos in comments

Since elf.h is a public header file copied to other projects,
try to make it free from spelling typos.

This change fixes the following spelling typos in comments of elf.h:

Auxialiary -> Auxiliary
tenatively -> tentatively
compatability -> compatibility

3 years agoFix spelling and grammar in several comments
Jonny Grant [Sat, 12 Dec 2020 00:16:22 +0000 (01:16 +0100)] 
Fix spelling and grammar in several comments

3 years agomalloc: Detect infinite-loop in _int_free when freeing tcache [BZ#27052]
W. Hashimoto [Fri, 11 Dec 2020 21:59:10 +0000 (16:59 -0500)] 
malloc: Detect infinite-loop in _int_free when freeing tcache [BZ#27052]

If linked-list of tcache contains a loop, it invokes infinite
loop in _int_free when freeing tcache. The PoC which invokes
such infinite loop is on the Bugzilla(#27052). This loop
should terminate when the loop exceeds mp_.tcache_count and
the program should abort. The affected glibc version is
2.29 or later.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoelf: Fix dl-load.c
Szabolcs Nagy [Fri, 11 Dec 2020 17:30:49 +0000 (17:30 +0000)] 
elf: Fix dl-load.c

Rebasing broke commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2
it was supposed to move code.

3 years agoelf: Include libc.so.6 as main program in dependency sort (bug 20972)
Florian Weimer [Fri, 11 Dec 2020 16:30:03 +0000 (17:30 +0100)] 
elf: Include libc.so.6 as main program in dependency sort (bug 20972)

_dl_map_object_deps always sorts the initially loaded object first
during dependency sorting.  This means it is relocated last in
dl_open_worker.  This results in crashes in IFUNC resolvers without
lazy bindings if libraries are preloaded that refer to IFUNCs in
libc.so.6: the resolvers are called when libc.so.6 has not been
relocated yet, so references to _rtld_global_ro etc. crash.

The fix is to check against the libc.so.6 link map recorded by the
__libc_early_init framework, and let it participate in the dependency
sort.

This fixes bug 20972.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agosupport: Add support_slibdir_prefix variable
Florian Weimer [Fri, 11 Dec 2020 16:24:08 +0000 (17:24 +0100)] 
support: Add support_slibdir_prefix variable

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoaarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]
Szabolcs Nagy [Tue, 1 Dec 2020 10:13:18 +0000 (10:13 +0000)] 
aarch64: Use mmap to add PROT_BTI instead of mprotect [BZ #26831]

Re-mmap executable segments if possible instead of using mprotect
to add PROT_BTI. This allows using BTI protection with security
policies that prevent mprotect with PROT_EXEC.

If the fd of the ELF module is not available because it was kernel
mapped then mprotect is used and failures are ignored.  To protect
the main executable even when mprotect is filtered the linux kernel
 will have to be changed to add PROT_BTI to it.

The delayed failure reporting is mainly needed because currently
_dl_process_gnu_properties does not propagate failures such that
the required cleanups happen. Using the link_map_machine struct for
error propagation is not ideal, but this seemed to be the least
intrusive solution.

Fixes bug 26831.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Pass the fd to note processing
Szabolcs Nagy [Wed, 28 Oct 2020 15:17:06 +0000 (15:17 +0000)] 
elf: Pass the fd to note processing

To handle GNU property notes on aarch64 some segments need to
be mmaped again, so the fd of the loaded ELF module is needed.

When the fd is not available (kernel loaded modules), then -1
is passed.

The fd is passed to both _dl_process_pt_gnu_property and
_dl_process_pt_note for consistency. Target specific note
processing functions are updated accordingly.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Move note processing after l_phdr is updated
Szabolcs Nagy [Thu, 29 Oct 2020 13:29:15 +0000 (13:29 +0000)] 
elf: Move note processing after l_phdr is updated

Program headers are processed in two pass: after the first pass
load segments are mmapped so in the second pass target specific
note processing logic can access the notes.

The second pass is moved later so various link_map fields are
set up that may be useful for note processing such as l_phdr.
The second pass should be before the fd is closed so that is
available.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoaarch64: align address for BTI protection [BZ #26988]
Szabolcs Nagy [Tue, 1 Dec 2020 10:12:32 +0000 (10:12 +0000)] 
aarch64: align address for BTI protection [BZ #26988]

Handle unaligned executable load segments (the bfd linker is not
expected to produce such binaries, but other linkers may).

Computing the mapping bounds follows _dl_map_object_from_fd more
closely now.

Fixes bug 26988.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoaarch64: Fix missing BTI protection from dependencies [BZ #26926]
Szabolcs Nagy [Fri, 20 Nov 2020 15:27:06 +0000 (15:27 +0000)] 
aarch64: Fix missing BTI protection from dependencies [BZ #26926]

The _dl_open_check and _rtld_main_check hooks are not called on the
dependencies of a loaded module, so BTI protection was missed on
every module other than the main executable and directly dlopened
libraries.

The fix just iterates over dependencies to enable BTI.

Fixes bug 26926.

3 years agoFix linknamespace errors in nss_database.c if build with -Os.
Stefan Liebler [Thu, 10 Dec 2020 10:31:57 +0000 (11:31 +0100)] 
Fix linknamespace errors in nss_database.c if build with -Os.

Starting with recent commits, I get 43 conform/.../linknamespace FAILs:
- nss: Introduce <nss_module.h>
- <nss_action.h>: New abstraction for combining NSS modules and NSS actions
- nss: Implement <nss_database.h> (see nss/nss_database.c)
- nsswitch: use new internal API (core)
- nsswitch: user new internal API (tests)
- nsswitch: use new internal API (callers)

e.g. conform/XPG42/wordexp.h/linknamespace.out
[initial] wordexp -> [libc.a(wordexp.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_database_get -> [libc.a(nss_database.o)] feof_unlocked
[initial] wordexp -> [libc.a(wordexp.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_database_get -> [libc.a(nss_database.o)] ferror_unlocked

This patch is just using __ferror_unlocked and __feof_unlocked instead of the
non "__" prefixed ones.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agotreewide: fix incorrect spelling of indices in comments
Dmitry V. Levin [Fri, 11 Dec 2020 02:00:00 +0000 (02:00 +0000)] 
treewide: fix incorrect spelling of indices in comments

Replace 'indeces' with 'indices', the most annoying of these typos were
those found in elf.h which is a public header file copied to other
projects.

3 years agolinux: Consolidate brk implementation
Adhemerval Zanella [Fri, 26 Jun 2020 19:06:49 +0000 (16:06 -0300)] 
linux: Consolidate brk implementation

It removes all the arch-specific assembly implementation.  The
outliers are alpha, where its kernel ABI explict return -ENOMEM
in case of failure; and i686, where it can't use
"call *%gs:SYSINFO_OFFSET" during statup in static PIE.

Also some ABIs exports an additional ___brk_addr symbol and to
handle it an internal HAVE_INTERNAL_BRK_ADDR_SYMBOL is added.

Checked on x86_64-linux-gnu, i686-linux-gnu, adn with builsd for
the affected ABIs.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agoelf: Include <sys/param.h> in cache.c
Florian Weimer [Thu, 10 Dec 2020 14:47:26 +0000 (15:47 +0100)] 
elf: Include <sys/param.h> in cache.c

The roundup macro is defined there.  Relying on an indirect
definition is brittle.

3 years agos390x: Add glibc-hwcaps support
Florian Weimer [Thu, 10 Dec 2020 12:51:18 +0000 (13:51 +0100)] 
s390x: Add glibc-hwcaps support

Subdirectories z13, z14, z15 can be selected, mostly based on the
level of support for vector instructions.

Co-Authored-By: Stefan Liebler <stli@linux.ibm.com>
3 years agoelf: Fix run-time dependencies of tst-dlopen-fail-2
Florian Weimer [Thu, 10 Dec 2020 11:24:53 +0000 (12:24 +0100)] 
elf: Fix run-time dependencies of tst-dlopen-fail-2

The misattributed dependencies can cause failures in parallel testing
if the dependencies have not been built yet.

Fixes commit a332bd1518af518c984fad73eba6f46dc5b2b2d4
("elf: Add elf/tst-dlopenfail-2 [BZ #25396]").

3 years agoHandle out-of-memory case in svc_tcp.c/svc_unix.c:rendezvous_request.
Stefan Liebler [Fri, 4 Dec 2020 16:00:27 +0000 (17:00 +0100)] 
Handle out-of-memory case in svc_tcp.c/svc_unix.c:rendezvous_request.

If glibc is build with -O3 on at least 390 (-m31) or x86 (-m32),
gcc 11 dumps this warning:
svc_tcp.c: In function 'rendezvous_request':
svc_tcp.c:274:3: error: 'memcpy' offset [0, 15] is out of the bounds [0, 0] [-Werror=array-bounds]
  274 |   memcpy (&xprt->xp_raddr, &addr, sizeof (addr));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

In out-of-memory case, if one of the mallocs in makefd_xprt function
returns NULL, a message is dumped, makefd_xprt returns NULL
and the subsequent memcpy would copy to NULL.

Instead of a segfaulting, we delay a bit (see also __svc_accept_failed
and Bug 14889 (CVE-2011-4609) - svc_run() produces high cpu usage when
accept() fails with EMFILE (CVE-2011-4609).

The same applies to svc_unix.c.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Fix incorrect comparison in sort_priorities_by_name
Florian Weimer [Wed, 9 Dec 2020 17:56:14 +0000 (18:56 +0100)] 
elf: Fix incorrect comparison in sort_priorities_by_name

Reported-By: Stefan Liebler <stli@linux.ibm.com>
3 years agoS390: Derive float_t from FLT_EVAL_METHOD
Marius Hillenbrand [Mon, 30 Nov 2020 14:53:59 +0000 (15:53 +0100)] 
S390: Derive float_t from FLT_EVAL_METHOD

float_t supposedly represents the type that is used to evaluate float
expressions internally. While the isa supports single-precision float
operations, the port of glibc to s390 incorrectly deferred to the
generic definitions which, back then, tied float_t to double. gcc by
default evaluates float in single precision, so that scenario violates
the C standard (sections 5.2.4.2.2 and 7.12 in C11/C17). With
-fexcess-precision=standard, gcc evaluates float in double precision,
which aligns with the standard yet at the cost of added conversion
instructions.

With this patch, we drop the s390-specific definition of float_t and
defer to the default behavior, which aligns float_t with the
compiler-defined FLT_EVAL_METHOD in a standard-compliant way.

Checked on s390x-linux-gnu with 31-bit and 64-bit builds.

3 years agoFix parsing of /sys/devices/system/cpu/online (bug 25859)
Andreas Schwab [Tue, 8 Dec 2020 18:17:41 +0000 (19:17 +0100)] 
Fix parsing of /sys/devices/system/cpu/online (bug 25859)

The file contains comma-separated ranges, not spaces.

3 years agoMake strtoimax, strtoumax, wcstoimax, wcstoumax into aliases
Joseph Myers [Tue, 8 Dec 2020 18:15:27 +0000 (18:15 +0000)] 
Make strtoimax, strtoumax, wcstoimax, wcstoumax into aliases

The functions strtoimax, strtoumax, wcstoimax, wcstoumax currently
have three implementations each (wordsize-32, wordsize-64 and dummy
implementation in stdlib/ using #error), defining the functions as
thin wrappers round corresponding *_internal functions.  Simplify the
code by changing them into aliases of functions such as strtol and
wcstoull.  This is more consistent with how e.g. imaxdiv is handled.

Tested for x86_64 and x86.

3 years agoFixed typos in "NEWS for version 2.32"
Paul Zimmermann [Tue, 8 Dec 2020 14:56:32 +0000 (20:26 +0530)] 
Fixed typos in "NEWS for version 2.32"

3 years agoAdd NEWS entry for CVE-2020-29562 (BZ #26923)
Siddhesh Poyarekar [Mon, 7 Dec 2020 16:59:18 +0000 (22:29 +0530)] 
Add NEWS entry for CVE-2020-29562 (BZ #26923)

BZ #26923 now has a CVE entry, so add a NEWS entry for it.

3 years agoiconv: Fix incorrect UCS4 inner loop bounds (BZ#26923)
Michael Colavita [Thu, 19 Nov 2020 16:44:40 +0000 (11:44 -0500)] 
iconv: Fix incorrect UCS4 inner loop bounds (BZ#26923)

Previously, in UCS4 conversion routines we limit the number of
characters we examine to the minimum of the number of characters in the
input and the number of characters in the output. This is not the
correct behavior when __GCONV_IGNORE_ERRORS is set, as we do not consume
an output character when we skip a code unit. Instead, track the input
and output pointers and terminate the loop when either reaches its
limit.

This resolves assertion failures when resetting the input buffer in a step of
iconv, which assumes that the input will be fully consumed given sufficient
output space.

3 years agox86: Rename readelflib.c
H.J. Lu [Fri, 4 Dec 2020 20:24:39 +0000 (12:24 -0800)] 
x86: Rename readelflib.c

Rename linux/i386/readelflib.c to linux/x86/readelflib.c and remove
x86_64/readelflib.c.

3 years agonsswitch: use new internal API (callers)
DJ Delorie [Tue, 10 Nov 2020 03:09:34 +0000 (22:09 -0500)] 
nsswitch: use new internal API (callers)

Stitch new ABI and types throughout all NSS callers.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonsswitch: user new internal API (tests)
DJ Delorie [Tue, 10 Nov 2020 03:08:04 +0000 (22:08 -0500)] 
nsswitch: user new internal API (tests)

Testsuite support and new test for new API.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonsswitch: use new internal API (core)
DJ Delorie [Tue, 10 Nov 2020 03:06:57 +0000 (22:06 -0500)] 
nsswitch: use new internal API (core)

Core changes to switch the NSS internals to use the new API.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonss: Implement <nss_database.h>
Florian Weimer [Thu, 20 Feb 2020 12:20:32 +0000 (13:20 +0100)] 
nss: Implement <nss_database.h>

This code manages the mappings of the available databases in NSS
(i.e. passwd, hosts, netgroup, etc) with the actions that should
be taken to do a query on those databases.

This is the main API between query functions scattered throughout
glibc and the underlying code (actions, modules, etc).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years ago<nss_action.h>: New abstraction for combining NSS modules and NSS actions
Florian Weimer [Thu, 20 Feb 2020 08:32:27 +0000 (09:32 +0100)] 
<nss_action.h>: New abstraction for combining NSS modules and NSS actions

nss_action manages a set of lists of actions; these are the portions
of the lines in nsswitch.conf to the right of the colons, like
"dns [!UNAVAIL=return] files".  Each permutation of actions and
conditionals is cached for reuse, which limits memory growth, and
refers to the static list of modules managed by nss_modules.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonss: Introduce <nss_module.h>
Florian Weimer [Wed, 19 Feb 2020 19:55:48 +0000 (20:55 +0100)] 
nss: Introduce <nss_module.h>

This provides the struct nss_module type, which combines the old
struct service_library type with the known_function tree, by
statically allocating space for all function pointers.

struct nss_module is fairly large (536 bytes), but it will be
shared across NSS databases.  The old known_function handling
had non-some per-function overhead (at least 32 bytes per looked-up
function, but more for long function anmes), so overall, this is not
too bad.  Resolving all functions at load time simplifies locking,
and the repeated lookups should be fast because the caches are hot
at this point.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoAdd scripts/move-symbol-to-libc.py
Florian Weimer [Fri, 4 Dec 2020 18:32:56 +0000 (19:32 +0100)] 
Add scripts/move-symbol-to-libc.py

This helper script can be used to move symbols to libc.abilist across
all architectures, while preserving their symbol version.

3 years agopowerpc64le: Add glibc-hwcaps support
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
powerpc64le: Add glibc-hwcaps support

The "power10" and "power9" subdirectories are selected in a way
that matches the -mcpu=power10 and -mcpu=power9 options of GCC.

3 years agox86: Adjust tst-cpu-features-supports.c for GCC 11
H.J. Lu [Thu, 3 Dec 2020 23:02:44 +0000 (15:02 -0800)] 
x86: Adjust tst-cpu-features-supports.c for GCC 11

Check HAS_CPU_FEATURE instead of CPU_FEATURE_USABLE for FSGSBASE, IBT,
LM, SHSTK and XSAVES since FSGSBASE requires kernel support, IBT/SHSTK/LM
require OS support and XSAVES is supervisor-mode only.

3 years agox86: Set RDRAND usable if CPU supports RDRAND
H.J. Lu [Thu, 3 Dec 2020 23:02:44 +0000 (15:02 -0800)] 
x86: Set RDRAND usable if CPU supports RDRAND

Set RDRAND usable if CPU supports RDRAND.

3 years agoelf: Add missing <stddef.h> header to elf/dl-hwcaps.h
Matheus Castanho [Fri, 4 Dec 2020 12:48:56 +0000 (09:48 -0300)] 
elf: Add missing <stddef.h> header to elf/dl-hwcaps.h

The lack of this header makes size_t unavailable on builds configured
with --disable-tunables, causing compilation errors.

3 years agolowlevellock-futex: Remove not used macros
Lukasz Majewski [Tue, 1 Dec 2020 11:26:55 +0000 (12:26 +0100)] 
lowlevellock-futex: Remove not used macros

Following macros: lll_futex_timed_lock_pi, lll_futex_clock_wait_bitset,
lll_futex_wait_requeue_pi, lll_futex_timed_wait_requeue_pi are not
used anymore so are eligible for removal.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agofutex: Remove not used futex_reltimed_wait{_cancelable}
Lukasz Majewski [Tue, 1 Dec 2020 10:25:11 +0000 (11:25 +0100)] 
futex: Remove not used futex_reltimed_wait{_cancelable}

After gai_suspend and aio_suspend conversion to support 64 bit time and
hence rewriting the code to use only absolute variants of futex wait
functions (i.e. __futex_abstimed_wait64 and __futex_abstimed_wait_cancelable64)
futex_reltimed_wait{_cancelable} are not needed anymore and can be removed.

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoy2038: Convert gai_suspend to support 64 bit time
Lukasz Majewski [Mon, 30 Nov 2020 13:33:12 +0000 (14:33 +0100)] 
y2038: Convert gai_suspend to support 64 bit time

This change uses (in gai_misc.h):
- __futex_abstimed_wait64 (instead of futex_reltimed_wait)
- __futex_abstimed_wait_cancellable64
     (instead of futex_reltimed_wait_cancellable)
        from ./sysdeps/nptl/futex-helpers.h

The gai_suspend() accepts relative timeout, which then is converted to
absolute one.

The i686-gnu port (HURD) do not define DONT_NEED_GAI_MISC_COND and as it
doesn't (yet) support 64 bit time it uses not converted
pthread_cond_timedwait().

The __gai_suspend() is supposed to be run on ports with __TIMESIZE !=64 and
__WORDSIZE==32. It internally utilizes __gai_suspend_time64() and hence the
conversion from 32 bit struct timespec to 64 bit one is required.

For ports supporting 64 bit time the __gai_suspend_time64() will be used
either via alias (to __gai_suspend when __TIMESIZE==64) or redirection
(when -D_TIME_BITS=64 is passed).

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agosymbols: Add defines for libanl's libanl_hidden_{def|proto}
Lukasz Majewski [Mon, 30 Nov 2020 16:57:56 +0000 (17:57 +0100)] 
symbols: Add defines for libanl's libanl_hidden_{def|proto}

The __gai_suspend_time64, which supports 64 bit time on ports with
__WORDSIZE == 32 && __TIMESIZE != 64, shall be exported from libanl
(the same library from which original gai_suspend is exported).

Up till now there were no defines for this library. This commit adds
them.

3 years agox86_64: Add glibc-hwcaps support
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
x86_64: Add glibc-hwcaps support

The subdirectories match those in the x86-64 psABI:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9a6b9396884b67c7c

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add glibc-hwcaps subdirectory support to ld.so cache processing
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Add glibc-hwcaps subdirectory support to ld.so cache processing

This recognizes the DL_CACHE_HWCAP_EXTENSION flag in cache entries,
and picks the supported cache entry with the highest priority.

The elf/tst-glibc-hwcaps-prepend-cache test documents a non-desired
aspect of the current cache implementation: If the cache selects a DSO
that does not exist on disk, _dl_map_object falls back to open_path,
which may or may not find an alternative implementation.  This is an
existing limitation that also applies to the legacy hwcaps processing
for ld.so.cache.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Process glibc-hwcaps subdirectories in ldconfig
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Process glibc-hwcaps subdirectories in ldconfig

Libraries from these subdirectories are added to the cache
with a special hwcap bit DL_CACHE_HWCAP_EXTENSION, so that
they are ignored by older dynamic loaders.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Implement tail merging of strings in ldconfig
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Implement tail merging of strings in ldconfig

This simplifies the string table construction in elf/cache.c
because there is no more need to keep track of offsets explicitly;
the string table implementation does this internally.

This change slightly reduces the size of the cache on disk.  The
file format does not change as a result.  The strings are
null-terminated, without explicit length, so tail merging is
transparent to readers.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Implement a string table for ldconfig, with tail merging
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Implement a string table for ldconfig, with tail merging

This will be used in ldconfig to reduce the ld.so.cache size slightly.

Tail merging is an optimization where a pointer points into another
string if the first string is a suffix of the second string.

The hash function FNV-1a was chosen because it is simple and achieves
good dispersion even for short strings (so that the hash table bucket
count can be a power of two).  It is clearly superior to the hsearch
hash and the ELF hash in this regard.

The hash table uses chaining for collision resolution.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add extension mechanism to ld.so.cache
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Add extension mechanism to ld.so.cache

A previously unused new-format header field is used to record
the address of an extension directory.

This change adds a demo extension which records the version of
ldconfig which builds a file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add endianness markup to ld.so.cache (bug 27008)
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Add endianness markup to ld.so.cache (bug 27008)

Use a reserved byte in the new format cache header to indicate whether
the file is in little endian or big endian format.  Eventually, this
information could be used to provide a unified cache for qemu-user
and similiar scenarios.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add glibc-hwcaps support for LD_LIBRARY_PATH
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)] 
elf: Add glibc-hwcaps support for LD_LIBRARY_PATH

This hacks non-power-set processing into _dl_important_hwcaps.
Once the legacy hwcaps handling goes away, the subdirectory
handling needs to be reworked, but it is premature to do this
while both approaches are still supported.

ld.so supports two new arguments, --glibc-hwcaps-prepend and
--glibc-hwcaps-mask.  Each accepts a colon-separated list of
glibc-hwcaps subdirectory names.  The prepend option adds additional
subdirectories that are searched first, in the specified order.  The
mask option restricts the automatically selected subdirectories to
those listed in the option argument.  For example, on systems where
/usr/lib64 is on the library search path,
--glibc-hwcaps-prepend=valgrind:debug causes the dynamic loader to
search the directories /usr/lib64/glibc-hwcaps/valgrind and
/usr/lib64/glibc-hwcaps/debug just before /usr/lib64 is searched.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Synchronize <elf.h> section header flags with binutils
Florian Weimer [Thu, 3 Dec 2020 13:10:21 +0000 (14:10 +0100)] 
elf: Synchronize <elf.h> section header flags with binutils

binutils 2.36 will add SHF_GNU_RETAIN support.  SHF_GNU_BUILD_NOTE
was also missing from the glibc header.

3 years agox86: Fix THREAD_SELF definition to avoid ld.so crash (bug 27004)
Jakub Jelinek [Thu, 3 Dec 2020 12:33:44 +0000 (13:33 +0100)] 
x86: Fix THREAD_SELF definition to avoid ld.so crash (bug 27004)

The previous definition of THREAD_SELF did not tell the compiler
that %fs (or %gs) usage is invalid for the !DL_LOOKUP_GSCOPE_LOCK
case in _dl_lookup_symbol_x.  As a result, ld.so could try to use the
TCB before it was initialized.

As the comment in tls.h explains, asm volatile is undesirable here.
Using the __seg_fs (or __seg_gs) namespace does not interfere with
optimization, and expresses that THREAD_SELF is potentially trapping.

3 years agohtl: Add hidden def for __pthread_create/detach
Samuel Thibault [Thu, 3 Dec 2020 11:21:47 +0000 (12:21 +0100)] 
htl: Add hidden def for __pthread_create/detach

to avoid a PLT.

3 years agomanual: Clarify File Access Modes section and add O_PATH
Florian Weimer [Thu, 3 Dec 2020 09:59:50 +0000 (10:59 +0100)] 
manual: Clarify File Access Modes section and add O_PATH

Kees Cook reported that the current text is misleading:

  <https://lore.kernel.org/lkml/202005150847.2B1ED8F81@keescook/>

3 years agohtl: Add missing symbols
Samuel Thibault [Thu, 3 Dec 2020 09:48:27 +0000 (10:48 +0100)] 
htl: Add missing symbols

hurd/hurdsig.c needs to detect whether __pthread_detach and
__pthread_create are available, so they need to be exposed.

3 years agoRevert "linux: Move xmknod{at} to compat symbols"
Adhemerval Zanella [Thu, 22 Oct 2020 18:24:12 +0000 (15:24 -0300)] 
Revert "linux: Move xmknod{at} to compat symbols"

This reverts commit 81b83ff61f95f30ad53d6075247af0ea61a0b16e to move
__xmknod{at} back to default symbols.  ABIs with default symbol version
of 2.33 or newer (such as riscv32) continue to just provide the mknod*
symbols.

The idea is to not force static libraries built against old glibc
to update against new glibcs (since they reference the the
xmknod{at} symbols).

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

3 years agoRevert "linux: Move {f}xstat{at} to compat symbols"
Adhemerval Zanella [Wed, 2 Dec 2020 16:51:57 +0000 (13:51 -0300)] 
Revert "linux: Move {f}xstat{at} to compat symbols"

This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 to move
{f}xstat{at} back to default symbols.  ABIs with default symbol version
of 2.33 or newer (such as riscv32) continue to just provide the stat
symbols.

The idea is to not force static libraries built against old glibc
to update against new glibcs (since they reference the old
{f}xstat{at} symbols).

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

3 years agoelf.h: Fix spelling of EM_TILE64 comment
Florian Weimer [Wed, 2 Dec 2020 12:52:54 +0000 (13:52 +0100)] 
elf.h: Fix spelling of EM_TILE64 comment

Reported-By: Jakub Jelinek <jakub@redhat.com>
3 years agonptl: Fix __futex_clocklock64 return error check [BZ #26964]
Lucas A. M. Magalhaes [Tue, 1 Dec 2020 21:05:07 +0000 (18:05 -0300)] 
nptl: Fix __futex_clocklock64 return error check [BZ #26964]

The earlier implementation of this, __lll_clocklock, calls lll_clockwait
that doesn't return the futex syscall error codes.  It always tries again
if that fails.

However in the current implementation, when the futex returns EAGAIN,
__futex_clocklock64 will also return EGAIN, even if the futex is taken.

This patch fixes the EAGAIN issue and also adds a check for EINTR.  As
futex syscall can return EINTR if the thread is interrupted by a signal.
In this case I'm assuming the function should continue trying to lock as
there is no mention to about it on POSIX.  Also add a test for both
scenarios.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agopowerpc64le: ifunc select *f128 routines in multiarch mode
Paul E. Murphy [Tue, 7 Apr 2020 21:20:55 +0000 (16:20 -0500)] 
powerpc64le: ifunc select *f128 routines in multiarch mode

Programatically generate simple wrappers for interesting libm *f128
objects.  Selected functions are transcendental functions or
those with trivial compiler builtins.  This can result in a 2-3x
speedup (e.g logf128 and expf128).

A second set of implementation files are generated which include
the first implementation encountered along the search path.  This
usually works, except when a wrapper is overriden and makefile
search order slightly diverges from include order.  Likewise,
wrapper object files are created for each generated file.  These
hold the ifunc selection routines which export ABI.

Next, several shared headers are intercepted to control renaming of
asm function redirects are used first, and sometimes macro renames
if the former is impractical.

Notably, if the request machine supports hardware IEEE128 (i.e POWER9
and newer) this ifunc machinery is disabled.  Likewise existing
ifunc support for float128 is consolidated into this (e.g sqrtf128
and fmaf128).

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agoy2038: Convert aio_suspend to support 64 bit time
Lukasz Majewski [Mon, 23 Nov 2020 20:47:20 +0000 (17:47 -0300)] 
y2038: Convert aio_suspend to support 64 bit time

The aio_suspend function has been converted to support 64 bit time.

This change uses (in aio_misc.h):
- __futex_abstimed_wait64 (instead of futex_reltimed_wait)
- __futex_abstimed_wait_cancellable64
(instead of futex_reltimed_wait_cancellable)
    from ./sysdeps/nptl/futex-helpers.h

The aio_suspend() accepts relative timeout, which then is converted to
absolute one.

The i686-gnu port (HURD) do not define DONT_NEED_AIO_MISC_COND and as it
doesn't (yet) support 64 bit time it uses not converted
pthread_cond_timedwait().

The __aio_suspend() is supposed to be run on ports with __TIMESIZE !=64 and
__WORDSIZE==32. It internally utilizes __aio_suspend_time64() and hence the
conversion from 32 bit struct timespec to 64 bit one is required.

For ports supporting 64 bit time the __aio_suspend_time64() will be used
either via alias (to __aio_suspend when __TIMESIZE==64) or redirection
(when -D_TIME_BITS=64 is passed).

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoFix typo in NEWS file
Shuo Wang [Mon, 2 Nov 2020 07:53:13 +0000 (15:53 +0800)] 
Fix typo in NEWS file

3 years agonptl: Add EOVERFLOW checks for futex calls
Adhemerval Zanella [Thu, 26 Nov 2020 13:54:04 +0000 (10:54 -0300)] 
nptl: Add EOVERFLOW checks for futex calls

Some futex-internal calls require additional check for EOVERFLOW (as
indicated by [1] [2] [3]).  For both mutex and rwlock code, EOVERFLOW is
handle as ETIMEDOUT; since it indicate to the caller that the blocking
operation could not be issued.

For mutex it avoids a possible issue where PTHREAD_MUTEX_ROBUST_* might
assume EOVERFLOW indicate futex has succeed, and for PTHREAD_MUTEX_PP_*
it avoid a potential busy infinite loop.  For rwlock and semaphores, it
also avoids potential busy infinite loops.

Checked on x86_64-linux-gnu and i686-linux-gnu, although EOVERFLOW
won't be possible with current usage (since all timeouts on 32-bit
architectures with 32-bit time_t support will be in the range of
32-bit time_t).

[1] https://sourceware.org/pipermail/libc-alpha/2020-November/120079.html
[2] https://sourceware.org/pipermail/libc-alpha/2020-November/120080.html
[3] https://sourceware.org/pipermail/libc-alpha/2020-November/120127.html

3 years agonptl: Fix PTHREAD_PRIO_PROTECT timed lock
Adhemerval Zanella [Wed, 25 Nov 2020 20:15:51 +0000 (17:15 -0300)] 
nptl: Fix PTHREAD_PRIO_PROTECT timed lock

The 878fe624d4 changed lll_futex_timed_wait, which expects a relative
timeout, with a __futex_abstimed_wait64, which expects an absolute
timeout.  However the code still passes a relative timeout.

Also, the PTHREAD_PRIO_PROTECT support for clocks different than
CLOCK_REALTIME was broken since the inclusion of
pthread_mutex_clocklock (9d20e22e46) since lll_futex_timed_wait
always use CLOCK_REALTIME.

This patch fixes by removing the relative time calculation.  It
also adds some xtests that tests both thread and inter-process
usage.

Checked on x86_64-linux-gnu.

3 years agosh: Add sh4 fpu Implies folder
Adhemerval Zanella [Wed, 25 Nov 2020 18:00:44 +0000 (15:00 -0300)] 
sh: Add sh4 fpu Implies folder

The commit 605f38177db (sh: Split BE/LE abilist) did not take in
consideration the SH4 fpu support.

Checked with a build for sh4-linux-gnu and manually checked that
the implementations at sysdeps/sh/sh4/fpu/ are selected.

John Paul Adrian Glaubitz also confirmed it fixes the build issues
he encontered.

3 years agoio: nftw/ftw: Fix stack overflow with large nopenfd [BZ #26353]
Xiaoming Ni [Thu, 26 Nov 2020 16:35:10 +0000 (13:35 -0300)] 
io: nftw/ftw: Fix stack overflow with large nopenfd [BZ #26353]

The nopenfd value is used as argument for the internal buffer on
ftw_statup, which is allocated with alloca and might trigger
a stack overflow for large values.  This patch replaces the memory
allocation to use malloc instead.

Checked on x86_64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Introduce enum opt_format in the ldconfig implementation
Florian Weimer [Thu, 26 Nov 2020 15:59:44 +0000 (16:59 +0100)] 
elf: Introduce enum opt_format in the ldconfig implementation

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agosupport: Add support_copy_file
Florian Weimer [Thu, 26 Nov 2020 15:59:44 +0000 (16:59 +0100)] 
support: Add support_copy_file

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoNEWS entry for commit b4f020c9b408fb3d1d3d4901c4a71839145f8791
Florian Weimer [Wed, 25 Nov 2020 14:51:51 +0000 (15:51 +0100)] 
NEWS entry for commit b4f020c9b408fb3d1d3d4901c4a71839145f8791

3 years agotimezone: Change zdump installation to bin directory
Prasanth R [Wed, 25 Nov 2020 14:51:51 +0000 (15:51 +0100)] 
timezone: Change zdump installation to bin directory

Commit 3bc4186c7a9, tzdata changed the zdump installation
to bin directory, which creates duplicates of zdump in the
Root filesystem.

3 years agonptl: Return EINVAL for invalid clock for pthread_clockjoin_np
Adhemerval Zanella [Mon, 23 Nov 2020 16:47:18 +0000 (13:47 -0300)] 
nptl: Return EINVAL for invalid clock for pthread_clockjoin_np

The align the GNU extension with the others one that accept specify
which clock to wait for (such as pthread_mutex_clocklock).

Check on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Return EINVAL for pthread_mutex_clocklock/PI with CLOCK_MONOTONIC [BZ #26801]
Adhemerval Zanella [Thu, 29 Oct 2020 18:34:31 +0000 (15:34 -0300)] 
nptl: Return EINVAL for pthread_mutex_clocklock/PI with CLOCK_MONOTONIC [BZ #26801]

Linux futex FUTEX_LOCK_PI operation only supports CLOCK_REALTIME,
so pthread_mutex_clocklock operation with priority aware mutexes
may fail depending of the input timeout.

Also, it is not possible to convert a CLOCK_MONOTONIC to a
CLOCK_REALTIME due the possible wall clock time change which might
invalid the requested timeout.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Replace lll_futex_wake with futex-internal.h
Adhemerval Zanella [Mon, 23 Nov 2020 13:38:12 +0000 (10:38 -0300)] 
nptl: Replace lll_futex_wake with futex-internal.h

The idea is to make NPTL implementation to use on the functions
provided by futex-internal.h.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>