]> sourceware.org Git - glibc.git/log
glibc.git
3 years agoaarch64: Respect p_flags when protecting code with PROT_BTI
Szabolcs Nagy [Mon, 13 Jul 2020 10:28:18 +0000 (11:28 +0100)]
aarch64: Respect p_flags when protecting code with PROT_BTI

Use PROT_READ and PROT_WRITE according to the load segment p_flags
when adding PROT_BTI.

This is before processing relocations which may drop PROT_BTI in
case of textrels.  Executable stacks are not protected via PROT_BTI
either.  PROT_BTI is hardening in case memory corruption happened,
it's value is reduced if there is writable and executable memory
available so missing it on such memory is fine, but we should
respect the p_flags and should not drop PROT_WRITE.

3 years agoDisable warnings due to deprecated libselinux symbols used by nss and nscd
Arjun Shankar [Thu, 23 Jul 2020 10:20:38 +0000 (12:20 +0200)]
Disable warnings due to deprecated libselinux symbols used by nss and nscd

The SELinux API deprecated several symbols in its 3.1 release, including
security_context_t, matchpathcon, avc_init, and sidput, which are used in
makedb and nscd.  While the usage of these should eventually be replaced by
newer interfaces, this commit disables GCC warnings due to the use of the
above symbols.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoRegenerate INSTALL for ARC port updates.
Carlos O'Donell [Thu, 23 Jul 2020 03:32:07 +0000 (23:32 -0400)]
Regenerate INSTALL for ARC port updates.

3 years agoUpdate libc.pot for 2.32 release.
Carlos O'Donell [Thu, 23 Jul 2020 03:28:05 +0000 (23:28 -0400)]
Update libc.pot for 2.32 release.

3 years agopowerpc: Fix POWER10 selection
Tulio Magno Quites Machado Filho [Tue, 21 Jul 2020 21:01:39 +0000 (18:01 -0300)]
powerpc: Fix POWER10 selection

Add a line that was missing from a previous commit.
Without increasing str, the null-byte is not validated, and
_dl_string_platform returns -1.

