platform/upstream/glibc.git
21 months agoriscv: Consolidate the libm-test-ulps
Alistair Francis [Thu, 15 Sep 2022 04:37:10 +0000 (00:37 -0400)]
riscv: Consolidate the libm-test-ulps

Both RV32 and RV64 should have the same libm-test-ulps, so consolidate
them into a single file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
21 months agohurd: Fix SIOCADD/DELRT ioctls
Samuel Thibault [Wed, 21 Sep 2022 17:28:56 +0000 (19:28 +0200)]
hurd: Fix SIOCADD/DELRT ioctls

The hurd network stack uses struct ifrtreq rather than ortentry.

21 months agohurd: Drop struct rtentry and in6_rtmsg
Samuel Thibault [Wed, 21 Sep 2022 17:28:25 +0000 (19:28 +0200)]
hurd: Drop struct rtentry and in6_rtmsg

These were cargo-culted, they are not used at all in Hurd interfaces.

21 months agohurd: Add _IOT_ifrtreq to <net/route.h>
Damien Zammit [Wed, 21 Sep 2022 17:27:39 +0000 (19:27 +0200)]
hurd: Add _IOT_ifrtreq to <net/route.h>

So that we can use struct ifrtreq in ioctls.

21 months agoelf: Use C11 atomics on _dl_mcount
Adhemerval Zanella [Tue, 20 Sep 2022 19:04:13 +0000 (16:04 -0300)]
elf: Use C11 atomics on _dl_mcount

All atomic operation are counters, so relaxed MO should be suffice.

Checked on x86_64-linux-gnu.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
21 months agohurd: Use IF_NAMESIZE rather than IFNAMSIZ
Samuel Thibault [Wed, 21 Sep 2022 06:51:50 +0000 (08:51 +0200)]
hurd: Use IF_NAMESIZE rather than IFNAMSIZ

The latter is not available without __USE_MISC.

21 months agohurd: Add ifrtreq structure to net/route.h
Damien Zammit [Tue, 20 Sep 2022 22:41:31 +0000 (00:41 +0200)]
hurd: Add ifrtreq structure to net/route.h

As used by the hurdish route ioctls.

21 months agohppa: undef __ASSUME_SET_ROBUST_LIST
John David Anglin [Tue, 20 Sep 2022 20:14:14 +0000 (20:14 +0000)]
hppa: undef __ASSUME_SET_ROBUST_LIST

QEMU does not support support set_robust_list. Thus, we need
to enable detection of set_robust_list system call.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
21 months agolinux: Use same type for MMAP2_PAGE_UNIT
Adhemerval Zanella [Thu, 10 Mar 2022 11:07:37 +0000 (08:07 -0300)]
linux: Use same type for MMAP2_PAGE_UNIT

It avoid a possible compiler warning where right size of operator
is converted from a negative value to unsigned.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
21 months agom68k: Enforce 4-byte alignment on internal locks (BZ #29537)
Adhemerval Zanella [Tue, 30 Aug 2022 13:33:15 +0000 (10:33 -0300)]
m68k: Enforce 4-byte alignment on internal locks (BZ #29537)

A new internal definition, __LIBC_LOCK_ALIGNMENT, is used to force
the 4-byte alignment only for m68k, other architecture keep the
natural alignment of the type used internally (and hppa does not
require 16-byte alignment for kernel-assisted CAS).

Reviewed-by: Florian Weimer <fweimer@redhat.com>
21 months agonss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816)
Florian Weimer [Tue, 13 Sep 2022 14:11:40 +0000 (16:11 +0200)]
nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816)

getent implicitly passes AI_ADDRCONFIG to getaddrinfo by default.
Use --no-addrconfig to suppress that, so that both IPv4 and IPv6
lookups succeed even if the address family is not supported by the
host.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
21 months agonss: Implement --no-addrconfig option for getent
Florian Weimer [Tue, 13 Sep 2022 14:10:20 +0000 (16:10 +0200)]
nss: Implement --no-addrconfig option for getent

The ahosts, ahostsv4, ahostsv6 commands unconditionally pass
AI_ADDRCONFIG to getaddrinfo, which is not always desired.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
21 months agogconv: Use 64-bit interfaces in gconv_parseconfdir (bug 29583)
Florian Weimer [Tue, 20 Sep 2022 10:12:43 +0000 (12:12 +0200)]
gconv: Use 64-bit interfaces in gconv_parseconfdir (bug 29583)

It's possible that inode numbers are outside the 32-bit range.
The existing code only handles the in-libc case correctly, and
still uses the legacy interfaces when building iconv.

Suggested-by: Helge Deller <deller@gmx.de>
21 months agoelf: Implement force_first handling in _dl_sort_maps_dfs (bug 28937)
Florian Weimer [Tue, 20 Sep 2022 09:00:42 +0000 (11:00 +0200)]
elf: Implement force_first handling in _dl_sort_maps_dfs (bug 28937)

The implementation in _dl_close_worker requires that the first
element of l_initfini is always this very map (“We are always the
zeroth entry, and since we don't include ourselves in the
dependency analysis start at 1.”).  Rather than fixing that
assumption, this commit adds an implementation of the force_first
argument to the new dependency sorting algorithm.  This also means
that the directly dlopen'ed shared object is always initialized last,
which is the least surprising behavior in the presence of cycles.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
21 months agoLinux: Do not skip d_ino == 0 entries in readdir, readdir64 (bug 12165)
Florian Weimer [Mon, 19 Sep 2022 06:10:41 +0000 (08:10 +0200)]
Linux: Do not skip d_ino == 0 entries in readdir, readdir64 (bug 12165)

POSIX does not say this value is special.  For example, old XFS file
systems may still use inode number zero.

Also update the comment regarding ENOENT.  Linux may return ENOENT
for some file systems.

22 months agohurd: Factorize at/non-at functions
Samuel Thibault [Sat, 17 Sep 2022 19:47:57 +0000 (19:47 +0000)]
hurd: Factorize at/non-at functions

Non-at functions can be implemented by just calling the corresponding at
function with AT_FDCWD and zero at_flags.

In the linkat case, the at behavior is different (O_NOLINK), so this introduces
__linkat_common to pass O_NOLINK as appropriate.

lstat functions can also be implemented with fstatat by adding
__fstatat64_common which takes a flags parameter in addition to the at_flags
parameter,

