]> sourceware.org Git - glibc.git/log
glibc.git
4 years agoy2038: linux: Provide __ntp_gettime64 implementation
Lukasz Majewski [Wed, 22 Apr 2020 08:54:01 +0000 (10:54 +0200)]
y2038: linux: Provide __ntp_gettime64 implementation

This patch provides new __ntp_gettime64 explicit 64 bit function for getting
time parameters via NTP interface.

Internally, the __clock_adjtime64 syscall is used instead of __adjtimex. This
patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - __ntp_gettime has been refactored to internally
use __ntp_gettime64.

The __ntp_gettime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
ntptimeval and 64 bit struct __ntptimeval64.

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

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __ntp_gettime64 and __ntp_gettime.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: Provide conversion helpers for struct __ntptimeval64
Lukasz Majewski [Wed, 22 Apr 2020 22:20:51 +0000 (00:20 +0200)]
y2038: Provide conversion helpers for struct __ntptimeval64

Those functions allow easy conversion between Y2038 safe, glibc internal
struct __ntptimeval64 and struct ntptimeval.

The reserved fields (i.e. __glibc_reserved{1234}) during conversion are
zeroed as well, to provide behavior similar to one in ntp_gettimex function
(where those are cleared before the struct ntptimeval is returned).

Those functions are put in Linux specific sys/timex.h file, as putting
them into glibc's local include/time.h would cause build break on HURD as
it doesn't support struct timex related syscalls.

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: Introduce struct __ntptimeval64 - new internal glibc type
Lukasz Majewski [Tue, 21 Apr 2020 23:01:21 +0000 (01:01 +0200)]
y2038: Introduce struct __ntptimeval64 - new internal glibc type

This type is a glibc's "internal" type to get time parameters data from
Linux kernel (NTP daemon interface). It stores time in struct __timeval64
rather than struct timeval, which makes it Y2038-proof.

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __adjtime64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 18:56:24 +0000 (20:56 +0200)]
y2038: linux: Provide __adjtime64 implementation

This patch provides new __adjtime64 explicit 64 bit function for adjusting
Linux kernel clock.

Internally, the __clock_adjtime64 syscall is used instead of __adjtimex. This
patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - __adjtime has been refactored to internally use
__adjtime64.

The __adjtime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
timeval and 64 bit struct __timeval64.

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

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __adjtime64 and __adjtime.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide ___adjtimex64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 17:29:31 +0000 (19:29 +0200)]
y2038: linux: Provide ___adjtimex64 implementation

This patch provides new ___adjtimex64 explicit 64 bit function for adjusting
Linux kernel clock.

Internally, the __clock_adjtime64 syscall is used. This patch is necessary
for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - ___adjtimex has been refactored to internally
use ___adjtimex64.

The ___adjtimex is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
timex and 64 bit struct __timex64.

Last but not least, in ___adjtimex64 function the __clock_adjtime syscall has
been replaced with __clock_adjtime64 to support 64 bit time on architectures
with __WORDSIZE == 32 and __TIMESIZE != 64.

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

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both ___adjtimex64 and ___adjtimex.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __clock_adjtime64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 17:14:18 +0000 (19:14 +0200)]
y2038: linux: Provide __clock_adjtime64 implementation

This patch replaces auto generated wrapper (as described in
sysdeps/unix/sysv/linux/syscalls.list) for clock_adjtime with one which adds
extra support for reading 64 bit time values on machines with __TIMESIZE != 64.

To achieve this goal new __clock_adjtime64 explicit 64 bit function for
adjusting Linux clock has been added.
Moreover, a 32 bit version - __clock_adjtime has been refactored to internally
use __clock_adjtime64.

The __clock_adjtime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between 64 bit
struct __timespec64 and struct timespec.

The new __clock_adjtime64 syscall available from Linux 5.1+ has been used, when
applicable.
Up till v5.4 in the Linux kernel there was a bug preventing this call from
obtaining correct struct's timex time.tv_sec time after time_t overflow
(i.e. not being Y2038 safe).

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

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

Linux kernel, headers and minimal kernel version for glibc build test matrix:
- Linux v5.1 (with clock_adjtime64) and glibc build with v5.1 as
  minimal kernel version (--enable-kernel="5.1.0")
  The __ASSUME_TIME64_SYSCALLS flag defined.

- Linux v5.1 and default minimal kernel version
  The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports clock_adjtime64
  syscall.

- Linux v4.19 (no clock_adjtime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support clock_adjtime64 syscall, so the fallback to
  clock_adjtime is tested.

Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).

No regressions were observed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoldconfig: Default to the new format for ld.so.cache
Josh Triplett [Tue, 19 May 2020 12:41:48 +0000 (14:41 +0200)]
ldconfig: Default to the new format for ld.so.cache

glibc has supported this format for close to 20 years.