Fixes: d2ba3677da7a ("powerpc: Add support for POWER10")
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agopowerpc64le: guarantee a .gnu.attributes section [BZ #26220]
Paul E. Murphy [Wed, 8 Jul 2020 21:49:34 +0000 (16:49 -0500)]
powerpc64le: guarantee a .gnu.attributes section [BZ #26220]

Upstream GCC 11 development is now building the ibm128 runtime
support (in libgcc) without a .gnu.attributes section on ppc64le.
Ensure we have one to replace by building one ibm128 file in
libc and libm with attributes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agolibio: Remove __libc_readline_unlocked
Florian Weimer [Wed, 15 Jul 2020 10:37:01 +0000 (12:37 +0200)]
libio: Remove __libc_readline_unlocked

__nss_readline supersedes it.  This reverts part of commit
3f5e3f5d066dcffb80af48ae2cf35a01a85a8f10 ("libio: Implement
internal function __libc_readline_unlocked").  The internal
aliases __fseeko64 and __ftello64 are preserved because
they are needed by __nss_readline as well.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoshadow: Implement fgetspent_r using __nss_fgetent_r
Florian Weimer [Thu, 16 Jul 2020 15:34:43 +0000 (17:34 +0200)]
shadow: Implement fgetspent_r using __nss_fgetent_r

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agopwd: Implement fgetpwent_r using __nss_fgetent_r
Florian Weimer [Thu, 16 Jul 2020 15:34:19 +0000 (17:34 +0200)]
pwd: Implement fgetpwent_r using __nss_fgetent_r

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agogshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338)
Florian Weimer [Thu, 16 Jul 2020 15:31:20 +0000 (17:31 +0200)]
gshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338)

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agogrp: Implement fgetgrent_r using __nss_fgetent_r
Florian Weimer [Thu, 16 Jul 2020 15:28:28 +0000 (17:28 +0200)]
grp: Implement fgetgrent_r using __nss_fgetent_r

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonss: Add __nss_fgetent_r
Florian Weimer [Wed, 15 Jul 2020 11:41:31 +0000 (13:41 +0200)]
nss: Add __nss_fgetent_r

And helper functions __nss_readline, __nss_readline_seek,
 __nss_parse_line_result.

This consolidates common code for handling overlong lines and
parse files.  Use the new functionality in internal_getent
in nss/nss_files/files-XXX.c.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agolibio: Add fseterr_unlocked for internal use
Florian Weimer [Thu, 16 Jul 2020 15:00:46 +0000 (17:00 +0200)]
libio: Add fseterr_unlocked for internal use

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonss_files: Use generic result pointer in parse_line
Florian Weimer [Thu, 16 Jul 2020 14:55:45 +0000 (16:55 +0200)]
nss_files: Use generic result pointer in parse_line

As a result, all parse_line functions have the same prototype, except
for that producing struct hostent.  This change is ABI-compatible, so
it does not alter the internal GLIBC_PRIVATE ABI (otherwise we should
probably have renamed the exported functions).

A future change will use this to implement a generict fget*ent_r
function.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonss_files: Consolidate line parse declarations in <nss_files.h>
Florian Weimer [Thu, 16 Jul 2020 14:40:44 +0000 (16:40 +0200)]
nss_files: Consolidate line parse declarations in <nss_files.h>

These functions should eventually have the same type, so it makes
sense to declare them together.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonss_compat: Do not use mmap to read database files (bug 26258)
Florian Weimer [Thu, 16 Jul 2020 14:21:28 +0000 (16:21 +0200)]
nss_compat: Do not use mmap to read database files (bug 26258)

This avoids crashes in case the files are truncated for some reason.
For typically file sizes, it is also going to be slightly faster.
Using __nss_files_fopen instead mirrors what nss_files does.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonss_files: Consolidate file opening in __nss_files_fopen
Florian Weimer [Thu, 16 Jul 2020 14:12:46 +0000 (16:12 +0200)]
nss_files: Consolidate file opening in __nss_files_fopen

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoUpdate powerpc-nofpu libm-test-ulps.
Joseph Myers [Mon, 20 Jul 2020 20:16:25 +0000 (20:16 +0000)]
Update powerpc-nofpu libm-test-ulps.

4 years agoUse MPFR 4.1.0 in build-many-glibcs.py.
Joseph Myers [Mon, 20 Jul 2020 18:16:50 +0000 (18:16 +0000)]
Use MPFR 4.1.0 in build-many-glibcs.py.

This patch makes build-many-glibcs.py use the new MPFR 4.1.0 release.

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

4 years agoelf: Change TLS static surplus default back to 1664
Florian Weimer [Mon, 20 Jul 2020 11:30:45 +0000 (13:30 +0200)]
elf: Change TLS static surplus default back to 1664

Make the computation in elf/dl-tls.c more transparent, and add
an explicit test for the historic value.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agohurd: Fix longjmp check for sigstate
Samuel Thibault [Sat, 18 Jul 2020 13:12:56 +0000 (15:12 +0200)]
hurd: Fix longjmp check for sigstate

* sysdeps/mach/hurd/i386/____longjmp_chk.S,__longjmp.S: Properly check for
sigstate being NULL.

4 years agohurd: Fix longjmp early in initialization
Samuel Thibault [Sat, 18 Jul 2020 13:08:03 +0000 (15:08 +0200)]
hurd: Fix longjmp early in initialization

When e.g. an LD_PRELOAD fails, _dl_signal_exception/error longjmps, but TLS
is not initialized yet, let along signal state.  We thus mustn't look at
them within __longjmp.

* sysdeps/mach/hurd/i386/____longjmp_chk.S,__longjmp.S: Check for
initialized value of %gs, and that sigstate is non-NULL.

4 years agomanual: New signal and errno string functions are AS-safe
Florian Weimer [Fri, 17 Jul 2020 15:13:59 +0000 (17:13 +0200)]
manual: New signal and errno string functions are AS-safe

The annotations for sigabbrev_np, sigdescr_np, strerrordesc_np,
strerrorname_np are not preliminary.  These functions were
added precisely because they are AS-safe.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAArch64: Improve strlen_asimd performance (bug 25824)
Wilco Dijkstra [Fri, 17 Jul 2020 13:09:36 +0000 (14:09 +0100)]
AArch64: Improve strlen_asimd performance (bug 25824)

Optimize strlen using a mix of scalar and SIMD code.  On modern micro
architectures large strings are 2.6 times faster than existing
strlen_asimd and 35% faster than the new MTE version of strlen.

On a random strlen benchmark using small sizes the speedup is 7% vs
strlen_asimd and 40% vs the MTE strlen.  This fixes the main strlen
regressions on Cortex-A53 and other cores with a simple Neon unit.

Rename __strlen_generic to __strlen_mte, and select strlen_asimd when
MTE is not enabled (this is waiting on support for a HWCAP_MTE bit).

This fixes big-endian bug 25824. Passes GLIBC regression tests.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 years agoMove <rpc/netdb.h> from sunrpc to inet
Florian Weimer [Fri, 17 Jul 2020 13:19:35 +0000 (15:19 +0200)]
Move <rpc/netdb.h> from sunrpc to inet

Restore <rpc/netdb.h> as an installed header. Delete the dummy header
resolv/rpc/netdb.h because inet is not an optional glibc component
(so its <rpc/netdb.h> is always available).

Fixes commit acb527929d0c2b3bb0798472c42ddb3203729708 ("Move
non-deprecated RPC-related functions from sunrpc to inet") in
combination with commit 5500cdba4018ddbda7909bc7f4f9718610b43cf0
("Remove --enable-obsolete-rpc configure flag").

4 years agoen_US: Minimize changes to date_fmt (Bug 25923)
Carlos O'Donell [Wed, 8 Jul 2020 19:58:06 +0000 (15:58 -0400)]
en_US: Minimize changes to date_fmt (Bug 25923)

In 2000 when date_fmt was originally added as an extension the
en_US locale did not have a date_fmt specifier and so used the
default which resulted in the abbreviated month name coming
before the day of the month (as expected in the US and other
locales).  In commit 7395f3a0efad9fc51bb54fa383ef6524702e0c49 the
date_fmt was added to en_US with a 12H time to better align with
US user expectations.  Unfortunately the abbreviated month name
and day were inverted during that transition, and that was seen
as a regression and reported against Fedora 32:
https://bugzilla.redhat.com/show_bug.cgi?id=1830623

The progression of date_fmt looks like this:
"%a %b %e %H:%M:%S %Z %Y"    <- Originally (2000)
"%a %d %b %Y %I:%M:%S %p %Z" <- glibc 2.29 (2019)
"%a %b %e %r %Z %Y"          <- glibc 2.32 (2020) [this commit]

Note: "%r" is "%I:%M:%S %p" in en_US and so shorter to write.

Likewise the year is in the wrong place in commit
7395f3a0efad9fc51bb54fa383ef6524702e0c49 and this is corrected in
this patch.

For reference d_t_fmt:
"%a %d %b %Y %r %Z"          <- d_t_fmt    (1997)

Yes, d_t_fmt and date_fmt are *not* the same, this is just the
history of this locale. This commit does not change d_t_fmt to
better align with date_fmt. No users have requested we change
d_t_fmt or given any justification for such a change.

The only goals of this change are to place the abbreviated month
name before the day of the month as it has been printed since
2000, and place the year at the end. This minimizes the change
from commit 7395f3a0efad9fc51bb54fa383ef6524702e0c49 and makes
good on changing only from 24H clock to 12H clock.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agoLinux: Remove rseq support
Florian Weimer [Thu, 16 Jul 2020 15:55:35 +0000 (17:55 +0200)]
Linux: Remove rseq support

The kernel ABI is not finalized, and there are now various proposals
to change the size of struct rseq, which would make the glibc ABI
dependent on the version of the kernels used for building glibc.
This is of course not acceptable.

This reverts commit 48699da1c468543ade14777819bd1b4d652709de ("elf:
Support at least 32-byte alignment in static dlopen"), commit
8f4632deb3545b2949cec5454afc3cb21a0024ea ("Linux: rseq registration
tests"), commit 6e29cb3f61ff5432c78a1c84b0d9b123a350ab36 ("Linux: Use
rseq in sched_getcpu if available"), and commit
0c76fc3c2b346dc5401dc055d97d4279632b0fb3 ("Linux: Perform rseq
registration at C startup and thread creation"), resolving the conflicts
introduced by the ARC port and the TLS static surplus changes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agomanual: Use Unicode instead HTML entities for characters (bug 19737)
Florian Weimer [Thu, 16 Jul 2020 08:17:31 +0000 (10:17 +0200)]
manual: Use Unicode instead HTML entities for characters (bug 19737)

Texinfo no longer treats arguments to @set in @ifhtml blocks as
literal HTML, so the & in the entity references was encoded as
@amp; in HTML.  Using the equivalent Unicode characters avoids
this issue.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd NEWS entry for CVE-2020-6096 (bug 25620)
Aurelien Jarno [Sun, 12 Jul 2020 19:58:43 +0000 (21:58 +0200)]
Add NEWS entry for CVE-2020-6096 (bug 25620)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoarm: remove string/tst-memmove-overflow XFAIL
Aurelien Jarno [Mon, 13 Jul 2020 20:37:41 +0000 (22:37 +0200)]
arm: remove string/tst-memmove-overflow XFAIL

The arm string/tst-memmove-overflow XFAIL has been added in commit
eca1b233322 ("arm: XFAIL string/tst-memmove-overflow due to bug 25620")
as a way to reproduce the reported bug.

Now that this bug has been fixed in commits 79a4fa341b8 ("arm:
CVE-2020-6096: fix memcpy and memmove for negative length [BZ #25620]")
and beea3610507 ("arm: CVE-2020-6096: Fix multiarch memcpy for negative
length [BZ #25620]"), let's remove the XFAIL.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAArch64: Rename IS_ARES to IS_NEOVERSE_N1
Wilco Dijkstra [Wed, 15 Jul 2020 15:58:07 +0000 (16:58 +0100)]
AArch64: Rename IS_ARES to IS_NEOVERSE_N1

Rename IS_ARES to IS_NEOVERSE_N1 since that is a bit clearer.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAArch64: Add optimized Q-register memcpy
Wilco Dijkstra [Wed, 15 Jul 2020 15:55:07 +0000 (16:55 +0100)]
AArch64: Add optimized Q-register memcpy

Add a new memcpy using 128-bit Q registers - this is faster on modern
cores and reduces codesize.  Similar to the generic memcpy, small cases
include copies up to 32 bytes.  64-128 byte copies are split into two
cases to improve performance of 64-96 byte copies.  Large copies align
the source rather than the destination.

bench-memcpy-random is ~9% faster than memcpy_falkor on Neoverse N1,
so make this memcpy the default on N1 (on Centriq it is 15% faster than
memcpy_falkor).

Passes GLIBC regression tests.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 years agoAArch64: Align ENTRY to a cacheline
Wilco Dijkstra [Wed, 15 Jul 2020 15:50:02 +0000 (16:50 +0100)]
AArch64: Align ENTRY to a cacheline

Given almost all uses of ENTRY are for string/memory functions,
align ENTRY to a cacheline to simplify things.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoCorrect timespec implementation [BZ #26232]
H.J. Lu [Mon, 13 Jul 2020 23:15:56 +0000 (16:15 -0700)]
Correct timespec implementation [BZ #26232]

commit 04deeaa9ea74b0679dfc9d9155a37b6425f19a9f
Author: Lucas A. M. Magalhaes <lamm@linux.ibm.com>
Date:   Fri Jul 10 19:41:06 2020 -0300

    Fix time/tst-cpuclock1 intermitent failures

has 2 issues:

1. It assumes time_t == long which is false on x32.
2. tst-timespec.c is compiled without -fexcess-precision=standard which
generates incorrect results on i686 in support_timespec_check_in_range:

  double ratio = (double)observed_norm / expected_norm;
  return (lower_bound <= ratio && ratio <= upper_bound);

This patch does

1. Compile tst-timespec.c with -fexcess-precision=standard.
2. Replace long with time_t.
3. Replace LONG_MIN and LONG_MAX with TYPE_MINIMUM (time_t) and
TYPE_MAXIMUM (time_t).

4 years agoRemove --enable-obsolete-rpc configure flag
Petr Vorel [Mon, 13 Jul 2020 17:36:35 +0000 (19:36 +0200)]
Remove --enable-obsolete-rpc configure flag

Sun RPC was removed from glibc. This includes rpcgen program, librpcsvc,
and Sun RPC headers. Also test for bug #20790 was removed
(test for rpcgen).

Backward compatibility for old programs is kept only for architectures
and ABIs that have been added in or before version 2.28.

libtirpc is mature enough, librpcsvc and rpcgen are provided in
rpcsvc-proto project.

NOTE: libnsl code depends on Sun RPC (installed libnsl headers use
installed Sun RPC headers), thus --enable-obsolete-rpc was a dependency
for --enable-obsolete-nsl (removed in a previous commit).

The arc ABI list file has to be updated because the port was added
with the sunrpc symbols

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agohurd: Fix build-many-glibcs.py
Adhemerval Zanella [Fri, 10 Jul 2020 17:48:17 +0000 (14:48 -0300)]
hurd: Fix build-many-glibcs.py

It fixes the issue report by Joseph [1].

Checked with a build-many-glibcs.py build for i686-gnu.

[1] https://sourceware.org/pipermail/libc-alpha/2020-July/116134.html

4 years agox86: Support usable check for all CPU features
H.J. Lu [Mon, 29 Jun 2020 23:36:08 +0000 (16:36 -0700)]
x86: Support usable check for all CPU features

Support usable check for all CPU features with the following changes:

1. Change struct cpu_features to

struct cpuid_features
{
  struct cpuid_registers cpuid;
  struct cpuid_registers usable;
};

struct cpu_features
{
  struct cpu_features_basic basic;
  struct cpuid_features features[COMMON_CPUID_INDEX_MAX];
  unsigned int preferred[PREFERRED_FEATURE_INDEX_MAX];
...
};

so that there is a usable bit for each cpuid bit.
2. After the cpuid bits have been initialized, copy the known bits to the
usable bits.  EAX/EBX from INDEX_1 and EAX from INDEX_7 aren't used for
CPU feature detection.
3. Clear the usable bits which require OS support.
4. If the feature is supported by OS, copy its cpuid bit to its usable
bit.
5. Replace HAS_CPU_FEATURE and CPU_FEATURES_CPU_P with CPU_FEATURE_USABLE
and CPU_FEATURE_USABLE_P to check if a feature is usable.
6. Add DEPR_FPU_CS_DS for INDEX_7_EBX_13.
7. Unset MPX feature since it has been deprecated.

The results are

1. If the feature is known and doesn't requre OS support, its usable bit
is copied from the cpuid bit.
2. Otherwise, its usable bit is copied from the cpuid bit only if the
feature is known to supported by OS.
3. CPU_FEATURE_USABLE/CPU_FEATURE_USABLE_P are used to check if the
feature can be used.
4. HAS_CPU_FEATURE/CPU_FEATURE_CPU_P are used to check if CPU supports
the feature.

4 years agostring: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed
Adhemerval Zanella [Thu, 9 Jul 2020 16:24:04 +0000 (13:24 -0300)]
string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installed

Without msgfmt libc.mo files are not generated and its loading failure
is silent ignored with xsetlocale.

Also unset LANGUAGE environment variable to avoid it taking precedence
when loading the message catalog.  Although not strictly required
(since the test is issued with test-container and it sets a strict
environment variable) it follows other tests that deal with
translation.

Checked on x86_64-linux-gnu.

4 years agomalloc: Deprecate more hook-related functionality
Florian Weimer [Mon, 13 Jul 2020 07:58:37 +0000 (09:58 +0200)]
malloc: Deprecate more hook-related functionality

__morecore, __after_morecore_hook, and __default_morecore had not
been deprecated in commit 7d17596c198f11fa85cbcf9587443f262e63b616
("Mark malloc hook variables as deprecated"), probably by accident.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Support at least 32-byte alignment in static dlopen
Florian Weimer [Sun, 12 Jul 2020 15:53:58 +0000 (17:53 +0200)]
elf: Support at least 32-byte alignment in static dlopen

Otherwise loading a dynamically linked libc with rseq support fails,
as result of the __rseq_abi TLS variable, which has an alignment
of 32 bytes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Vineet Gupta <vgupta@synopsys.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
4 years agox86: Remove __ASSEMBLER__ check in init-arch.h
H.J. Lu [Sat, 11 Jul 2020 17:03:05 +0000 (10:03 -0700)]
x86: Remove __ASSEMBLER__ check in init-arch.h

Since

commit 430388d5dc0e1861b869096f4f5d946d7d74232a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Aug 3 08:04:49 2018 -0700

    x86: Don't include <init-arch.h> in assembly codes

removed all usages of <init-arch.h> from assembly codes, we can remove
__ASSEMBLER__ check in init-arch.h.

4 years agox86: Remove the unused __x86_prefetchw
H.J. Lu [Sat, 11 Jul 2020 16:04:34 +0000 (09:04 -0700)]
x86: Remove the unused __x86_prefetchw

Since

commit c867597bff2562180a18da4b8dba89d24e8b65c4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jun 8 13:57:50 2016 -0700

    X86-64: Remove previous default/SSE2/AVX2 memcpy/memmove

removed the only usage of __x86_prefetchw, we can remove the unused
__x86_prefetchw.

4 years agoDocumentation for ARC port
Vineet Gupta [Mon, 20 Nov 2017 20:46:17 +0000 (12:46 -0800)]
Documentation for ARC port

(a) ABI doc:
    https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/wiki/files/ARCv2_ABI.pdf

(b) Programmer's Reference Manual (PRM) : needs a download request to be filled
    https://www.synopsys.com/dw/ipdir.php?ds=arc-hs44-hs46-hs48
    https://www.synopsys.com/dw/doc.php/ds/cc/programmers-reference-manual-ARC-HS.pdf

As of port merge (and Florian's patch to fix static TLS), glibc testsuite
(cross-test setup) has following failures:

FAIL: elf/tst-audit14
FAIL: elf/tst-audit15
FAIL: elf/tst-audit16
FAIL: elf/tst-ldconfig-ld_so_conf-update
FAIL: elf/tst-libc_dlvsym
FAIL: elf/tst-libc_dlvsym-static
FAIL: iconv/test-iconvconfig # Needs gconv installed
FAIL: io/ftwtest # Requires execution by non-root
FAIL: io/tst-lockf
FAIL: libio/tst-wfile-sync
FAIL: locale/tst-localedef-path-norm
FAIL: nptl/test-cond-printers # needs Python3 and target GDB on target
FAIL: nptl/test-condattr-printers #    ditto
FAIL: nptl/test-mutex-printers #    ditto
FAIL: nptl/test-mutexattr-printers #    ditto
FAIL: nptl/test-rwlock-printers #    ditto
FAIL: nptl/test-rwlockattr-printers #    ditto
FAIL: nptl/tst-umask1 # passes if run natively on target (NFS ACLv3 support needed)
FAIL: nss/bug-erange
FAIL: nss/tst-nss-files-hosts-getent
FAIL: nss/tst-nss-files-hosts-multi
FAIL: posix/bug-ga2
FAIL: posix/globtest # require same user on target and host
FAIL: posix/tst-getaddrinfo5
FAIL: stdio-common/tst-vfprintf-width-prec
FAIL: stdio-common/tst-vfprintf-width-prec-alloc
FAIL: stdio-common/tst-vfprintf-width-prec-mem
FAIL: string/tst-strerror
FAIL: string/tst-strsignal
FAIL: sunrpc/bug20790 # missing cpp on target
FAIL: timezone/tst-tzset

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agobuild-many-glibcs.py: Enable ARC builds
Vineet Gupta [Fri, 13 Mar 2020 01:29:59 +0000 (18:29 -0700)]
build-many-glibcs.py: Enable ARC builds

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: Build Infrastructure
Vineet Gupta [Tue, 23 Oct 2018 22:39:50 +0000 (15:39 -0700)]
ARC: Build Infrastructure

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: ABI lists
Vineet Gupta [Tue, 23 Oct 2018 22:37:08 +0000 (15:37 -0700)]
ARC: ABI lists

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: Linux Startup and Dynamic Loading
Vineet Gupta [Tue, 23 Oct 2018 21:58:39 +0000 (14:58 -0700)]
ARC: Linux Startup and Dynamic Loading

A big shoutout to Cupertino Miranda <cmiranda@synopsys.com> for his
valuable contribution in initial bringup and debugging on Linux and
later in solving pesky unwinding/cancelation failures in testsuite.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: Linux ABI
Vineet Gupta [Tue, 23 Oct 2018 21:56:39 +0000 (14:56 -0700)]
ARC: Linux ABI

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: Linux Syscall Interface
Vineet Gupta [Tue, 23 Oct 2018 21:44:30 +0000 (14:44 -0700)]
ARC: Linux Syscall Interface

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: hardware floating point support
Vineet Gupta [Tue, 5 Nov 2019 00:20:37 +0000 (16:20 -0800)]
ARC: hardware floating point support

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: math soft float support
Vineet Gupta [Wed, 24 Oct 2018 21:22:54 +0000 (14:22 -0700)]
ARC: math soft float support

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: Atomics and Locking primitives
Vineet Gupta [Tue, 23 Oct 2018 21:36:39 +0000 (14:36 -0700)]
ARC: Atomics and Locking primitives

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: Thread Local Storage support
Vineet Gupta [Tue, 23 Oct 2018 21:18:04 +0000 (14:18 -0700)]
ARC: Thread Local Storage support

This includes all 4 TLS addressing models

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: startup and dynamic linking code
Vineet Gupta [Tue, 23 Oct 2018 19:36:32 +0000 (12:36 -0700)]
ARC: startup and dynamic linking code

Code for C runtime startup and dynamic loading including PLT layout.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoARC: ABI Implementation
Vineet Gupta [Tue, 23 Oct 2018 18:38:32 +0000 (11:38 -0700)]
ARC: ABI Implementation

This code deals with the ARC ABI.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoFix time/tst-cpuclock1 intermitent failures
Lucas A. M. Magalhaes [Fri, 10 Jul 2020 22:41:06 +0000 (19:41 -0300)]
Fix time/tst-cpuclock1 intermitent failures

This test fails intermittently in systems with heavy load as
CLOCK_PROCESS_CPUTIME_ID is subject to scheduler pressure.  Thus the
test boundaries were relaxed to keep it from failing on such systems.

A refactor of the spent time checking was made with some support
functions.  With the advantage to representing time jitter in percent
of the target.

The values used by the test boundaries are all empirical.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agopowerpc64: Fix calls when r2 is not used [BZ #26173]
Tulio Magno Quites Machado Filho [Fri, 10 Jul 2020 22:41:06 +0000 (19:41 -0300)]
powerpc64: Fix calls when r2 is not used [BZ #26173]

Teach the linker that __mcount_internal, __sigjmp_save_symbol,
__syscall_error and __GI_exit do not use r2, so that it does not need to
recover r2 after the call.

Test at configure time if the assembler supports @notoc and define
USE_PPC64_NOTOC.

4 years agoAdd NEWS entry for Update to Unicode 13.0.0 [BZ #25819]
Mike FABIAN [Wed, 8 Jul 2020 12:41:23 +0000 (14:41 +0200)]
Add NEWS entry for Update to Unicode 13.0.0 [BZ #25819]

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 agoUpdate i686 libm-test-ulps
Patsy Franklin [Thu, 9 Jul 2020 20:06:17 +0000 (16:06 -0400)]
Update i686 libm-test-ulps

Without my ULP patch these 18 tests fail on i686:
 https://koji.fedoraproject.org/koji/taskinfo?taskID=46467301

+ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 85
model name : Intel Xeon Processor (Cascadelake)

FAIL: math/test-double-j0
FAIL: math/test-double-y0
FAIL: math/test-float-erfc
FAIL: math/test-float-j0
FAIL: math/test-float-j1
FAIL: math/test-float-lgamma
FAIL: math/test-float-tgamma
FAIL: math/test-float-y0
FAIL: math/test-float32-erfc
FAIL: math/test-float32-j0
FAIL: math/test-float32-j1
FAIL: math/test-float32-lgamma
FAIL: math/test-float32-tgamma
FAIL: math/test-float32-y0
FAIL: math/test-float32x-j0
FAIL: math/test-float32x-y0
FAIL: math/test-float64-j0
FAIL: math/test-float64-y0

With my ULP patch applied these tests now pass:
 https://koji.fedoraproject.org/koji/taskinfo?taskID=46436310

4 years agoFix memory leak in __printf_fp_l (bug 26215).
Joseph Myers [Thu, 9 Jul 2020 21:52:24 +0000 (21:52 +0000)]
Fix memory leak in __printf_fp_l (bug 26215).

__printf_fp_l has a memory leak in the case of some I/O errors, where
both buffer and wbuffer have been malloced but the handling of I/O
errors only frees wbuffer.  This patch fixes this by moving the
declaration of buffer to an outer scope and ensuring that it is freed
when wbuffer is freed.

Tested for x86_64 and x86.

4 years agoFix double free in __printf_fp_l (bug 26214).
Joseph Myers [Thu, 9 Jul 2020 21:51:49 +0000 (21:51 +0000)]
Fix double free in __printf_fp_l (bug 26214).

__printf_fp_l has a double free bug in the case where it allocates
memory with malloc internally, then has an I/O error while outputting
trailing padding and tries to free that already-freed memory when the
error occurs.  This patch fixes this by setting the relevant pointer
to NULL after the first free (the only free of this pointer that isn't
immediately followed by returning from the function).

Tested for x86_64 and x86.

4 years agolinux: Fix syscall list generation instructions
Maciej W. Rozycki [Thu, 9 Jul 2020 16:43:57 +0000 (17:43 +0100)]
linux: Fix syscall list generation instructions

Make the instructions for syscall list generation match Makefile and
refer to `update-syscall-lists'; there has been no `update-arch-syscall'
target.  Also use single quotes around the command to stick to the ASCII
character set.

Fixes 4cf0d223052d ("Linux: Add tables with system call numbers").

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
4 years agosysv: linux: Add 64-bit time_t variant for shmctl
Adhemerval Zanella [Tue, 30 Jun 2020 17:08:22 +0000 (14:08 -0300)]
sysv: linux: Add 64-bit time_t variant for shmctl

To provide a y2038 safe interface a new symbol __shmctl64 is added
and __shmctl is change to call it instead (it adds some extra buffer
copying for the 32 bit time_t implementation).

Two new structures are added:

  1. kernel_shmid64_ds: used internally only on 32-bit architectures
     to issue the syscall.  A handful of architectures (hppa, i386,
     mips, powerpc32, and sparc32) require specific implementations
     due to their kernel ABI.

  2. shmid_ds64: this is only for __TIMESIZE != 64 to use along with
     the 64-bit shmctl.  It is different than the kernel struct because
     the exported 64-bit time_t might require different alignment
     depending on the architecture ABI.

So the resulting implementation does:

  1. For 64-bit architectures it assumes shmid_ds already contains
     64-bit time_t fields and will result in just the __shmctl symbol
     using the __shmctl64 code.  The shmid_ds argument is passed as-is
     to the syscall.

  2. For 32-bit architectures with default 64-bit time_t (newer ABIs
     such riscv32 or arc), it will also result in only one exported
     symbol but with the required high/low time handling.

  3. Finally for 32-bit architecture with both 32-bit and 64-bit time_t
     support we follow the already set way to provide one symbol with
     64-bit time_t support and implement the 32-bit time_t support
     using of the 64-bit one.

     The default 32-bit symbol will allocate and copy the shmid_ds
     over multiple buffers, but this should be deprecated in favor
     of the __shmctl64 anyway.

Checked on i686-linux-gnu and x86_64-linux-gnu.  I also did some sniff
tests on powerpc, powerpc64, mips, mips64, armhf, sparcv9, and
sparc64.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agosysvipc: Remove the linux shm-pad.h file
Adhemerval Zanella [Tue, 30 Jun 2020 14:02:52 +0000 (11:02 -0300)]
sysvipc: Remove the linux shm-pad.h file

Each architecture overrides the struct msqid_ds which its required
kernel ABI one.

Checked on x86_64-linux-gnu and some bases sysvipc tests on hppa,
mips, mipsle, mips64, mips64le, sparc64, sparcv9, powerpc64le,
powerpc64, and powerpc.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agosysvipc: Split out linux struct shmid_ds
Adhemerval Zanella [Tue, 30 Jun 2020 13:30:14 +0000 (10:30 -0300)]
sysvipc: Split out linux struct shmid_ds

This will allow us to have architectures specify their own version.

Not semantic changes expected.  Checked with a build against the
all affected ABIs.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agosysv: linux: Add 64-bit time_t variant for msgctl
Adhemerval Zanella [Tue, 30 Jun 2020 12:20:48 +0000 (09:20 -0300)]
sysv: linux: Add 64-bit time_t variant for msgctl

To provide a y2038 safe interface a new symbol __msgctl64 is added
and __msgctl is change to call it instead (it adds some extra buffer
coping for the 32 bit time_t implementation).

Two new structures are added:

  1. kernel_msqid64_ds: used internally only on 32-bit architectures
     to issue the syscall.  A handful of architectures (hppa, i386, mips,
     powerpc32, and sparc32) require specific implementations due to
     their kernel ABI.

  2. msqid_ds64: this is only for __TIMESIZE != 64 to use along with
     the 64-bit msgctl.  It is different than the kernel struct because
     the exported 64-bit time_t might require different alignment
     depending on the architecture ABI.

So the resulting implementation does:

  1. For 64-bit architectures it assumes msqid_ds already contains
     64-bit time_t fields and will result in just the __msgctl symbol
     using the __msgctl64 code.  The msgid_ds argument is passed as-is
     to the syscall.

  2. For 32-bit architectures with default 64-bit time_t (newer ABIs
     such riscv32 or arc), it will also result in only one exported
     symbol but with the required high/low time handling.

  3. Finally for 32-bit architecture with both 32-bit and 64-bit time_t
     support we follow the already set way to provide one symbol with
     64-bit time_t support and implement the 32-bit time_t support using
     the 64-bit time_t.

     The default 32-bit symbol will allocate and copy the msqid_ds
     over multiple buffers, but this should be deprecated in favor
     of the __msgctl64 anyway.

Checked on i686-linux-gnu and x86_64-linux-gnu.  I also did some sniff
tests on powerpc, powerpc64, mips, mips64, armhf, sparcv9, and
sparc64.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
4 years agosysvipc: Remove the linux msq-pad.h file
Adhemerval Zanella [Tue, 30 Jun 2020 00:33:14 +0000 (21:33 -0300)]
sysvipc: Remove the linux msq-pad.h file

Each architecture overrides the struct msqid_ds which its required
kernel ABI one.

Checked on x86_64-linux-gnu and some bases sysvipc tests on hppa,
mips, mipsle, mips64, mips64le, sparc64, sparcv9, powerpc64le,
powerpc64, and powerpc.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
4 years agosysvipc: Split out linux struct semid_ds
Adhemerval Zanella [Mon, 29 Jun 2020 21:21:14 +0000 (18:21 -0300)]
sysvipc: Split out linux struct semid_ds

This will allow us to have architectures specify their own version.

Not semantic changes expected.  Checked with a build against the
all affected ABIs.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agosysv: linux: Add 64-bit time_t variant for semctl
Adhemerval Zanella [Mon, 29 Jun 2020 16:35:50 +0000 (13:35 -0300)]
sysv: linux: Add 64-bit time_t variant for semctl

Different than others 64-bit time_t syscalls, the SysIPC interface
does not provide a new set of syscall for y2038 safeness.  Instead it
uses unused fields in semid_ds structure to return the high bits for
the timestamps.

To provide a y2038 safe interface a new symbol __semctl64 is added
and __semctl is change to call it instead (it adds some extra buffer
copying for the 32 bit time_t implementation).

Two new structures are added:

  1. kernel_semid64_ds: used internally only on 32-bit architectures
     to issue the syscall.  A handful of architectures (hppa, i386,
     mips, powerpc32, sparc32) require specific implementations due
     their kernel ABI.

  2. semid_ds64: this is only for __TIMESIZE != 64 to use along with
     the 64-bit semctl.  It is different than the kernel struct because
     the exported 64-bit time_t might require different alignment
     depending on the architecture ABI.

So the resulting implementation does:

  1. For 64-bit architectures it assumes semid_ds already contains
     64-bit time_t fields and will result in just the __semctl symbol
     using the __semctl64 code.  The semid_ds argument is passed as-is
     to the syscall.

  2. For 32-bit architectures with default 64-bit time_t (newer ABIs
     such riscv32 or arc), it will also result in only one exported
     symbol but with the required high/low handling.

     It might be possible to optimize it further to avoid the
     kernel_semid64_ds to semun transformation if the exported ABI
     for the architectures matches the expected kernel ABI, but the
     implementation is already complex enough and don't think this
     should be a hotspot in any case.

  3. Finally for 32-bit architecture with both 32-bit and 64-bit time_t
     support we follow the already set way to provide one symbol with
     64-bit time_t support and implement the 32-bit time_t support
     using the 64-bit one.

     The default 32-bit symbol will allocate and copy the semid_ds
     over multiple buffers, but this should be deprecated in favor
     of the __semctl64 anyway.

Checked on i686-linux-gnu and x86_64-linux-gnu.  I also did some sniff
tests on powerpc, powerpc64, mips, mips64, armhf, sparcv9, and
sparc64.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Alistair Francis <alistair.francis@wdc.com>
Tested-by: Vineet Gupta <vgupta@synopsys.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 years agortld: Avoid using up static TLS surplus for optimizations [BZ #25051]
Szabolcs Nagy [Wed, 10 Jun 2020 12:40:40 +0000 (13:40 +0100)]
rtld: Avoid using up static TLS surplus for optimizations [BZ #25051]

On some targets static TLS surplus area can be used opportunistically
for dynamically loaded modules such that the TLS access then becomes
faster (TLSDESC and powerpc TLS optimization). However we don't want
all surplus TLS to be used for this optimization because dynamically
loaded modules with initial-exec model TLS can only use surplus TLS.

The new contract for surplus static TLS use is:

- libc.so can have up to 192 bytes of IE TLS,
- other system libraries together can have up to 144 bytes of IE TLS.
- Some "optional" static TLS is available for opportunistic use.

The optional TLS is now tunable: rtld.optional_static_tls, so users
can directly affect the allocated static TLS size. (Note that module
unloading with dlclose does not reclaim static TLS. After the optional
TLS runs out, TLS access is no longer optimized to use static TLS.)

The default setting of rtld.optional_static_tls is 512 so the surplus
TLS is 3*192 + 4*144 + 512 = 1664 by default, the same as before.

Fixes BZ #25051.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agortld: Account static TLS surplus for audit modules
Szabolcs Nagy [Tue, 7 Jul 2020 09:49:11 +0000 (10:49 +0100)]
rtld: Account static TLS surplus for audit modules

The new static TLS surplus size computation is

  surplus_tls = 192 * (nns-1) + 144 * nns + 512

where nns is controlled via the rtld.nns tunable. This commit
accounts audit modules too so nns = rtld.nns + audit modules.

rtld.nns should only include the namespaces required by the
application, namespaces for audit modules are accounted on top
of that so audit modules don't use up the static TLS that is
reserved for the application. This allows loading many audit
modules without tuning rtld.nns or using up static TLS, and it
fixes

FAIL: elf/tst-auditmany

Note that DL_NNS is currently a hard upper limit for nns, and
if rtld.nns + audit modules go over the limit that's a fatal
error. By default rtld.nns is 4 which allows 12 audit modules.

Counting the audit modules is based on existing audit string
parsing code, we cannot use GLRO(dl_naudit) before the modules
are actually loaded.

4 years agortld: Add rtld.nns tunable for the number of supported namespaces
Szabolcs Nagy [Tue, 9 Jun 2020 08:57:28 +0000 (09:57 +0100)]
rtld: Add rtld.nns tunable for the number of supported namespaces

TLS_STATIC_SURPLUS is 1664 bytes currently which is not enough to
support DL_NNS (== 16) number of dynamic link namespaces, if we
assume 192 bytes of TLS are reserved for libc use and 144 bytes
are reserved for other system libraries that use IE TLS.

A new tunable is introduced to control the number of supported
namespaces and to adjust the surplus static TLS size as follows:

surplus_tls = 192 * (rtld.nns-1) + 144 * rtld.nns + 512

The default is rtld.nns == 4 and then the surplus TLS size is the
same as before, so the behaviour is unchanged by default. If an
application creates more namespaces than the rtld.nns setting
allows, then it is not guaranteed to work, but the limit is not
checked. So existing usage will continue to work, but in the
future if an application creates more than 4 dynamic link
namespaces then the tunable will need to be set.

In this patch DL_NNS is a fixed value and provides a maximum to
the rtld.nns setting.

Static linking used fixed 2048 bytes surplus TLS, this is changed
so the same contract is used as for dynamic linking.  With static
linking DL_NNS == 1 so rtld.nns tunable is forced to 1, so by
default the surplus TLS is reduced to 144 + 512 = 656 bytes. This
change is not expected to cause problems.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoRemove --enable-obsolete-nsl configure flag
Petr Vorel [Wed, 8 Jul 2020 11:06:55 +0000 (13:06 +0200)]
Remove --enable-obsolete-nsl configure flag

this means that *always* libnsl is only built as shared library for
backward compatibility and the NSS modules libnss_nis and libnss_nisplus
are not built at all, libnsl's headers aren't installed.

This compatibility is kept only for architectures and ABIs that have
been added in or before version 2.28.

Replacement implementations based on TIRPC, which additionally support
IPv6, are available from <https://github.com/thkukuk/>.

This change does not affect libnss_compat which does not depended
on libnsl since 2.27 and thus can be used without NIS.

libnsl code depends on Sun RPC, e.g. on --enable-obsolete-rpc (installed
libnsl headers use installed Sun RPC headers), which will be removed in
the following commit.

4 years agoMove non-deprecated RPC-related functions from sunrpc to inet
Florian Weimer [Wed, 8 Jul 2020 10:15:23 +0000 (12:15 +0200)]
Move non-deprecated RPC-related functions from sunrpc to inet

This includes bindresvport and the NSS-related RPC functions.  This will
simplify the removal of the sunrpc functionality because these functions
no longer have to be treated specially.

4 years agoaarch64: add NEWS entry about branch protection support
Szabolcs Nagy [Thu, 11 Jun 2020 17:19:40 +0000 (18:19 +0100)]
aarch64: add NEWS entry about branch protection support

This is a new security feature that relies on architecture
extensions and needs glibc to be built with a gcc configured
with branch protection.

4 years agoaarch64: redefine RETURN_ADDRESS to strip PAC
Szabolcs Nagy [Wed, 15 Apr 2020 16:40:45 +0000 (17:40 +0100)]
aarch64: redefine RETURN_ADDRESS to strip PAC

RETURN_ADDRESS is used at several places in glibc to mean a valid
code address of the call site, but with pac-ret it may contain a
pointer authentication code (PAC), so its definition is adjusted.

This is gcc PR target/94891: __builtin_return_address should not
expose signed pointers to user code where it can cause ABI issues.
In glibc RETURN_ADDRESS is only changed if it is built with pac-ret.
There is no detection for the specific gcc issue because it is
hard to test and the additional xpac does not cause problems.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: fix pac-ret support in _mcount
Szabolcs Nagy [Wed, 13 May 2020 11:10:13 +0000 (12:10 +0100)]
aarch64: fix pac-ret support in _mcount

Currently gcc -pg -mbranch-protection=pac-ret passes signed return
address to _mcount, so _mcount now has to always strip pac from the
frompc since that's from user code that may be built with pac-ret.

This is gcc PR target/94791: signed pointers should not escape and get
passed across extern call boundaries, since that's an ABI break, but
because existing gcc has this issue we work it around in glibc until
that is resolved. This is compatible with a fixed gcc and it is a nop
on systems without PAuth support. The bug was introduced in gcc-7 with
-msign-return-address=non-leaf|all support which in gcc-9 got renamed
to -mbranch-protection=pac-ret|pac-ret+leaf|standard.

strip_pac uses inline asm instead of __builtin_aarch64_xpaclri since
that is not a documented api and not available in all supported gccs.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: Add pac-ret support to assembly files
Szabolcs Nagy [Wed, 29 Apr 2020 10:49:20 +0000 (11:49 +0100)]
aarch64: Add pac-ret support to assembly files

Use return address signing in assembly files for functions that save
LR when pac-ret is enabled in the compiler.

The GNU property note for PAC-RET is not meaningful to the dynamic
linker so it is not strictly required, but it may be used to track
the security property of binaries. (The PAC-RET property is only set
if BTI is set too because BTI implies working GNU property support.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: configure check for pac-ret code generation
Szabolcs Nagy [Thu, 7 May 2020 17:30:12 +0000 (18:30 +0100)]
aarch64: configure check for pac-ret code generation

Return address signing requires unwinder support, which is
present in libgcc since >=gcc-7, however due to bugs the
support may be broken in <gcc-10 (and similarly there may
be issues in custom unwinders), so pac-ret is not always
safe to use. So in assembly code glibc should only use
pac-ret if the compiler uses it too. Unfortunately there
is no predefined feature macro for it set by the compiler
so pac-ret is inferred from the code generation.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: ensure objects are BTI compatible
Szabolcs Nagy [Tue, 30 Jun 2020 10:12:40 +0000 (11:12 +0100)]
aarch64: ensure objects are BTI compatible

When glibc is built with branch protection (i.e. with a gcc configured
with --enable-standard-branch-protection), all glibc binaries should
be BTI compatible and marked as such.

It is easy to link BTI incompatible objects by accident and this is
silent currently which is usually not the expectation, so this is
changed into a link error. (There is no linker flag for failing on
BTI incompatible inputs so all warnings are turned into fatal errors
outside the test system when building glibc with branch protection.)

Unfortunately, outlined atomic functions are not BTI compatible in
libgcc (PR libgcc/96001), so to build glibc with current gcc use
'CC=gcc -mno-outline-atomics', this should be fixed in libgcc soon
and then glibc can be built and tested without such workarounds.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: enable BTI at runtime
Sudakshina Das [Mon, 22 Jun 2020 09:57:20 +0000 (10:57 +0100)]
aarch64: enable BTI at runtime

Binaries can opt-in to using BTI via an ELF object file marking.
The dynamic linker has to then mprotect the executable segments
with PROT_BTI. In case of static linked executables or in case
of the dynamic linker itself, PROT_BTI protection is done by the
operating system.

On AArch64 glibc uses PT_GNU_PROPERTY instead of PT_NOTE to check
the properties of a binary because PT_NOTE can be unreliable with
old linkers (old linkers just append the notes of input objects
together and add them to the output without checking them for
consistency which means multiple incompatible GNU property notes
can be present in PT_NOTE).

BTI property is handled in the loader even if glibc is not built
with BTI support, so in theory user code can be BTI protected
independently of glibc. In practice though user binaries are not
marked with the BTI property if glibc has no support because the
static linked libc objects (crt files, libc_nonshared.a) are
unmarked.

This patch relies on Linux userspace API that is not yet in a
linux release but in v5.8-rc1 so scheduled to be in Linux 5.8.

Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: fix RTLD_START for BTI
Szabolcs Nagy [Tue, 31 Mar 2020 16:32:14 +0000 (17:32 +0100)]
aarch64: fix RTLD_START for BTI

Tailcalls must use x16 or x17 for the indirect branch instruction
to be compatible with code that uses BTI c at function entries.
(Other forms of indirect branches can only land on BTI j.)

Also added a BTI c at the ELF entry point of rtld, this is not
strictly necessary since the kernel does not use indirect branch
to get there, but it seems safest once building glibc itself with
BTI is supported.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: fix swapcontext for BTI
Szabolcs Nagy [Wed, 1 Apr 2020 09:31:41 +0000 (10:31 +0100)]
aarch64: fix swapcontext for BTI

setcontext returns to the specified context via an indirect jump,
so there should be a BTI j.

In case of getcontext (and all other returns_twice functions) the
compiler adds BTI j at the call site, but swapcontext is a normal
c call that is currently not handled specially by the compiler.

So we change swapcontext such that the saved context returns to a
local address that has BTI j and then swapcontext returns to the
caller via a normal RET. For this we save the original return
address in the slot for x1 of the context because x1 need not be
preserved by swapcontext but it is restored when the context saved
by swapcontext is resumed.

The alternative fix (which is done on x86) would make swapcontext
special in the compiler so BTI j is emitted at call sites, on
x86 there is an indirect_return attribute for this, on AArch64
we would have to use returns_twice. It was decided against because
such fix may need user code updates: the attribute has to be added
when swapcontext is called via a function pointer and it breaks
always_inline functions with swapcontext.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: Add BTI support to assembly files
Sudakshina Das [Tue, 17 Mar 2020 15:44:18 +0000 (15:44 +0000)]
aarch64: Add BTI support to assembly files

To enable building glibc with branch protection, assembly code
needs BTI landing pads and ELF object file markings in the form
of a GNU property note.

The landing pads are unconditionally added to all functions that
may be indirectly called. When the code segment is not mapped
with PROT_BTI these instructions are nops. They are kept in the
code when BTI is not supported so that the layout of performance
critical code is unchanged across configurations.

The GNU property notes are only added when there is support for
BTI in the toolchain, because old binutils does not handle the
notes right. (Does not know how to merge them nor to put them in
PT_GNU_PROPERTY segment instead of PT_NOTE, and some versions
of binutils emit warnings about the unknown GNU property. In
such cases the produced libc binaries would not have valid
ELF marking so BTI would not be enabled.)

Note: functions using ENTRY or ENTRY_ALIGN now start with an
additional BTI c, so alignment of the following code changes,
but ENTRY_ALIGN_AND_PAD was fixed so there is no change to the
existing code layout. Some string functions may need to be
tuned for optimal performance after this commit.

Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: Rename place holder .S files to .c
Szabolcs Nagy [Wed, 1 Apr 2020 08:52:37 +0000 (09:52 +0100)]
aarch64: Rename place holder .S files to .c

The compiler can add required elf markings based on CFLAGS
but the assembler cannot, so using C code for empty files
creates less of a maintenance problem.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoaarch64: configure test for BTI support
Szabolcs Nagy [Wed, 6 May 2020 19:22:16 +0000 (20:22 +0100)]
aarch64: configure test for BTI support

Check BTI support in the compiler and linker.  The check also
requires READELF that understands the BTI GNU property note.
It is expected to succeed with gcc >=gcc-9 configured with
--enable-standard-branch-protection and binutils >=binutils-2.33.

Note: passing -mbranch-protection=bti in CFLAGS when building glibc
may not be enough to get a glibc that supports BTI because crtbegin*
and crtend* provided by the compiler needs to be BTI compatible too.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoRewrite abi-note.S in C.
Szabolcs Nagy [Wed, 1 Apr 2020 15:02:03 +0000 (16:02 +0100)]
Rewrite abi-note.S in C.

Using C code allows the compiler to add target specific object file
markings based on CFLAGS.

The arm specific abi-note.S is removed and similar object file fix
up will be avoided on AArch64 with standard branch protection.

4 years agortld: Clean up PT_NOTE and add PT_GNU_PROPERTY handling
Szabolcs Nagy [Mon, 22 Jun 2020 09:56:38 +0000 (10:56 +0100)]
rtld: Clean up PT_NOTE and add PT_GNU_PROPERTY handling

Add generic code to handle PT_GNU_PROPERTY notes. Invalid
content is ignored, _dl_process_pt_gnu_property is always called
after PT_LOAD segments are mapped and it has no failure modes.
Currently only one NT_GNU_PROPERTY_TYPE_0 note is handled, which
contains target specific properties: the _dl_process_gnu_property
hook is called for each property.

The old _dl_process_pt_note and _rtld_process_pt_note differ in how
the program header is read.  The old _dl_process_pt_note is called
before PT_LOAD segments are mapped and _rtld_process_pt_note is called
after PT_LOAD segments are mapped. The old _rtld_process_pt_note is
removed and _dl_process_pt_note is always called after PT_LOAD
segments are mapped and now it has no failure modes.

The program headers are scanned backwards so that PT_NOTE can be
skipped if PT_GNU_PROPERTY exists.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agostring: Move tst-strsignal tst-strerror to tests-container
Adhemerval Zanella [Wed, 8 Jul 2020 13:23:14 +0000 (10:23 -0300)]
string: Move tst-strsignal tst-strerror to tests-container

Both tests require libc.mo translation files which might not be
installed on the system.

Checked on x86_64-linux-gnu.

4 years agostring: Fix prototype mismatch in sigabbrev_np, __sigdescr_np
Florian Weimer [Wed, 8 Jul 2020 12:19:58 +0000 (14:19 +0200)]
string: Fix prototype mismatch in sigabbrev_np, __sigdescr_np

GCC 6 does not ignore the const specifier on the return type.

4 years agoarm: CVE-2020-6096: Fix multiarch memcpy for negative length [BZ #25620]
Alexander Anisimov [Wed, 8 Jul 2020 12:18:31 +0000 (14:18 +0200)]
arm: CVE-2020-6096: Fix multiarch memcpy for negative length [BZ #25620]

Unsigned branch instructions could be used for r2 to fix the wrong
behavior when a negative length is passed to memcpy.
This commit fixes the armv7 version.

4 years agoarm: CVE-2020-6096: fix memcpy and memmove for negative length [BZ #25620]
Evgeny Eremin [Wed, 8 Jul 2020 12:18:19 +0000 (14:18 +0200)]
arm: CVE-2020-6096: fix memcpy and memmove for negative length [BZ #25620]

Unsigned branch instructions could be used for r2 to fix the wrong
behavior when a negative length is passed to memcpy and memmove.
This commit fixes the generic arm implementation of memcpy amd memmove.

4 years agosunrpc: Remove hidden aliases for global data symbols (bug 26210)
Florian Weimer [Wed, 8 Jul 2020 05:58:51 +0000 (07:58 +0200)]
sunrpc: Remove hidden aliases for global data symbols (bug 26210)

It is generally not possible to add hidden aliases for global data
symbols: If the main executable contains a copy relocation against
the symbol, the hidden aliases keep pointing to the glibc-internal
copy of the symbol, instead of the symbol actually used by the
application.

Fixes commit 89aacb513eb77549a29df2638913a0f8178cf3f5 ("sunrpc:
Remove stray exports without --enable-obsolete-rpc [BZ #23166]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agohurd: Fix strerror not setting errno
Samuel Thibault [Tue, 7 Jul 2020 21:46:53 +0000 (21:46 +0000)]
hurd: Fix strerror not setting errno

* sysdeps/mach/strerror_l.c: Include <errno.h>.
(__strerror_l): Save errno on entry and restore it on exit.

4 years agotst-strsignal: fix checking for RT signals support
Samuel Thibault [Tue, 7 Jul 2020 21:24:48 +0000 (21:24 +0000)]
tst-strsignal: fix checking for RT signals support

* string/tst-strsignal.c (do_test): Actually check that RT signals are
available by comparing SIGRTMAX to SIGRTMIN. Check that SIGRTMAX is 64
before testing for a message reporting 65 for SIGRTMAX+1.

4 years agohurd: Evaluate fd before entering the critical section
Samuel Thibault [Tue, 7 Jul 2020 20:09:29 +0000 (22:09 +0200)]
hurd: Evaluate fd before entering the critical section

* sysdeps/hurd/include/hurd/fd.h (HURD_FD_PORT_USE_CANCEL): Evaluate fd
before calling _hurd_critical_section_lock.

4 years agoRewrite iconv option parsing [BZ #19519]
Arjun Shankar [Tue, 7 Jul 2020 18:31:48 +0000 (20:31 +0200)]
Rewrite iconv option parsing [BZ #19519]

This commit replaces string manipulation during `iconv_open' and iconv_prog
option parsing with a structured, flag based conversion specification.  In
doing so, it alters the internal `__gconv_open' interface and accordingly
adjusts its uses.

This change fixes several hangs in the iconv program and therefore includes
a new test to exercise iconv_prog options that originally led to these hangs.
It also includes a new regression test for option handling in the iconv
function.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonss: Remove cryptographic key support from nss_files, nss_nis, nss_nisplus
Florian Weimer [Mon, 6 Jul 2020 18:20:44 +0000 (20:20 +0200)]
nss: Remove cryptographic key support from nss_files, nss_nis, nss_nisplus

The interface has hard-coded buffer sizes and is therefore tied to
DES.  It also does not match current practice where different
services on the same host use different key material.

This change simplifies removal of the sunrpc code.

4 years agosunrpc: Do not export getrpcport by default
Florian Weimer [Mon, 6 Jul 2020 17:19:24 +0000 (19:19 +0200)]
sunrpc: Do not export getrpcport by default

This function looks like an NSS function, but is actually a wrapper
around pmap_getport, so it should only be exported with
--enable-obsolete-rpc.

4 years agosunrpc: Do not export key handling hooks by default
Florian Weimer [Mon, 6 Jul 2020 15:59:26 +0000 (17:59 +0200)]
sunrpc: Do not export key handling hooks by default

__key_encryptsession_pk_LOCAL, __key_decryptsession_pk_LOCAL,
__key_gendes_LOCAL had a default version symbol even without
--enable-obsolete-rpc.

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