In the end this factorizes chmod, chown, link, lstat64, mkdir, readlink,
rename, stat64, symlink, unlink, utimes.

This also makes __lstat, __lxstat64, __stat and __xstat64 directly use
__fstatat64_common instead of __lstat64 or __stat64.

22 months agotst-sprintf-errno: Update Hurd message length
Samuel Thibault [Sat, 17 Sep 2022 15:42:42 +0000 (17:42 +0200)]
tst-sprintf-errno: Update Hurd message length

03ad444e8e08 ("mach: Fix incoherency between perror and strerror") fixesd
the output of error messages, but tst-sprintf-errno.c was still checking
the old (erroneous) format length. This updates the expected output length
according to the 03ad444e8e08 fix.

22 months agoRISC-V: Allow long jumps to __syscall_error
Łukasz Stelmach [Fri, 16 Sep 2022 19:31:27 +0000 (21:31 +0200)]
RISC-V: Allow long jumps to __syscall_error

__syscall_error may end up farther than 1MiB away from a caller,
especially when linking statically large binaries. tail allows for
4GiB jumps and is reduced to j when a linked symbol is within range.

Fixes: 36960f0c76 ("RISC-V: Linux Syscall Interface")
Fixes: 7f33b09c65 ("RISC-V: Linux ABI")
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
22 months agohurd: Make readlink* just reopen the file used for stat
Samuel Thibault [Thu, 15 Sep 2022 19:53:57 +0000 (21:53 +0200)]
hurd: Make readlink* just reopen the file used for stat

9e5c991106cb ("hurd: Fix readlink() hanging on fifo") separated opening
the file for the stat call from opening the file for the read call. That
however opened a small window for the file to change. Better make this
atomic by reopening the file with O_READ.

22 months agohurd: Fix readlink() hanging on fifo
Samuel Thibault [Wed, 14 Sep 2022 16:52:52 +0000 (18:52 +0200)]
hurd: Fix readlink() hanging on fifo

readlink() opens the target with O_READ to be able to read the symlink
content. When the target is actually a fifo, that would hang waiting for a
writer (caught in the coreutils testsuite). We thus have to first lookup the
target without O_READ to perform io_stat and lookout for fifos, and only
after checking the symlink type, we can re-lookup with O_READ.

22 months agoFix BRE typos in check-safety.sh
Paul Eggert [Wed, 14 Sep 2022 05:10:45 +0000 (00:10 -0500)]
Fix BRE typos in check-safety.sh

* manual/check-safety.sh: Fix BRE portability typos.
POSIX says \] produces undefined results.

