]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
5 hours agoelf: Initialize GLRO (dl_read_only_area) after static dlopen (bug 33139) master
Florian Weimer [Fri, 18 Jul 2025 17:58:59 +0000 (19:58 +0200)] 
elf: Initialize GLRO (dl_read_only_area) after static dlopen (bug 33139)

The _dl_read_only_area function in the uninitialized ld.so after
static dlopen is not able to find anything.  Instead, we need to
redirect to the code from the statically linked main program.

Fixes commit d60fffe28a46b2a41fc308c1804ff02375d27408 ("debug:
Improve '%n' fortify detection (BZ 30932)").

Reviewed-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
5 hours agodebug: Do not link tst-sprintf-fortify-rdonly against the dlopen module
Florian Weimer [Fri, 18 Jul 2025 17:58:56 +0000 (19:58 +0200)] 
debug: Do not link tst-sprintf-fortify-rdonly against the dlopen module

The test intends to load tst-sprintf-fortify-rdonly-dlopen.so via
dlopen, and directly linking against it prevents that.

Reviewed-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
6 hours agox86-64: Properly compile ISA optimized modf and modff
H.J. Lu [Thu, 17 Jul 2025 23:00:42 +0000 (16:00 -0700)] 
x86-64: Properly compile ISA optimized modf and modff

There are 3 variants of modf and modff: SSE2, SSE4.1 and AVX.  s_modf.c
and s_modff.c include the generic implementation compiled with the minimum
x86 ISA level.  The IFUNC selector is used only if the minimum ISA level
is less than AVX.  SSE4.1 variant is included only if the ISA level is
less than SSE4.1.  AVX variant is included only the ISA level is less than
AVX.

AVX variant should be compiled with -mavx, not -msse2avx -DSSE2AVX which
are used to encode SSE assembly sources with EVEX encoding.

The routines that are shared between libc and libm should use different
rules to avoid using the same MODULE_NAME, to avoid potential issues
like BZ #33165 where __stack_chk_fail not being routed to the internal
symbol.

Tested with -march=x86-64, -march=x86-64-v2, -march=x86-64-v3 and
-march=x86-64-v4.

This fixes BZ #33165 and BZ #33173.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
34 hours agox86-64: Compile ISA versions of modf/modff with -fno-stack-protector
H.J. Lu [Thu, 17 Jul 2025 00:17:34 +0000 (17:17 -0700)] 
x86-64: Compile ISA versions of modf/modff with -fno-stack-protector

Since modf and modff are compiled into both libc and libm, when glibc is
configured with --enable-stack-protector=all, ISA versions of modf and
modff should be compiled with -fno-stack-protector to avoid calling
__stack_chk_fail via PLT in libc.so.

This fixes BZ #33165.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
34 hours agoiconv: iconv -o should not create executable files (bug 33164)
Florian Weimer [Thu, 17 Jul 2025 12:44:05 +0000 (14:44 +0200)] 
iconv: iconv -o should not create executable files (bug 33164)

The mistake is that open must use 0666 to pick up the umask,
and not 0777 (which is required by mkdir).

Fixes commit 8ef3cff9d1ceafe369f982d980678d749fb93bd2
("iconv: Support in-place conversions (bug 10460, bug 32033)").

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 days agomalloc: fix definition for MAX_TCACHE_SMALL_SIZE
Cupertino Miranda [Tue, 8 Jul 2025 17:54:44 +0000 (18:54 +0100)] 
malloc: fix definition for MAX_TCACHE_SMALL_SIZE

Reviewed-by: Arjun Shankar <arjun@redhat.com>
4 days agoSFrame: Add tests that uses DWARF backtracer
Claudiu Zissulescu [Mon, 14 Jul 2025 09:43:31 +0000 (12:43 +0300)] 
SFrame: Add tests that uses DWARF backtracer

When SFrame is enabled, we need to tests DW backtracer as well. Do
this by executing the same backtrace tests with .sframe section
stripped.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agoconfigure: Add --enable-sframe option
Claudiu Zissulescu [Mon, 14 Jul 2025 09:43:30 +0000 (12:43 +0300)] 
configure: Add --enable-sframe option

Enable SFrame stack track information. The --enable-sframe option
allows the glibc build to compile with SFrame stack track
information. Thus, enabling glibc's backtrace to work within glibc.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Sam James <sam@gentoo.org>
4 days agoelf: Add SFrame stack tracing
Claudiu Zissulescu [Mon, 14 Jul 2025 09:43:29 +0000 (12:43 +0300)] 
elf: Add SFrame stack tracing

This patch adds the necessary bits to enable stack tracing using
SFrame.  In the case the new SFrame stack tracing procedure doesn't
find SFrame related info, the stack tracing falls back on default
Dwarf implementation.

The new SFrame stack tracing procedure is added to debug/backtrace.c
file, the support functions are added in sysdeps folder, namely
sframe.h, read-sframe.c and read-sfame.h.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agoaarch64: Add SFrame support for aarch64 architecture
Claudiu Zissulescu [Mon, 14 Jul 2025 09:43:28 +0000 (12:43 +0300)] 
aarch64: Add SFrame support for aarch64 architecture

    The SFrame is supported for AArch64 architecture.
    Enable SFrame stack tracer for AArch64 too.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agox86: Add SFrame support for x86 architecture
Claudiu Zissulescu [Mon, 14 Jul 2025 09:43:27 +0000 (12:43 +0300)] 
x86: Add SFrame support for x86 architecture

The SFrame is well supported by x86 architecture since binutils 2.41.
Enable it to be used as default frame tracer.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
4 days agoelf: Add SFrame support to _dl_find_object function
Claudiu Zissulescu [Mon, 14 Jul 2025 09:43:26 +0000 (12:43 +0300)] 
elf: Add SFrame support to _dl_find_object function

The SFrame provides information to be able to do stack trace is now
well defined and implemented in Binutils 2.41.  The format simply
contains enough information to be able to do stack trace given a
program counter (PC) value, the stack pointer, and the frame pointer.
The SFrame information is stored in a .sframe ELF section, which is
loaded into its own PT_GNU_SFRAME segment. We consider for this support
SFrame version 2.

This patch adds the bits to _dl_find_object to recognize and store in
struct dl_find_object the necessary info about SFrame section.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 days agox86_64: Optimize modf/modff for x86_64-v2
Adhemerval Zanella [Mon, 16 Jun 2025 13:17:37 +0000 (10:17 -0300)] 
x86_64: Optimize modf/modff for x86_64-v2

The SSE4.1 provides a direct instruction for trunc, which improves
modf/modff performance with a less text size.  On Ryzen 9 (zen3) with
gcc 14.2.1:

x86_64-v2
reciprocal-throughput        master        patch       difference
workload-0_1                 7.9610       7.7914            2.13%
workload-1_maxint            9.4323       7.8021           17.28%
workload-maxint_maxfloat     8.7379       7.8049           10.68%
workload-integral            7.9492       7.7991            1.89%

latency                      master        patch       difference
workload-0_1                 7.9511      10.8910          -36.97%
workload-1_maxint           15.8278      10.9048           31.10%
workload-maxint_maxfloat    11.3495      10.9139            3.84%
workload-integral           11.5938      10.9071            5.92%

x86_64-v3
reciprocal-throughput        master        patch       difference
workload-0_1                 8.7522       7.9781            8.84%
workload-1_maxint            9.6690       7.9872           17.39%
workload-maxint_maxfloat     8.7634       7.9857            8.87%
workload-integral            8.7397       7.9893            8.59%

latency                      master        patch       difference
workload-0_1                 8.7447       9.5589           -9.31%
workload-1_maxint           13.7480       9.5690           30.40%
workload-maxint_maxfloat    10.0092       9.5680            4.41%
workload-integral            9.7518       9.5743            1.82%

For x86_64-v1 the optimization is done through a new ifunc selector.
The avx is to follow other SSE4_1 optimization (like trunc) to avoid
the ifunc for x86_64-v3.

Checked on x86_64-linux-gnu.
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
7 days agoLinux: Keep termios ioctl constants strictly internal
Florian Weimer [Fri, 11 Jul 2025 14:04:07 +0000 (16:04 +0200)] 
Linux: Keep termios ioctl constants strictly internal

Undefine TCGETS, TCGETS2, and related ioctl constants in the installed
headers.  Extract the correct constants (using the kernel type
definitions) automatically from the UAPI headers.  The kernel
constants are available under KERNEL_* names during the glibc build,
computed using assembler constant extraction mechanism.

Alpha may have to use TCGETS instead of TCGETS2 because TCTGETS2
became available in Linux 4.20 only.  Introduce ARCH_TCGETS to make
this choice explict.

To support emulation on powerpc, glibc versions of the termios
constants are added to the emulation code in internal-ioctl.h.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 days agotermios: Move isatty, __isatty_nostatus from io
Florian Weimer [Fri, 11 Jul 2025 14:04:07 +0000 (16:04 +0200)] 
termios: Move isatty, __isatty_nostatus from io

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
The definition may depend on termios internals.

7 days agotermios: Reflow and sort Makefile
Florian Weimer [Fri, 11 Jul 2025 14:04:07 +0000 (16:04 +0200)] 
termios: Reflow and sort Makefile

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 days agoRemove termios2 ioctl defintions from public headers
Andreas Schwab [Thu, 10 Jul 2025 07:19:38 +0000 (09:19 +0200)] 
Remove termios2 ioctl defintions from public headers

The use of the termios2 ioctl interface is an implementation detail which
should not bleed into public headers.  Remove the PowerPC version of
<bits/ioctls.h> and define the termios2 ioctl numbers in <termios_arch.h>
instead.  Also remove the include check from there which is unneeded in an
internal header.

9 days agoelf: Remove now pointless empty ld.so.conf files in single tests
Andreas K. Hüttel [Sat, 8 Feb 2025 16:09:04 +0000 (17:09 +0100)] 
elf: Remove now pointless empty ld.so.conf files in single tests

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agosupport: Always run ldconfig in containered tests
Andreas K. Hüttel [Sat, 8 Feb 2025 16:09:03 +0000 (17:09 +0100)] 
support: Always run ldconfig in containered tests

This is required so the generated ld.so.conf files take effect.

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoMakefile: Add ld.so.conf with libgcc dir to testroot.pristine
Andreas K. Hüttel [Sat, 8 Feb 2025 16:09:02 +0000 (17:09 +0100)] 
Makefile: Add ld.so.conf with libgcc dir to testroot.pristine

This way, a nonstandard directory within the testroot containing
libgcc_s.so can actually be picked up and used during the test runs.

Also provide a subdirectory ld.so.conf.d for drop-in configuration

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoMakeconfig: Add libgcc directory to rtld-prefix search path
Andreas K. Hüttel [Sat, 8 Feb 2025 16:09:01 +0000 (17:09 +0100)] 
Makeconfig: Add libgcc directory to rtld-prefix search path

* This needs to be done twice, for test runs with and without
  --enable-hardcoded-path-in-tests
* Also, we need to query the used $(CC) for the library location.

* The container tests run ldd and dump the list of needed libraries, then
  copy these into the container.
* Without this patch, ldd may not find libgcc_s.so, resulting in"not found"
  output and no copying of the library.
* With this patch, the library is picked up independent of its location (as
  long as the proper directory is provided) and copied into the testroot.

* This does not mean yet that ld.so in the testroot actually finds it.

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoNEWS: Mention changes to setjmp on aarch64
Yury Khrustalev [Wed, 9 Jul 2025 12:13:44 +0000 (13:13 +0100)] 
NEWS: Mention changes to setjmp on aarch64

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
9 days agoMark support for lock elision as deprecated.
Stefan Liebler [Tue, 8 Jul 2025 13:06:45 +0000 (15:06 +0200)] 
Mark support for lock elision as deprecated.

As discussed here:
https://sourceware.org/pipermail/libc-alpha/2025-July/168492.html
The support for TX lock elision of pthread mutexes is deprecated on
all architectures and will be removed in the next release.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
10 days agox86: Avoid vector/r16-r31 registers and memcpy/memset in mcount_internal
H.J. Lu [Mon, 7 Jul 2025 22:38:38 +0000 (06:38 +0800)] 
x86: Avoid vector/r16-r31 registers and memcpy/memset in mcount_internal

Since mcount_internal is called from mcount/__fentry__ which preserve
only RAX, RCX, RDX, RSI, RDI, R8 and R9, compile mcount.c with

-fno-tree-loop-distribute-patterns -mgeneral-regs-only -mno-apxf

to void vector/r16-r31 registers and memcpy/memset in mcount_internal.
This fixes BZ #33134.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
10 days agoNEWS: Mention tcache improvements
Wilco Dijkstra [Tue, 8 Jul 2025 15:03:46 +0000 (15:03 +0000)] 
NEWS: Mention tcache improvements

Update NEWS with tcache improvements.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
10 days agofstat: add test and documentation for an edge case.
Matteo Croce [Tue, 24 Jun 2025 16:40:13 +0000 (18:40 +0200)] 
fstat: add test and documentation for an edge case.

The fstatat behaviour when the target is a dangling symlink is different
if flags contains AT_SYMLINK_NOFOLLOW or not.
Add a test for this and document it.

10 days agofstatat: extend tests and documentation
Matteo Croce [Sat, 14 Jun 2025 09:59:03 +0000 (11:59 +0200)] 
fstatat: extend tests and documentation

Document the fstatat behaviour leading to a ENOENT errno, and extend
tests to test the case where filename does not exist.

Signed-off-by: Matteo Croce <teknoraver@meta.com>
12 days agohtl: move __pthread_get_cleanup_stack to libc
Samuel Thibault [Sun, 6 Jul 2025 09:01:19 +0000 (11:01 +0200)] 
htl: move __pthread_get_cleanup_stack to libc

This fixes the cleanup call from __qsort_r

12 days agohtl: Drop ptr_pthread_once from pthread_functions
Samuel Thibault [Sun, 6 Jul 2025 10:00:22 +0000 (10:00 +0000)] 
htl: Drop ptr_pthread_once from pthread_functions

It is unused since ccdb68e829a3 ("htl: move pthread_once into libc")

13 days agoelf: Restore support for _r_debug interpositions and copy relocations
Florian Weimer [Fri, 4 Jul 2025 19:46:30 +0000 (21:46 +0200)] 
elf: Restore support for _r_debug interpositions and copy relocations

The changes in commit a93d9e03a31ec14405cb3a09aa95413b67067380
("Extend struct r_debug to support multiple namespaces [BZ #15971]")
break the dyninst dynamic instrumentation tool.  It brings its
own definition of _r_debug (rather than a declaration).

Furthermore, it turns out it is rather hard to use the proposed
handshake for accessing _r_debug via DT_DEBUG. If applications want
to access _r_debug, they can do so directly if the relevant code has
been built as PIC.  To protect against harm from accidental copy
relocations due to linker relaxations, this commit restores copy
relocation support by adjusting both copies if interposition or
copy relocations are in play.  Therefore, it is possible to
use a hidden reference in ld.so to access _r_debug.

Only perform the copy relocation initialization if libc has been
loaded.  Otherwise, the ld.so search scope can be empty, and the
lookup of the _r_debug symbol mail fail.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
13 days agoelf: Introduce _dl_debug_change_state
Florian Weimer [Fri, 4 Jul 2025 19:46:16 +0000 (21:46 +0200)] 
elf: Introduce _dl_debug_change_state

It combines updating r_state with the debugger notification.

The second change to  _dl_open introduces an additional debugger
notification for dlmopen, but debuggers are expected to ignore it.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
13 days agoelf: Introduce separate _r_debug_array variable
Florian Weimer [Fri, 4 Jul 2025 19:46:05 +0000 (21:46 +0200)] 
elf: Introduce separate _r_debug_array variable

It replaces the ns_debug member of the namespaces.  Previously,
the base namespace had an unused ns_debug member.

This change also fixes a concurrency issue: Now _dl_debug_initialize
only updates r_next of the previous namespace's r_debug after the new
r_debug is initialized, so that only the initialized version is
observed.  (Client code accessing _r_debug will benefit from load
dependency tracking in CPUs even without explicit barriers.)

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
13 days agohurd: Mark more xfails for missing RLIMIT_AS support
Samuel Thibault [Sat, 5 Jul 2025 09:13:46 +0000 (11:13 +0200)] 
hurd: Mark more xfails for missing RLIMIT_AS support

2 weeks agoLinux: Fix typo in comment in termios_internals.h
Florian Weimer [Fri, 4 Jul 2025 08:50:06 +0000 (10:50 +0200)] 
Linux: Fix typo in comment in termios_internals.h

2 weeks agomanual: Remove '.info' suffix in manual names passed to @ref [BZ #32962].
Collin Funk [Tue, 13 May 2025 02:07:15 +0000 (19:07 -0700)] 
manual: Remove '.info' suffix in manual names passed to @ref [BZ #32962].

Texinfo 7.2 began warning about the '.info' suffix in the manual names
passed to @ref and similar commands.  They eventually plan to stop
stripping the '.info' suffix internally which will lead to broken links
in the manuals without this change.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2 weeks agostdlib/Makefile: Remove deleted test's libm dependency
Arjun Shankar [Wed, 2 Jul 2025 15:11:32 +0000 (17:11 +0200)] 
stdlib/Makefile: Remove deleted test's libm dependency

tst-qsort5 was deleted in 709fbd3ec3595f2d1076b4fec09a739327459288.
Therefore remove its redundant libm dependency.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agoelf: Add DL_ADDRESS_WITHOUT_RELOC [BZ #33088]
H.J. Lu [Sun, 15 Jun 2025 03:38:54 +0000 (11:38 +0800)] 
elf: Add DL_ADDRESS_WITHOUT_RELOC [BZ #33088]

Add DL_ADDRESS_WITHOUT_RELOC to force an address into a general purpose
register to prevent loading it into a vector register directly before
run-time relocation.  This is an updated fix for BZ #33088.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agostdlib: Fix __libc_message_impl iovec size (BZ 32947)
Adhemerval Zanella [Wed, 25 Jun 2025 19:33:24 +0000 (16:33 -0300)] 
stdlib: Fix __libc_message_impl iovec size (BZ 32947)

The iovec size should account for all substrings between each conversion
specification.  For the format:

  "abc %s efg"

The list of substrings are:

  ["abc ", arg, " efg]

which is 2 times the number of maximum arguments *plus* one.

This issue triggered 'out of bounds' errors by stdlib/tst-bz20544 when
glibc is built with experimental UBSAN support [1].

Besides adjusting the iovec size, a new runtime and check is added to
avoid wrong __libc_message_impl usage.

Checked on x86_64-linux-gnu.

[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/ubsan-undef

Co-authored-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agoAArch64: Avoid memset ifunc in cpu-features.c [BZ #33112]
Wilco Dijkstra [Fri, 27 Jun 2025 14:10:55 +0000 (14:10 +0000)] 
AArch64: Avoid memset ifunc in cpu-features.c [BZ #33112]

During early startup memcpy or memset must not be called since many targets
use ifuncs for them which won't be initialized yet.  Security hardening may
use -ftrivial-auto-var-init=zero which inserts calls to memset.  Redirect
memset to memset_generic by including dl-symbol-redir-ifunc.h in cpu-features.c.
This fixes BZ #33112.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agomalloc: Cleanup tcache_init()
Wilco Dijkstra [Thu, 3 Apr 2025 18:05:24 +0000 (18:05 +0000)] 
malloc: Cleanup tcache_init()

Cleanup tcache_init() by using the new __libc_malloc2 interface.

Reviewed-by: Cupertino Miranda <cupertino.miranda@oracle.com>
3 weeks agomalloc: replace instances of __builtin_expect with __glibc_unlikely
William Hunt [Thu, 26 Jun 2025 15:07:14 +0000 (15:07 +0000)] 
malloc: replace instances of __builtin_expect with __glibc_unlikely

Replaced all instances of __builtin_expect to __glibc_unlikely
within malloc.c and malloc-debug.c.  This improves the portability
of glibc by avoiding calls to GNU C built-in functions.  Since all
the expected results from calls to __builtin_expect were 0,
__glibc_likely was never used as a replacement.  Multiple
calls to __builtin_expect within a single if statement have
been replaced with one call to __glibc_unlikely, which wraps
every condition.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 weeks agomalloc: refactored aligned_OK and misaligned_chunk
William Hunt [Wed, 25 Jun 2025 11:35:05 +0000 (11:35 +0000)] 
malloc: refactored aligned_OK and misaligned_chunk

Renamed aligned_OK to misaligned_mem as to be similar
to misaligned_chunk, and reversed any assertions using
the macro.  Made misaligned_chunk call misaligned_mem after
chunk2mem rather than bitmasking with the malloc alignment
itself, since misaligned_chunk is meant to test the data
chunk itself rather than the header, and the compiler
will optimise the addition so the ternary operator is not
needed.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
3 weeks agomanual: Clarify renameat documentation
Jitka Obselkova [Sat, 14 Jun 2025 09:19:46 +0000 (11:19 +0200)] 
manual: Clarify renameat documentation

Clarify the meaning of renameat arguments.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agoRevert "manual: Clarify renameat documentation"
Florian Weimer [Thu, 26 Jun 2025 12:22:58 +0000 (14:22 +0200)] 
Revert "manual: Clarify renameat documentation"

This reverts commit abc2e954af77f8d10f4f54754520814590e79830.
Reason for revert: Wrong version of the patch.

3 weeks agoelf: Add missing DSO dependencies for tst-rtld-no-malloc-{audit,preload}
Florian Weimer [Thu, 26 Jun 2025 09:38:00 +0000 (11:38 +0200)] 
elf: Add missing DSO dependencies for tst-rtld-no-malloc-{audit,preload}

Fixes commit c1560f3f75c0e892b5522c16f91b4e303f677094
("elf: Switch to main malloc after final ld.so self-relocation").

Reviewed-by: Frédéric Bérat <fberat@redhat.com>
3 weeks agopowerpc: Remove modf optimization
Adhemerval Zanella [Mon, 16 Jun 2025 13:17:36 +0000 (10:17 -0300)] 
powerpc: Remove modf optimization

The generic implementation is slight more optimized than the powerpc
one, where it has a more optimized inf/nan check (by not using FP
unit checks, along with branch prediction hints), and removed one
branch by issuing trunc instead of a combination of floor/ceil (which
also generated less code).

On power10 with gcc 14.2.1:

reciprocal-throughput        master         patch        difference
workload-0_1                 1.1351        0.9067            20.12%
workload-1_maxint            1.4230        0.9040            36.47%
workload-maxint_maxfloat     1.5038        0.9076            39.65%
workload-integral            1.1280        0.9111            19.23%

latency                      master         patch        difference
workload-0_1                 1.1440        2.7117          -137.03%
workload-1_maxint            4.0556        2.7070            33.25%
workload-maxint_maxfloat     3.2122        2.7164            15.43%
workload-integral            3.2381        2.7281            15.75%

Checked on powerpc64le-linux-gnu.
Reviewed-by: Sachin Monga <smonga@linux.ibm.com>
3 weeks agopowerpc: Remove modff optimization
Adhemerval Zanella [Mon, 16 Jun 2025 13:17:35 +0000 (10:17 -0300)] 
powerpc: Remove modff optimization

The generic implementation is slight more optimized than the powerpc
one, where it has a more optimized inf/nan check (by not using FP
unit checks, along with branch prediction hints), and removed one
branch by issuing trunc instead of a combination of floor/ceil (which
also generated less code).

On power10 with gcc 14.2.1:

reciprocal-throughput        master        patch        difference
workload-0_1                 1.5210       1.3942             8.34%
workload-1_maxint            2.0926       1.3940            33.38%
workload-maxint_maxfloat     1.7851       1.3940            21.91%
workload-integral            1.5216       1.3941             8.37%

latency                      master        patch        difference
workload-0_1                 1.5928       2.6337           -65.35%
workload-1_maxint            3.2929       2.6337            20.02%
workload-maxint_maxfloat     1.9697       2.6341           -33.73%
workload-integral            2.0597       2.6337           -27.87%

Checked on powerpc64le-linux-gnu.
Reviewed-by: Sachin Monga <smonga@linux.ibm.com>
3 weeks agomanual: Add missing free to open_memstream example [BZ #27866]
Ravina Jain [Tue, 24 Jun 2025 15:06:25 +0000 (20:36 +0530)] 
manual: Add missing free to open_memstream example [BZ #27866]

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agoLinux: Convert '__close_nocancel_nostatus' to a standalone handler
Maciej W. Rozycki [Tue, 24 Jun 2025 20:17:25 +0000 (21:17 +0100)] 
Linux: Convert '__close_nocancel_nostatus' to a standalone handler

Make '__close_nocancel_nostatus' standalone.  This is a generic version
analogous to '__close_nocancel'.  Platforms may choose to implement an
inline variant instead where the syscall invocation code sequence is
short enough to be beneficial over a function call.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 weeks agoLinux: Fix '__close_nocancel_nostatus' clobbering 'errno' [BZ #33035]
Maciej W. Rozycki [Tue, 24 Jun 2025 20:17:25 +0000 (21:17 +0100)] 
Linux: Fix '__close_nocancel_nostatus' clobbering 'errno' [BZ #33035]

Fix fallout from commit c181840c93d3 ("Consolidate non cancellable close
call") that caused '__close_nocancel_nostatus' to clobber 'errno' on a
close(2) failure, a 2.27 regression.

The problem came from a rewrite from 'close_not_cancel_no_status' to
'__close_nocancel_nostatus' switching from an inline implementation that
used INTERNAL_SYSCALL macro (which stays away from 'errno') to a call to
'__close_nocancel' function that uses INLINE_SYSCALL_CALL macro (which
does poke at 'errno').

Implement '__close_nocancel_nostatus' in terms of INTERNAL_SYSCALL_CALL
then, which leaves 'errno' intact.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 weeks agoinet: Implement inet_ntoa on top of inet_ntop
Adhemerval Zanella [Wed, 4 Jun 2025 20:42:44 +0000 (17:42 -0300)] 
inet: Implement inet_ntoa on top of inet_ntop

Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoresolv: Optimize inet_ntop
Adhemerval Zanella [Wed, 4 Jun 2025 20:42:43 +0000 (17:42 -0300)] 
resolv: Optimize inet_ntop

The benchtests/inet_ntop_ipv4 and benchtests/inet_ntop_ipv6 profile
shows that most of time is spent in costly sprint operations:

$ perf record ./benchtests/bench-inet_ntop_ipv4 && perf report --stdio
[...]
    38.53%  bench-inet_ntop  libc.so               [.] __printf_buffer
    18.69%  bench-inet_ntop  libc.so               [.] __printf_buffer_write
    11.01%  bench-inet_ntop  libc.so               [.] _itoa_word
     8.02%  bench-inet_ntop  bench-inet_ntop_ipv4  [.] bench_start
     6.99%  bench-inet_ntop  libc.so               [.] __memmove_avx_unaligned_erms
     3.86%  bench-inet_ntop  libc.so               [.] __strchrnul_avx2
     2.82%  bench-inet_ntop  libc.so               [.] __strcpy_avx2
     1.90%  bench-inet_ntop  libc.so               [.] inet_ntop4
     1.78%  bench-inet_ntop  libc.so               [.] __vsprintf_internal
     1.55%  bench-inet_ntop  libc.so               [.] __sprintf_chk
     1.18%  bench-inet_ntop  libc.so               [.] __GI___inet_ntop

$ perf record ./benchtests/bench-inet_ntop_ipv6 && perf report --stdio
    35.44%  bench-inet_ntop  libc.so               [.] __printf_buffer
    14.35%  bench-inet_ntop  libc.so               [.] __printf_buffer_write
    10.27%  bench-inet_ntop  libc.so               [.] __GI___inet_ntop
     7.93%  bench-inet_ntop  libc.so               [.] _itoa_word
     7.00%  bench-inet_ntop  libc.so               [.] __sprintf_chk
     6.20%  bench-inet_ntop  libc.so               [.] __vsprintf_internal
     5.26%  bench-inet_ntop  libc.so               [.] __strchrnul_avx2
     5.05%  bench-inet_ntop  bench-inet_ntop_ipv6  [.] bench_start
     3.70%  bench-inet_ntop  libc.so               [.] __memmove_avx_unaligned_erms
     2.11%  bench-inet_ntop  libc.so               [.] __printf_buffer_done

A new implementation is used instead:

  * The printf usage is replaced with an expanded function that prints
    either an IPv4 octet or an IPv6 quartet;

  * The strcpy is replaced with a memcpy (since ABIs usually tends to
    optimize the latter);

  * For IPv6, the '::' shorthanding is done in-place instead of using
    a temporary buffer.

  * An temporary buffer is used iff the size if larger than
    INET_ADDRSTRLEN/INET6_ADDRSTRLEN.

  * Inline is used for both inet_ntop4 and inet_ntop6,

The code is significand rewrote, so I take this requires a new license.

The performance results on aarch64 Neoverse1 with gcc 14.2.1:

* master

aarch64-linux-gnu-master$ ./benchtests/bench-inet_ntop_ipv4
  "inet_ntop_ipv4": {
   "workload-ipv4-random": {
    "duration": 1.43067e+09,
    "iterations": 8e+06,
    "reciprocal-throughput": 178.572,
    "latency": 179.096,
    "max-throughput": 5.59997e+06,
    "min-throughput": 5.58359e+06
   }
aarch64-linux-gnu-master$ ./benchtests/bench-inet_ntop_ipv6
  "inet_ntop_ipv6": {
   "workload-ipv6-random": {
    "duration": 1.68539e+09,
    "iterations": 4e+06,
    "reciprocal-throughput": 421.307,
    "latency": 421.388,
    "max-throughput": 2.37357e+06,
    "min-throughput": 2.37311e+06
   }
  }

* patched

aarch64-linux-gnu$ ./benchtests/bench-inet_ntop_ipv4
  "inet_ntop_ipv4": {
   "workload-ipv4-random": {
    "duration": 1.06133e+09,
    "iterations": 5.6e+07,
    "reciprocal-throughput": 18.8482,
    "latency": 19.0565,
    "max-throughput": 5.30555e+07,
    "min-throughput": 5.24755e+07
   }
  }
aarch64-linux-gnu$ ./benchtests/bench-inet_ntop_ipv6
  "inet_ntop_ipv6": {
   "workload-ipv6-random": {
    "duration": 1.01246e+09,
    "iterations": 2.4e+07,
    "reciprocal-throughput": 42.5576,
    "latency": 41.8139,
    "max-throughput": 2.34976e+07,
    "min-throughput": 2.39155e+07
   }
  }

Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoresolve: Proper indent resolv/inet_ntop.c
Adhemerval Zanella [Wed, 4 Jun 2025 20:42:42 +0000 (17:42 -0300)] 
resolve: Proper indent resolv/inet_ntop.c

Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agobenchtests: Add IPv6 inet_ntop benchmark
Adhemerval Zanella [Wed, 4 Jun 2025 20:42:41 +0000 (17:42 -0300)] 
benchtests: Add IPv6 inet_ntop benchmark

Random IP addresses in the full range.  There is no extra workload
to check the effectiveness '::' optimization for a set of 0-oct
sets (although it would be a possible workload).
Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agobenchtests: Add IPv4 inet_ntop benchmark
Adhemerval Zanella [Wed, 4 Jun 2025 20:42:40 +0000 (17:42 -0300)] 
benchtests: Add IPv4 inet_ntop benchmark

Random IP addresses in the full range.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
3 weeks agoriscv: linux: Add support for getrandom vDSO
Xi Ruoyao [Thu, 19 Jun 2025 16:25:32 +0000 (00:25 +0800)] 
riscv: linux: Add support for getrandom vDSO

Linux kernel >= 6.16 has getrandom() in vDSO for RISC-V.  Enable the use
of it in Glibc so it would benefit the programs using the Glibc high
quality random number functions.

Link: https://git.kernel.org/torvalds/c/ee0d03053e70
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoposix: Fix fnmatch build with gcc-16
Adhemerval Zanella [Fri, 20 Jun 2025 14:35:56 +0000 (11:35 -0300)] 
posix: Fix fnmatch build with gcc-16

The master branch started to enable some warnings due to optimization
that were only triggered with -Os [1].  Enable the suppression regardless
of optimization level.

Checked on aarch64-linux-gnu build.

[1] https://gcc.gnu.org/pipermail/gcc-regression/2025-June/082378.html
Reviewed-by: Sam James <sam@gentoo.org>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 weeks agopowerpc: use .machine power10 in POWER10 assembler sources
Andreas Schwab [Mon, 23 Jun 2025 09:37:23 +0000 (11:37 +0200)] 
powerpc: use .machine power10 in POWER10 assembler sources

They were misattributed as POWER9 sources.

3 weeks agohurd: Remove a duplicate entry from 'tests-unsupported'.
Collin Funk [Tue, 17 Jun 2025 03:14:19 +0000 (20:14 -0700)] 
hurd: Remove a duplicate entry from 'tests-unsupported'.

When building on GNU/Hurd the following warnings repeat themselves:

    ../Rules:400: target '/home/collin/obj/glibc/io/test-lfs.out' given more than once in the same rule
    ../Rules:400: target '/home/collin/obj/glibc/io/test-lfs.out' given more than once in the same rule

This is because commit 73b854e955 (hurd: Mark more memory-hungry tests
as unsupported, 2025-01-12) added it to 'tests-unsupported' even though
it was already added by decf02d382 (hurd: Mark two tests as unsupported,
2023-04-13).
Message-ID: <54dc6bf7e0dbedb1b19356f41fec843c1c523b11.1750130025.git.collin.funk1@gmail.com>

3 weeks agohurd: Fix redefinition of 'P2ALIGN'.
Collin Funk [Tue, 17 Jun 2025 03:45:14 +0000 (20:45 -0700)] 
hurd: Fix redefinition of 'P2ALIGN'.

When building on GNU/Hurd warnings like the following occur:

    ../sysdeps/x86_64/multiarch/strnlen-evex-base.S:53:10: warning: "P2ALIGN" redefined
       53 | # define P2ALIGN(...)   .p2align 4,, 6
          |          ^~~~~~~
    In file included from /usr/include/x86_64-gnu/mach/x86_64/syscall_sw.h:30,
                     from ../sysdeps/mach/sysdep.h:21,
                     from ../sysdeps/mach/x86/sysdep.h:31,
                     from ../sysdeps/x86_64/multiarch/strnlen-evex-base.S:24:
    /usr/include/x86_64-gnu/mach/x86_64/asm.h:78:9: note: this is the location of the previous definition
       78 | #define P2ALIGN(p2)     .p2align p2     /* gas-specific */
          |         ^~~~~~~

The fix is to undefine the macro from system headers in sysdep.h so that
it can be properly defined in assembly files where its definition
depends on whether string functions are being compiled for
wide-characters or not.
Message-ID: <721cd3a1bae1a553857db1dd69761a175f611364.1750131904.git.collin.funk1@gmail.com>

4 weeks agoresource/Makefile: Split and sort tests
Martin Coufal [Sat, 14 Jun 2025 09:08:18 +0000 (11:08 +0200)] 
resource/Makefile: Split and sort tests

Split and sort tests in resource/Makefile.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
4 weeks agomalloc: Link large tcache tests with $(shared-thread-library)
Florian Weimer [Thu, 19 Jun 2025 04:30:12 +0000 (06:30 +0200)] 
malloc: Link large tcache tests with $(shared-thread-library)

Introduce tests-link-with-libpthread to list tests that
require linking with libpthread, and use that to generate
dependencies on $(shared-thread-library) for all multi-threaded tests.

Fixes build failures of commit cde5caa4bb21d5c474b9e4762cc847bcbc70e481
("malloc: add testing for large tcache support") on Hurd.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agox86: Update tst-gnu2-tls2 tests
H.J. Lu [Mon, 9 Jun 2025 00:17:49 +0000 (08:17 +0800)] 
x86: Update tst-gnu2-tls2 tests

Update tst-gnu2-tls2 tests to set XMM0...XMM7 to all 1s in malloc to
verify that XMM registers are preserved when _dl_tlsdesc_dynamic is
called by clearing vectors with zeroed XMM registers before
_dl_tlsdesc_dynamic and using these XMM registers to clear vectors
after _dl_tlsdesc_dynamic.  This improves the BZ #31372 test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
4 weeks agoi386: Update ___tls_get_addr to preserve vector registers
H.J. Lu [Sun, 8 Jun 2025 21:22:10 +0000 (05:22 +0800)] 
i386: Update ___tls_get_addr to preserve vector registers

Compiler generates the following instruction sequence for dynamic TLS
access:

leal tls_var@tlsgd(,%ebx,1), %eax
call ___tls_get_addr@PLT

CALL instruction is transparent to compiler which assumes all registers,
except for EFLAGS, AX, CX, and DX, are unchanged after CALL.  But
___tls_get_addr is a normal function which doesn't preserve any vector
registers.

1. Rename the generic __tls_get_addr function to ___tls_get_addr_internal.
2. Change ___tls_get_addr to a wrapper function with implementations for
FNSAVE, FXSAVE, XSAVE and XSAVEC to save and restore all vector registers.
3. dl-tlsdesc-dynamic.h has:

_dl_tlsdesc_dynamic:
/* Like all TLS resolvers, preserve call-clobbered registers.
   We need two scratch regs anyway.  */
subl $32, %esp
cfi_adjust_cfa_offset (32)

It is wrong to use

movl %ebx, -28(%esp)
movl %esp, %ebx
cfi_def_cfa_register(%ebx)
...
mov %ebx, %esp
cfi_def_cfa_register(%esp)
movl -28(%esp), %ebx

to preserve EBX on stack.  Fix it with:

movl %ebx, 28(%esp)
movl %esp, %ebx
cfi_def_cfa_register(%ebx)
...
mov %ebx, %esp
cfi_def_cfa_register(%esp)
movl 28(%esp), %ebx

4. Update _dl_tlsdesc_dynamic to call ___tls_get_addr_internal directly.
5. Add have-test-mtls-traditional to compile tst-tls23-mod.c with
traditional TLS variant to verify the fix.
6. Define DL_RUNTIME_RESOLVE_REALIGN_STACK in sysdeps/x86/sysdep.h.

This fixes BZ #32996.

Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agomanual: Clarify renameat documentation
Jitka Obselkova [Sat, 14 Jun 2025 09:19:46 +0000 (11:19 +0200)] 
manual: Clarify renameat documentation

Clarify the meaning of renameat arguments.

Signed-off-by: Jitka Obselkova <jobselko@redhat.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
4 weeks agoposix: Add nonnull attribute to glob_pattern_p.
Collin Funk [Sat, 7 Jun 2025 23:20:27 +0000 (16:20 -0700)] 
posix: Add nonnull attribute to glob_pattern_p.

* posix/glob.h (glob_pattern_p): Add __nonnull ((1)) since this function
expects a string and does not check for NULL.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agomath: Simplify and optimize modf implementation
Adhemerval Zanella [Mon, 16 Jun 2025 13:17:34 +0000 (10:17 -0300)] 
math: Simplify and optimize modf implementation

Refactor the generic implementation to use math_config.h definitions,
and add an alternative one if the ABI supports truncf instructions
(gated through math-use-builtins-trunc.h).

The generic implementation generates similar code on x86_64, while
the optimization one for aarch64 (where truncf is supported as a
builtin by through frintz), the improvements are:

reciprocal-throughput           master    patch    difference
workload-0_1                    3.0595   3.0698        -0.34%
workload-1_maxint               5.1747   3.0542        40.98%
workload-maxint_maxfloat        3.4391   3.0349        11.75%
workload-integral               3.2732   3.0293         7.45%

latency                         master    patch    difference
workload-0_1                    3.5267   4.7107       -33.57%
workload-1_maxint               6.9074   4.7282        31.55%
workload-maxint_maxfloat        3.7210   4.7506       -27.67%
workload-integral               3.8634   4.8137       -24.60%

Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agomath: Simplify and optimize modff implementation
Adhemerval Zanella [Mon, 16 Jun 2025 13:17:33 +0000 (10:17 -0300)] 
math: Simplify and optimize modff implementation

Refactor the generic implementation to use math_config.h definitions,
and add an alternative one if the ABI supports truncf instructions
(gated through math-use-builtins-trunc.h).

The generic implementation generates similar code for x86_64, while
the optimization path aarch64 (where truncf is supported as a builtin)
through frintz), the improvements are:

reciprocal-throughput           master     patch    difference
workload-0_1                    3.0740    3.0326         1.35%
workload-1_maxint               5.2231    3.0436        41.73%
workload-maxint_maxfloat        4.0962    3.0551        25.42%
workload-integral               3.7093    3.0612        17.47%

latency                         master     patch    difference
workload-0_1                    3.5521    4.7313       -33.20%
workload-1_maxint               6.7148    4.7314        29.54%
workload-maxint_maxfloat        4.0458    4.7518       -17.45%
workload-integral               3.9719    4.7427       -19.40%

Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agoAArch64: Improve codegen SVE log1p helper
Luna Lamb [Wed, 18 Jun 2025 16:12:19 +0000 (16:12 +0000)] 
AArch64: Improve codegen SVE log1p helper

Improve codegen by packing coefficients.
4% and 2% improvement in throughput microbenchmark on Neoverse V1, for acosh
and atanh respectively.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agoAArch64: Optimise SVE FP64 Hyperbolics
Dylan Fleming [Wed, 18 Jun 2025 16:19:22 +0000 (16:19 +0000)] 
AArch64: Optimise SVE FP64 Hyperbolics

Reworke SVE FP64 hyperbolics to use the SVE FEXPA
instruction.

Also update the special case handelling for large
inputs to be entirely vectorised.

Performance improvements on Neoverse V1:

cosh_sve: 19% for |x| < 709, 5x otherwise
sinh_sve: 24% for |x| < 709, 5.9x otherwise
tanh_sve: 12% for |x| < 19,  9x otherwise

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agoAArch64: Optimize SVE exp functions
Dylan Fleming [Wed, 18 Jun 2025 16:17:12 +0000 (16:17 +0000)] 
AArch64: Optimize SVE exp functions

Improve performance of SVE exps by making better use
of the SVE FEXPA instruction.

Performance improvement on Neoverse V1:
exp2_sve:   21%
exp2f_sve:  24%
exp10f_sve: 23%
expm1_sve:  25%

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
4 weeks agosparc: Fix sparc32 Fix argument passing to __libc_start_main (BZ 32981)
Adhemerval Zanella [Fri, 13 Jun 2025 14:23:44 +0000 (11:23 -0300)] 
sparc: Fix sparc32 Fix argument passing to __libc_start_main (BZ 32981)

Commit 404526ee2e58f3c075253943ddc9988f4bd6b80c changed _start to write
the last argument to __libc_start_main without taking into consideration
that the function did not create a full stack frame, which leads to
overwriting the argv[0].

4 weeks agoFix termios related targets
Andreas Schwab [Wed, 18 Jun 2025 11:17:29 +0000 (13:17 +0200)] 
Fix termios related targets

Move Linux-specific termios headers and tests from misc to termios subdir
and install newly added bits/termios-cbaud.h.

4 weeks agomalloc: Cleanup _mid_memalign
Wilco Dijkstra [Wed, 28 May 2025 14:44:10 +0000 (14:44 +0000)] 
malloc: Cleanup _mid_memalign

Remove unused 'address' parameter from _mid_memalign and callers.
Fix off-by-one alignment calculation in __libc_pvalloc.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 weeks agoaarch64: simplify calls to __libc_arm_za_disable in assembly
Yury Khrustalev [Mon, 16 Jun 2025 09:01:22 +0000 (10:01 +0100)] 
aarch64: simplify calls to __libc_arm_za_disable in assembly

There is no functional change in this patch.

We remove stores and loads to stack, return address signing, and redundant
CFI directives before and after call to __libc_arm_za_disable().

The __libc_arm_za_disable implementation follows special calling convention
that allows to avoid most of the operations that would be necessary for a
call to a normal function (see [1] for details).

First, we rely on __libc_arm_za_disable() not clobbering certain registers,
and we put return address into one of these registers. Now we don't need
to store it on stack, so we don't need to sign return address using PAC.

Second, as a result of the above, we don't need to update the CFI offset.

This patch provides small optimisation avoiding unnecessary store and load
on stack also simplifies assembly code and CFI directives.

[1]: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agoaarch64: GCS: use internal struct in __alloc_gcs
Yury Khrustalev [Wed, 16 Apr 2025 18:08:47 +0000 (19:08 +0100)] 
aarch64: GCS: use internal struct in __alloc_gcs

No functional change here, just a small refactoring to simplify
using __alloc_gcs() for allocating shadow stacks.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agopowerpc: Remove assembler workarounds
Andreas Schwab [Thu, 5 Jun 2025 08:24:46 +0000 (10:24 +0200)] 
powerpc: Remove assembler workarounds

Now that we require at least binutils 2.39 the support for POWER9 and
POWER10 instructions can be assumed.

4 weeks agomalloc: Fix tests-malloc-largetcache tests
Adhemerval Zanella [Tue, 17 Jun 2025 17:22:49 +0000 (14:22 -0300)] 
malloc: Fix tests-malloc-largetcache tests

The commit cde5caa4bb21d5c474b9e4762cc847bcbc70e481 added the
tests-malloc-largetcache without adjusting the previous entry.  The
make check fails with:

  make[1]: Entering directory '/path/to/glibc'
  make  subdir=csu -C csu ..=../ tests
  make[2]: Entering directory '/path/to/glibc/csu'
  make[2]: *** No rule to make target ')', needed by 'tests'.  Stop.
  make[2]: Leaving directory '/path/to/csu'
  make[1]: *** [Makefile:484: csu/tests] Error 2

4 weeks agoAdd TCPI_OPT_USEC_TS from Linux 6.14 and TCPI_OPT_TFO_CHILD from 6.15 to netinet...
Jeremy Harris [Sat, 31 May 2025 07:57:20 +0000 (08:57 +0100)] 
Add TCPI_OPT_USEC_TS from Linux 6.14 and TCPI_OPT_TFO_CHILD from 6.15 to netinet/tcp.h.

This patch adds the TCPI_OPT_USEC_TS constant from Linux 6.14 to
sysdeps/gnu/netinet/tcp.h

This patch adds the TCPI_OPT_TFO_CHILD constant from Linux 6.15 to
sysdeps/gnu/netinet/tcp.h

Signed-off-by: Jeremy Harris <jgh@exim.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agolinux/termios: regression test for termios speed functions
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:45 +0000 (18:35 -0700)] 
linux/termios: regression test for termios speed functions

Test that runs through a fairly large combination of the various
termios speed functions, for the new speed_t interface, for the old
speed_t interface (if enabled), and for the new baud_t interface.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
4 weeks agoinclude/array_length.h: add array_foreach[_const] macros
H. Peter Anvin [Thu, 12 Jun 2025 01:35:44 +0000 (18:35 -0700)] 
include/array_length.h: add array_foreach[_const] macros

Add simple-to-use iterator macros for arrays.  They are used instead
of explicit for statements, like:

      /* Test all common speeds */
      array_foreach_const (ts, test_speeds)
test (fd, *ts);

In this case, ts will be a const pointer to each of the elements of
test_speeds in turn.

Named array_foreach*() to allow for other kinds of equivalent iterator
macros in the future.

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agotermios: unify the naming of the termios speed fields
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:43 +0000 (18:35 -0700)] 
termios: unify the naming of the termios speed fields

The generic code has __ispeed and __ospeed; Linux has c_ispeed and
c_ospeed. Use an anonymous union member to allow both set of names on
all platforms.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
4 weeks agotermios: add new baud_t interface, defined to be explicitly numeric
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:42 +0000 (18:35 -0700)] 
termios: add new baud_t interface, defined to be explicitly numeric

Add an explicitly numeric interface for baudrate setting. For glibc,
this only announces what is a fair accompli, but this is a plausible
way forward for standardization, and may be possible to infill on
non-compliant systems. The POSIX committee has stated:

[https://www.austingroupbugs.net/view.php?id=1916#c7135]

A future version of this standard is expected to add at least
the following symbolic constants for use as values of objects
of type speed_t: B57600, B115200B230400B460800, and
B921600.

Implementations are encouraged to propose additional
interfaces which will make it possible to set and query a
wider range of speeds than just those enumerated by the
constants beginning with B. If a set of common interfaces
emerges between several implementations, a future version of
this standard will likely add those interfaces.

This is exactly that interface.

The use of the term "baud" is due to the need to have a term
contrasting "speed", and it is already well established as a legacy
term -- including in the names of the legacy Bxxx
constants. Futhermore, it *is* valid from the point of view that the
termios interface fundamentally emulates an RS-232 serial port as far
as the application software is concerned.

The documentation states that for the current version of glibc,
speed_t == baud_t, but explicitly declares that this may not be the
case in the future.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agomanual: document all the termios Bxxx constants in the manual
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:41 +0000 (18:35 -0700)] 
manual: document all the termios Bxxx constants in the manual

Add all the Bxxx constants defined in the now-generic
<bits/termios-baud.h> in the manual.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
4 weeks agotermios: merge the termios baud definitions
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:40 +0000 (18:35 -0700)] 
termios: merge the termios baud definitions

Now all platforms unconditionally use the "sane" definitions of the
termios baud constants. Unify them into a common file.

Note: I have made them explicitly unsigned to avoid problems with
compiler warnings for comparisons of unequal signedness or
similar. These constants were historically octal on most platforms,
and so unsigned by default.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agohurd+generic/termios: make speed_t an unsigned int
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:39 +0000 (18:35 -0700)] 
hurd+generic/termios: make speed_t an unsigned int

POSIX requires that speed_t is an unsigned integer type, so change the
generic speed_t definition to be an unsigned int instead of a plain
int.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
4 weeks agotermios: change the generic cfsetspeed() to support arbitrary speeds
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:38 +0000 (18:35 -0700)] 
termios: change the generic cfsetspeed() to support arbitrary speeds

The generic implementaion of cfsetspeed() had an internal table of
permitted baud rates, which was enforced even on an implementation
supporting arbitrary baud rates. This was to be able to *also* accept
numeric constants as well as Bxxx values.

This fundamentally makes no sense; not only does it go against the
documented behavior of cfsetspeed() which is to take the same input
as cfset[io]speed(), but it means cfsetspeed() is broken with regard
to a platform supporting arbitrary speeds.

With Linux converted to arbitrary baud rates, the only remaining case
of non-arbitrary baud rates appears to be Hurd with USE_OLD_TTY, which
one can presume being a legacy case that few if any people care about,
and so simply strip out this code and make cfsetspeed() rely on
cfsetospeed() to validate acceptable speed constants.

If a new platform is introduced which does not have arbitrary baud
rate support, using non-baud rate Bxxx constants (highly not
recommended; should be abstracted at the glibc level) but such
aliasing is desired, it should be supported by cfset[io]speed() as
well, and belongs in the platform-specific code.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agohurd/termios: remove USE_OLD_TTY
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:37 +0000 (18:35 -0700)] 
hurd/termios: remove USE_OLD_TTY

Hurd with USE_OLD_TTY was the only remaining platform with speed_t not
containing a proper baud rate. From the looks of it, that code has
long since bitrotted.

Remove the vestiges of USE_OLD_TTY.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
4 weeks agolinux: implement arbitrary and split speeds in termios
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:36 +0000 (18:35 -0700)] 
linux: implement arbitrary and split speeds in termios

Linux has supported arbitrary speeds and split speeds in the kernel
since 2008 on all platforms except Alpha (fixed in 2020), but glibc
was never updated to match. This is further complicated by POSIX uses
of macros for the cf[gs]et[io]speed interfaces, rather than plain
numbers, as it really ought to have.

On most platforms, the glibc ABI includes the c_[io]speed fields in
struct termios, but they are incorrectly used. On MIPS and SPARC, they
are entirely missing.

For backwards compatibility, the kernel will still use the legacy
speed fields unless they are set to BOTHER, and will use the legacy
output speed as the input speed if the latter is 0 (== B0). However,
the specific encoding used is visible to user space applications,
including ones other than the one running.

- SPARC and MIPS get a new struct termios, and tc[gs]etattr() is
  versioned accordingly. However, the new struct termios is set to be
  a strict extension of the old one, which means that cf* interfaces
  other than the speed-related ones do not need versioning.
- The Bxxx constants are redefined as equivalent to their integer
  values and the legacy Bxxx constants are renamed __Bxxx.
- cf[gs]et[io]speed() and cfsetspeed() are versioned accordingly.
- tcgetattr() and cfset[io]speed() are adjusted to always keep the
  c_[io]speed fields correct (unlike earlier versions), but to
  canonicalize the representation to ALSO configure the legacy fields
  if a valid legacy representation exists.
- tcsetattr(), too, canonicalizes the representation in this way
  before passing it to the kernel, to maximize compatibility with
  older applications/tools.
- The old IBAUD0 hack is removed; it is no longer necessary since
  even the legacy c_cflag baud rate fields have had separate input
  values for a long time.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agolinux/termios/powerpc: deal with powerpc-unique ioctl emulation
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:35 +0000 (18:35 -0700)] 
linux/termios/powerpc: deal with powerpc-unique ioctl emulation

The powerpc architecture, only, emulates the termios ioctls using the
glibc termios structure. Export the real kernel ones as the termios2
interface; although the kernel doesn't call it termios2, it is exactly
the termios2 interface, and it avoids the namespace clash between the
emulated ioctls and the real kernel ioctls.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agolinux/ioctls: use <linux/sockios.h> for sockios ioctls
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:34 +0000 (18:35 -0700)] 
linux/ioctls: use <linux/sockios.h> for sockios ioctls

In the kernel, these are <linux/sockios.h>. The differences between
<linux/sockios.h> and the copied data in <bits/ioctls.h> are minor;
mainly some #ifdefs, so try to use <linux/sockios.h> directly; it is
hopefully clean enough these days to use directly.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agoio: replace local_isatty() with a proper function __isatty_nostatus()
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:33 +0000 (18:35 -0700)] 
io: replace local_isatty() with a proper function __isatty_nostatus()

Replace local_isatty() inlined in libio with a proper function
__isatty_nostatus(). This allows simpler system-specific
implementations that don't need to touch errno at all.

Note: I left the prototype in include/unistd.h (the internal header
file.) It didn't much make sense to me to put it in a different header
(not-cancel.h), but perhaps someone can elucidate the need.

Add such an implementation for Linux, with a generic fallback.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agotermios: make __tcsetattr() the internal interface
H. Peter Anvin (Intel) [Thu, 12 Jun 2025 01:35:32 +0000 (18:35 -0700)] 
termios: make __tcsetattr() the internal interface

There is a prototype for an internal __tcsetattr() function in
include/termios.h, but tcsetattr without __ were still declared as the
actual functions.

Make this match the comment and make __tcsetattr() an internal
interface. This will be required to version struct termios for Linux on
MIPS and SPARC.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 weeks agoUpdate advisory GLIBC-SA-2025-0003 and GLIBC-SA-2025-0004
Carlos O'Donell [Mon, 16 Jun 2025 22:16:18 +0000 (18:16 -0400)] 
Update advisory GLIBC-SA-2025-0003 and GLIBC-SA-2025-0004

Add Fix-Commit information for backported fixes.

4 weeks agomalloc: Sort tests-exclude-largetcache in Makefile
H.J. Lu [Mon, 16 Jun 2025 21:52:27 +0000 (05:52 +0800)] 
malloc: Sort tests-exclude-largetcache in Makefile

This fixes:

FAIL: lint-makefiles

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agoppc64le: Revert "powerpc: Optimized strcmp for power10" (CVE-2025-5702)
Carlos O'Donell [Mon, 16 Jun 2025 17:09:57 +0000 (13:09 -0400)] 
ppc64le: Revert "powerpc: Optimized strcmp for power10" (CVE-2025-5702)

This reverts commit 3367d8e180848030d1646f088759f02b8dfe0d6f

Reason for revert: Power10 strcmp clobbers non-volatile vector
registers (Bug 33056)

Tested on ppc64le without regression.

4 weeks agoppc64le: Revert "powerpc : Add optimized memchr for POWER10" (Bug 33059)
Carlos O'Donell [Wed, 11 Jun 2025 13:33:45 +0000 (09:33 -0400)] 
ppc64le: Revert "powerpc : Add optimized memchr for POWER10" (Bug 33059)

This reverts commit b9182c793caa05df5d697427c0538936e6396d4b

Reason for revert: Power10 memchr clobbers v20 vector register
(Bug 33059)

This is not a security issue, unlike CVE-2025-5745 and
CVE-2025-5702.

Tested on ppc64le without regression.

4 weeks agoppc64le: Revert "powerpc: Fix performance issues of strcmp power10" (CVE-2025-5702)
Carlos O'Donell [Wed, 11 Jun 2025 13:43:50 +0000 (09:43 -0400)] 
ppc64le: Revert "powerpc: Fix performance issues of strcmp power10" (CVE-2025-5702)

This reverts commit 90bcc8721ef82b7378d2b080141228660e862d56

This change is in the chain of the final revert that fixes the CVE
i.e. 3367d8e180848030d1646f088759f02b8dfe0d6f

Reason for revert: Power10 strcmp clobbers non-volatile vector
registers (Bug 33056)

Tested on ppc64le with no regressions.

4 weeks agoppc64le: Revert "powerpc: Optimized strncmp for power10" (CVE-2025-5745)
Carlos O'Donell [Wed, 11 Jun 2025 13:19:17 +0000 (09:19 -0400)] 
ppc64le: Revert "powerpc: Optimized strncmp for power10" (CVE-2025-5745)

This reverts commit 23f0d81608d0ca6379894ef81670cf30af7fd081

Reason for revert: Power10 strncmp clobbers non-volatile vector
registers (Bug 33060)

Tested on ppc64le with no regressions.

4 weeks agomalloc: add testing for large tcache support
Cupertino Miranda [Mon, 16 Jun 2025 12:51:53 +0000 (12:51 +0000)] 
malloc: add testing for large tcache support

This patch adds large tcache support tests by re-executing malloc tests
using the tunable:  glibc.malloc.tcache_max=1048576
Test names are postfixed with "largetcache".

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>