4 years agonss_compat: internal_end*ent may clobber errno, hiding ERANGE [BZ #25976]
Florian Weimer [Tue, 19 May 2020 12:09:38 +0000 (14:09 +0200)]
nss_compat: internal_end*ent may clobber errno, hiding ERANGE [BZ #25976]

During cleanup, before returning from get*_r functions, the end*ent
calls must not change errno.  Otherwise, an ERANGE error from the
underlying implementation can be hidden, causing unexpected lookup
failures.  This commit introduces an internal_end*ent_noerror
function which saves and restore errno, and marks the original
internal_end*ent function as warn_unused_result, so that it is used
only in contexts were errors from it can be handled explicitly.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agopowerpc: Optimized rawmemchr for POWER9
Anton Blanchard [Thu, 14 May 2020 11:49:16 +0000 (21:49 +1000)]
powerpc: Optimized rawmemchr for POWER9

This version uses vector instructions and is up to 60% faster on medium
matches and up to 90% faster on long matches, compared to the POWER7
version. A few examples:

                            __rawmemchr_power9  __rawmemchr_power7
Length   32, alignment  0:   2.27566             3.77765
Length   64, alignment  2:   2.46231             3.51064
Length 1024, alignment  0:  17.3059             32.6678

4 years agox86: Add --enable-cet=permissive
H.J. Lu [Mon, 27 Apr 2020 22:44:07 +0000 (15:44 -0700)]
x86: Add --enable-cet=permissive

When CET is enabled, it is an error to dlopen a non CET enabled shared
library in CET enabled application.  It may be desirable to make CET
permissive, that is disable CET when dlopening a non CET enabled shared
library.  With the new --enable-cet=permissive configure option, CET is
disabled when dlopening a non CET enabled shared library.

Add DEFAULT_DL_X86_CET_CONTROL to config.h.in:

 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_elf_property

which enables CET features based on ELF property note.

--enable-cet=permissive it to

 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_permissive

which enables CET features permissively.

Update tst-cet-legacy-5a, tst-cet-legacy-5b, tst-cet-legacy-6a and
tst-cet-legacy-6b to check --enable-cet and --enable-cet=permissive.

4 years agoRemove NO_CTORS_DTORS_SECTIONS macro
Florian Weimer [Mon, 18 May 2020 12:56:26 +0000 (14:56 +0200)]
Remove NO_CTORS_DTORS_SECTIONS macro

This was originally added to support binutils older than version
2.22:

  <https://sourceware.org/ml/libc-alpha/2010-12/msg00051.html>

Since 2.22 is older than the minimum required binutils version
for building glibc, we no longer need this.  (The changes do
not impact the statically linked startup code.)

4 years agoelf: Assert that objects are relocated before their constructors run
Florian Weimer [Mon, 18 May 2020 13:21:04 +0000 (15:21 +0200)]
elf: Assert that objects are relocated before their constructors run

If we try to run constructors before relocation, this is always
a dynamic linker bug.  An assert is easier to notice than a call
via an invalid function pointer (which may not even produce a valid
call stack).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agopowerpc: Optimized stpcpy for POWER9
Anton Blanchard via Libc-alpha [Wed, 13 May 2020 23:08:35 +0000 (09:08 +1000)]
powerpc: Optimized stpcpy for POWER9

Add stpcpy support to the POWER9 strcpy. This is up to 40% faster on
small strings and up to 90% faster on long relatively unaligned strings,
compared to the POWER8 version. A few examples:

                                        __stpcpy_power9  __stpcpy_power8
Length   20, alignments in bytes  4/ 4:  2.58246          4.8788
Length 1024, alignments in bytes  1/ 6: 24.8186          47.8528

4 years agopowerpc: Optimized strcpy for POWER9
Anton Blanchard via Libc-alpha [Wed, 13 May 2020 23:00:26 +0000 (09:00 +1000)]
powerpc: Optimized strcpy for POWER9

This version uses VSX store vector with length instructions and is
significantly faster on small strings and relatively unaligned large
strings, compared to the POWER8 version. A few examples:

                                        __strcpy_power9  __strcpy_power8
Length   16, alignments in bytes  0/ 0: 2.52454          4.62695
Length  412, alignments in bytes  4/ 0: 11.6             22.9185

4 years agox86: Move CET control to _dl_x86_feature_control [BZ #25887]
H.J. Lu [Tue, 28 Apr 2020 17:05:25 +0000 (10:05 -0700)]
x86: Move CET control to _dl_x86_feature_control [BZ #25887]

1. Include <dl-procruntime.c> to get architecture specific initializer in
rtld_global.
2. Change _dl_x86_feature_1[2] to _dl_x86_feature_1.
3. Add _dl_x86_feature_control after _dl_x86_feature_1, which is a
struct of 2 bitfields for IBT and SHSTK control

This fixes [BZ #25887].

4 years agosunrpc/tst-udp-*: Fix timeout value
Samuel Thibault [Sat, 16 May 2020 17:29:50 +0000 (19:29 +0200)]
sunrpc/tst-udp-*: Fix timeout value

Following on 00c3da43a ('sunrpc/tst-udp-timeout: Fix timeout value').

While e.g. 2.5 timeout can be represented exactly with doubles, time stamps
may not be represented that exactly, and thus with coarse-grain clocks (e.g.
10ms) we may end up with 2.499-ish values due to rounding errors.

* sunrpc/tst-udp-timeout.c (test_udp_server): Add more timeout slack.
* sunrpc/tst-udp-nonblocking.c (do_test): Likewise.

4 years agoLinux: Remove remnants of the getcpu cache
Florian Weimer [Fri, 15 May 2020 09:32:30 +0000 (11:32 +0200)]
Linux: Remove remnants of the getcpu cache

The getcpu cache was removed from the kernel in Linux 2.6.24.  glibc
support from the sched_getcpu implementation was removed in commit
dd26c44403582fdf10d663170f947dfe4b3207a0 ("Consolidate sched_getcpu").

4 years agoUpdate timezone code from tzcode 2020a
Paul Eggert [Fri, 15 May 2020 15:52:25 +0000 (08:52 -0700)]
Update timezone code from tzcode 2020a

This patch updates files coming from tzcode to tzcode 2020a.
This is mostly for better support for Internet RFC 8536, by adding
support to zic for the Expires line (new to tzcode 2020a), the -b
option (new to 2019b) and the -r option (new to 2019a).
One trivial change to other glibc was needed.
* time/tzfile.c (__tzfile_read): Adjust to tzcode private.h renaming.
* timezone/private.h, timezone/tzfile.h, timezone/version:
* timezone/zdump.c, timezone/zic.c: Update from tzcode 2020a.

4 years agoaarch64: fix strcpy and strnlen for big-endian [BZ #25824]
Lexi Shao [Fri, 15 May 2020 10:48:59 +0000 (18:48 +0800)]
aarch64: fix strcpy and strnlen for big-endian [BZ #25824]

This patch fixes the optimized implementation of strcpy and strnlen
on a big-endian arm64 machine.

The optimized method uses neon, which can process 128bit with one
instruction. On a big-endian machine, the bit order should be reversed
for the whole 128-bits double word. But with instuction
rev64 datav.16b, datav.16b
it reverses 64bits in the two halves rather than reversing 128bits.
There is no such instruction as rev128 to reverse the 128bits, but we
can fix this by loading the data registers accordingly.

Fixes 0237b61526e7("aarch64: Optimized implementation of strcpy") and
2911cb68ed3d("aarch64: Optimized implementation of strnlen").

Signed-off-by: Lexi Shao <shaolexi@huawei.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 years agolocale: Add transliteration for Geresh, Gershayim (U+05F3, U+05F4)
Florian Weimer [Fri, 15 May 2020 08:38:10 +0000 (10:38 +0200)]
locale: Add transliteration for Geresh, Gershayim (U+05F3, U+05F4)

ISO-8859-8-based locales will need this transliteration if the locale
files contain these Unicode characters.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agostring: Fix string/tst-memmove-overflow to compile with GCC 7
Florian Weimer [Thu, 14 May 2020 10:12:29 +0000 (12:12 +0200)]
string: Fix string/tst-memmove-overflow to compile with GCC 7

GCC 8 relaxed what kind of expressions can be used in initializers,
and the previous use of static const variables relied on that.  Switch
to wide (non-int) enum constants instead, which is another GCC
extension that is more widely implemented.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd arch-syscall.h dependency for generating sysd-syscalls file
guojinhui [Thu, 14 May 2020 16:09:46 +0000 (18:09 +0200)]
Add arch-syscall.h dependency for generating sysd-syscalls file

After using "make update-syscall-lists" to update arch-syscall.h for
new kernel versions, sysd-syscalls will not be not be regenerated.
This will cause a compile error because the new data is not being
picked up.

Fixes commit a1bd5f86739926469bbe0054b93305ff5905b070
("Linux: Use system call tables during build").

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agoarm: XFAIL string/tst-memmove-overflow due to bug 25620
Florian Weimer [Wed, 13 May 2020 14:45:29 +0000 (16:45 +0200)]
arm: XFAIL string/tst-memmove-overflow due to bug 25620

Also reduce the amount of output in case of a large-scale mismatch in
the copied data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Remove redundant add_to_global_resize_failure call from dl_open_args
Florian Weimer [Tue, 12 May 2020 17:06:18 +0000 (19:06 +0200)]
elf: Remove redundant add_to_global_resize_failure  call from dl_open_args

The second call does not do anything because the data structures have
already been resized by the call that comes before the demarcation
point.  Fixes commit a509eb117fac1d764b15eba64993f4bdb63d7f3c
("Avoid late dlopen failure due to scope, TLS slotinfo updates
[BZ #25112]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agostring: Add string/tst-memmove-overflow, a test case for bug 25620
Florian Weimer [Tue, 12 May 2020 17:02:08 +0000 (19:02 +0200)]
string: Add string/tst-memmove-overflow, a test case for bug 25620

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agosupport: Add support_blob_repeat_allocate_shared
Florian Weimer [Tue, 12 May 2020 17:01:49 +0000 (19:01 +0200)]
support: Add support_blob_repeat_allocate_shared

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: wait for pending setxid request also in detached thread (bug 25942)
Andreas Schwab [Thu, 7 May 2020 13:50:09 +0000 (15:50 +0200)]
nptl: wait for pending setxid request also in detached thread (bug 25942)

There is a race between __nptl_setxid and exiting detached thread, which
causes a deadlock on stack_cache_lock.  The deadlock happens in this
state:

T1: setgroups -> __nptl_setxid (holding stack_cache_lock, waiting on cmdp->cntr == 0)
T2 (detached, exiting): start_thread -> __deallocate_stack (waiting on stack_cache_lock)
more threads waiting on stack_cache_lock in pthread_create

For non-detached threads, start_thread waits for its own setxid handler to
finish before exiting.  Do this for detached threads as well.

4 years agoaarch64: Accept PLT calls to __getauxval within libc.so
Florian Weimer [Tue, 12 May 2020 09:30:30 +0000 (11:30 +0200)]
aarch64: Accept PLT calls to __getauxval within libc.so

When using outline atomics (-moutline-atomics, the default for ARMv8-A
starting with GCC 10), libgcc contains an ELF constructor which calls
__getauxval.  This code is built outside of glibc, so none of its
internal PLT avoidance schemes can be applied to it.  This change
suppresses the elf/check-localplt failure.

4 years agoUse unsigned constants for ICMP6 filters [BZ #22489]
Sergey [Fri, 24 Apr 2020 21:18:41 +0000 (17:18 -0400)]
Use unsigned constants for ICMP6 filters [BZ #22489]

The core problem here is that the filter array elements are unsigned
but the computed constants are signed.  This both causes a
signededness conversion at the &= step and may cause undefined
behavior if the MSB is being modified.  This patch uses unsigned
constants to avoid both cases. - DJ

4 years agoLinux: Enhance glibcsyscalls.py to support listing system calls
Florian Weimer [Mon, 11 May 2020 20:23:34 +0000 (22:23 +0200)]
Linux: Enhance glibcsyscalls.py to support listing system calls

The script can now be called to query the definition status of
system call numbers across all architectures, like this:

$ python3 sysdeps/unix/sysv/linux/glibcsyscalls.py query-syscall sync_file_range sync_file_range2
sync_file_range:
  defined: aarch64 alpha csky hppa i386 ia64 m68k microblaze mips/mips32 mips/mips64/n32 mips/mips64/n64 nios2 riscv/rv64 s390/s390-32 s390/s390-64 sh sparc/sparc32 sparc/sparc64 x86_64/64 x86_64/x32
  undefined: arm powerpc/powerpc32 powerpc/powerpc64
sync_file_range2:
  defined: arm powerpc/powerpc32 powerpc/powerpc64
  undefined: aarch64 alpha csky hppa i386 ia64 m68k microblaze mips/mips32 mips/mips64/n32 mips/mips64/n64 nios2 riscv/rv64 s390/s390-32 s390/s390-64 sh sparc/sparc32 sparc/sparc64 x86_64/64 x86_64/x32

This command lists the headers containing the system call numbers:

$ python3 sysdeps/unix/sysv/linux/glibcsyscalls.py list-headers

The argument parser code is based on a suggestion from Adhemerval Zanella.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoSuppress GCC 10 true positive warnings [BZ #25967]
Martin Sebor [Mon, 11 May 2020 17:29:39 +0000 (11:29 -0600)]
Suppress GCC 10 true positive warnings [BZ #25967]

Suppress or avoid warnings in tests that exercise failure modes by making
calls with invalid arguments.

Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
4 years agoPOWER: Add context-synchronizing instructions to pkey_write [BZ #25954]
Florian Weimer [Mon, 11 May 2020 09:20:02 +0000 (11:20 +0200)]
POWER: Add context-synchronizing instructions to pkey_write [BZ #25954]

Sandipan Das reported that,

"The Power ISA mandates that all writes to the Authority
Mask Register (AMR) must always be preceded as well as
succeeded by a context-synchronizing instruction. This
applies to both the privileged and unprivileged variants
of the Move To AMR instruction.

This [requirement] is from Table 6 of Chapter 11 in page 1134 of Power
ISA 3.0B. The document can be found here:
<https://ibm.ent.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv>
"

See this kernel patch submission:

<https://lore.kernel.org/linuxppc-dev/5f65cf37be993760de8112a88da194e3ccbb2bf8.1588959697.git.sandipan@linux.ibm.com/>

4 years agohurd: Add missing sigstate members initialization
Samuel Thibault [Sun, 10 May 2020 23:30:29 +0000 (01:30 +0200)]
hurd: Add missing sigstate members initialization

* hurd/hurdsig.c (_hurd_thread_sigstate): Initialize
  critical_section_lock, active_resources, cancel, and cancel_hook fields.

4 years agox86-64: Use RDX_LP on __x86_shared_non_temporal_threshold [BZ #25966]
H.J. Lu [Sat, 9 May 2020 19:04:23 +0000 (12:04 -0700)]
x86-64: Use RDX_LP on __x86_shared_non_temporal_threshold [BZ #25966]

Since __x86_shared_non_temporal_threshold is defined as

long int __x86_shared_non_temporal_threshold;

and long int is 4 bytes for x32, use RDX_LP to compare against
__x86_shared_non_temporal_threshold in assembly code.

4 years agolinux: Remove assembly umount2 implementation
Adhemerval Zanella [Fri, 8 May 2020 12:30:18 +0000 (09:30 -0300)]
linux: Remove assembly umount2 implementation

Only alpha and ia64 do not support __NR_umount2 (defined as
__NR_umount), but recent kernel fixes (74cd2184833f for ia64, and
12b57c5c70f39 for alpha) add the required alias.

Checked with a build against all affected ABIs.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agosignal: Use <sigsetops.h> for sigemptyset, sigfillset
Florian Weimer [Fri, 8 May 2020 15:29:10 +0000 (17:29 +0200)]
signal: Use <sigsetops.h> for sigemptyset, sigfillset

This avoids changing the entire sigset_t structure.  Updating the
actually used part is sufficient.

4 years agockb_IQ, or_IN locales: Add missing reorder-end keywords
Florian Weimer [Fri, 8 May 2020 08:51:32 +0000 (10:51 +0200)]
ckb_IQ, or_IN locales: Add missing reorder-end keywords

This suppresses a non-fatal error during locale building.

Reviewed-by: Rafał Lużyński <digitalfreak@lingonborough.com>
4 years agosemaphore: consolidate arch headers into a generic one
Vineet Gupta [Tue, 5 May 2020 19:53:41 +0000 (12:53 -0700)]
semaphore: consolidate arch headers into a generic one

This consolidates the copy-pasted arch specific semaphore header into
single version (based on s390) which suffices 32-bit and and 64-bit
arch/ABI based on the canonical WORDSIZE.

For now I've left out arches which use alternate defines to choose for
32 vs 64-bit builds (aarch64, mips) which in theory can also use the same
header.

Passes build-many for
  aarch64-linux-gnu arm-linux-gnueabi arm-linux-gnueabihf
  riscv64-linux-gnu-rv64imac-lp64 riscv64-linux-gnu-rv64imafdc-lp64
  x86_64-linux-gnu microblaze-linux-gnu nios2-linux-gnu

Suggested-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC 10 branch in build-many-glibcs.py.
Joseph Myers [Wed, 6 May 2020 15:41:55 +0000 (15:41 +0000)]
Use GCC 10 branch in build-many-glibcs.py.

This updates the default GCC version used in build-many-glibcs.py when
no version is specified explicitly.  I'm replacing my bot using GCC 8
with one using GCC 10 (leaving the GCC 9 and GCC mainline bots running
as at present).

4 years agoDocument the internal _ and N_ macros
Florian Weimer [Wed, 6 May 2020 15:35:21 +0000 (17:35 +0200)]
Document the internal _ and N_ macros

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoy2038: Provide conversion helpers for struct __timex64
Lukasz Majewski [Tue, 21 Apr 2020 17:12:17 +0000 (19:12 +0200)]
y2038: Provide conversion helpers for struct __timex64

Those functions allow easy conversion between Y2038 safe, glibc internal
struct __timex64 and struct timex.

Those functions are put in Linux specific sys/timex.h file, as putting
them into glibc's local include/time.h would cause build break on HURD as
it doesn't support struct timex related syscalls.

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>
4 years agoy2038: Introduce struct __timex64 - new internal glibc type
Lukasz Majewski [Tue, 21 Apr 2020 17:08:33 +0000 (19:08 +0200)]
y2038: Introduce struct __timex64 - new internal glibc type

The introduced glibc's 'internal' struct __timex64 is a copy of Linux kernel's
struct __kernel_timex (v5.6) introduced for properly handling data for
clock_adjtime64 syscall.
As the struct's __kernel_timex size is the same as for archs with
__WORDSIZE == 64, proper padding and data types conversion (i.e. long to long
long) had to be added for architectures with __WORDSIZE == 32 &&
__TIMESIZE != 64.

Moreover, it stores time in struct __timeval64 rather than struct
timeval, which makes it Y2038-proof.

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>
4 years agoy2038: include: Move struct __timeval64 definition to a separate file
Lukasz Majewski [Tue, 21 Apr 2020 17:01:56 +0000 (19:01 +0200)]
y2038: include: Move struct __timeval64 definition to a separate file

The struct __timeval64's definition has been moved from ./include/time.h to
./include/struct___timeval64.h.

This change would prevent from polluting other glibc namespaces (when
headers are modified to support 64 bit time on architectures with
__WORDSIZE==32).

Now it is possible to just include definition of this particular structure
when needed.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: nscd: Modify nscd_helper to use __clock_gettime64
Lukasz Majewski [Mon, 16 Mar 2020 12:50:23 +0000 (13:50 +0100)]
y2038: nscd: Modify nscd_helper to use __clock_gettime64

The nscd/nscd_helper.c uses __clock_gettime to get current time and on this
basis calculate the relative timeout for poll.
By using __clock_gettime64 on systems with __WORDSIZE == 32 && __TIMESIZE != 64
the timeout is correctly calculated after time_t overflow.

4 years agoy2038: inet: Convert inet deadline to support 64 bit time
Lukasz Majewski [Mon, 16 Mar 2020 09:09:13 +0000 (10:09 +0100)]
y2038: inet: Convert inet deadline to support 64 bit time

This change brings 64 bit time support to inet deadline related code for
architectures with __WORDSIZE == 32 && __TIMESIZE != 64.

It is also safe to replace struct timespec with struct __timespec64 in
deadline related structures as:

- The __deadline_to_ms () returns the number of miliseconds to deadline to
  be used with __poll (and hence it is a relative value).
- To calculate the deadline from timeval (which will be converted latter)
  the uintmax_t type is used (unsinged long long int).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: hurd: Provide __clock_gettime64 function
Lukasz Majewski [Thu, 16 Jan 2020 13:27:27 +0000 (14:27 +0100)]
y2038: hurd: Provide __clock_gettime64 function

For Linux glibc ports the __TIMESIZE == 64 ensures proper aliasing for
__clock_gettime64 (to __clock_gettime).
When __TIMESIZE != 64 (like ARM32, PPC) the glibc expects separate definition
of the __clock_gettime64.

The HURD port only provides __clock_gettime, so this patch adds
__clock_gettime64 as a tiny wrapper on it.
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
4 years agoy2038: Export __clock_gettime64 to be usable in other libraries
Lukasz Majewski [Tue, 24 Mar 2020 07:52:15 +0000 (08:52 +0100)]
y2038: Export __clock_gettime64 to be usable in other libraries

In the glibc project calls to clock_gettime shall be replaced with
__clock_gettime64, which is supporting 64 bit time.
To allow that the __clock_gettime64 needs to be exported as a GLIBC_PRIVATE
symbol.

4 years agomanual: Document the O_NOFOLLOW open flag
Florian Weimer [Tue, 5 May 2020 07:23:53 +0000 (09:23 +0200)]
manual: Document the O_NOFOLLOW open flag

4 years agopowerpc64le/power9: guard power9 strcmp against rtld usage [BZ# 25905]
Paul E. Murphy [Fri, 1 May 2020 19:30:42 +0000 (14:30 -0500)]
powerpc64le/power9: guard power9 strcmp against rtld usage [BZ# 25905]

strcmp is used while resolving PLT references.  Vector registers
should not be used during this.  The P9 strcmp makes heavy use of
vector registers, so it should be avoided in rtld.

This prevents quiet vector register corruption when glibc is configured
with --disable-multi-arch and --with-cpu=power9.  This can be seen with
test-float64x-compat_totalordermag during the first call into
totalordermagf64x@GLIBC_2.27.

Add a guard to fallback to the power8 implementation when building
power9 strcmp for libraries other than libc.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agofloat128: use builtin_signbitf128 always
Paul E. Murphy [Tue, 7 Apr 2020 21:20:35 +0000 (16:20 -0500)]
float128: use builtin_signbitf128 always

The minimum GCC version has been raised to 6.2 for building
glibc.  Therefore, follow the advice inside the implementation
and remove the GCC < 6 codepath.

Likewise, remove the hidden_proto as all internal usages should
inline now.

4 years agoimprove out-of-bounds checking with GCC 10 attribute access [BZ #25219]
Martin Sebor [Mon, 4 May 2020 17:21:50 +0000 (11:21 -0600)]
improve out-of-bounds checking with GCC 10 attribute access [BZ #25219]

Adds the access attribute newly introduced in GCC 10 to the subset of
function declarations that are already covered by _FORTIFY_SOURCE and
that don't have corresponding GCC built-in equivalents.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agonios2: delete sysdeps/unix/sysv/linux/nios2/kernel-features.h
Chung-Lin Tang [Mon, 4 May 2020 12:23:25 +0000 (20:23 +0800)]
nios2: delete sysdeps/unix/sysv/linux/nios2/kernel-features.h

Commit 06436acf819d9e6ada7be3ca977d5c0a23d3f138 created a kernel-features.h
file with '#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64', which is wrong for Nios II.
Deleting the header.

4 years agopowerpc: Rename argN to _argN in LOADARGS_N [BZ #25902]
H.J. Lu [Thu, 30 Apr 2020 22:49:47 +0000 (15:49 -0700)]
powerpc: Rename argN to _argN in LOADARGS_N [BZ #25902]

LOADARGS_N in powerpc/sysdep.h uses argN as local variables.  It breaks
when argN is also a function argument.  Rename argN to _argN to avoid
conflict.

4 years agolocale/tst-localedef-path-norm: Don't create $(complocaledir)
Carlos O'Donell [Tue, 28 Apr 2020 19:46:00 +0000 (15:46 -0400)]
locale/tst-localedef-path-norm: Don't create $(complocaledir)

We automatically create $(complocaledir) in the testroot.root
now and so we don't need to create it in the test.

Tested on x86_64.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agosupport: Set errno before testing it.
Carlos O'Donell [Wed, 29 Apr 2020 20:31:29 +0000 (16:31 -0400)]
support: Set errno before testing it.

In test-conainer we should set errno to 0 before calling strtol,
and check after with TEST_COMPARE.

In tst-support_capture_subprocess we should set errno to 0 before
checking it after the call to strtol.

Tested on x86_64.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agolocaledef: Add tests-container test for --no-hard-links.
Carlos O'Donell [Tue, 25 Feb 2020 15:15:30 +0000 (10:15 -0500)]
localedef: Add tests-container test for --no-hard-links.

The new tst-localedef-hardlinks verifies that when compiling
two locales (with default output directory) one with
--no-hard-links and one without the option, results in the
expected behaviour.  When --no-hard-links is used the link
counts on LC_CTYPE is 1, indicating that even thoug the two
locale are identical (though different named source files and
output direcotry) the localedef did not carry out the hard
link optimization.  Then when --no-hard-links is omitted the
localedef hard link optimization is correctly carried out and
for 2 compiled locales the link count for LC_CTYPE is 2.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agotest-container: Support $(complocaledir) and mkdirp.
Carlos O'Donell [Thu, 23 Jan 2020 14:45:00 +0000 (09:45 -0500)]
test-container: Support $(complocaledir) and mkdirp.

Expand the support infrastructure:
- Create $(complocaledir) in the testroot.pristine to support localedef.
- Add the variable $complocaledir to script support.
- Add the script command 'mkdirp'.

All localedef tests which run with default paths need to have the
$(complocaledir) created in testroot.pristine. The localedef binary
will not by itself create the default path, but it will write into
the path. By adding this we can simplify the localedef tests.

The variable $complocaledir is the value of the configured
$(complocaledir) which is the location of the compiled locales that
will be searched by the runtime by default.

The command mkdirp will be available in script setup and will
be equivalent to running `mkdir -p`.

The variable and command can be used to write more complex tests.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agoi386: Remove unused variable in sysdeps/x86/cacheinfo.c
Florian Weimer [Thu, 30 Apr 2020 19:12:23 +0000 (21:12 +0200)]
i386: Remove unused variable in sysdeps/x86/cacheinfo.c

Commit a98dc92dd1e278df4c501deb07985018bc2b06de ("x86: Add cache
information support for Zhaoxin processors") introduced an unused
variable warning in the default i686-linux-gnu build:

In file included from ../sysdeps/i386/cacheinfo.c:3:
../sysdeps/x86/cacheinfo.c: In function 'init_cacheinfo':
../sysdeps/x86/cacheinfo.c:762:16: error: unused variable 'eax' [-Werror=unused-variable]
  762 |   unsigned int eax;
      |                ^~~

4 years agoAdd a C wrapper for prctl [BZ #25896]
H.J. Lu [Thu, 30 Apr 2020 17:42:43 +0000 (10:42 -0700)]
Add a C wrapper for prctl [BZ #25896]

Add a C wrapper to pass arguments in

/* Control process execution.  */
extern int prctl (int __option, ...) __THROW;

to prctl syscall:

extern int prctl (int, unsigned long int, unsigned long int,
  unsigned long int, unsigned long int);

4 years agopowerpc64le: Enable support for IEEE long double
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:28 +0000 (11:48 -0300)]
powerpc64le: Enable support for IEEE long double

On platforms where long double may have two different formats, i.e.: the
same format as double (64-bits) or something else (128-bits), building
with -mlong-double-128 is the default and function calls in the user
program match the name of the function in Glibc.  When building with
-mlong-double-64, Glibc installed headers redirect such calls to the
appropriate function.

Likewise, the internals of glibc are now built against IEEE long double.
However, the only (minimally) notable usage of long double is difftime.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: blacklist broken GCC compilers (e.g GCC 7.5.0)
Paul E. Murphy [Tue, 17 Mar 2020 13:38:54 +0000 (08:38 -0500)]
powerpc64le: blacklist broken GCC compilers (e.g GCC 7.5.0)

GCC 7.5.0 (PR94200) will refuse to compile if both -mabi=% and
-mlong-double-128 are passed on the command line.  Surprisingly,
it will work happily if the latter is not.  For the sake of
maintaining status quo, test for and blacklist such compilers.

Tested with a GCC 8.3.1 and GCC 7.5.0 compiler for ppc64le.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: bump binutils version requirement to >= 2.26
Paul E. Murphy [Thu, 5 Mar 2020 15:32:08 +0000 (09:32 -0600)]
powerpc64le: bump binutils version requirement to >= 2.26

This is a small step up from 2.25 which brings in support for
rewriting the .gnu.attributes section of libc/libm.so.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: raise GCC requirement to 7.4 for long double transition
Paul E. Murphy [Fri, 7 Feb 2020 20:08:23 +0000 (14:08 -0600)]
powerpc64le: raise GCC requirement to 7.4 for long double transition

Add compiler feature tests to ensure we can build ieee128 long double.
These test for -mabi=ieeelongdouble, -mno-gnu-attribute, and -Wno-psabi.

Likewise, verify some compiler bugs have been addressed.  These aren't
helpful for building glibc, but may cause test failures when testing
the new long double.  See notes below from Raji.

On powerpc64le, some older compiler versions give error for the function
signbit() for 128-bit floating point types.  This is fixed by PR83862
in gcc 8.0 and backported to gcc6 and gcc7.  This patch adds a test
to check compiler version to avoid compiler errors during make check.

Likewise, test for -mno-gnu-attribute support which was

On powerpc64le, a few files are built on IEEE long double mode
(-mabi=ieeelongdouble), whereas most are built on IBM long double mode
(-mabi=ibmlongdouble, the default for -mlong-double-128).  Since binutils
2.31, linking object files with different long double modes causes
errors similar to:

  ld: libc_pic.a(s_isinfl.os) uses IBM long double,
      libc_pic.a(ieee128-qefgcvt.os) uses IEEE long double.
  collect2: error: ld returned 1 exit status
  make[2]: *** [../Makerules:649: libc_pic.os] Error 1

The warnings are fair and correct, but in order for glibc to have
support for both long double modes on powerpc64le, they have to be
ignored.  This can be accomplished with the use of -mno-gnu-attribute
option when building the few files that require IEEE long double mode.

However, -mno-gnu-attribute is not available in GCC 6, the minimum
version required to build glibc, so this patch adds a test for this
feature in powerpc64le builds, and fails early if it's not available.

Co-Authored-By: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Co-Authored-By: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoRename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI
Paul E. Murphy [Fri, 14 Feb 2020 22:41:11 +0000 (16:41 -0600)]
Rename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI

Improve the commentary to aid future developers who will stumble
upon this novel, yet not always perfect, mechanism to support
alternative formats for long double.

Likewise, rename __LONG_DOUBLE_USES_FLOAT128 to
__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI now that development work
has settled down.  The command used was

git grep -l __LONG_DOUBLE_USES_FLOAT128 ':!./ChangeLog*' | \
  xargs sed -i 's/__LONG_DOUBLE_USES_FLOAT128/__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI/g'

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoldbl-128ibm-compat: workaround GCC 9 C++ PR90731
Paul E. Murphy [Fri, 6 Mar 2020 15:41:03 +0000 (09:41 -0600)]
ldbl-128ibm-compat: workaround GCC 9 C++ PR90731

GCC 9 has a bug (PR90731) whereby __typeof does not correctly copy
exception specifiers[1].  Surprisingly, this can be quieted by declaring
"#pragma system_header", or if the headers are installed in a system
directory.

Work around this by using the pragma for any gcc version between
9.0 and 9.2 to ensure tests continue to compile.

[1] Example error from g++ 9.2.1:

In file included from ../include/sys/cdefs.h:3,
                 from ../include/features.h:465,
                 from ../bits/libc-header-start.h:33,
                 from ../math/math.h:27,
                 from ../include/math.h:7,
                 from test-math-isinff.cc:21:
../libio/bits/stdio-ldbl.h:25:20: error: declaration of ‘int sprintf(char*, const char*, ...)’ has a different exception specifier
   25 | __LDBL_REDIR_DECL (sprintf)
      |                    ^~~~~~~
../misc/sys/cdefs.h:461:26: note: in definition of macro ‘__LDBL_REDIR_DECL’
  461 |   extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
      |                          ^~~~
In file included from ../include/stdio.h:5,
                 from test-math-isinff.cc:22:
../libio/stdio.h:334:12: note: from previous declaration ‘int sprintf(char*, const char*, ...) throw ()’
  334 | extern int sprintf (char *__restrict __s,
      |            ^~~~~~~

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agox86: Add the test case of __get_cpu_features support for Zhaoxin processors
mayshao-oc [Sun, 26 Apr 2020 05:49:44 +0000 (13:49 +0800)]
x86: Add the test case of __get_cpu_features support for Zhaoxin processors

For the test case of the __get_cpu_features interface, add an item in
cpu_kinds and a switch case for Zhaoxin support.

4 years agox86: Add cache information support for Zhaoxin processors
mayshao-oc [Sun, 26 Apr 2020 05:48:27 +0000 (13:48 +0800)]
x86: Add cache information support for Zhaoxin processors

To obtain Zhaoxin CPU cache information, add a new function
handle_zhaoxin().

Add a new function get_common_cache_info() that extracts the code
in init_cacheinfo() to get the value of the variable shared, threads.

Add Zhaoxin branch in init_cacheinfo() for initializing variables,
such as __x86_shared_cache_size.

4 years agox86: Add CPU Vendor ID detection support for Zhaoxin processors
mayshao [Fri, 24 Apr 2020 04:55:38 +0000 (12:55 +0800)]
x86: Add CPU Vendor ID detection support for Zhaoxin processors

To recognize Zhaoxin CPU Vendor ID, add a new architecture type
arch_kind_zhaoxin for Vendor Zhaoxin detection.

4 years agoUpdate translations
Siddhesh Poyarekar [Thu, 30 Apr 2020 01:57:51 +0000 (07:27 +0530)]
Update translations

Incorporate updates from translationproject.org.

4 years agoAdd C wrappers for process_vm_readv/process_vm_writev [BZ #25810]
H.J. Lu [Wed, 29 Apr 2020 20:20:27 +0000 (13:20 -0700)]
Add C wrappers for process_vm_readv/process_vm_writev [BZ #25810]

Since the the U marker can only be applied to 2 unsigned long arguments
in syscalls.list files, add a C wrapper for process_vm_readv and
process_vm_writev syscals which have more than 2 unsigned long arguments.

4 years agogeneric/typesizes.h: Add support for 32-bit arches with 64-bit types
Alistair Francis [Fri, 14 Feb 2020 19:02:29 +0000 (11:02 -0800)]
generic/typesizes.h: Add support for 32-bit arches with 64-bit types

Update the default typesizes.h to match the new kernel sizes for 32-bit
architectures with a 64-bit time_t and friends. This follows the sizes
used for RV32 which is a y2038 safe architecture added after Linux 5.1.

Reviewed-by: Vineet Gupta <vgupta@synopsys.com>
Tested-by: Vineet Gupta <vgupta@synopsys.com>
4 years agosemctl: Remove the sem-pad.h file
Alistair Francis [Tue, 25 Feb 2020 23:52:59 +0000 (15:52 -0800)]
semctl: Remove the sem-pad.h file

Remove the sem-pad.h file and instead have architectures override the
struct semid_ds via the bits/types/struct_semid_ds.h file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agobits/sem.h: Split out struct semid_ds
Alistair Francis [Tue, 25 Feb 2020 22:52:27 +0000 (14:52 -0800)]
bits/sem.h: Split out struct semid_ds

Split out the struct semid_ds into it's own file. This will allow us to
have architectures specify their own version.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoMark unsigned long arguments with U in more syscalls [BZ #25810]
H.J. Lu [Wed, 29 Apr 2020 15:08:40 +0000 (08:08 -0700)]
Mark unsigned long arguments with U in more syscalls [BZ #25810]

Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U in
syscalls.list files.

4 years agoelf: Add initial flag argument to __libc_early_init
Florian Weimer [Wed, 29 Apr 2020 13:44:03 +0000 (15:44 +0200)]
elf: Add initial flag argument to __libc_early_init

The rseq initialization should happen only for the libc in the base
namespace (in the dynamic case) or the statically linked libc.  The
__libc_multiple_libcs flag does not quite cover this case at present,
so this commit introduces a flag argument to __libc_early_init,
indicating whether the libc being libc is the primary one (of the main
program).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd SYSCALL_ULONG_ARG_[12] to pass long to syscall [BZ #25810]
H.J. Lu [Wed, 29 Apr 2020 12:35:34 +0000 (05:35 -0700)]
Add SYSCALL_ULONG_ARG_[12] to pass long to syscall [BZ #25810]

X32 has 32-bit long and pointer with 64-bit off_t.  Since x32 psABI
requires that pointers passed in registers must be zero-extended to
64bit, x32 can share many syscall interfaces with LP64.  When a LP64
syscall with long and unsigned long int arguments is used for x32, these
arguments must be properly extended to 64-bit.  Otherwise if the upper
32 bits of the register have undefined value, such a syscall will be
rejected by kernel.

For syscalls implemented in assembly codes, 'U' is added to syscall
signature key letters for unsigned long, which is zero-extended to
64-bit types.  SYSCALL_ULONG_ARG_1 and SYSCALL_ULONG_ARG_2 are passed
to syscall-template.S for the first and the second unsigned long int
arguments if PSEUDOS_HAVE_ULONG_INDICES is defined.  They are used by
x32 to zero-extend 32-bit arguments to 64 bits.

Tested on i386, x86-64 and x32 as well as with build-many-glibcs.py.

4 years agoMakeconfig: Use $(error ...) to output error message
Simon Marchi [Wed, 29 Apr 2020 09:24:41 +0000 (11:24 +0200)]
Makeconfig: Use $(error ...) to output error message

Being not familiar with the glibc repository, I typed "make" inside some
subdirectory that has a Makefile, and was met with:

    $ make
    ../Makeconfig:42: *** missing separator.  Stop.

At Makeconfig:42, we have:

    objdir must be defined by the build-directory Makefile.

Change that to use $(error ...), which I guess was the original
intention.  The result is:

    $ make
    ../Makeconfig:42: *** objdir must be defined by the build-directory Makefile.  Stop.

4 years agomanual: Fix typos in the fexecve description
Florian Weimer [Wed, 29 Apr 2020 08:15:51 +0000 (10:15 +0200)]
manual: Fix typos in the fexecve description

Reported by Michael Kerrisk.

4 years agomisc: Remove sstk from the autogenerated system call list
Florian Weimer [Tue, 28 Apr 2020 10:10:32 +0000 (12:10 +0200)]
misc: Remove sstk from the autogenerated system call list

This change should not have an effect because the system call was
never defined.  Also add the misssing attribute_compat_text_section
attribute to the sstk function (a minor optimization).  Also update the
NEWS file to document the change.

Fixes commit 9cc93ba0973ad04ee26c515a1552afb85e73c6ba
("misc: Turn sstk into a compat symbol").

4 years agoRemove unused floating-point configuration from gmp-impl.h.
Joseph Myers [Tue, 28 Apr 2020 15:05:09 +0000 (15:05 +0000)]
Remove unused floating-point configuration from gmp-impl.h.

This patch removes the IEEE_DOUBLE_BIG_ENDIAN and
IEEE_DOUBLE_MIXED_ENDIAN macros from gmp-impl.h and gmp-mparam.h, and
the ieee_double_extract union from gmp-impl.h.  The macros were used
only in defining the union, which was used nowhere in glibc.  As GMP's
gmp-impl.h is over 5000 lines, the file in glibc is so far from the
GMP version that it doesn't seem to make sense to keep things there
that are not relevant in glibc.  (I expect there is plenty more in the
header after this patch that is also not relevant in glibc and can be
cleaned up later.)

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

4 years agosupport: Implement <support/xthread.h> key create/delete
Mathieu Desnoyers [Mon, 27 Apr 2020 19:40:24 +0000 (21:40 +0200)]
support: Implement <support/xthread.h> key create/delete

Expose xpthread_key_create and xpthread_key_delete wrappers
for tests.

4 years agonptl/tst-setuid1-static: Improve isolation from system objects
Florian Weimer [Mon, 27 Apr 2020 13:00:14 +0000 (15:00 +0200)]
nptl/tst-setuid1-static: Improve isolation from system objects

Static dlopen needs an LD_LIBRARY_PATH setting to avoid loading system
libraries.

4 years agoIncrease the timeout of locale/tst-localedef-path-norm
Szabolcs Nagy [Mon, 27 Apr 2020 11:24:14 +0000 (12:24 +0100)]
Increase the timeout of locale/tst-localedef-path-norm

On the current AArch64 buildbot the default 20s timeout is not
enough to run this test, it seems

 make test t=locale/tst-localedef-path-norm

takes about 25s, so i increased the timeout to 30s.

4 years agoUse 2020 as copyright year.
Carlos O'Donell [Mon, 27 Apr 2020 14:31:02 +0000 (10:31 -0400)]
Use 2020 as copyright year.

Use the year 2020 for files added by commit:
92954ffa5a5662fbfde14febd7e5dcc358c85470

4 years agomisc: Turn sstk into a compat symbol
Florian Weimer [Mon, 27 Apr 2020 10:04:23 +0000 (12:04 +0200)]
misc: Turn sstk into a compat symbol

It is not implemented anywhere.  There is an osf_sstk system call on
alpha, but it is not used to implement sstk, and the system call
is not implemented on Linux, either.

4 years agomanual: Document the fexecve function
Florian Weimer [Mon, 27 Apr 2020 09:38:28 +0000 (11:38 +0200)]
manual: Document the fexecve function

4 years agonptl: Start new threads with all signals blocked [BZ #25098]
Florian Weimer [Mon, 27 Apr 2020 07:55:10 +0000 (09:55 +0200)]
nptl: Start new threads with all signals blocked [BZ #25098]

New threads inherit the signal mask from the current thread.  This
means that signal handlers can run on the newly created thread
immediately after the kernel has created the userspace thread, even
before glibc has initialized the TCB.  Consequently, new threads can
observe uninitialized ctype data, among other things.

To address this, block all signals before starting the thread, and
pass the original signal mask to the start routine wrapper.  On the
new thread, first perform all thread initialization, and then unblock
signals.

The cost of doing this is two rt_sigprocmask system calls on the old
thread, and one rt_sigprocmask system call on the new thread.  (If
there was a way to clone a new thread with a signals disabled, this
could be brought down to one system call each.)  The thread descriptor
increases in size, too, and sigset_t is fairly large.  This increase
could be brought down by reusing space the in the descriptor which is
not needed before running user code, or by switching to an internal
sigset_t definition which only covers the signals supported by the
kernel definition.  (Part of the thread descriptor size increase is
already offset by reduced stack usage in the thread start wrapper
routine after this commit.)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agolocaledef: Add verbose messages for failure paths.
Carlos O'Donell [Wed, 8 Jan 2020 18:24:42 +0000 (13:24 -0500)]
localedef: Add verbose messages for failure paths.

During testing of localedef running in a minimal container
there were several error cases which were hard to diagnose
since they appeared as strerror (errno) values printed by the
higher level functions.  This change adds three new verbose
messages for potential failure paths.  The new messages give
the user the opportunity to use -v and display additional
information about why localedef might be failing.  I found
these messages useful myself while writing a localedef
container test for --no-hard-links.

Since the changes cleanup the code that handle codeset
normalization we add tst-localedef-path-norm which contains
many sub-tests to verify the correct expected normalization of
codeset strings both when installing to default paths (the
only time normalization is enabled) and installing to absolute
paths.  During the refactoring I created at least one
buffer-overflow which valgrind caught, but these tests did not
catch because the exec in the container had a very clean heap
with zero-initialized memory. However, between valgrind and
the tests the results are clean.

The new tst-localedef-path-norm passes without regression on
x86_64.

Change-Id: I28b9f680711ff00252a2cb15625b774cc58ecb9d

4 years agoRemove most gmp-mparam.h headers.
Joseph Myers [Fri, 24 Apr 2020 22:08:59 +0000 (22:08 +0000)]
Remove most gmp-mparam.h headers.

Most gmp-mparam.h headers in glibc define various macros to the same
values they would be defined to by the generic version of that header,
plus macros IEEE_DOUBLE_BIG_ENDIAN or IEEE_DOUBLE_MIXED_ENDIAN related
to the representation of double.  The latter macros are in turn only
used in gmp-impl.h to define union ieee_double_extract, which is not
used in glibc.  Thus all of these headers, except for the generic one
and those that define _LONG_LONG_LIMB for ILP32 configurations with
64-bit registers, are redundant, and this patch removes them.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

4 years agoelf: Implement __libc_early_init
Florian Weimer [Fri, 24 Apr 2020 20:31:15 +0000 (22:31 +0200)]
elf: Implement __libc_early_init

This function is defined in libc.so, and the dynamic loader calls
right after relocation has been finished, before any ELF constructors
or the preinit function is invoked.  It is also used in the static
build for initializing parts of the static libc.

To locate __libc_early_init, a direct symbol lookup function is used,
_dl_lookup_direct.  It does not search the entire symbol scope and
consults merely a single link map.  This function could also be used
to implement lookups in the vDSO (as an optimization).

A per-namespace variable (libc_map) is added for locating libc.so,
to avoid repeated traversals of the search scope.  It is similar to
GL(dl_initfirst).  An alternative would have been to thread a context
argument from _dl_open down to _dl_map_object_from_fd (where libc.so
is identified).  This could have avoided the global variable, but
the change would be larger as a result.  It would not have been
possible to use this to replace GL(dl_initfirst) because that global
variable is used to pass the function pointer past the stack switch
from dl_main to the main program.  Replacing that requires adding
a new argument to _dl_init, which in turn needs changes to the
architecture-specific libc.so startup code written in assembler.

__libc_early_init should not be used to replace _dl_var_init (as
it exists today on some architectures).  Instead, _dl_lookup_direct
should be used to look up a new variable symbol in libc.so, and
that should then be initialized from the dynamic loader, immediately
after the object has been loaded in _dl_map_object_from_fd (before
relocation is run).  This way, more IFUNC resolvers which depend on
these variables will work.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Introduce <elf_machine_sym_no_match.h>
Florian Weimer [Fri, 24 Apr 2020 20:13:03 +0000 (22:13 +0200)]
elf: Introduce <elf_machine_sym_no_match.h>

MIPS needs to ignore certain existing symbols during symbol lookup.
The old scheme uses the ELF_MACHINE_SYM_NO_MATCH macro, with an
inline function, within its own header, with a sysdeps override for
MIPS.  This allows re-use of the function from another file (without
having to include <dl-machine.h> or providing the default definition
for ELF_MACHINE_SYM_NO_MATCH).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd a syscall test for [BZ #25810]
H.J. Lu [Wed, 22 Apr 2020 16:48:10 +0000 (09:48 -0700)]
Add a syscall test for [BZ #25810]

Add a test to pass 64-bit long arguments to syscall with undefined upper
32 bits on x32.

Tested on i386, x86-64 and x32 as well as with build-many-glibcs.py.

4 years agoelf: Support lld-style link map for librtld.map
Fangrui Song [Tue, 21 Apr 2020 16:28:42 +0000 (13:28 -0300)]
elf: Support lld-style link map for librtld.map

GNU ld and gold's -Map include a line like:

  path/to/build/libc_pic.a(check_fds.os)

lld -Map does not have the archive member list, but we can still derive the
members from the following output

             VMA              LMA     Size Align Out     In      Symbol
...
           1a1c0            1a1c0       e2    16         path/to/build/libc_pic.a(check_fds.os):(.text)

4 years agosignal: Only handle on NSIG signals on signal functions (BZ #25657)
Adhemerval Zanella [Thu, 12 Mar 2020 12:50:19 +0000 (09:50 -0300)]
signal: Only handle on NSIG signals on signal functions (BZ #25657)

The upper bits of the sigset_t s not fully initialized in the signal
mask calls that return information from kernel (sigprocmask,
sigpending, and pthread_sigmask), since the exported sigset_t size
(1024 bits) is larger than Linux support one (64 or 128 bits).
It might make sigisemptyset/sigorset/sigandset fail if the mask
is filled prior the call.

This patch changes the internal signal function to handle up to
supported Linux signal number (_NSIG), the remaining bits are
untouched.

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

4 years agolinux: Use pthread_sigmask on sigprocmask
Adhemerval Zanella [Wed, 11 Mar 2020 18:21:59 +0000 (15:21 -0300)]
linux: Use pthread_sigmask on sigprocmask

With pthread_sigmask on libc.so, it allows implement sigprocmask
on top of pthread_sigmask.

Checked on x86_64-linux-gnu.

4 years agoia64: Remove sigprocmask/sigblock objects from libpthread
Adhemerval Zanella [Fri, 13 Mar 2020 19:10:08 +0000 (19:10 +0000)]
ia64: Remove sigprocmask/sigblock objects from libpthread

It is required because __libc_unwind_longjmp (used on thread
cancellation) calls __sigprocmask.  Replace with a direct call.

They are required because __libc_unwind_longjmp (used for thread
cancellation) calls __sigprocmask.  Replace this with a direct call.

The sigblock function is not exported and is not used internally, so
it can be removed.

Checked on cross build for ia64-linux-gnu.

4 years agonptl: Move pthread_sigmask implementation to libc
Adhemerval Zanella [Wed, 11 Mar 2020 18:19:24 +0000 (15:19 -0300)]
nptl: Move pthread_sigmask implementation to libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

A new symbol version is added on libc to force loading failure
instead of lazy binding one for newly binaries with old loaders.

Checked with a build against all affected ABIs.

4 years agoBug 25819: Update to Unicode 13.0.0
Mike FABIAN [Tue, 14 Apr 2020 16:43:13 +0000 (18:43 +0200)]
Bug 25819: Update to Unicode 13.0.0

Unicode 13.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 13.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Total added characters in newly generated CHARMAP: 5930
Total added characters in newly generated WIDTH: 5536

4 years agoARC: Update syscall-names.list for ARC specific syscalls
Vineet Gupta [Thu, 9 Apr 2020 02:56:12 +0000 (19:56 -0700)]
ARC: Update syscall-names.list for ARC specific syscalls

4 years agoRevert "x86_64: Add SSE sfp-exceptions"
Adhemerval Zanella [Mon, 20 Apr 2020 11:14:48 +0000 (08:14 -0300)]
Revert "x86_64: Add SSE sfp-exceptions"

The __sfp_handle_exceptions is not fully correct regarding raising
exceptions, since there is no direct way to raise only FP_EX_OVERFLOW
nor FP_EX_UNDERFLOW for SSE mode.  Both libgcc and feraiseexcept rely
on x87 mode to accomplish it.

This reverts commit 460ee50de054396cc9791ff4cfdc2f5029fb923d.

Checked on x86_64.

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