22 months agoMakerules: fix MAKEFLAGS assignment for upcoming make-4.4 [BZ# 29564]
Sergei Trofimovich [Tue, 13 Sep 2022 17:39:13 +0000 (13:39 -0400)]
Makerules: fix MAKEFLAGS assignment for upcoming make-4.4 [BZ# 29564]

make-4.4 will add long flags to MAKEFLAGS variable:

    * WARNING: Backward-incompatibility!
      Previously only simple (one-letter) options were added to the MAKEFLAGS
      variable that was visible while parsing makefiles.  Now, all options
      are available in MAKEFLAGS.

This causes locale builds to fail when long options are used:

    $ make --shuffle
    ...
    make  -C localedata install-locales
    make: invalid shuffle mode: '1662724426r'

The change fixes it by passing eash option via whitespace and dashes.
That way option is appended to both single-word form and whitespace
separated form.

While at it fixed --silent mode detection in $(MAKEFLAGS) by filtering
out --long-options. Otherwise options like --shuffle flag enable silent
mode unintentionally. $(silent-make) variable consolidates the checks.

Resolves: BZ# 29564

CC: Paul Smith <psmith@gnu.org>
CC: Siddhesh Poyarekar <siddhesh@gotplt.org>
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoUse relaxed atomics since there is no MO dependence
Wilco Dijkstra [Tue, 13 Sep 2022 10:58:07 +0000 (11:58 +0100)]
Use relaxed atomics since there is no MO dependence

Replace the 3 uses of atomic_bit_set and atomic_bit_test_set with
atomic_fetch_or_relaxed.  Using relaxed MO is correct since the
atomics are used to ensure memory is released only once.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
22 months agomakedb: fix build with libselinux >= 3.1 (Bug 26233)
Aurelien Jarno [Sun, 11 Sep 2022 15:30:17 +0000 (11:30 -0400)]
makedb: fix build with libselinux >= 3.1 (Bug 26233)

glibc doesn't build with libselinux 3.1 that has been released recently
due to new deprecations introduced in that version and the fact that
glibc is built with -Werror by default:

| makedb.c: In function ‘set_file_creation_context’:
| makedb.c:849:3: error: ‘security_context_t’ is deprecated [-Werror=deprecated-declarations]
|   849 |   security_context_t ctx;
|       |   ^~~~~~~~~~~~~~~~~~
| makedb.c:863:3: error: ‘matchpathcon’ is deprecated: Use selabel_lookup instead [-Werror=deprecated-declarations]
|   863 |   if (matchpathcon (outname, S_IFREG | mode, &ctx) == 0 && ctx != NULL)
|       |   ^~
| In file included from makedb.c:50:
| /usr/include/selinux/selinux.h:500:12: note: declared here
|   500 | extern int matchpathcon(const char *path,
|       |            ^~~~~~~~~~~~
| cc1: all warnings being treated as errors

This patch fixes the makedb half of bug 26233 by moving to the new
SELinux APIs and removes the existing compiler pragmas as no longer
required. Upstream API usage feedback gathered by Arjun is integrated
into this version of the fix.

The built makedb was tested and operates as expected on x86_64 with
SELinu in enforcing mode.

No regressions on x86_64 with libselinux 3.3.

Co-authored-by: Arjun Shankar <arjun@redhat.com>
Co-authored-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agotst-sprintf-errno: Update Hurd message output
Samuel Thibault [Sun, 11 Sep 2022 12:20:32 +0000 (14:20 +0200)]
tst-sprintf-errno: Update Hurd message output

03ad444e8e08 ("mach: Fix incoherency between perror and strerror")
fixesd the output of error messages, but tst-sprintf-errno.c was still
checking the old (erroneous) format. This updates the expected output
according to the 03ad444e8e08 fix.

22 months agoUse C11 atomics instead of atomic_decrement(_val)
Wilco Dijkstra [Fri, 9 Sep 2022 13:22:26 +0000 (14:22 +0100)]
Use C11 atomics instead of atomic_decrement(_val)

Replace atomic_decrement and atomic_decrement_val with
atomic_fetch_add_relaxed.

Reviewed-by: DJ Delorie <dj@redhat.com>
22 months agoUse C11 atomics instead atomic_add(_zero)
Wilco Dijkstra [Fri, 9 Sep 2022 13:11:23 +0000 (14:11 +0100)]
Use C11 atomics instead atomic_add(_zero)

Replace atomic_add and atomic_add_zero with atomic_fetch_add_relaxed.

Reviewed-by: DJ Delorie <dj@redhat.com>
22 months agomktime: improve heuristic for ca-1986 Indiana DST
Paul Eggert [Fri, 9 Sep 2022 01:08:32 +0000 (20:08 -0500)]
mktime: improve heuristic for ca-1986 Indiana DST

This patch syncs mktime.c from Gnulib, fixing a
problem reported by Mark Krenz <https://bugs.gnu.org/48085>,
and it should fix BZ#29035 too.
* time/mktime.c (__mktime_internal): Be more generous about
accepting arguments with the wrong value of tm_isdst, by falling
back to a one-hour DST difference if we find no nearby DST that is
unusual.  This fixes a problem where "1986-04-28 00:00 EDT" was
rejected when TZ="America/Indianapolis" because the nearest DST
timestamp occurred in 1970, a temporal distance too great for the
old heuristic.  This also also narrows the search a bit, which
is a minor performance win.

22 months agoAssume HAVE_TZSET in time/mktime.c
Paul Eggert [Fri, 9 Sep 2022 01:08:32 +0000 (20:08 -0500)]
Assume HAVE_TZSET in time/mktime.c

This patch does not affect glibc.  It affects only Gnulib-specific
code and is for coordination with Gnulib.

22 months agoelf: Fix hwcaps string size overestimation
Javier Pello [Mon, 5 Sep 2022 18:09:01 +0000 (20:09 +0200)]
elf: Fix hwcaps string size overestimation

Commit dad90d528259b669342757c37dedefa8577e2636 added glibc-hwcaps
support for LD_LIBRARY_PATH and, for this, it adjusted the total
string size required in _dl_important_hwcaps. However, in doing so
it inadvertently altered the calculation of the size required for
the power set strings, as the computation of the power set string
size depended on the first value assigned to the total variable,
which is later shifted, resulting in overallocation of string
space. Fix this now by using a different variable to hold the
string size required for glibc-hwcaps.

Signed-off-by: Javier Pello <devel@otheo.eu>
22 months agoerrlist: add missing entry for EDEADLOCK (bug 29545)
Andreas Schwab [Thu, 8 Sep 2022 08:25:21 +0000 (10:25 +0200)]
errlist: add missing entry for EDEADLOCK (bug 29545)

Some architectures (mips, powerpc and sparc) define separate values for
EDEADLOCK and EDEADLK.  Readd the errlist entry for EDEADLOCK for those
configurations.  Also use the dependency files from generating the
auxiliary errlist and siglist files.

22 months agoDo not define static_assert or thread_local in headers for C2x
Joseph Myers [Wed, 7 Sep 2022 18:39:28 +0000 (18:39 +0000)]
Do not define static_assert or thread_local in headers for C2x

C2x makes static_assert and thread_local into keywords, removing the
definitions as macros in assert.h and threads.h.  Thus, disable those
macros in those glibc headers for C2x.

The disabling is done based on a combination of language version and
__GNUC_PREREQ, *not* based on __GLIBC_USE (ISOC2X), on the principle
that users of the header (when requesting C11 or later APIs - not
assert.h for C99 and older API versions) should always have the names
static_assert or thread_local available after inclusion of the header,
whether as a keyword or as a macro.  Thus, when using a compiler
without the keywords (whether an older compiler, possibly in C2x mode,
or _GNU_SOURCE with any compiler but in an older language mode, for
example) the macros should be defined, even when C2x APIs have been
requested.  The __GNUC_PREREQ conditionals here may well need updating
with the versions of other compilers that gained support for these
keywords in C2x mode.

Tested for x86_64.

22 months agomalloc: Use C11 atomics rather than atomic_exchange_and_add
Wilco Dijkstra [Tue, 6 Sep 2022 15:49:01 +0000 (16:49 +0100)]
malloc: Use C11 atomics rather than atomic_exchange_and_add

Replace a few counters using atomic_exchange_and_add with
atomic_fetch_add_relaxed.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
22 months agoAdd NEWS entry for CVE-2022-39046
Siddhesh Poyarekar [Tue, 6 Sep 2022 13:31:50 +0000 (09:31 -0400)]
Add NEWS entry for CVE-2022-39046

22 months agoelf: Rename _dl_sort_maps parameter from skip to force_first
Florian Weimer [Tue, 6 Sep 2022 05:38:10 +0000 (07:38 +0200)]
elf: Rename _dl_sort_maps parameter from skip to force_first

The new implementation will not be able to skip an arbitrary number
of objects.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
22 months agoscripts/dso-ordering-test.py: Generate program run-time dependencies
Florian Weimer [Tue, 6 Sep 2022 05:38:10 +0000 (07:38 +0200)]
scripts/dso-ordering-test.py: Generate program run-time dependencies

The main program needs to depend on all shared objects, even objects
that have link-time dependencies among shared objects.  Filtering
out shared objects that already have an link-time dependencies is not
necessary here; make will do this automatically.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
22 months agomath: x86: Use prefix for FP_INIT_ROUNDMODE
Adhemerval Zanella [Thu, 10 Mar 2022 17:48:44 +0000 (14:48 -0300)]
math: x86: Use prefix for FP_INIT_ROUNDMODE

Not all compilers support the inline asm prefix '%v' to emit the avx
instruction if AVX is enable.  Use a prefix instead.

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

22 months agoscripts/build-many-glibcs.py: Use https:// for sourceware.org Git clones
Florian Weimer [Mon, 5 Sep 2022 13:51:05 +0000 (15:51 +0200)]
scripts/build-many-glibcs.py: Use https:// for sourceware.org Git clones

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
22 months agodebug: test for more required cacellation points (BZ# 29274)
Adhemerval Zanella [Mon, 27 Jun 2022 20:37:45 +0000 (20:37 +0000)]
debug: test for more required cacellation points (BZ# 29274)

Generalize the test for cancellation point in __read_chk to also test
the other fortified functions with required cancellation points.

Since there is not easy way to force some syscalls to block (for
instance pread) the test tests two modes: cancellation on blocked
syscalls and early cancellation on pending request.

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

Co-authored-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
22 months agoelf.h: Remove duplicate definition of VER_FLG_WEAK
Florian Weimer [Mon, 5 Sep 2022 10:11:19 +0000 (12:11 +0200)]
elf.h: Remove duplicate definition of VER_FLG_WEAK

This did not cause a warning before because the token sequence for
the two definitions was identical.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
22 months agosyslog: Remove extra whitespace between timestamp and message (BZ#29544)
Adhemerval Zanella [Mon, 5 Sep 2022 12:34:39 +0000 (09:34 -0300)]
syslog: Remove extra whitespace between timestamp and message (BZ#29544)

The rfc3164 clear states that a single space character must follow
the timestamp field.

Checked on x86_64-linux-gnu.

22 months agoLoongArch: Add soft float support.
caiyinyu [Mon, 22 Aug 2022 08:00:51 +0000 (16:00 +0800)]
LoongArch: Add soft float support.

22 months agoelf: Restore how vDSO dependency is printed with LD_TRACE_LOADED_OBJECTS (BZ #29539)
Adhemerval Zanella [Tue, 30 Aug 2022 16:35:52 +0000 (13:35 -0300)]
elf: Restore how vDSO dependency is printed with LD_TRACE_LOADED_OBJECTS (BZ #29539)

The d7703d3176d225d5743b21811d888619eba39e82 changed how vDSO like
dependencies are printed, instead of just the name and address it
follows other libraries mode and prints 'name => path'.

Unfortunately, this broke some ldd consumer that uses the output to
filter out the program's dependencies.  For instance CMake
bundleutilities module [1], where GetPrequirite uses the regex to filter
out 'name => path' [2].

This patch restore the previous way to print just the name and the
mapping address.

Checked on x86_64-linux-gnu.

[1] https://github.com/Kitware/CMake/tree/master/Tests/BundleUtilities
[2] https://github.com/Kitware/CMake/blob/master/Modules/GetPrerequisites.cmake#L733

Reviewed-by: Florian Weimer <fweimer@redhat.com>
22 months agonptl: x86_64: Use same code for CURRENT_STACK_FRAME and stackinfo_get_sp
Adhemerval Zanella [Tue, 8 Mar 2022 20:31:08 +0000 (17:31 -0300)]
nptl: x86_64: Use same code for CURRENT_STACK_FRAME and stackinfo_get_sp

It avoids the possible warning of uninitialized 'frame' variable when
building with clang:

  ../sysdeps/nptl/jmp-unwind.c:27:42: error: variable 'frame' is
  uninitialized when used here [-Werror,-Wuninitialized]
    __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);

The resulting code is similar to CURRENT_STACK_FRAME.

Checked on x86_64-linux-gnu.

22 months agoApply asm redirections in wchar.h before first use
Raphael Moreira Zinsly [Wed, 24 Aug 2022 14:43:37 +0000 (11:43 -0300)]
Apply asm redirections in wchar.h before first use

Similar to d0fa09a770, but for wchar.h.  Fixes [BZ #27087] by applying
all long double related asm redirections before using functions in
bits/wchar2.h.
Moves the function declarations from wcsmbs/bits/wchar2.h to a new file
wcsmbs/bits/wchar2-decl.h that will be included first in wcsmbs/wchar.h.

Tested with build-many-glibcs.py.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
22 months agoresolv: Fix building tst-resolv-invalid-cname for earlier C standards
Florian Weimer [Tue, 30 Aug 2022 11:30:03 +0000 (13:30 +0200)]
resolv: Fix building tst-resolv-invalid-cname for earlier C standards

This fixes this compiler error:

tst-resolv-invalid-cname.c: In function ‘test_mode_to_string’:
tst-resolv-invalid-cname.c:164:10: error: label at end of compound statement
     case test_mode_num:
          ^~~~~~~~~~~~~

Fixes commit 9caf782276ecea4bc86fc94fbb52779736f3106d
("resolv: Add new tst-resolv-invalid-cname").

22 months agosyslog: Fix large messages (BZ#29536)
Adhemerval Zanella [Sun, 28 Aug 2022 19:52:53 +0000 (16:52 -0300)]
syslog: Fix large messages (BZ#29536)

The a583b6add407c17cd change did not handle large messages that
would require a heap allocation correctly, where the message itself
is not take in consideration.

This patch fixes it and extend the tst-syslog to check for large
messages as well.

Checked on x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoposix: Fix macro expansion producing 'defined' has undefined behavior
Adhemerval Zanella [Wed, 9 Mar 2022 21:22:46 +0000 (18:22 -0300)]
posix: Fix macro expansion producing 'defined' has undefined behavior

The NEED_CHECK_SPEC is defined as:

  #define NEED_CHECK_SPEC \
    (!defined _XBS5_ILP32_OFF32 || !defined _XBS5_ILP32_OFFBIG \
     || !defined _XBS5_LP64_OFF64 || !defined _XBS5_LPBIG_OFFBIG \
     || !defined _POSIX_V6_ILP32_OFF32 || !defined _POSIX_V6_ILP32_OFFBIG \
     || !defined _POSIX_V6_LP64_OFF64 || !defined _POSIX_V6_LPBIG_OFFBIG \
     || !defined _POSIX_V7_ILP32_OFF32 || !defined _POSIX_V7_ILP32_OFFBIG \
     || !defined _POSIX_V7_LP64_OFF64 || !defined _POSIX_V7_LPBIG_OFFBIG)

Which is undefined behavior accordingly to C Standard (Preprocessing
directives, p4).

Checked on x86_64-linux-gnu.

22 months agostdlib: Fix macro expansion producing 'defined' has undefined behavior
Adhemerval Zanella [Wed, 9 Mar 2022 18:36:53 +0000 (15:36 -0300)]
stdlib: Fix macro expansion producing 'defined' has undefined behavior

The FPIOCONST_HAVE_EXTENDED_RANGE is defined as:

  #define FPIOCONST_HAVE_EXTENDED_RANGE \
    ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
    || __HAVE_DISTINCT_FLOAT128)

Which is undefined behavior accordingly to C Standard (Preprocessing
directives, p4).

Checked on x86_64-linux-gnu.

22 months agoS390: Always use svc 0
Stefan Liebler [Thu, 25 Aug 2022 10:17:48 +0000 (12:17 +0200)]
S390: Always use svc 0

On s390x syscalls are triggered by svc instruction. One can
pass the syscall number encoded in the instruction "svc 123"
or by storing it in r1:
lghi r1,123
svc 0

If the syscall number is encoded in the instruction, this can
cause broken syscall restarts.  Therefore this patch is now just
passing the syscall number in r1.

See also kernel-commit:
"s390/signal: switch to using vdso for sigreturn and syscall restart"
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/s390/[%e2%80%a6]call.c?h=v6.0-rc1&id=df29a7440c4b5c65765c8f60396b3b13063e24e9

As information, the "svc 0" feature was introduced in kernel 2.5.62:
commit b5aad611393ef2e132e3648fa4c6e56a9cfa8708

22 months agonss_dns: Rewrite _nss_dns_gethostbyname4_r using current interfaces
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
nss_dns: Rewrite _nss_dns_gethostbyname4_r using current interfaces

Introduce struct alloc_buffer to this function, and use it and
struct ns_rr_cursor in gaih_getanswer_slice.  Adjust gaih_getanswer
and gaih_getanswer_noaaaa accordingly.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add new tst-resolv-invalid-cname
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add new tst-resolv-invalid-cname

This test checks resolution through CNAME chains that do not contain
host names (bug 12154).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agonss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)

If the name is not a host name, skip adding it to the result, instead
of reporting query failure.  This fixes bug 12154 for getaddrinfo.

This commit still keeps the old parsing code, and only adjusts when
a host name is copied.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agonss_dns: Rewrite getanswer_r to match getanswer_ptr (bug 12154, bug 29305)
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
nss_dns: Rewrite getanswer_r to match getanswer_ptr (bug 12154, bug 29305)

Allocate the pointer arrays only at the end, when their sizes
are known.  This addresses bug 29305.

Skip over invalid names instead of failing lookups.  This partially
fixes bug 12154 (for gethostbyname, fixing getaddrinfo requires
different changes).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agonss_dns: Remove remnants of IPv6 address mapping
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
nss_dns: Remove remnants of IPv6 address mapping

res_use_inet6 always returns false since commit 3f8b44be0a658266adff5
("resolv: Remove support for RES_USE_INET6 and the inet6 option").

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agonss_dns: Rewrite _nss_dns_gethostbyaddr2_r and getanswer_ptr
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
nss_dns: Rewrite _nss_dns_gethostbyaddr2_r and getanswer_ptr

The simplification takes advantage of the split from getanswer_r.
It fixes various aliases issues, and optimizes NSS buffer usage.
The new DNS packet parsing helpers are used, too.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agonss_dns: Split getanswer_ptr from getanswer_r
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
nss_dns: Split getanswer_ptr from getanswer_r

And expand the use of name_ok and qtype in getanswer_ptr (the
former also in getanswer_r).

After further cleanups, not much code will be shared between the
two functions.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add DNS packet parsing helpers geared towards wire format
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add DNS packet parsing helpers geared towards wire format

The public parser functions around the ns_rr record type produce
textual domain names, but usually, this is not what we need while
parsing DNS packets within glibc.  This commit adds two new helper
functions, __ns_rr_cursor_init and __ns_rr_cursor_next, for writing
packet parsers, and struct ns_rr_cursor, struct ns_rr_wire as
supporting types.

In theory, it is possible to avoid copying the owner name
into the rname field in __ns_rr_cursor_next, but this would need
more functions that work on compressed names.

Eventually, __res_context_send could be enhanced to preserve the
result of the packet parsing that is necessary for matching the
incoming UDP packets, so that this works does not have to be done
twice.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add internal __ns_name_length_uncompressed function
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add internal __ns_name_length_uncompressed function

This function is useful for checking that the question name is
uncompressed (as it should be).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add the __ns_samebinaryname function
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add the __ns_samebinaryname function

During packet parsing, only the binary name is available.  If the name
equality check is performed before conversion to text, we can sometimes
skip the last step.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add internal __res_binary_hnok function
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add internal __res_binary_hnok function

During package parsing, only the binary representation is available,
and it is convenient to check that directly for conformance with host
name requirements.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add tst-resolv-aliases
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add tst-resolv-aliases

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoresolv: Add tst-resolv-byaddr for testing reverse lookup
Florian Weimer [Tue, 30 Aug 2022 08:02:49 +0000 (10:02 +0200)]
resolv: Add tst-resolv-byaddr for testing reverse lookup

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
22 months agoLoongArch: Use __builtin_{fmax,fmaxf,fmin,fminf} with GCC >= 13
Xi Ruoyao [Sat, 20 Aug 2022 08:43:44 +0000 (16:43 +0800)]
LoongArch: Use __builtin_{fmax,fmaxf,fmin,fminf} with GCC >= 13

GCC 13 compiles these built-ins to {fmax,fmin}.{s/d} instruction, use
them instead of the generic implementation.

Link: https://gcc.gnu.org/r13-2085
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
22 months agoLoongArch: Fix ptr mangling/demangling features.
caiyinyu [Wed, 17 Aug 2022 00:17:39 +0000 (08:17 +0800)]
LoongArch: Fix ptr mangling/demangling features.

22 months agonscd: Fix netlink cache invalidation if epoll is used [BZ #29415]
Fabian Vogt [Wed, 27 Jul 2022 09:44:07 +0000 (11:44 +0200)]
nscd: Fix netlink cache invalidation if epoll is used [BZ #29415]

Processes cache network interface information such as whether IPv4 or IPv6
are enabled. This is only checked again if the "netlink timestamp" provided
by nscd changed, which is triggered by netlink socket activity.

However, in the epoll handler for the netlink socket, it was missed to
assign the new timestamp to the nscd database. The handler for plain poll
did that properly, copy that over.

This bug caused that e.g. processes which started before network
configuration got unusuable addresses from getaddrinfo, like IPv6 only even
though only IPv4 is available:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1041

It's a bit hard to reproduce, so I verified this by checking the timestamp
on calls to __check_pf manually. Without this patch it's stuck at 1, now
it's increasing on network changes as expected.

Signed-off-by: Fabian Vogt <fvogt@suse.de>
22 months agoAdd test for bug 29530
Andreas Schwab [Mon, 29 Aug 2022 13:05:40 +0000 (15:05 +0200)]
Add test for bug 29530

This tests for a bug that was introduced in commit edc1686af0 ("vfprintf:
Reuse work_buffer in group_number") and fixed as a side effect of commit
6caddd34bd ("Remove most vfprintf width/precision-dependent allocations
(bug 14231, bug 26211).").

22 months agoMakeconfig: Set pie-ccflag to -fPIE by default [BZ# 29514]
Richard Henderson [Tue, 23 Aug 2022 20:49:23 +0000 (13:49 -0700)]
Makeconfig: Set pie-ccflag to -fPIE by default [BZ# 29514]

We should default to the larger code model, in order to support
larger applications built with -static -pie.  This should be
consistent with pic-ccflag, which defaults to -fPIC.

Remove the now redundant override from sysdeps/sparc/Makefile.
Note that -fno-pie and -fno-PIE have the same effect.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
22 months agohurd: Fix vm_size_t incoherencies
Samuel Thibault [Sun, 28 Aug 2022 23:42:47 +0000 (01:42 +0200)]
hurd: Fix vm_size_t incoherencies

In gnumach, 3e1702a65fb3 ("add rpc_versions for vm types") changed the type
of vm_size_t, making it always a unsigned long. This made it incompatible on
x86 with size_t. Even if we may want to revert it to unsigned int, it's
better to fix the types of parameters according to the .defs files.

22 months agomach: Make xpg_strerror_r set a message on error
Samuel Thibault [Sat, 27 Aug 2022 12:46:23 +0000 (14:46 +0200)]
mach: Make xpg_strerror_r set a message on error

posix advises to have strerror_r fill a message even when we are returning
an error.

This makes mach's xpg_strerror_r do this, like the generic version does.

Spotted by the libunistring testsuite test-strerror_r

22 months agomach: Fix incoherency between perror and strerror
Samuel Thibault [Sat, 27 Aug 2022 11:52:46 +0000 (13:52 +0200)]
mach: Fix incoherency between perror and strerror

08d2024b4167 ("string: Simplify strerror_r") inadvertently made
__strerror_r print unknown error system in decimal while the original
code was printing it in hexadecimal. perror was kept printing in
hexadecimal in 725eeb4af14c ("string: Use tls-internal on strerror_l"),
let us keep both coherent.

This also fixes a duplicate ':'

Spotted by the libunistring testsuite test-perror2

22 months agoelf: Call __libc_early_init for reused namespaces (bug 29528)
Florian Weimer [Fri, 26 Aug 2022 19:15:43 +0000 (21:15 +0200)]
elf: Call __libc_early_init for reused namespaces (bug 29528)

libc_map is never reset to NULL, neither during dlclose nor on a
dlopen call which reuses the namespace structure.  As a result, if a
namespace is reused, its libc is not initialized properly.  The most
visible result is a crash in the <ctype.h> functions.

To prevent similar bugs on namespace reuse from surfacing,
unconditionally initialize the chosen namespace to zero using memset.

22 months agocsu: Change start code license to have link exception
Szabolcs Nagy [Mon, 22 Aug 2022 13:21:53 +0000 (14:21 +0100)]
csu: Change start code license to have link exception

The start code can get linked into dynamic linked executables where
LGPL would require shipping the source or linkable binaries when the
executable is distributed.

On some targets the license exception was missing in start.S (which
is compiled into crt1.o and Scrt1.o which may end up linked into PDE
and PIE binaries).

I did not review what other code may end up in executables, just
fixed the start.S license inconsistency across targets.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
22 months agos390: Move hwcaps/platform names out of _rtld_global_ro
Florian Weimer [Thu, 25 Aug 2022 14:34:20 +0000 (16:34 +0200)]
s390: Move hwcaps/platform names out of _rtld_global_ro

Changes to these arrays are often backported to stable releases,
but additions to these arrays shift the offsets of the following
_rltd_global_ro members, thus breaking the GLIBC_PRIVATE ABI.

Obviously, this change is itself an internal ABI break, but at least
it will avoid further ABI breaks going forward.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
22 months agoRevert "Detect ld.so and libc.so version inconsistency during startup"
Florian Weimer [Thu, 25 Aug 2022 16:46:41 +0000 (18:46 +0200)]
Revert "Detect ld.so and libc.so version inconsistency during startup"

This reverts commit 6f85dbf102ad7982409ba0fe96886caeb6389fef.

Once this change hits the release branches, it will require relinking
of all statically linked applications before static dlopen works
again, for the majority of updates on release branches: The NEWS file
is regularly updated with bug references, so the __libc_early_init
suffix changes, and static dlopen cannot find the function anymore.

While this ABI check is still technically correct (we do require
rebuilding & relinking after glibc updates to keep static dlopen
working), it is too drastic for stable release branches.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
22 months agoAdd NT_LOONGARCH_* from Linux 5.19 to elf.h
Joseph Myers [Wed, 24 Aug 2022 18:19:13 +0000 (18:19 +0000)]
Add NT_LOONGARCH_* from Linux 5.19 to elf.h

Add the new NT_LOONGARCH_* constants from Linux 5.19 to glibc's elf.h.

Tested for x86_64.

22 months agoDetect ld.so and libc.so version inconsistency during startup
Florian Weimer [Wed, 24 Aug 2022 15:35:36 +0000 (17:35 +0200)]
Detect ld.so and libc.so version inconsistency during startup

The files NEWS, include/link.h, and sysdeps/generic/ldsodefs.h
contribute to the version fingerprint used for detection.  The
fingerprint can be further refined using the --with-extra-version-id
configure argument.

_dl_call_libc_early_init is replaced with _dl_lookup_libc_early_init.
The new function is used store a pointer to libc.so's
__libc_early_init function in the libc_map_early_init member of the
ld.so namespace structure.  This function pointer can then be called
directly, so the separate invocation function is no longer needed.

The versioned symbol lookup needs the symbol versioning data
structures, so the initialization of libc_map and libc_map_early_init
is now done from _dl_check_map_versions, after this information
becomes available.  (_dl_map_object_from_fd does not set this up
in time, so the initialization code had to be moved from there.)
This means that the separate initialization code can be removed from
dl_main because _dl_check_map_versions covers all maps, including
the initial executable loaded by the kernel.  The lookup still happens
before relocation and the invocation of IFUNC resolvers, so IFUNC
resolvers are protected from ABI mismatch.

The __libc_early_init function pointer is not protected because
so little code runs between the pointer write and the invocation
(only dynamic linker code and IFUNC resolvers).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
22 months agoMerge getopt patch from Gnulib
Paul Eggert [Wed, 24 Aug 2022 04:16:40 +0000 (21:16 -0700)]
Merge getopt patch from Gnulib

* posix/getopt.c [!_LIBC]: Merge _WIN32 patch from Gnulib
so that these source files are identical.
This makes no difference for glibc.

22 months agoMerge _GL_UNUSED C23 patch from Gnulib
Paul Eggert [Wed, 24 Aug 2022 04:16:39 +0000 (21:16 -0700)]
Merge _GL_UNUSED C23 patch from Gnulib

* posix/getopt.c (_getopt_initialize):
* sysdeps/posix/tempname.c (try_dir, try_nocreate):
Put _GL_UNUSED before args instead of after.
This makes no difference for glibc.
It is needed for Gnulib when being compiled on
non-GCC C23 compilers.

22 months agoLoongArch: Fix dl-machine.h code formatting.
Xi Ruoyao [Wed, 24 Aug 2022 01:27:04 +0000 (09:27 +0800)]
LoongArch: Fix dl-machine.h code formatting.

No functional change.

22 months agoscripts/glibcelf.py: Add hashing support
Florian Weimer [Fri, 19 Aug 2022 09:16:32 +0000 (11:16 +0200)]
scripts/glibcelf.py: Add hashing support

ELF and GNU hashes can now be computed using the elf_hash and
gnu_hash functions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
22 months agohurd: Fix starting static binaries with stack protection enabled
Samuel Thibault [Mon, 22 Aug 2022 20:34:31 +0000 (22:34 +0200)]
hurd: Fix starting static binaries with stack protection enabled

gcc introduces gs:0x14 accesses in most functions, so we need some tcbhead
to be ready very early during initialization.  This configures a static area
which can be referenced by various protected functions, until proper TLS is
set up.

22 months agohtl: Make pthread*_cond_timedwait register wref before releasing mutex
Samuel Thibault [Mon, 22 Aug 2022 20:27:24 +0000 (22:27 +0200)]
htl: Make pthread*_cond_timedwait register wref before releasing mutex

Otherwise another thread could be rightly trying to destroy the condition,
see e.g. tst-cond20.

22 months agohtl: make __pthread_hurd_cond_timedwait_internal check mutex is held
Samuel Thibault [Mon, 22 Aug 2022 20:25:27 +0000 (22:25 +0200)]
htl: make __pthread_hurd_cond_timedwait_internal check mutex is held

Like __pthread_cond_timedwait_internal already does.

22 months agoAdd AArch64 HWCAP2_* constants from Linux 5.19
Joseph Myers [Mon, 22 Aug 2022 14:59:39 +0000 (14:59 +0000)]
Add AArch64 HWCAP2_* constants from Linux 5.19

Linux 5.19 adds more HWCAP2_* values for AArch64; add these to its
bits/hwcap.h header in glibc.

Tested with build-many-glibcs.py for aarch64-linux-gnu.

22 months agoAdd AGROUP from Linux 5.19 to sys/acct.h, remove Alpha version (bug 29502)
Joseph Myers [Mon, 22 Aug 2022 14:16:57 +0000 (14:16 +0000)]
Add AGROUP from Linux 5.19 to sys/acct.h, remove Alpha version (bug 29502)

Linux 5.19 adds a new accounting flag AGROUP; add it to the
enumeration in sys/acct.h.

This shows up that the Alpha-specific variant of this header has a
different set of constants and struct acct, which appear to be the
constants and structure layout from Linux 2.0.  These were changed
some time between Linux 2.0 and Linux 2.2; I see no evidence of an
Alpha-specific layout or set of constants, but haven't checked the
detailed Linux kernel history between those versions.  Rather, it
looks like tha Alpha-specific header was originally needed because of
the use of types in the kernel structure (such as uid_t and gid_t)
that had different sizes on Alpha, and when glibc was updated for
changes to the structure and constants in the kernel

1998-10-02  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

        * sysdeps/unix/sysv/linux/sys/acct.h: Bring in sync with current
        linux 2.1 version.

that simply omitted to do anything about the Alpha version.

Thus, remove the Alpha version in order to get the updated definitions
into use on Alpha, as I don't think the interfaces are actually
different for Alpha with any kernel version supported by glibc.

Tested for x86_64, and with build-many-glibcs.py for alpha-linux-gnu.

22 months agoalpha: Fix generic brk system call emulation in __brk_call (bug 29490)
Florian Weimer [Mon, 22 Aug 2022 09:04:47 +0000 (11:04 +0200)]
alpha: Fix generic brk system call emulation in __brk_call (bug 29490)

The kernel special-cases the zero argument for alpha brk, and we can
use that to restore the generic Linux error handling behavior.

Fixes commit b57ab258c1140bc45464b4b9908713e3e0ee35aa ("Linux:
Introduce __brk_call for invoking the brk system call").

22 months agohurd: Assume non-suid during bootstrap
Samuel Thibault [Fri, 19 Aug 2022 00:16:54 +0000 (02:16 +0200)]
hurd: Assume non-suid during bootstrap

We do not have a hurd data block only when bootstrapping the system, in
which case we don't have a notion of suid yet anyway.

This is needed, otherwise init_standard_fds would check that standard
file descriptors are allocated, which is meaningless during bootstrap.

23 months agoUse binutils 2.39 branch in build-many-glibcs.py
Joseph Myers [Thu, 18 Aug 2022 13:16:56 +0000 (13:16 +0000)]
Use binutils 2.39 branch in build-many-glibcs.py

This patch makes build-many-glibcs.py use binutils 2.39 branch.

Tested with build-many-glibcs.py (compilers and glibcs builds).  Note:
binutils 2.39 shows the same failures for i686-linux-gnu-no-pie,
x86_64-linux-gnu-no-pie and x86_64-linux-gnu-x32-no-pie building the
glibc testsuite as binutils mainline does.

23 months agoS390: Fix werror=unused-variable in ifunc-impl-list.c.
Stefan Liebler [Thu, 18 Aug 2022 07:10:48 +0000 (09:10 +0200)]
S390: Fix werror=unused-variable in ifunc-impl-list.c.

If the architecture level set is high enough, no IFUNCs are used at
all and the variable i would be unused.  Then the build fails with:
../sysdeps/s390/multiarch/ifunc-impl-list.c: In function ‘__libc_ifunc_impl_list’:
../sysdeps/s390/multiarch/ifunc-impl-list.c:76:10: error: unused variable ‘i’ [-Werror=unused-variable]
   76 |   size_t i = max;
      |          ^
cc1: all warnings being treated as errors

23 months agoEnsure calculations happen with desired rounding mode in y1lf128
Michael Hudson-Doyle [Thu, 11 Aug 2022 23:29:31 +0000 (11:29 +1200)]
Ensure calculations happen with desired rounding mode in y1lf128

math/test-float128-y1 fails on x86_64 and ppc64el with gcc 12 and -O3,
because code inside a block guarded by SET_RESTORE_ROUNDL is being moved
after the rounding mode has been restored. Use math_force_eval to
prevent this (and insert some math_opt_barrier calls to prevent code
from being moved before the rounding mode is set).

Fixes #29463

Reviewed-By: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
23 months agolocaledata: Convert French language locales (fr_*) to UTF-8
Florian Weimer [Wed, 17 Aug 2022 07:10:20 +0000 (09:10 +0200)]
localedata: Convert French language locales (fr_*) to UTF-8

23 months agoLinux: Fix enum fsconfig_command detection in <sys/mount.h>
Florian Weimer [Tue, 16 Aug 2022 07:25:23 +0000 (09:25 +0200)]
Linux: Fix enum fsconfig_command detection in <sys/mount.h>

The #ifdef FSOPEN_CLOEXEC check did not work because the macro
was always defined in this header prior to the check, so that
the <linux/mount.h> contents did not matter.

Fixes commit 774058d72942249f71d74e7f2b639f77184160a6
("linux: Fix sys/mount.h usage with kernel headers").

23 months agoelf: Run tst-audit-tlsdesc, tst-audit-tlsdesc-dlopen everywhere
Florian Weimer [Tue, 16 Aug 2022 06:27:50 +0000 (08:27 +0200)]
elf: Run tst-audit-tlsdesc, tst-audit-tlsdesc-dlopen everywhere

The test is valid for all TLS models, but we want to make a reasonable
effort to test the GNU2 model specifically.  For example, aarch64
defaults to GNU2, but does not have -mtls-dialect=gnu2, and the test
was not run there.

Suggested-by: Martin Coufal <mcoufal@redhat.com>
23 months agoMove ip_mreqn structure from Linux to generic
Samuel Thibault [Sat, 13 Aug 2022 21:02:51 +0000 (23:02 +0200)]
Move ip_mreqn structure from Linux to generic

I.e. from sysdeps/unix/sysv/linux/bits/in.h to netinet/in.h

It is following both the BSD and Linux definitions.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
23 months agomalloc: Do not use MAP_NORESERVE to allocate heap segments
Florian Weimer [Mon, 15 Aug 2022 14:45:40 +0000 (16:45 +0200)]
malloc: Do not use MAP_NORESERVE to allocate heap segments

Address space for heap segments is reserved in a mmap call with
MAP_ANONYMOUS | MAP_PRIVATE and protection flags PROT_NONE.  This
reservation does not count against the RSS limit of the process or
system.  Backing memory is allocated using mprotect in alloc_new_heap
and grow_heap, and at this point, the allocator expects the kernel
to provide memory (subject to memory overcommit).

The SIGSEGV that might generate due to MAP_NORESERVE (according to
the mmap manual page) does not seem to occur in practice, it's always
SIGKILL from the OOM killer.  Even if there is a way that SIGSEGV
could be generated, it is confusing to applications that this only
happens for secondary heaps, not for large mmap-based allocations,
and not for the main arena.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
23 months agoLinux: Terminate subprocess on late failure in tst-pidfd (bug 29485)
Florian Weimer [Mon, 15 Aug 2022 14:43:59 +0000 (16:43 +0200)]
Linux: Terminate subprocess on late failure in tst-pidfd (bug 29485)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
23 months agonon-linux: bits/in.h: Add more RFC options
Samuel Thibault [Mon, 15 Aug 2022 09:25:55 +0000 (11:25 +0200)]
non-linux: bits/in.h: Add more RFC options

23 months agoarm: Remove nested functionf rom relocate_pc24
Adhemerval Zanella [Tue, 26 Jul 2022 13:34:01 +0000 (10:34 -0300)]
arm: Remove nested functionf rom relocate_pc24

Checked on arm-linux-gnueabihf.

23 months agolinux: Fix sys/mount.h usage with kernel headers
Adhemerval Zanella [Wed, 10 Aug 2022 17:24:47 +0000 (14:24 -0300)]
linux: Fix sys/mount.h usage with kernel headers

Now that kernel exports linux/mount.h and includes it on linux/fs.h,
its definitions might clash with glibc exports sys/mount.h.  To avoid
the need to rearrange the Linux header to be always after glibc one,
the glibc sys/mount.h is changed to:

  1. Undefine the macros also used as enum constants.  This covers prior
     inclusion of <linux/mount.h> (for instance MS_RDONLY).

  2. Include <linux/mount.h> based on the usual __has_include check
     (needs to use __has_include ("linux/mount.h") to paper over GCC
     bugs.

  3. Define enum fsconfig_command only if FSOPEN_CLOEXEC is not defined.
     (FSOPEN_CLOEXEC should be a very close proxy.)

  4. Define struct mount_attr if MOUNT_ATTR_SIZE_VER0 is not defined.
     (Added in the same commit on the Linux side.)

This patch also adds some tests to check if including linux/fs.h and
linux/mount.h after and before sys/mount.h does work.

Checked on x86_64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>