]> sourceware.org Git - glibc.git/log
glibc.git
2 months agomanual: clarify defintions of floating point exponent bounds (bug 31518)
Andreas Schwab [Wed, 8 May 2024 14:55:40 +0000 (16:55 +0200)]
manual: clarify defintions of floating point exponent bounds (bug 31518)

For decimal exponent bounds the range is inclusive, for binary exponent
bounds the range is exclusive.

2 months agoLoongArch: Update ulps
caiyinyu [Tue, 21 May 2024 04:06:41 +0000 (12:06 +0800)]
LoongArch: Update ulps

For the log2p1 implementation.

2 months agoLoongArch: Fix tst-gnu2-tls2 compiler error
mengqinggang [Mon, 20 May 2024 09:05:12 +0000 (17:05 +0800)]
LoongArch: Fix tst-gnu2-tls2 compiler error

Add -mno-lsx to tst-gnu2-tlsmod*.c if gcc support -mno-lsx.
Add escape character '\' in vector support test function.

2 months agoresolv: Make _res_opcodes a compat symbol [BZ #31764]
H.J. Lu [Mon, 20 May 2024 20:49:10 +0000 (13:49 -0700)]
resolv: Make _res_opcodes a compat symbol [BZ #31764]

_res_opcodes was exported by accident as a variable.  Fix BZ #31764 by
making _res_opcodes a compat symbol.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
2 months agoi386: Don't define stpncpy alias when used in IFUNC [BZ #31768]
H.J. Lu [Tue, 21 May 2024 00:32:14 +0000 (17:32 -0700)]
i386: Don't define stpncpy alias when used in IFUNC [BZ #31768]

Fix BZ #31768 by not defining stpncpy alias when used in IFUNC.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
2 months agopowerpc: Update ulps
Adhemerval Zanella [Mon, 20 May 2024 15:56:49 +0000 (15:56 +0000)]
powerpc: Update ulps

For the log2p1 implementation.

2 months agoarm: Update ulps
Adhemerval Zanella [Mon, 20 May 2024 15:54:31 +0000 (15:54 +0000)]
arm: Update ulps

For the log2p1 implementation.

2 months agoaarch64: Update ulps
Adhemerval Zanella [Mon, 20 May 2024 15:52:18 +0000 (15:52 +0000)]
aarch64: Update ulps

For the log2p1 implementation.

2 months agomath: Add more details to the test driver output.
Joe Simmons-Talbott [Mon, 20 May 2024 14:09:35 +0000 (14:09 +0000)]
math: Add more details to the test driver output.

Add start and end indicators that identify the test being run in the
verbose output.  Better identify the tests for max errors in the
summary output.  Count each exception checked for each test. Remove
double counting of tests for the check_<type> functions other than
check_float_internal. Rename print_max_error and
print_complex_max_error to check_max_error and check_complex_max_error
respectively since they have side effects.

Co-Authored-By: Carlos O'Donell <carlos@redhat.com>
Reviewed-By: Joseph Myers <josmyers@redhat.com>
2 months agoImplement C23 log2p1
Joseph Myers [Mon, 20 May 2024 13:41:39 +0000 (13:41 +0000)]
Implement C23 log2p1

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the log2p1 functions (log2(1+x): like log1p, but for
base-2 logarithms).

This illustrates the intended structure of implementations of all
these function families: define them initially with a type-generic
template implementation.  If someone wishes to add type-specific
implementations, it is likely such implementations can be both faster
and more accurate than the type-generic one and can then override it
for types for which they are implemented (adding benchmarks would be
desirable in such cases to demonstrate that a new implementation is
indeed faster).

The test inputs are copied from those for log1p.  Note that these
changes make gen-auto-libm-tests depend on MPFR 4.2 (or later).

The bulk of the changes are fairly generic for any such new function.
(sysdeps/powerpc/nofpu/Makefile only needs changing for those
type-generic templates that use fabs.)

Tested for x86_64 and x86, and with build-many-glibcs.py.

2 months agoUpdate syscall lists for Linux 6.9
Joseph Myers [Mon, 20 May 2024 13:10:31 +0000 (13:10 +0000)]
Update syscall lists for Linux 6.9

Linux 6.9 has no new syscalls.  Update the version number in
syscall-names.list to reflect that it is still current for 6.9.

Tested with build-many-glibcs.py.

2 months agoRename procutils_read_file to __libc_procutils_read_file [BZ #31755]
H.J. Lu [Mon, 20 May 2024 01:46:36 +0000 (18:46 -0700)]
Rename procutils_read_file to __libc_procutils_read_file [BZ #31755]

Fix BZ #31755 by renaming the internal function procutils_read_file to
__libc_procutils_read_file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agonearbyint: Don't define alias when used in IFUNC [BZ #31759]
H.J. Lu [Sun, 19 May 2024 23:36:01 +0000 (16:36 -0700)]
nearbyint: Don't define alias when used in IFUNC [BZ #31759]

Fix BZ #31759 by not defining nearbyint aliases when used in IFUNC.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2 months agoPass -nostdlib -nostartfiles together with -r [BZ #31753]
H.J. Lu [Sat, 18 May 2024 03:00:38 +0000 (20:00 -0700)]
Pass -nostdlib -nostartfiles together with -r [BZ #31753]

Since -r in GCC 6/7/8 doesn't imply -nostdlib -nostartfiles, update the
link-static-libc.out rule to also pass -nostdlib -nostartfiles.  This
fixes BZ #31753.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agosocket: Use may_alias on sockaddr structs (bug 19622)
Florian Weimer [Sat, 18 May 2024 07:33:19 +0000 (09:33 +0200)]
socket: Use may_alias on sockaddr structs (bug 19622)

This supports common coding patterns.  The GCC C front end before
version 7 rejects the may_alias attribute on a struct definition
if it was not present in a previous forward declaration, so this
attribute can only be conditionally applied.

This implements the spirit of the change in Austin Group issue 1641.

Suggested-by: Marek Polacek <polacek@redhat.com>
Suggested-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Sam James <sam@gentoo.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agoUse a doubly-linked list for _IO_list_all (bug 27777)
Alexandre Ferrieux [Thu, 16 May 2024 12:54:30 +0000 (05:54 -0700)]
Use a doubly-linked list for _IO_list_all (bug 27777)

This patch fixes BZ #27777 "fclose does a linear search, takes ages when
many FILE* are opened".  Simply put, the master list of opened (FILE*),
namely _IO_list_all, is a singly-linked list.  As a consequence, the
removal of a single element is in O(N), which cripples the performance
of fclose().  The patch switches to a doubly-linked list, yielding O(1)
removal.  The one padding field in struct _IO_FILE, __pad5, is renamed
to _prevchain for a doubly-linked list.  Since fields in struct _IO_FILE
after the _lock field are internal to glibc and opaque to applications.
We can change them as long as the size of struct _IO_FILE is unchanged,
which is checked as the part of glibc ABI with sizes of _IO_2_1_stdin_,
_IO_2_1_stdout_ and _IO_2_1_stderr_.

NB: When _IO_vtable_offset (fp) == 0, copy relocation will cover the
whole struct _IO_FILE.  Otherwise, only fields up to the _lock field
will be copied to applications at run-time.  It is used to check if
the _prevchain field can be safely accessed.

After opening 2 million (FILE*), the fclose() of 100 of them takes quite
a few seconds without the patch, and under 2 seconds with it on a loaded
machine.

No test is added since there are no functional changes.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agopowerpc64: Fix by using the configure value $libc_cv_cc_submachine [BZ #31629]
Manjunath Matti [Thu, 16 May 2024 22:24:36 +0000 (17:24 -0500)]
powerpc64: Fix by using the configure value $libc_cv_cc_submachine [BZ #31629]

This patch ensures that $libc_cv_cc_submachine, which is set from
"--with-cpu", overrides $CFLAGS for configure time tests.

Suggested-by: Peter Bergner <bergner@linux.ibm.com>
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
3 months agobenchtests: Add fclose benchmark
H.J. Lu [Thu, 16 May 2024 15:08:42 +0000 (08:08 -0700)]
benchtests: Add fclose benchmark

Measure duration of 100 fclose calls after opening 1 million FILEs.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agoaarch64/fpu: Add vector variants of cbrt
Joe Ramsay [Tue, 30 Apr 2024 12:49:59 +0000 (13:49 +0100)]
aarch64/fpu: Add vector variants of cbrt

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 months agoaarch64/fpu: Add vector variants of hypot
Joe Ramsay [Tue, 30 Apr 2024 12:49:58 +0000 (13:49 +0100)]
aarch64/fpu: Add vector variants of hypot

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 months agoUse Linux 6.9 in build-many-glibcs.py
Joseph Myers [Thu, 16 May 2024 10:49:30 +0000 (10:49 +0000)]
Use Linux 6.9 in build-many-glibcs.py

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

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

3 months agolocaledata: Fix several issues with the set of characters considered 0-width [BZ...
Jules Bertholet [Fri, 23 Feb 2024 20:54:57 +0000 (20:54 +0000)]
localedata: Fix several issues with the set of characters considered 0-width [BZ #31370]

= `Default_Ignorable_Code_Point`s should have width 0 =

Unicode specifies (https://www.unicode.org/faq/unsup_char.html#3) that characters
with the `Default_Ignorable_Code_Point` property

> should be rendered as completely invisible (and non advancing, i.e. “zero width”),
if not explicitly supported in rendering.

Hence, `wcwidth()` should give them all a width of 0, with two exceptions:

- the soft hyphen (U+00AD SOFT HYPHEN) is assigned width 1 by longstanding precedent
- U+115F HANGUL CHOSEONG FILLER needs a carveout
  due to the unique behavior of the conjoining Korean jamo characters.
  One composed Hangul "syllable block" like 퓛
  is made up of two to three individual component characters, or "jamo".
  These are all assigned an `East_Asian_Width` of `Wide`
  by Unicode, which would normally mean they would all be assigned
  width 2 by glibc; a combination of (leading choseong jamo) +
  (medial jungseong jamo) + (trailing jongseong jamo) would then have width 2 + 2 + 2 = 6.
  However, glibc (and other wcwidth implementations) special-cases jungseong and jongseong,
  assigning them all width 0,
  to ensure that the complete block has width 2 + 0 + 0 = 2 as it should.
  U+115F is meant for use in syllable blocks
  that are intentionally missing a leading jamo;
  it must be assigned a width of 2 even though it has no visible display
  to ensure that the complete block has width 2.

However, `wcwidth()` currently (before this patch)
incorrectly assigns non-zero width to
U+3164 HANGUL FILLER and U+FFA0 HALFWIDTH HANGUL FILLER;
this commit fixes that.

Unicode spec references:
- Hangul:  §3.12 https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G24646 and
  §18.6 https://www.unicode.org/versions/Unicode15.0.0/ch18.pdf#G31028
- `Default_Ignorable_Code_Point`: §5.21 https://www.unicode.org/versions/Unicode15.0.0/ch05.pdf#G40095.

= Non-`Default_Ignorable_Code_Point` format controls should be visible =

The Unicode Standard, §5.21 - Characters Ignored for Display
(https://www.unicode.org/versions/Unicode15.0.0/ch05.pdf#G40095)
says the following:

> A small number of format characters (General_Category = Cf )
> are also not given the Default_Ignorable_Code_Point property.
> This may surprise implementers, who often assume
> that all format characters are generally ignored in fallback display.
> The exact list of these exceptional format characters
> can be found in the Unicode Character Database.
> There are, however, three important sets of such format characters to note:
>
> - prepended concatenation marks
> - interlinear annotation characters
> - Egyptian hieroglyph format controls
>
> The prepended concatenation marks always have a visible display.
> See “Prepended Concatenation Marks” in [*Section 23.2, Layout Controls*](https://www.unicode.org/versions/Unicode15.1.0/ch23.pdf#M9.35858.HeadingBreak.132.Layout.Controls)
> for more discussion of the use and display of these signs.
>
> The other two notable sets of format characters that exceptionally are not ignored
> in fallback display consist of the interlinear annotation characters,
> U+FFF9 INTERLINEAR ANNOTATION ANCHOR through
> U+FFFB INTERLINEAR ANNOTATION TERMINATOR,
> and the Egyptian hieroglyph format controls,
> U+13430 EGYPTIAN HIEROGLYPH VERTICAL JOINER through
> U+1343F EGYPTIAN HIEROGLYPH END WALLED ENCLOSURE.
> These characters should have a visible glyph display for fallback rendering,
> because if they are not displayed,
> it is too easy to misread the resulting displayed text.
> See “Annotation Characters” in [*Section 23.8, Specials*](https://www.unicode.org/versions/Unicode15.1.0/ch23.pdf#M9.21335.Heading.133.Specials),
> as well as [*Section 11.4, Egyptian Hieroglyphs*](https://www.unicode.org/versions/Unicode15.1.0/ch11.pdf#M9.73291.Heading.1418.Egyptian.Hieroglyphs)
> for more discussion of the use and display of these characters.

glibc currently correctly assigns non-zero width to the prepended concatenation marks,
but it incorrectly gives zero width to the interlinear annotation characters
(which a generic terminal cannot interpret)
and the Egyptian hieroglyph format controls
(which are not widely supported in rendering implementations at present).
This commit fixes both these issues as well.

= Derive Hangul syllable type from Unicode data =

Previosuly, the jungseong and jongseong jamo ranges
were hard-coded into the script. With this commit, they are instead parsed
from the HangulSyllableType.txt data file published by Unicode.
This does not affect the end result.

Signed-off-by: Jules Bertholet <julesbertholet@quoi.xyz>
3 months agoLoongArch: Add support for TLS Descriptors
mengqinggang [Wed, 8 May 2024 02:06:15 +0000 (10:06 +0800)]
LoongArch: Add support for TLS Descriptors

This is mostly based on AArch64 and RISC-V implementation.

Add R_LARCH_TLS_DESC32 and R_LARCH_TLS_DESC64 relocations.

For _dl_tlsdesc_dynamic function slow path, temporarily save and restore
all vector registers.

3 months agomath: Add GLIBC_TEST_LIBM_VERBOSE environment variable support.
Joe Talbott [Tue, 14 May 2024 14:39:38 +0000 (14:39 +0000)]
math: Add GLIBC_TEST_LIBM_VERBOSE environment variable support.

Allow the libm-test-driver based tests to have their verbosity set based
on the GLIBC_TEST_LIBM_VERBOSE environment variable.  This allows the entire
testsuite to be run with a non-default verbosity.

While here check the conversion for the verbose option as well.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomalloc: Improve aligned_alloc and calloc test coverage.
Joe Simmons-Talbott [Tue, 14 May 2024 14:36:50 +0000 (14:36 +0000)]
malloc: Improve aligned_alloc and calloc test coverage.

Add a DSO (malloc/tst-aligned_alloc-lib.so) that can be used during
testing to interpose malloc with a call that randomly uses either
aligned_alloc, __libc_malloc, or __libc_calloc in the place of malloc.
Use LD_PRELOAD with the DSO to mirror malloc/tst-malloc.c testing as an
example in malloc/tst-malloc-random.c.  Add malloc/tst-aligned-alloc-random.c
as another example that does a number of malloc calls with randomly sized,
but limited to 0xffff, requests.

The intention is to be able to utilize existing malloc testing to ensure
that similar allocation APIs are also exposed to the same rigors.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 months agoaarch64: Fix AdvSIMD libmvec routines for big-endian
Joe Ramsay [Thu, 2 May 2024 15:43:13 +0000 (16:43 +0100)]
aarch64: Fix AdvSIMD libmvec routines for big-endian

Previously many routines used * to load from vector types stored
in the data table. This is emitted as ldr, which byte-swaps the
entire vector register, and causes bugs for big-endian when not
all lanes contain the same value. When a vector is to be used
this way, it has been replaced with an array and the load with an
explicit ld1 intrinsic, which byte-swaps only within lanes.

As well, many routines previously used non-standard GCC syntax
for vector operations such as indexing into vectors types with []
and assembling vectors using {}. This syntax should not be mixed
with ACLE, as the former does not respect endianness whereas the
latter does. Such examples have been replaced with, for instance,
vcombine_* and vgetq_lane* intrinsics. Helpers which only use the
GCC syntax, such as the v_call helpers, do not need changing as
they do not use intrinsics.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 months agoUnify output from backtrace_symbols_fd with backtrace_symbols (bug 31730)
Andreas Schwab [Mon, 13 May 2024 10:35:48 +0000 (12:35 +0200)]
Unify output from backtrace_symbols_fd with backtrace_symbols (bug 31730)

3 months agomanual: add dup3
DJ Delorie [Fri, 10 May 2024 21:34:29 +0000 (17:34 -0400)]
manual: add dup3

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agolibio/bug-wsetpos: Make the error message match the causing function
Maciej W. Rozycki [Mon, 13 May 2024 11:50:48 +0000 (12:50 +0100)]
libio/bug-wsetpos: Make the error message match the causing function

This test case calls `fopen':

  FILE *fp = fopen (temp_file, "r");

however if that fails it reports `fdopen' being the origin of the error.
Adjust the message to say `fopen' then.

3 months agomalloc/Makefile: Split and sort tests
H.J. Lu [Fri, 10 May 2024 03:27:39 +0000 (20:27 -0700)]
malloc/Makefile: Split and sort tests

Put each test on a separate line and sort tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agoForce DT_RPATH for --enable-hardcoded-path-in-tests
H.J. Lu [Fri, 10 May 2024 03:07:01 +0000 (20:07 -0700)]
Force DT_RPATH for --enable-hardcoded-path-in-tests

On Fedora 40/x86-64, linker enables --enable-new-dtags by default which
generates DT_RUNPATH instead of DT_RPATH.  Unlike DT_RPATH, DT_RUNPATH
only applies to DT_NEEDED entries in the executable and doesn't applies
to DT_NEEDED entries in shared libraries which are loaded via DT_NEEDED
entries in the executable.  Some glibc tests have libstdc++.so.6 in
DT_NEEDED, which has libm.so.6 in DT_NEEDED.  When DT_RUNPATH is generated,
/lib64/libm.so.6 is loaded for such tests.  If the newly built glibc is
older than glibc 2.36, these tests fail with

assert/tst-assert-c++: /export/build/gnu/tools-build/glibc-gitlab-release/build-x86_64-linux/libc.so.6: version `GLIBC_2.36' not found (required by /lib64/libm.so.6)
assert/tst-assert-c++: /export/build/gnu/tools-build/glibc-gitlab-release/build-x86_64-linux/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /lib64/libm.so.6)

Pass -Wl,--disable-new-dtags to linker when building glibc tests with
--enable-hardcoded-path-in-tests.  This fixes BZ #31719.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agopowerpc: Fix __fesetround_inline_nocheck on POWER9+ (BZ 31682)
Adhemerval Zanella [Tue, 7 May 2024 12:19:48 +0000 (09:19 -0300)]
powerpc: Fix __fesetround_inline_nocheck on POWER9+ (BZ 31682)

The e68b1151f7460d5fa88c3a567c13f66052da79a7 commit changed the
__fesetround_inline_nocheck implementation to use mffscrni
(through __fe_mffscrn) instead of mtfsfi.  For generic powerpc
ceil/floor/trunc, the function is supposed to disable the
floating-point inexact exception enable bit, however mffscrni
does not change any exception enable bits.

This patch fixes by reverting the optimization for the
__fesetround_inline_nocheck.

Checked on powerpc-linux-gnu.
Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
3 months agox86_64: Fix missing wcsncat function definition without multiarch (x86-64-v4)
Gabi Falk [Tue, 7 May 2024 18:25:00 +0000 (18:25 +0000)]
x86_64: Fix missing wcsncat function definition without multiarch (x86-64-v4)

This code expects the WCSCAT preprocessor macro to be predefined in case
the evex implementation of the function should be defined with a name
different from __wcsncat_evex.  However, when glibc is built for
x86-64-v4 without multiarch support, sysdeps/x86_64/wcsncat.S defines
WCSNCAT variable instead of WCSCAT to build it as wcsncat.  Rename the
variable to WCSNCAT, as it is actually a better naming choice for the
variable in this case.

Reported-by: Kenton Groombridge
Link: https://bugs.gentoo.org/921945
Fixes: 64b8b6516b ("x86: Add evex optimized functions for the wchar_t strcpy family")
Signed-off-by: Gabi Falk <gabifalk@gmx.com>
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
3 months agolocaledata: fix weekdays in mdf_RU locale
Mike FABIAN [Wed, 8 May 2024 07:43:17 +0000 (09:43 +0200)]
localedata: fix weekdays in mdf_RU locale

From Кирилл Изместьев <izmestevks@basealt.ru>,
see: https://sourceware.org/bugzilla/show_bug.cgi?id=31530#c6
and the following comments.

3 months agolocaledata: add mdf_RU locale
Mike FABIAN [Tue, 7 May 2024 09:12:38 +0000 (11:12 +0200)]
localedata: add mdf_RU locale

Resolves: BZ # 31530

3 months agoelf: Make glibc.rtld.enable_secure ignore alias environment variables
Adhemerval Zanella [Mon, 6 May 2024 16:18:48 +0000 (13:18 -0300)]
elf: Make glibc.rtld.enable_secure ignore alias environment variables

Tunable with environment variables aliases are also ignored if
glibc.rtld.enable_secure is enabled.  The tunable parsing is also
optimized a bit, where the loop that checks each environment variable
only checks for the tunables with aliases instead of all tables.

Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agosupport: Add envp argument to support_capture_subprogram
Adhemerval Zanella [Mon, 6 May 2024 16:18:47 +0000 (13:18 -0300)]
support: Add envp argument to support_capture_subprogram

So tests can specify a list of environment variables.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoelf: Remove glibc.rtld.enable_secure check from parse_tunables_string
Adhemerval Zanella [Mon, 6 May 2024 16:18:46 +0000 (13:18 -0300)]
elf: Remove glibc.rtld.enable_secure check from parse_tunables_string

And move it to parse_tunables.  It avoids a string comparison for
each tunable.

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

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoelf: Only process multiple tunable once (BZ 31686)
Adhemerval Zanella [Mon, 6 May 2024 16:18:45 +0000 (13:18 -0300)]
elf: Only process multiple tunable once (BZ 31686)

The 680c597e9c3 commit made loader reject ill-formatted strings by
first tracking all set tunables and then applying them. However, it does
not take into consideration if the same tunable is set multiple times,
where parse_tunables_string appends the found tunable without checking
if it was already in the list. It leads to a stack-based buffer overflow
if the tunable is specified more than the total number of tunables.  For
instance:

  GLIBC_TUNABLES=glibc.malloc.check=2:... (repeat over the number of
  total support for different tunable).

Instead, use the index of the tunable list to get the expected tunable
entry.  Since now the initial list is zero-initialized, the compiler
might emit an extra memset and this requires some minor adjustment
on some ports.

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

Reported-by: Yuto Maeda <maeda@cyberdefense.jp>
Reported-by: Yutaro Shimizu <shimizu@cyberdefense.jp>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoNEWS: Add advisories.
Carlos O'Donell [Thu, 2 May 2024 01:54:11 +0000 (21:54 -0400)]
NEWS: Add advisories.

  GLIBC-SA-2024-0004:
    ISO-2022-CN-EXT: fix out-of-bound writes when writing escape
    sequence (CVE-2024-2961)

  GLIBC-SA-2024-0005:
    nscd: Stack-based buffer overflow in netgroup cache (CVE-2024-33599)

  GLIBC-SA-2024-0006:
    nscd: Null pointer crashes after notfound response
    (CVE-2024-33600)

  GLIBC-SA-2024-0007:
    nscd: netgroup cache may terminate daemon on memory allocation
    failure (CVE-2024-33601)

  GLIBC-SA-2024-0008:
    nscd: netgroup cache assumes NSS callback uses in-buffer strings
    (CVE-2024-33602)

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoDocument CVE-2024-33599, CVE-2024-33600, CVE-2024-33601, CVE-2024-33602
Carlos O'Donell [Mon, 29 Apr 2024 12:55:42 +0000 (08:55 -0400)]
Document CVE-2024-33599, CVE-2024-33600, CVE-2024-33601, CVE-2024-33602

This commit adds advisory data for the above CVE(s).

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoAdd crt1-2.0.o for glibc 2.0 compatibility tests
H.J. Lu [Tue, 30 Apr 2024 16:57:12 +0000 (09:57 -0700)]
Add crt1-2.0.o for glibc 2.0 compatibility tests

Starting from glibc 2.1, crt1.o contains _IO_stdin_used which is checked
by _IO_check_libio to provide binary compatibility for glibc 2.0.  Add
crt1-2.0.o for tests against glibc 2.0.  Define tests-2.0 for glibc 2.0
compatibility tests.  Add and update glibc 2.0 compatibility tests for
stderr, matherr and pthread_kill.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agopowerpc: Optimized strncmp for power10
Amrita H S [Mon, 6 May 2024 14:01:29 +0000 (09:01 -0500)]
powerpc: Optimized strncmp for power10

This patch is based on __strcmp_power10.

Improvements from __strncmp_power9:

    1. Uses new POWER10 instructions
       - This code uses lxvp to decrease contention on load
 by loading 32 bytes per instruction.

    2. Performance implication
       - This version has around 38% better performance on average.
       - Minor performance regression is seen for few small sizes
 and specific combination of alignments.

Signed-off-by: Amrita H S <amritahs@linux.ibm.com>
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
3 months agobuild-many-glibcs.py: Add openrisc hard float glibc variant
Stafford Horne [Sat, 8 Jan 2022 06:35:24 +0000 (15:35 +0900)]
build-many-glibcs.py: Add openrisc hard float glibc variant

This adds the OpenRISC hard float glibc variant to the build many
script.  We update the compiler for glibc to support hard-float
multilibs to allow us to use a single generic compiler for all glibc
variants, this requires updating the compiler name.

Tested and all builds are passing.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoor1k: Add hard float support
Stafford Horne [Sat, 27 Apr 2024 05:35:09 +0000 (06:35 +0100)]
or1k: Add hard float support

This patch adds hardware floating point support to OpenRISC.  Hardware
floating point toolchain builds are enabled by passing the machine
specific argument -mhard-float to gcc via CFLAGS.  With this enabled GCC
generates floating point instructions for single-precision operations
and exports __or1k_hard_float__.

There are 2 main parts to this patch.

 - Implement fenv functions to update the FPCSR flags keeping it in sync
   with sfp (software floating point).
 - Update machine context functions to store and restore the FPCSR
   state.

*On mcontext_t ABI*

This patch adds __fpcsr to mcontext_t.  This is an ABI change, but also
an ABI fix.  The Linux kernel has always defined padding in mcontext_t
that space was missing from the glibc ABI.  In Linux this unused space
has now been re-purposed for storing the FPCSR.  This patch brings
OpenRISC glibc in line with the Linux kernel and other libc
implementation (musl).

Compatibility getcontext, setcontext, etc symbols have been added to
allow for binaries expecting the old ABI to continue to work.

*Hard float ABI*

The calling conventions and types do not change with OpenRISC hard-float
so glibc hard-float builds continue to use dynamic linker
/lib/ld-linux-or1k.so.1.

*Testing*

I have tested this patch both with hard-float and soft-float builds and
the test results look fine to me.  Results are as follows:

Hard Float

    # failures
    FAIL: elf/tst-sprof-basic (Haven't figured out yet, not related to hard-float)
    FAIL: gmon/tst-gmon-pie (PIE bug in or1k toolchain)
    FAIL: gmon/tst-gmon-pie-gprof (PIE bug in or1k toolchain)
    FAIL: iconvdata/iconv-test (timeout, passed when run manually)
    FAIL: nptl/tst-cond24 (Timeout)
    FAIL: nptl/tst-mutex10 (Timeout)

    # summary
  6 FAIL
       4289 PASS
 86 UNSUPPORTED
 16 XFAIL
  2 XPASS

    # versions
    Toolchain: or1k-smhfpu-linux-gnu
    Compiler:  gcc version 14.0.1 20240324 (experimental) [master r14-9649-gbb04a11418f] (GCC)
    Binutils:  GNU assembler version 2.42.0 (or1k-smhfpu-linux-gnu) using BFD version (GNU Binutils) 2.42.0.20240324
    Linux:     Linux buildroot 6.9.0-rc1-00008-g4dc70e1aadfa #112 SMP Sat Apr 27 06:43:11 BST 2024 openrisc GNU/Linux
    Tester:    shorne
    Glibc:     2024-04-25 b62928f907 Florian Weimer   x86: In ld.so, diagnose missing APX support in APX-only builds  (origin/master, origin/HEAD)

Soft Float

    # failures
    FAIL: elf/tst-sprof-basic
    FAIL: gmon/tst-gmon-pie
    FAIL: gmon/tst-gmon-pie-gprof
    FAIL: nptl/tst-cond24
    FAIL: nptl/tst-mutex10

    # summary
  5 FAIL
       4295 PASS
 81 UNSUPPORTED
 16 XFAIL
  2 XPASS

    # versions
    Toolchain: or1k-smh-linux-gnu
    Compiler:  gcc version 14.0.1 20240324 (experimental) [master r14-9649-gbb04a11418f] (GCC)
    Binutils:  GNU assembler version 2.42.0 (or1k-smh-linux-gnu) using BFD version (GNU Binutils) 2.42.0.20240324
    Linux:     Linux buildroot 6.9.0-rc1-00008-g4dc70e1aadfa #112 SMP Sat Apr 27 06:43:11 BST 2024 openrisc GNU/Linux
    Tester:    shorne
    Glibc:     2024-04-25 b62928f907 Florian Weimer   x86: In ld.so, diagnose missing APX support in APX-only builds  (origin/master, origin/HEAD)

Documentation: https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.4-rev0.pdf
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoor1k: Add hard float libm-test-ulps
Stafford Horne [Sat, 27 Apr 2024 05:32:59 +0000 (06:32 +0100)]
or1k: Add hard float libm-test-ulps

This patch adds the ulps test file to prepare for the upcoming
hard float patch.  This is separated out to make the hard float patch
smaller.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agonscd: Use time_t for return type of addgetnetgrentX
Florian Weimer [Thu, 2 May 2024 15:06:19 +0000 (17:06 +0200)]
nscd: Use time_t for return type of addgetnetgrentX

Using int may give false results for future dates (timeouts after the
year 2028).

Fixes commit 04a21e050d64a1193a6daab872bca2528bda44b ("CVE-2024-33601,
CVE-2024-33602: nscd: netgroup: Use two buffers in addgetnetgrentX
(bug 31680)").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agoAdd a test to check for duplicate definitions in the static library
Gabi Falk [Tue, 30 Apr 2024 20:05:04 +0000 (20:05 +0000)]
Add a test to check for duplicate definitions in the static library

This change follows two previous fixes addressing multiple definitions
of __memcpy_chk and __mempcpy_chk functions on i586, and __memmove_chk
and __memset_chk functions on i686.  The test is intended to prevent
such issues from occurring in the future.

Signed-off-by: Gabi Falk <gabifalk@gmx.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
3 months agoi686: Fix multiple definitions of __memmove_chk and __memset_chk
Gabi Falk [Tue, 30 Apr 2024 20:05:03 +0000 (20:05 +0000)]
i686: Fix multiple definitions of __memmove_chk and __memset_chk

Commit c73c96a4a1af1326df7f96eec58209e1e04066d8 updated memcpy.S and
mempcpy.S, but omitted memmove.S and memset.S.  As a result, the static
library built as PIC, whether with or without multiarch support,
contains two definitions for each of the __memmove_chk and __memset_chk
symbols.

/usr/lib/gcc/i686-pc-linux-gnu/14/../../../../i686-pc-linux-gnu/bin/ld: /usr/lib/gcc/i686-pc-linux-gnu/14/../../../../lib/libc.a(memset-ia32.o): in function `__memset_chk':
/var/tmp/portage/sys-libs/glibc-2.39-r3/work/glibc-2.39/string/../sysdeps/i386/i686/memset.S:32: multiple definition of `__memset_chk'; /usr/lib/gcc/i686-pc-linux-gnu/14/../../../../lib/libc.a(memset_chk.o):/var/tmp/portage/sys-libs/glibc-2.39-r3/work/glibc-2.39/debug/../sysdeps/i386/i686/multiarch/memset_chk.c:24: first defined here

After this change, regardless of PIC options, the static library, built
for i686 with multiarch contains implementations of these functions
respectively from debug/memmove_chk.c and debug/memset_chk.c, and
without multiarch contains implementations of these functions
respectively from sysdeps/i386/memmove_chk.S and
sysdeps/i386/memset_chk.S.  This ensures that memmove and memset won't
pull in __chk_fail and the routines it calls.

Reported-by: Sam James <sam@gentoo.org>
Tested-by: Sam James <sam@gentoo.org>
Fixes: c73c96a4a1 ("i686: Fix build with --disable-multiarch")
Signed-off-by: Gabi Falk <gabifalk@gmx.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
3 months agoi586: Fix multiple definitions of __memcpy_chk and __mempcpy_chk
Gabi Falk [Tue, 30 Apr 2024 20:05:02 +0000 (20:05 +0000)]
i586: Fix multiple definitions of __memcpy_chk and __mempcpy_chk

/home/bmg/install/compilers/x86_64-linux-gnu/lib/gcc/x86_64-glibc-linux-gnu/13.2.1/../../../../x86_64-glibc-linux-gnu/bin/ld: /home/bmg/build/glibcs/i586-linux-gnu/glibc/libc.a(memcpy_chk.o): in function `__memcpy_chk':
/home/bmg/src/glibc/debug/../sysdeps/i386/memcpy_chk.S:29: multiple definition of `__memcpy_chk';/home/bmg/build/glibcs/i586-linux-gnu/glibc/libc.a(memcpy.o):/home/bmg/src/glibc/string/../sysdeps/i386/i586/memcpy.S:31: first defined here /home/bmg/install/compilers/x86_64-linux-gnu/lib/gcc/x86_64-glibc-linux-gnu/13.2.1/../../../../x86_64-glibc-linux-gnu/bin/ld: /home/bmg/build/glibcs/i586-linux-gnu/glibc/libc.a(mempcpy_chk.o): in function `__mempcpy_chk': /home/bmg/src/glibc/debug/../sysdeps/i386/mempcpy_chk.S:28: multiple definition of `__mempcpy_chk'; /home/bmg/build/glibcs/i586-linux-gnu/glibc/libc.a(mempcpy.o):/home/bmg/src/glibc/string/../sysdeps/i386/i586/memcpy.S:31: first defined here

After this change, the static library built for i586, regardless of PIC
options, contains implementations of these functions respectively from
sysdeps/i386/memcpy_chk.S and sysdeps/i386/mempcpy_chk.S.  This ensures
that memcpy and mempcpy won't pull in __chk_fail and the routines it
calls.

Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Gabi Falk <gabifalk@gmx.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
3 months agonscd: Typo inside comment in netgroup cache
Florian Weimer [Tue, 30 Apr 2024 10:31:37 +0000 (12:31 +0200)]
nscd: Typo inside comment in netgroup cache

Reported-by: Jonathan Wakely <jwakely@redhat.com>
3 months agotime: Allow later version licensing.
Carlos O'Donell [Tue, 23 Apr 2024 17:30:37 +0000 (13:30 -0400)]
time: Allow later version licensing.

The FSF's Licensing and Compliance Lab noted a discrepancy in the
licensing of several files in the glibc package.

When timespect_get.c was impelemented the license did not include
the standard ", or (at your option) any later version." text.

Change the license in timespec_get.c and all copied files to match
the expected license.

This change was previously approved in principle by the FSF in
RT ticket #1316403. And a similar instance was fixed in
commit 46703efa02f6ddebce5ee54c92f7c32598de0de6.

3 months agohurd: Stop mapping AT_NO_AUTOMOUNT to O_NOTRANS
Sergey Bugaev [Mon, 6 Nov 2023 13:50:51 +0000 (16:50 +0300)]
hurd: Stop mapping AT_NO_AUTOMOUNT to O_NOTRANS

While AT_NO_AUTOMOUNT is similar in function to the Hurd's O_NOTRANS,
there are significant enough differences in semantics:

1. AT_NO_AUTOMOUNT has no effect on already established mounts,
   whereas O_NOTRANS causes the lookup to ignore both passive and active
   translators. A better approximation of the AT_NO_AUTOMOUNT behavior
   would be to honor active translators, but avoid starting passive
   ones; like what the file_name_lookup_carefully () routine from
   sutils/clookup.c in the Hurd source tree does.

2. On GNU/Hurd, translators are used much more pervasively than mounts
   on "traditional" Unix systems: among other things, translators
   underlie features like symlinks, device nodes, and sockets. And while
   on a "traditional" Unix system, the mountpoint and the root of the
   mounted tree may look similar enough for many purposes (they're both
   directories, for one thing), the Hurd allows for any combination of
   the two node types, and indeed it is common to have e.g. a device
   node "mounted" on top of a regular file node on the underlying
   filesystem. Ignoring the translator and stat'ing the underlying node
   is therefore likely to return very different results from what you'd
   get if you stat the translator's root node.

In practice, mapping AT_NO_AUTOMOUNT to O_NOTRANS was breaking GNU
Coreutils, including stat(1) and ls(1):

$ stat /dev/hd0s1
  File: /dev/hd0s1
  Size: 0       Blocks: 8          IO Block: 8192   regular empty file
Device: 0,8     Inode: 32866       Links: 1

This was also breaking GNOME's glib, where a g_local_file_stat () call
that is supposed to stat () a file through a symlink uses
AT_NO_AUTOMOUNT, which gets mapped to O_NOTRANS, which then causes the
stat () call to stat symlink itself like lstat () would, rather then the
file it points to, which is what the logic expects to happen.

This reverts most of 13710e7e6af6c8965cc9a63a0660cb4ce1966557
"hurd: Add support for AT_NO_AUTOMOUNT".

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
3 months agolibio: Sort test variables in Makefile
H.J. Lu [Tue, 30 Apr 2024 16:21:16 +0000 (09:21 -0700)]
libio: Sort test variables in Makefile

Sort test variables in libio/Makefile using scripts/sort-makefile-lines.py.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
3 months agoAArch64: Remove unused defines of CPU names
Wilco Dijkstra [Thu, 18 Apr 2024 15:33:32 +0000 (16:33 +0100)]
AArch64: Remove unused defines of CPU names

Remove unused defines of CPU names in cpu-features.h.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoMake sure INSTALL is ASCII plaintext again
Mark Wielaard [Sun, 28 Apr 2024 14:59:39 +0000 (16:59 +0200)]
Make sure INSTALL is ASCII plaintext again

This reverts commit 84e93afc7 ("Switch to UTF-8 for INSTALL") and
reinstates commit c14f2e4aa ("Make sure INSTALL is ASCII plaintext")
and regenerates INSTALL.

It turns out that different versions of makeinfo (texinfo/texi2any),
at least versions 7.0.3 and 7.1, put unicode quote glyphs in different
places (specifically whether contractions like you'd, don't, aren't or
you'll use ’ or '). This breaks the make dist target as used for
(snapshot) releases, which have a check on the regenerated INSTALL
file. Using --disable-encoding generates the same plaintext ASCII on
all versions.

An alternative would be to regenerate INSTALL with texinfo 7.1 and
require at least that version. But that seems too soon while various
distros don't have 7.1 yet. We can try again to use UTF-8 for INSTALL
in a couple of years.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agox86: In ld.so, diagnose missing APX support in APX-only builds
Florian Weimer [Thu, 25 Apr 2024 15:20:28 +0000 (17:20 +0200)]
x86: In ld.so, diagnose missing APX support in APX-only builds

At this point, this is mainly a tool for testing the early ld.so
CPU compatibility diagnostics: GCC uses the new instructions in most
functions, so it's easy to spot if some of the early code is not
built correctly.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoelf: Also compile dl-misc.os with $(rtld-early-cflags)
H.J. Lu [Thu, 25 Apr 2024 15:06:52 +0000 (08:06 -0700)]
elf: Also compile dl-misc.os with $(rtld-early-cflags)

Also compile dl-misc.os with $(rtld-early-cflags) to avoid

Program received signal SIGILL, Illegal instruction.
0x00007ffff7fd36ea in _dl_strtoul (nptr=nptr@entry=0x7fffffffe2c9 "2",
    endptr=endptr@entry=0x7fffffffd728) at dl-misc.c:156
156   bool positive = true;
(gdb) bt
 #0  0x00007ffff7fd36ea in _dl_strtoul (nptr=nptr@entry=0x7fffffffe2c9 "2",
    endptr=endptr@entry=0x7fffffffd728) at dl-misc.c:156
 #1  0x00007ffff7fdb1a9 in tunable_initialize (
    cur=cur@entry=0x7ffff7ffbc00 <tunable_list+2176>,
    strval=strval@entry=0x7fffffffe2c9 "2", len=len@entry=1)
    at dl-tunables.c:131
 #2  0x00007ffff7fdb3a2 in parse_tunables (valstring=<optimized out>)
    at dl-tunables.c:258
 #3  0x00007ffff7fdb5d9 in __GI___tunables_init (envp=0x7fffffffdd58)
    at dl-tunables.c:288
 #4  0x00007ffff7fe44c3 in _dl_sysdep_start (
    start_argptr=start_argptr@entry=0x7fffffffdcb0,
    dl_main=dl_main@entry=0x7ffff7fe5f80 <dl_main>)
    at ../sysdeps/unix/sysv/linux/dl-sysdep.c:110
 #5  0x00007ffff7fe5cae in _dl_start_final (arg=0x7fffffffdcb0) at rtld.c:494
 #6  _dl_start (arg=0x7fffffffdcb0) at rtld.c:581
 #7  0x00007ffff7fe4b38 in _start ()
(gdb)

when setting GLIBC_TUNABLES in glibc compiled with APX.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agoCVE-2024-33601, CVE-2024-33602: nscd: netgroup: Use two buffers in addgetnetgrentX...
Florian Weimer [Thu, 25 Apr 2024 13:01:07 +0000 (15:01 +0200)]
CVE-2024-33601, CVE-2024-33602: nscd: netgroup: Use two buffers in addgetnetgrentX (bug 31680)

This avoids potential memory corruption when the underlying NSS
callback function does not use the buffer space to store all strings
(e.g., for constant strings).

Instead of custom buffer management, two scratch buffers are used.
This increases stack usage somewhat.

Scratch buffer allocation failure is handled by return -1
(an invalid timeout value) instead of terminating the process.
This fixes bug 31679.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoCVE-2024-33600: nscd: Avoid null pointer crashes after notfound response (bug 31678)
Florian Weimer [Thu, 25 Apr 2024 13:01:07 +0000 (15:01 +0200)]
CVE-2024-33600: nscd: Avoid null pointer crashes after notfound response (bug 31678)

The addgetnetgrentX call in addinnetgrX may have failed to produce
a result, so the result variable in addinnetgrX can be NULL.
Use db->negtimeout as the fallback value if there is no result data;
the timeout is also overwritten below.

Also avoid sending a second not-found response.  (The client
disconnects after receiving the first response, so the data stream did
not go out of sync even without this fix.)  It is still beneficial to
add the negative response to the mapping, so that the client can get
it from there in the future, instead of going through the socket.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoCVE-2024-33600: nscd: Do not send missing not-found response in addgetnetgrentX ...
Florian Weimer [Thu, 25 Apr 2024 13:01:07 +0000 (15:01 +0200)]
CVE-2024-33600: nscd: Do not send missing not-found response in addgetnetgrentX (bug 31678)

If we failed to add a not-found response to the cache, the dataset
point can be null, resulting in a null pointer dereference.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoCVE-2024-33599: nscd: Stack-based buffer overflow in netgroup cache (bug 31677)
Florian Weimer [Thu, 25 Apr 2024 13:00:45 +0000 (15:00 +0200)]
CVE-2024-33599: nscd: Stack-based buffer overflow in netgroup cache (bug 31677)

Using alloca matches what other caches do.  The request length is
bounded by MAXKEYLEN.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agoi386: ulp update for SSE2 --disable-multi-arch configurations
Florian Weimer [Thu, 25 Apr 2024 10:56:48 +0000 (12:56 +0200)]
i386: ulp update for SSE2 --disable-multi-arch configurations

3 months agoGLIBC-SA-2024-0004: add commit for 2.31 branch
Aurelien Jarno [Mon, 22 Apr 2024 22:04:08 +0000 (00:04 +0200)]
GLIBC-SA-2024-0004: add commit for 2.31 branch

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
3 months agobenchtests: Add difficult strstr needle for bruteforce algorithms
Wilco Dijkstra [Wed, 24 Apr 2024 17:24:45 +0000 (18:24 +0100)]
benchtests: Add difficult strstr needle for bruteforce algorithms

Add another difficult needle to strstr that clearly shows the quadratic
complexity of bruteforce algorithms.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agox86: Define MINIMUM_X86_ISA_LEVEL in config.h [BZ #31676]
H.J. Lu [Tue, 23 Apr 2024 20:59:50 +0000 (13:59 -0700)]
x86: Define MINIMUM_X86_ISA_LEVEL in config.h [BZ #31676]

Define MINIMUM_X86_ISA_LEVEL at configure time to avoid

/usr/bin/ld: …/build/elf/librtld.os: in function `init_cpu_features':
…/git/elf/../sysdeps/x86/cpu-features.c:1202: undefined reference to `_dl_runtime_resolve_fxsave'
/usr/bin/ld: …/build/elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `_dl_runtime_resolve_fxsave' can not be used when making a shared object
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

when glibc is built with -march=x86-64-v3 and configured with
--with-rtld-early-cflags=-march=x86-64, which is used to allow ld.so to
print an error message on unsupported CPUs:

Fatal glibc error: CPU does not support x86-64-v3

This fixes BZ #31676.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
3 months agoLoongArch: Add glibc.cpu.hwcap support.
caiyinyu [Fri, 15 Sep 2023 09:35:19 +0000 (17:35 +0800)]
LoongArch: Add glibc.cpu.hwcap support.

The current IFUNC selection is always using the most recent
features which are available via AT_HWCAP.  But in
some scenarios it is useful to adjust this selection.

The environment variable:

GLIBC_TUNABLES=glibc.cpu.hwcaps=-xxx,yyy,zzz,....

can be used to enable HWCAP feature yyy, disable HWCAP feature xxx,
where the feature name is case-sensitive and has to match the ones
used in sysdeps/loongarch/cpu-tunables.c.

Signed-off-by: caiyinyu <caiyinyu@loongson.cn>
3 months agonptl: Fix tst-cancel30 on kernels without ppoll_time64 support
Florian Weimer [Tue, 23 Apr 2024 19:16:32 +0000 (21:16 +0200)]
nptl: Fix tst-cancel30 on kernels without ppoll_time64 support

Fall back to ppoll if ppoll_time64 fails with ENOSYS.
Fixes commit 370da8a121c3ba9eeb2f13da15fc0f21f4136b25 ("nptl: Fix
tst-cancel30 on sparc64").

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoRevert "Allow glibc to be compiled without EXEC_PAGESIZE"
Samuel Thibault [Mon, 22 Apr 2024 21:00:18 +0000 (23:00 +0200)]
Revert "Allow glibc to be compiled without EXEC_PAGESIZE"

This reverts commit 49aa652db810ebdca3a662ebd5b0468bd08ec688.

This is still being discussed.

3 months agolocale: Handle loading a missing locale twice (Bug 14247)
Carlos O'Donell [Mon, 22 Apr 2024 12:16:09 +0000 (08:16 -0400)]
locale: Handle loading a missing locale twice (Bug 14247)

Delay setting file->decided until the data has been successfully loaded
by _nl_load_locale().  If the function fails to load the data then we
must return and error and leave decided untouched to allow the caller to
attempt to load the data again at a later time.  We should not set
decided to 1 early in the function since doing so may prevent attempting
to load it again. We want to try loading it again because that allows an
open to fail and set errno correctly.

On the other side of this problem is that if we are called again with
the same inputs we will fetch the cached version of the object and carry
out no open syscalls and that fails to set errno so we must set errno to
ENOENT in that case.  There is a second code path that has to be handled
where the name of the locale matches but the codeset doesn't match.

These changes ensure that errno is correctly set on failure in all the
return paths in _nl_find_locale().

Adds tst-locale-loadlocale to cover the bug.

No regressions on x86_64.

Co-authored-by: Jeff Law <law@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoelf: Do not check for loader mmap on tst-decorate-maps (BZ 31553)
Adhemerval Zanella [Tue, 26 Mar 2024 13:47:42 +0000 (10:47 -0300)]
elf: Do not check for loader mmap on tst-decorate-maps (BZ 31553)

On some architectures and depending on the page size, the loader can
also allocate some memory during dependencies loading and it will be
marked as 'loader malloc'.  However, if the system page size is
large enough, the initial data page will be enough for all required
allocation and there will be no extra loader mmap.  To avoid false
negatives, the test does not check for such pages.

Checked on powerpc64le-linux-gnu with 64k pagesize.
Reviewed-by: Simon Chopin <simon.chopin@canonical.com>
3 months agoUse --enable-obsolete in build-many-glibcs.py for nios2-linux-gnu
Joseph Myers [Fri, 19 Apr 2024 17:03:56 +0000 (17:03 +0000)]
Use --enable-obsolete in build-many-glibcs.py for nios2-linux-gnu

Until GCC removes Nios II support (at which point we should do so as
well), this is now needed for GCC 14 / mainline to build for
nios2-linux-gnu target.

Tested with build-many-glibcs.py (GCC mainline) for nios2-linux-gnu.

3 months agologin: Use unsigned 32-bit types for seconds-since-epoch
Florian Weimer [Fri, 19 Apr 2024 12:38:17 +0000 (14:38 +0200)]
login: Use unsigned 32-bit types for seconds-since-epoch

These fields store timestamps when the system was running.  No Linux
systems existed before 1970, so these values are unused.  Switching
to unsigned types allows continued use of the existing struct layouts
beyond the year 2038.

The intent is to give distributions more time to switch to improved
interfaces that also avoid locking/data corruption issues.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agologin: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701)
Florian Weimer [Fri, 19 Apr 2024 12:38:17 +0000 (14:38 +0200)]
login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701)

These structs describe file formats under /var/log, and should not
depend on the definition of _TIME_BITS.  This is achieved by
defining __WORDSIZE_TIME64_COMPAT32 to 1 on 32-bit ports that
support 32-bit time_t values (where __time_t is 32 bits).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agologin: Check default sizes of structs utmp, utmpx, lastlog
Florian Weimer [Fri, 19 Apr 2024 12:38:17 +0000 (14:38 +0200)]
login: Check default sizes of structs utmp, utmpx, lastlog

The default <utmp-size.h> is for ports with a 64-bit time_t.
Ports with a 32-bit time_t or with __WORDSIZE_TIME64_COMPAT32=1
need to override it.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agobenchtests: Add random() benchmark
Wilco Dijkstra [Tue, 28 Nov 2023 13:33:56 +0000 (13:33 +0000)]
benchtests: Add random() benchmark

Add a simple benchmark to measure the overhead of internal libc locks in
the random() implementation on both single- and multi-threaded cases.
This relies on the implementation of random using internal locks to
access shared global data, and that the runtime uses multi-threaded
locking once a thread has been created (even after it finishes).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoadvisories: Add Reported-By
Siddhesh Poyarekar [Thu, 18 Apr 2024 12:51:37 +0000 (08:51 -0400)]
advisories: Add Reported-By

Add a new tag to give credit to vulnerability discoverers.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 months agoFix 'Reported-By' to use Camel Case for commit 6a98f4640ea453f
Adhemerval Zanella [Wed, 17 Apr 2024 17:27:42 +0000 (14:27 -0300)]
Fix 'Reported-By' to use Camel Case for commit 6a98f4640ea453f

3 months agoDocument CVE-2024-2961
Adhemerval Zanella [Wed, 17 Apr 2024 17:24:26 +0000 (14:24 -0300)]
Document CVE-2024-2961

This commit adds "advisories" entries for the above three CVEs.

3 months agoiconv: ISO-2022-CN-EXT: fix out-of-bound writes when writing escape sequence (CVE...
Charles Fol [Thu, 28 Mar 2024 15:25:38 +0000 (12:25 -0300)]
iconv: ISO-2022-CN-EXT: fix out-of-bound writes when writing escape sequence (CVE-2024-2961)

ISO-2022-CN-EXT uses escape sequences to indicate character set changes
(as specified by RFC 1922).  While the SOdesignation has the expected
bounds checks, neither SS2designation nor SS3designation have its;
allowing a write overflow of 1, 2, or 3 bytes with fixed values:
'$+I', '$+J', '$+K', '$+L', '$+M', or '$*H'.

Checked on aarch64-linux-gnu.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
4 months agoelf/rtld: Count skipped environment variables for enable_secure
Joe Simmons-Talbott [Tue, 16 Apr 2024 20:31:42 +0000 (20:31 +0000)]
elf/rtld: Count skipped environment variables for enable_secure

When using the glibc.rtld.enable_secure tunable we need to keep track of
the count of environment variables we skip due to __libc_enable_secure
being set and adjust the auxv section of the stack.  This fixes an
assertion when running ld.so directly with glibc.rtld.enable_secure set.
Add a testcase that ensures the assert is not hit.

elf/rtld.c:1324   assert (auxv == sp + 1);

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agopowerpc: Fix ld.so address determination for PCREL mode (bug 31640)
Florian Weimer [Sun, 14 Apr 2024 06:24:51 +0000 (08:24 +0200)]
powerpc: Fix ld.so address determination for PCREL mode (bug 31640)

This seems to have stopped working with some GCC 14 versions,
which clobber r2.  With other compilers, the kernel-provided
r2 value is still available at this point.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
4 months agoRevert "x86_64: Suppress false positive valgrind error"
Florian Weimer [Sat, 13 Apr 2024 14:17:38 +0000 (16:17 +0200)]
Revert "x86_64: Suppress false positive valgrind error"

This reverts commit a1735e0aa858f0c8b15e5ee9975bff4279423680.

The test failure is a real valgrind bug that needs to be fixed before
valgrind is usable with a glibc that has been built with
CC="gcc -march=x86-64-v3".  The proposed valgrind patch teaches
valgrind to replace ld.so strcmp with an unoptimized scalar
implementation, thus avoiding any AVX2-related problems.

Valgrind bug: <https://bugs.kde.org/show_bug.cgi?id=485487>

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 months agowcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865)
Adhemerval Zanella [Tue, 19 Mar 2024 13:15:28 +0000 (10:15 -0300)]
wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865)

It uses the same two-way algorithm used on strstr, strcasestr, and
memmem.  Different than strstr, neither the "shift table" optimization
nor the self-adapting filtering check is used because it would result in
a too-large shift table (and it also simplifies the implementation bit).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
4 months agowcsmbs: Add test-wcsstr
Adhemerval Zanella [Tue, 19 Mar 2024 13:15:27 +0000 (10:15 -0300)]
wcsmbs: Add test-wcsstr

Parametrize test-strstr.c so it can be used to check wcsstr.

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

Reviewed-by: DJ Delorie <dj@redhat.com>
4 months agoposix: Sync tempname with gnulib
Adhemerval Zanella [Tue, 10 Oct 2023 19:22:39 +0000 (16:22 -0300)]
posix: Sync tempname with gnulib

The gnulib version contains an important change (9ce573cde), which
fixes some problems with multithreading, entropy loss, and ASLR leak
nfo.  It also fixes an issue where getrandom is not being used
on some new files generation (only for __GT_NOCREATE on first try).

The 044bf893ac removed __path_search, which is now moved to another
gnulib shared files (stdio-common/tmpdir.{c,h}).  Tthis patch
also fixes direxists to use __stat64_time64 instead of __xstat64,
and move the include of pathmax.h for !_LIBC (since it is not used
by glibc).  The license is also changed from GPL 3.0 to 2.1, with
permission from the authors (Bruno Haible and Paul Eggert).

The sync also removed the clock fallback, since clock_gettime
with CLOCK_REALTIME is expected to always succeed.

It syncs with gnulib commit 323834962817af7b115187e8c9a833437f8d20ec.

Checked on x86_64-linux-gnu.

Co-authored-by: Bruno Haible <bruno@clisp.org>
Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Bruno Haible <bruno@clisp.org>
4 months agosocket: Add new test for connect
Sergey Kolosov [Wed, 10 Apr 2024 15:58:05 +0000 (17:58 +0200)]
socket: Add new test for connect

This commit adds a simple bind/accept/connect test for an IPv4 TCP
connection to a local process via the loopback interface.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
4 months agolibsupport: Add xgetpeername
Sergey Kolosov [Wed, 10 Apr 2024 15:58:04 +0000 (17:58 +0200)]
libsupport: Add xgetpeername

The patch adds redirections for getpeername.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
4 months agonptl: Add tst-pthread-key1-static for BZ #21777
H.J. Lu [Mon, 8 Apr 2024 19:33:36 +0000 (12:33 -0700)]
nptl: Add tst-pthread-key1-static for BZ #21777

Add a static pthread static tests to verify that BZ #21777 is fixed.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 months agoelf: Add ld.so test with non-existing program name
Florian Weimer [Mon, 8 Apr 2024 17:19:09 +0000 (19:19 +0200)]
elf: Add ld.so test with non-existing program name

None of the existing tests seem to cover the case where
_dl_signal_error is called without an active error handler.
The new elf/tst-rtld-does-not-exist test triggers such a
_dl_signal_error call from _dl_map_object.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 months agoelf: Check objname before calling fatal_error
H.J. Lu [Mon, 8 Apr 2024 16:06:09 +0000 (09:06 -0700)]
elf: Check objname before calling fatal_error

_dl_signal_error may be called with objname == NULL.  _dl_exception_create
checks objname == NULL.  But fatal_error doesn't.  Check objname before
calling fatal_error.  This fixes BZ #31596.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
4 months agoUse crtbeginT.o and crtend.o for non-PIE static executables
H.J. Lu [Fri, 5 Apr 2024 23:42:57 +0000 (16:42 -0700)]
Use crtbeginT.o and crtend.o for non-PIE static executables

When static PIE is enabled by default, we shouldn't use crtbeginS.o and
crtendS.o for non-PIE static executables.  Check $($(@F)-no-pie) to use
crtbeginT.o and crtend.o to create non-PIE static executables.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
4 months agoaarch64: Enhanced CPU diagnostics for ld.so
Florian Weimer [Mon, 8 Apr 2024 14:48:55 +0000 (16:48 +0200)]
aarch64: Enhanced CPU diagnostics for ld.so

This prints some information from struct cpu_features, and the midr_el1
and dczid_el0 system register contents on every CPU.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 months agox86: Add generic CPUID data dumper to ld.so --list-diagnostics
Florian Weimer [Mon, 8 Apr 2024 14:48:55 +0000 (16:48 +0200)]
x86: Add generic CPUID data dumper to ld.so --list-diagnostics

This is surprisingly difficult to implement if the goal is to produce
reasonably sized output.  With the current approaches to output
compression (suppressing zeros and repeated results between CPUs,
folding ranges of identical subleaves, dealing with the %ecx
reflection issue), the output is less than 600 KiB even for systems
with 256 logical CPUs.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 months agoelf: Add CPU iteration support for future use in ld.so diagnostics
Florian Weimer [Mon, 8 Apr 2024 14:48:55 +0000 (16:48 +0200)]
elf: Add CPU iteration support for future use in ld.so diagnostics

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 months agotimezone: sync to TZDB 2024a
Paul Eggert [Sun, 7 Apr 2024 06:39:53 +0000 (23:39 -0700)]
timezone: sync to TZDB 2024a

Sync tzselect, zdump, zic to TZDB 2024a.
This patch incorporates the following TZDB source code changes,
listed roughly in descending order of importance.

  zic now supports links to links, needed for future tzdata
  zic now defaults to '-b slim'
  zic now updates output files atomically
  zic has new options -R, -l -, -p -
  zic -r now uses -00 for unspecified timestamps
  zdump now uses [lo,hi) for both -c and -t
  Fix several integer overflow bugs
  zic now checks input bytes more carefully
  Simplify and fix new TZDIR setup
  Default time_t to 64 bits on glibc 2.34+ 32-bit
  zic now generates TZ strings that conform to POSIX when all-year DST
  zic -v now shows extreme-int tm_year transitions
  Fix zic bug in last time type of Asia/Gaza etc.
  Fix zic bug with Palestine after 2075
  Fix bug uncovered by recent change to Iran history
  Fix 'zic -b fat' bug with Port Moresby 32-bit data
  Fix zic bug with -r @X where X is deduced from TZ
  Fix bug with zic -r cutoff before 1st transition
  Fix leap second expiry and truncation
  Fix zic bug on Linux 2.6.16 and 2.6.17
  Fix bug with 'zic -d /a/b/c' if /a is unwriteable
  Don't mistruncate TZif files at leap seconds
  Fix zdump undefined behavior if !USE_LTZ
  zdump -v reports localtime+gmtime failures better
  Fix zdump diagnostic for missing timezone
  Don't assume nonempty argv
  Port better to C23
  Do not assume negative >> behavior
  I18nize zdump a bit better
  Port zdump to right_only installations
  New tzselect menu option 'now'
  tzselect can now use current time to help choose
  Improve tzselect behavior for Turkey etc.
  tzselect: do not create temporary files
  tzselect: work around mawk bug with {2,}
  tzselect: Port to POSIX awk, which prohibits -v newlines
  Do not use empty RE in tzselect
  Don't set TZ in tzselect
  Avoid sed, expr in tzselect
  tzselect: Fix problems with spaces in TZDIR
  Improve tzselect diagnostics
  Remove zic workaround for Qt bug 53071
  Remove zic support for "min" in Rule lines
  Remove zic support for zic -y, Rule TYPEs, pacificnew
  Remove tzselect workaround for Bash 1.14.7 bug

* SHARED-FILES: Update to match current sync.
* config.h.in (HAVE_STRERROR): Remove; no longer needed.
* timezone/Makefile ($(objpfx)zic.o): Depend on tzdir.h.
($(objpfx)tzdir.h): New rule to build a placeholder.
* timezone/private.h, timezone/tzfile.h, timezone/version:
* timezone/zdump.c, timezone/zic.c: Copy verbatim from TZDB 2024a.

4 months agoFix bsearch, qsort doc to match POSIX better
Paul Eggert [Sat, 6 Apr 2024 15:44:01 +0000 (08:44 -0700)]
Fix bsearch, qsort doc to match POSIX better

* manual/search.texi (Array Search Function):
Correct the statement about lfind’s mean runtime:
it is proportional to a number (not that number),
and this is true only if random elements are searched for.
Relax the constraint on bsearch’s array argument:
POSIX says it need not be sorted, only partially sorted.
Say that the first arg passed to bsearch’s comparison function
is the key, and the second arg is an array element, as
POSIX requires.  For bsearch and qsort, say that the
comparison function should not alter the array, as POSIX
requires.  For qsort, say that the comparison function
must define a total order, as POSIX requires, that
it should not depend on element addresses, that
the original array index can be used for stable sorts,
and that if qsort still works if memory allocation fails.
Be more consistent in calling the array elements
“elements” rather than “objects”.

Co-authored-by: Zack Weinberg <zack@owlfolio.org>
4 months agox86-64: Exclude FMA4 IFUNC functions for -mapxf
H.J. Lu [Thu, 4 Apr 2024 22:43:50 +0000 (15:43 -0700)]
x86-64: Exclude FMA4 IFUNC functions for -mapxf

When -mapxf is used to build glibc, the resulting glibc will never run
on FMA4 machines.  Exclude FMA4 IFUNC functions when -mapxf is used.
This requires GCC which defines __APX_F__ for -mapxf with commit:

1df56719bd8 x86: Define __APX_F__ for -mapxf

Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
4 months agoReinstate generic features-time64.h
Adhemerval Zanella [Fri, 5 Apr 2024 12:02:36 +0000 (09:02 -0300)]
Reinstate generic features-time64.h

The a4ed0471d7 removed the generic version which is included by
features.h and used by Hurd.

Checked by building i686-gnu and x86_64-gnu with build-many-glibc.py.

4 months agoCleanup __tls_get_addr on alpha/microblaze localplt.data
Adhemerval Zanella [Thu, 4 Apr 2024 20:04:23 +0000 (17:04 -0300)]
Cleanup __tls_get_addr on alpha/microblaze localplt.data

They are not required.

Checked with a make check for both ABIs.

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