]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
2 days agox86: fix wmemset ifunc stray '!' (bug 33542) release/2.42/master
Jiamei Xie [Tue, 14 Oct 2025 12:14:11 +0000 (20:14 +0800)] 
x86: fix wmemset ifunc stray '!' (bug 33542)

The ifunc selector for wmemset had a stray '!' in the
X86_ISA_CPU_FEATURES_ARCH_P(...) check:

  if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2)
      && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features,
                                      AVX_Fast_Unaligned_Load, !))

This effectively negated the predicate and caused the AVX2/AVX512
paths to be skipped, making the dispatcher fall back to the SSE2
implementation even on CPUs where AVX2/AVX512 are available. The
regression leads to noticeable throughput loss for wmemset.

Remove the stray '!' so the AVX_Fast_Unaligned_Load capability is
tested as intended and the correct AVX2/EVEX variants are selected.

Impact:
- On AVX2/AVX512-capable x86_64, wmemset no longer incorrectly
  falls back to SSE2; perf now shows __wmemset_evex/avx2 variants.

Testing:
- benchtests/bench-wmemset shows improved bandwidth across sizes.
- perf confirm the selected symbol is no longer SSE2.

Signed-off-by: xiejiamei <xiejiamei@hygon.com>
Signed-off-by: Li jing <lijing@hygon.cn>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 4d86b6cdd8132e0410347e07262239750f86dfb4)

2 weeks agoaarch64: tests for SME
Yury Khrustalev [Fri, 26 Sep 2025 09:03:45 +0000 (10:03 +0100)] 
aarch64: tests for SME

This commit adds tests for the following use cases relevant to handing of
the SME state:

 - fork() and vfork()
 - clone() and clone3()
 - signal handler

While most cases are trivial, the case of clone3() is more complicated since
the clone3() symbol is not public in Glibc.

To avoid having to check all possible ways clone3() may be called via other
public functions (e.g. vfork() or pthread_create()), we put together a test
that links directly with clone3.o. All the existing functions that have calls
to clone3() may not actually use it, in which case the outcome of such tests
would be unexpected. Having a direct call to the clone3() symbol in the test
allows to check precisely what we need to test: that the __arm_za_disable()
function is indeed called and has the desired effect.

Linking to clone3.o also requires linking to __arm_za_disable.o that in
turn requires the _dl_hwcap2 hidden symbol which to provide in the test
and initialise it before using.

Co-authored-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit ecb0fc2f0f839f36cd2a106283142c9df8ea8214)

2 weeks agoaarch64: clear ZA state of SME before clone and clone3 syscalls
Yury Khrustalev [Thu, 25 Sep 2025 14:54:36 +0000 (15:54 +0100)] 
aarch64: clear ZA state of SME before clone and clone3 syscalls

This change adds a call to the __arm_za_disable() function immediately
before the SVC instruction inside clone() and clone3() wrappers. It also
adds a macro for inline clone() used in fork() and adds the same call to
the vfork implementation. This sets the ZA state of SME to "off" on return
from these functions (for both the child and the parent).

The __arm_za_disable() function is described in [1] (8.1.3). Note that
the internal Glibc name for this function is __libc_arm_za_disable().

When this change was originally proposed [2,3], it generated a long
discussion where several questions and concerns were raised. Here we
will address these concerns and explain why this change is useful and,
in fact, necessary.

In a nutshell, a C library that conforms to the AAPCS64 spec [1] (pertinent
to this change, mainly, the chapters 6.2 and 6.6), should have a call to the
__arm_za_disable() function in clone() and clone3() wrappers. The following
explains in detail why this is the case.

When we consider using the __arm_za_disable() function inside the clone()
and clone3() libc wrappers, we talk about the C library subroutines clone()
and clone3() rather than the syscalls with similar names. In the current
version of Glibc, clone() is public and clone3() is private, but it being
private is not pertinent to this discussion.

We will begin with stating that this change is NOT a bug fix for something
in the kernel. The requirement to call __arm_za_disable() does NOT come from
the kernel. It also is NOT needed to satisfy a contract between the kernel
and userspace. This is why it is not for the kernel documentation to describe
this requirement. This requirement is instead needed to satisfy a pure userspace
scheme outlined in [1] and to make sure that software that uses Glibc (or any
other C library that has correct handling of SME states (see below)) conforms
to [1] without having to unnecessarily become SME-aware thus losing portability.

To recap (see [1] (6.2)), SME extension defines SME state which is part of
processor state. Part of this SME state is ZA state that is necessary to
manage ZA storage register in the context of the ZA lazy saving scheme [1]
(6.6). This scheme exists because it would be challenging to handle ZA
storage of SME in either callee-saved or caller-saved manner.

There are 3 kinds of ZA state that are defined in terms of the PSTATE.ZA
bit and the TPIDR2_EL0 register (see [1] (6.6.3)):

- "off":       PSTATE.ZA == 0
- "active":    PSTATE.ZA == 1 TPIDR2_EL0 == null
- "dormant":   PSTATE.ZA == 1 TPIDR2_EL0 != null

As [1] (6.7.2) outlines, every subroutine has exactly one SME-interface
depending on the permitted ZA-states on entry and on normal return from
a call to this subroutine. Callers of a subroutine must know and respect
the ZA-interface of the subroutines they are using. Using a subroutine
in a way that is not permitted by its ZA-interface is undefined behaviour.

In particular, clone() and clone3() (the C library functions) have the
ZA-private interface. This means that the permitted ZA-states on entry
are "off" and "dormant" and that the permitted states on return are "off"
or "dormant" (but if and only if it was "dormant" on entry).

This means that both functions in question should correctly handle both
"off" and "dormant" ZA-states on entry. The conforming states on return
are "off" and "dormant" (if inbound state was already "dormant").

This change ensures that the ZA-state on return is always "off". Note,
that, in the context of clone() and clone3(), "on return" means a point
when execution resumes at certain address after transferring from clone()
or clone3(). For the caller (we may refer to it as "parent") this is the
return address in the link register where the RET instruction jumps. For
the "child", this is the target branch address.

So, the "off" state on return is permitted and conformant. Why can't we
retain the "dormant" state? In theory, we can, but we shouldn't, here is
why.

Every subroutine with a private-ZA interface, including clone() and clone3(),
must comply with the lazy saving scheme [1] (6.7.2). This puts additional
responsibility on a subroutine if ZA-state on return is "dormant" because
this state has special meaning. The "caller" (that is the place in code
where execution is transferred to, so this include both "parent" and "child")
may check the ZA-state and use it as per the spec of the "dormant" state that
is outlined in [1] (6.6.6 and 6.6.7).

Conforming to this would require more code inside of clone() and clone3()
which hardly is desirable.

For the return to "parent" this could be achieved in theory, but given that
neither clone() nor clone3() are supposed to be used in the middle of an
SME operation, if wouldn't be useful. For the "return" to "child" this
would be particularly difficult to achieve given the complexity of these
functions and their interfaces. Most importantly, it would be illegal
and somewhat meaningless to allow a "child" to start execution in the
"dormant" ZA-state because the very essence of the "dormant" state implies
that there is a place to return and that there is some outer context that
we are allowed to interact with.

To sum up, calling __arm_za_disable() to ensure the "off" ZA-state when the
execution resumes after a call to clone() or clone3() is correct and also
the most simple way to conform to [1].

Can there be situations when we can avoid calling __arm_za_disable()?

Calling __arm_za_disable() implies certain (sufficiently small) overhead,
so one might rightly ponder avoiding making a call to this function when
we can afford not to. The most trivial cases like this (e.g. when the
calling thread doesn't have access to SME or to the TPIDR2_EL0 register)
are already handled by this function (see [1] (8.1.3 and 8.1.2)). Reasoning
about other possible use cases would require making code inside clone() and
clone3() more complicated and it would defeat the point of trying to make
an optimisation of not calling __arm_za_disable().

Why can't the kernel do this instead?

The handling of SME state by the kernel is described in [4]. In short,
kernel must not impose a specific ZA-interface onto a userspace function.
Interaction with the kernel happens (among other thing) via system calls.
In Glibc many of the system calls (notably, including SYS_clone and
SYS_clone3) are used via wrappers, and the kernel has no control of them
and, moreover, it cannot dictate how these wrappers should behave because
it is simply outside of the kernel's remit.

However, in certain cases, the kernel may ensure that a "child" doesn't
start in an incorrect state. This is what is done by the recent change
included in 6.16 kernel [5]. This is not enough to ensure that code that
uses clone() and clone3() function conforms to [1] when it runs on a
system that provides SME, hence this change.

[1]: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst
[2]: https://inbox.sourceware.org/libc-alpha/20250522114828.2291047-1-yury.khrustalev@arm.com
[3]: https://inbox.sourceware.org/libc-alpha/20250609121407.3316070-1-yury.khrustalev@arm.com
[4]: https://www.kernel.org/doc/html/v6.16/arch/arm64/sme.html
[5]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cde5c32db55740659fca6d56c09b88800d88fd29

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 27effb3d50424fb9634be77a2acd614b0386ff25)

2 weeks agoaarch64: define macro for calling __libc_arm_za_disable
Yury Khrustalev [Thu, 25 Sep 2025 14:51:30 +0000 (15:51 +0100)] 
aarch64: define macro for calling __libc_arm_za_disable

A common sequence of instructions is used in several places
in assembly files, so define it in one place as an assembly
macro.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit b4b713bd8921aff04773557da94fabb5fb9dd705)

4 weeks agox86: Detect Intel Nova Lake Processor
Sunil K Pandey [Wed, 24 Sep 2025 16:38:17 +0000 (09:38 -0700)] 
x86: Detect Intel Nova Lake Processor

Detect Intel Nova Lake Processor and tune it similar to Intel Panther
Lake.  https://cdrdv2.intel.com/v1/dl/getContent/671368 Section 1.2.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit a114e29ddd530962d2b44aa9d89f1f6075abe7fa)

4 weeks agox86: Detect Intel Wildcat Lake Processor
Sunil K Pandey [Tue, 7 Oct 2025 01:13:04 +0000 (18:13 -0700)] 
x86: Detect Intel Wildcat Lake Processor

Detect Intel Wildcat Lake Processor and tune it similar to Intel Panther
Lake.  https://cdrdv2.intel.com/v1/dl/getContent/671368 Section 1.2.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit f8dd52901b72805a831d5a4cb7d971e4a3c9970b)

6 weeks agonptl: Fix MADV_GUARD_INSTALL logic for thread without guard page (BZ 33356)
Adhemerval Zanella [Mon, 8 Sep 2025 16:06:13 +0000 (13:06 -0300)] 
nptl: Fix MADV_GUARD_INSTALL logic for thread without guard page (BZ 33356)

The main issue is that setup_stack_prot fails to account for cases where
the cached thread stack lacks a guard page, which can cause madvise to
fail. Update the logic to also handle whether MADV_GUARD_INSTALL is
supported when resizing the guard page.

Checked on x86_64-linux-gnu with 6.8.0 and 6.15 kernels.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 855bfa2566bbefefa27c516b344df58a75824a5c)

6 weeks agonss: Group merge does not react to ERANGE during merge (bug 33361)
Florian Weimer [Fri, 12 Sep 2025 19:33:34 +0000 (21:33 +0200)] 
nss: Group merge does not react to ERANGE during merge (bug 33361)

The break statement in CHECK_MERGE is expected to exit the surrounding
while loop, not the do-while loop with in the macro.  Remove the
do-while loop from the macro.  It is not needed to turn the macro
expansion into a single statement due to the way CHECK_MERGE is used
(and the statement expression would cover this anyway).

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
(cherry picked from commit 0fceed254559836b57ee05188deac649bc505d05)

6 weeks agolibio: Define AT_RENAME_* with the same tokens as Linux
Florian Weimer [Fri, 5 Sep 2025 17:02:57 +0000 (19:02 +0200)] 
libio: Define AT_RENAME_* with the same tokens as Linux

Linux uses different expressions for the RENAME_* and AT_RENAME_*
constants.  Mirror that in <stdio.h>, so that the macro redefinitions
do not result in preprocessor warnings.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
(cherry picked from commit b173557da978a04ac3bdfc0bd3b0e7ac583b44d5)

2 months agoAArch64: Fix SVE powf routine [BZ #33299]
Pierre Blanchard [Wed, 20 Aug 2025 17:41:50 +0000 (17:41 +0000)] 
AArch64: Fix SVE powf routine [BZ #33299]

Fix a bug in predicate logic introduced in last change.
A slight performance improvement from relying on all true
predicates during conversion from single to double.
This fixes BZ #33299.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
(cherry picked from commit aac077645a645bba0d67f3250e82017c539d0f4b)

2 months agoi386: Also add GLIBC_ABI_GNU2_TLS version [BZ #33129]
H.J. Lu [Mon, 18 Aug 2025 16:06:48 +0000 (09:06 -0700)] 
i386: Also add GLIBC_ABI_GNU2_TLS version [BZ #33129]

Since the GNU2 TLS run-time bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=31372

affects both i386 and x86-64, also add GLIBC_ABI_GNU2_TLS version to i386
to indicate the working GNU2 TLS run-time.  For x86-64, the additional
GNU2 TLS run-time bug fix is needed for

https://sourceware.org/bugzilla/show_bug.cgi?id=31501

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
(cherry picked from commit bd4628f3f18ac312408782eea450429c6f044860)

2 months agox86-64: Add GLIBC_ABI_DT_X86_64_PLT [BZ #33212]
H.J. Lu [Thu, 14 Aug 2025 14:03:20 +0000 (07:03 -0700)] 
x86-64: Add GLIBC_ABI_DT_X86_64_PLT [BZ #33212]

When the linker -z mark-plt option is used to add DT_X86_64_PLT,
DT_X86_64_PLTSZ and DT_X86_64_PLTENT, the r_addend field of the
R_X86_64_JUMP_SLOT relocation stores the offset of the indirect
branch instruction.  However, glibc versions without the commit:

commit f8587a61892cbafd98ce599131bf4f103466f084
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 20 19:21:48 2022 -0700

    x86-64: Ignore r_addend for R_X86_64_GLOB_DAT/R_X86_64_JUMP_SLOT

    According to x86-64 psABI, r_addend should be ignored for R_X86_64_GLOB_DAT
    and R_X86_64_JUMP_SLOT.  Since linkers always set their r_addends to 0, we
    can ignore their r_addends.

Reviewed-by: Fangrui Song <maskray@google.com>
won't ignore the r_addend value in the R_X86_64_JUMP_SLOT relocation.
Such programs and shared libraries will fail at run-time randomly.

Add GLIBC_ABI_DT_X86_64_PLT version to indicate that glibc is compatible
with DT_X86_64_PLT.

The linker can add the glibc GLIBC_ABI_DT_X86_64_PLT version dependency
whenever -z mark-plt is passed to the linker.  The resulting programs and
shared libraries will fail to load at run-time against libc.so without the
GLIBC_ABI_DT_X86_64_PLT version, instead of fail randomly.

This fixes BZ #33212.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
(cherry picked from commit 399384e0c8193e31aea014220ccfa24300ae5938)

2 months agox86-64: Add GLIBC_ABI_GNU2_TLS version [BZ #33129]
H.J. Lu [Mon, 28 Jul 2025 19:18:22 +0000 (12:18 -0700)] 
x86-64: Add GLIBC_ABI_GNU2_TLS version [BZ #33129]

Programs and shared libraries compiled with -mtls-dialect=gnu2 may fail
silently at run-time against glibc without the GNU2 TLS run-time fix
for:

https://sourceware.org/bugzilla/show_bug.cgi?id=31372

Add GLIBC_ABI_GNU2_TLS version to indicate that glibc has the working
GNU2 TLS run-time.  Linker can add the GLIBC_ABI_GNU2_TLS version to
binaries which depend on the working GNU2 TLS run-time:

https://sourceware.org/bugzilla/show_bug.cgi?id=33130

so that such programs and shared libraries will fail to load and run at
run-time against libc.so without the GLIBC_ABI_GNU2_TLS version, instead
of fail silently at random.

This fixes BZ #33129.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
(cherry picked from commit 9df8fa397d515dc86ff5565f6c45625e672d539e)

2 months agoi386: Add GLIBC_ABI_GNU_TLS version [BZ #33221]
H.J. Lu [Mon, 28 Jul 2025 19:16:11 +0000 (12:16 -0700)] 
i386: Add GLIBC_ABI_GNU_TLS version [BZ #33221]

On i386, programs and shared libraries with __thread usage may fail
silently at run-time against glibc without the TLS run-time fix for:

https://sourceware.org/bugzilla/show_bug.cgi?id=32996

Add GLIBC_ABI_GNU_TLS version to indicate that glibc has the working
GNU TLS run-time.  Linker can add the GLIBC_ABI_GNU_TLS version to
binaries which depend on the working TLS run-time so that such programs
and shared libraries will fail to load and run at run-time against
libc.so without the GLIBC_ABI_GNU_TLS version, instead of fail silently
at random.

This fixes BZ #33221.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
(cherry picked from commit ed1b7a5a489ab555a27fad9c101ebe2e1c1ba881)

2 months agoUse TLS initial-exec model for __libc_tsd_CTYPE_* thread variables [BZ #33234]
Jens Remus [Fri, 25 Jul 2025 13:40:03 +0000 (15:40 +0200)] 
Use TLS initial-exec model for __libc_tsd_CTYPE_* thread variables [BZ #33234]

Commit 10a66a8e421b ("Remove <libc-tsd.h>") removed the TLS initial-exec
(IE) model attribute from the __libc_tsd_CTYPE_* thread variable declarations
and definitions.  Commit a894f04d8776 ("Optimize __libc_tsd_* thread
variable access") restored it on declarations.

Restore the TLS initial-exec model attribute on __libc_tsd_CTYPE_* thread
variable definitions.

This resolves test tst-locale1 failure on s390 32-bit, when using a
GNU linker without the fix from GNU binutils commit aefebe82dc89
("IBM zSystems: Fix offset relative to static TLS").

Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit e5363e6f460c2d58809bf10fc96d70fd1ef8b5b2)

2 months agomalloc: Fix checking for small negative values of tcache_key
Samuel Thibault [Sun, 10 Aug 2025 21:43:37 +0000 (23:43 +0200)] 
malloc: Fix checking for small negative values of tcache_key

tcache_key is unsigned so we should turn it explicitly to signed before
taking its absolute value.

(cherry picked from commit 8543577b04ded6d979ffcc5a818930e4d74d0645)

2 months agomalloc: Make sure tcache_key is odd enough
Samuel Thibault [Tue, 29 Jul 2025 23:55:22 +0000 (01:55 +0200)] 
malloc: Make sure tcache_key is odd enough

We want tcache_key not to be a commonly-occurring value in memory, so ensure
a minimum amount of one and zero bits.

And we need it non-zero, otherwise even if tcache_double_free_verify sets
e->key to 0 before calling __libc_free, it gets called again by __libc_free,
thus looping indefinitely.

Fixes: c968fe50628db74b52124d863cd828225a1d305c ("malloc: Use tailcalls in __libc_free")
(cherry picked from commit 2536c4f8584082a1ac4c5e0a2a6222e290d43983)

2 months agomalloc: Fix MAX_TCACHE_SMALL_SIZE
Wilco Dijkstra [Thu, 17 Jul 2025 14:31:06 +0000 (14:31 +0000)] 
malloc: Fix MAX_TCACHE_SMALL_SIZE

MAX_TCACHE_SMALL_SIZE should use chunk size since it is used after
checked_request2size.  Increase limit of tcache_max_bytes by 1 since all
comparisons use '<'.  As a result, the last tcache entry is now used as
expected.

Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit ad4caba4146583fc543cd434221dec7113c03e09)

2 months agomalloc: Remove redundant NULL check
Wilco Dijkstra [Thu, 10 Jul 2025 15:49:14 +0000 (15:49 +0000)] 
malloc: Remove redundant NULL check

Remove a redundant NULL check from tcache_get_n.

Reviewed-by: Cupertino Miranda <cupertino.miranda@oracle.com>
(cherry picked from commit 089b4fb90fac8ed53039bc4c465c4d333c6b4048)

3 months agohurd: support: Fix running SGID tests
Samuel Thibault [Fri, 18 Jul 2025 21:14:40 +0000 (23:14 +0200)] 
hurd: support: Fix running SGID tests

Secure mode is enabled only if SGID actually provides a new privilege,
so we have to drop it before gaining it again.

Fixes commit 3a3fb2ed83f79100c116c824454095ecfb335ad7
("Fix error reporting (false negatives) in SGID tests")

(cherry picked from commit ad4589e2d834c80a042a8c354fb00cf33e06802c)

3 months agoRevert "tst-freopen4-main.c: Call support_capture_subprocess with chroot"
H.J. Lu [Tue, 5 Aug 2025 16:16:14 +0000 (09:16 -0700)] 
Revert "tst-freopen4-main.c: Call support_capture_subprocess with chroot"

Revert commit 6463d4a7b28e5ee3891c34a8a1f0a59c24dfa9de to fix

FAIL: stdio-common/tst-freopen4-mem
FAIL: stdio-common/tst-freopen64-4-mem

This fixes BZ #33254.

Reviewed-by: Sam James <sam@gentoo.org>
(cherry picked from commit adec0bf05bc23ec35573c7a5b96440089b69265e)

3 months agotst-env-setuid: Delete LD_DEBUG_OUTPUT output
H.J. Lu [Sat, 19 Jul 2025 14:43:29 +0000 (07:43 -0700)] 
tst-env-setuid: Delete LD_DEBUG_OUTPUT output

Update tst-env-setuid.c to delete LD_DEBUG_OUTPUT output, instead of
leaving it behind.

This partially fixes BZ #33182.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 5d23dfb289174d73b8907b86d2bef7a3ca889840)

3 months agotst-freopen4-main.c: Call support_capture_subprocess with chroot
H.J. Lu [Sat, 19 Jul 2025 14:43:28 +0000 (07:43 -0700)] 
tst-freopen4-main.c: Call support_capture_subprocess with chroot

Update tst-freopen4-main.c to call support_capture_subprocess with chroot,
which makes temporary files inaccessible, so that temporary files can be
deleted.

This partially fixes BZ #33182.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 6463d4a7b28e5ee3891c34a8a1f0a59c24dfa9de)

3 months agotst-fopen-threaded.c: Delete temporary file
H.J. Lu [Sat, 19 Jul 2025 14:43:27 +0000 (07:43 -0700)] 
tst-fopen-threaded.c: Delete temporary file

Update tst-fopen-threaded.c to call support_create_temp_directory to
create a temporary directory and open "file" in the temporary directory,
instead of using /tmp/openclosetest and leaving it behind.

This partially fixes BZ #33182.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit e7db5150603bb2224a2bfd9628cae04ddcbe49e3)

3 months agoDelete temporary files in support_subprocess
H.J. Lu [Sat, 19 Jul 2025 14:43:26 +0000 (07:43 -0700)] 
Delete temporary files in support_subprocess

Call support_delete_temp_files to delete temporary files before exit in
support_subprocess.

This partially fixes BZ #33182.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit d27b1a71cd424710813bd3d81afb32a36470d643)

3 months agonptl: Fix SYSCALL_CANCEL for return values larger than INT_MAX (BZ 33245)
Adhemerval Zanella [Fri, 1 Aug 2025 18:00:25 +0000 (15:00 -0300)] 
nptl: Fix SYSCALL_CANCEL for return values larger than INT_MAX (BZ 33245)

The SYSCALL_CANCEL calls __syscall_cancel, which in turn
calls __internal_syscall_cancel with an 'int' return instead of the
expected 'long int'.  This causes issues with syscalls that return
values larger than INT_MAX, such as copy_file_range [1].

Checked on x86_64-linux-gnu.

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79139

Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
(cherry picked from commit 7107bebf19286f42dcb0a97581137a5893c16206)

3 months agoelf: Handle ld.so with LOAD segment gaps in _dl_find_object (bug 31943)
Florian Weimer [Fri, 1 Aug 2025 17:27:35 +0000 (19:27 +0200)] 
elf: Handle ld.so with LOAD segment gaps in _dl_find_object (bug 31943)

Detect if ld.so not contiguous and handle that case in _dl_find_object.
Set l_find_object_processed even for initially loaded link maps,
otherwise dlopen of an initially loaded object adds it to
_dlfo_loaded_mappings (where maps are expected to be contiguous),
in addition to _dlfo_nodelete_mappings.

Test elf/tst-link-map-contiguous-ldso iterates over the loader
image, reading every word to make sure memory is actually mapped.
It only does that if the l_contiguous flag is set for the link map.
Otherwise, it finds gaps with mmap and checks that _dl_find_object
does not return the ld.so mapping for them.

The test elf/tst-link-map-contiguous-main does the same thing for
the libc.so shared object.  This only works if the kernel loaded
the main program because the glibc dynamic loader may fill
the gaps with PROT_NONE mappings in some cases, making it contiguous,
but accesses to individual words may still fault.

Test elf/tst-link-map-contiguous-libc is again slightly different
because the dynamic loader always fills the gaps with PROT_NONE
mappings, so a different form of probing has to be used.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 20681be149b9eb1b6c1f4246bf4bd801221c86cd)

3 months agoelf: Extract rtld_setup_phdr function from dl_main
Florian Weimer [Fri, 1 Aug 2025 17:27:04 +0000 (19:27 +0200)] 
elf: Extract rtld_setup_phdr function from dl_main

Remove historic binutils reference from comment and update
how this data is used by applications.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit 2cac9559e06044ba520e785c151fbbd25011865f)

3 months agostdlib: resolve a double lock init issue after fork [BZ #32994]
Davide Cavalca [Thu, 31 Jul 2025 15:32:58 +0000 (17:32 +0200)] 
stdlib: resolve a double lock init issue after fork [BZ #32994]

The __abort_fork_reset_child (introduced in
d40ac01cbbc66e6d9dbd8e3485605c63b2178251) call resets the lock after the
fork. This causes a DRD regression in valgrind
(https://bugs.kde.org/show_bug.cgi?id=503668), as it's effectively a
double initialization, despite it being actually ok in this case. As
suggested in https://sourceware.org/bugzilla/show_bug.cgi?id=32994#c2
we replace it here with a memcpy of another initialized lock instead,
which makes valgrind happy.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit d9a348d0927c7a1aec5caf3df3fcd36956b3eb23)

3 months agoinet-fortified: fix namespace violation (bug 33227)
Sam James [Mon, 28 Jul 2025 20:55:30 +0000 (21:55 +0100)] 
inet-fortified: fix namespace violation (bug 33227)

We need to use __sz, not sz, as we do elsewhere.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 87afbd7a1ad9c1dd116921817fa97198171045db)

3 months agoNEWS: add new section
Andreas K. Hüttel [Mon, 28 Jul 2025 21:39:48 +0000 (23:39 +0200)] 
NEWS: add new section

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoReplace advisories directory with pointer file
Andreas K. Hüttel [Mon, 28 Jul 2025 18:35:38 +0000 (20:35 +0200)] 
Replace advisories directory with pointer file

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoCreate ChangeLog.old/ChangeLog.31 glibc-2.42
Andreas K. Hüttel [Mon, 28 Jul 2025 18:22:55 +0000 (20:22 +0200)] 
Create ChangeLog.old/ChangeLog.31

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoBump version number to 2.42
Andreas K. Hüttel [Mon, 28 Jul 2025 18:19:17 +0000 (20:19 +0200)] 
Bump version number to 2.42

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoNEWS: update with last-minute fix bug 33224
Andreas K. Hüttel [Mon, 28 Jul 2025 18:12:05 +0000 (20:12 +0200)] 
NEWS: update with last-minute fix bug 33224

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agomath: Update auto-libm-tests-in with ldbl-128ibm compoundn/pown failures
Adhemerval Zanella [Mon, 28 Jul 2025 13:59:07 +0000 (10:59 -0300)] 
math: Update auto-libm-tests-in with ldbl-128ibm compoundn/pown failures

It fixes ce488f7c1615bc2f6fe96ff4d51456e470aa5805 which updated
the out files without using gen-auto-libm-tests.c instructions.

Checked on powerpc64le-linux-gnu.

Tested-by: Andreas K. Huettel <dilfridge@gentoo.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agoINSTALL: Update newest tested binutils version
Andreas K. Hüttel [Mon, 28 Jul 2025 14:49:01 +0000 (16:49 +0200)] 
INSTALL: Update newest tested binutils version

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoelf: Compile _dl_debug_state separately (bug 33224)
Florian Weimer [Mon, 28 Jul 2025 12:16:52 +0000 (14:16 +0200)] 
elf: Compile _dl_debug_state separately (bug 33224)

This ensures that the compiler will not inline it, so that
debuggers which do not use the Systemtap probes can reliably
set a breakpoint on it.

Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
Tested-by: Andreas K. Huettel <dilfridge@gentoo.org>
3 months agoconfigure.ac: fix bashisms in SFrame checks
Sam James [Mon, 28 Jul 2025 13:00:52 +0000 (14:00 +0100)] 
configure.ac: fix bashisms in SFrame checks

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoINSTALL: regenerate
Andreas K. Hüttel [Sat, 26 Jul 2025 15:07:14 +0000 (17:07 +0200)] 
INSTALL: regenerate

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoinstall.texi: Update tested build tool versions
Andreas K. Hüttel [Sat, 26 Jul 2025 15:05:21 +0000 (17:05 +0200)] 
install.texi: Update tested build tool versions

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agocontrib.texi: Update
Andreas K. Hüttel [Sat, 26 Jul 2025 14:53:43 +0000 (16:53 +0200)] 
contrib.texi: Update

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoNEWS: insert list of CVEs
Andreas K. Hüttel [Sat, 26 Jul 2025 13:23:49 +0000 (15:23 +0200)] 
NEWS: insert list of CVEs

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoadvisories: s/CVE-id/CVE-Id/ (the lowercase i breaks our tooling)
Andreas K. Hüttel [Sat, 26 Jul 2025 13:21:27 +0000 (15:21 +0200)] 
advisories: s/CVE-id/CVE-Id/ (the lowercase i breaks our tooling)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoNEWS: Generalize testing section and mention the manual.
Carlos O'Donell [Fri, 25 Jul 2025 22:38:59 +0000 (18:38 -0400)] 
NEWS: Generalize testing section and mention the manual.

3 months agoNEWS: Insert list of bugs fixed in 2.42
Andreas K. Hüttel [Fri, 25 Jul 2025 21:52:41 +0000 (23:52 +0200)] 
NEWS: Insert list of bugs fixed in 2.42

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoNEWS: Collect some more newsworthy items
Andreas K. Hüttel [Fri, 25 Jul 2025 21:36:56 +0000 (23:36 +0200)] 
NEWS: Collect some more newsworthy items

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoNEWS: editorial changes
Andreas K. Hüttel [Fri, 25 Jul 2025 19:18:13 +0000 (21:18 +0200)] 
NEWS: editorial changes

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agopo: Update swedish translations
Andreas K. Hüttel [Fri, 25 Jul 2025 17:31:37 +0000 (19:31 +0200)] 
po: Update swedish translations

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agodebug: Only run sframe tests if run-built-tests is enabled
Adhemerval Zanella [Fri, 25 Jul 2025 17:03:23 +0000 (14:03 -0300)] 
debug: Only run sframe tests if run-built-tests is enabled

3 months agoaarch64: Fix aarch64_be build with --enable-sframe
Adhemerval Zanella [Fri, 25 Jul 2025 16:57:44 +0000 (13:57 -0300)] 
aarch64: Fix aarch64_be build with --enable-sframe

3 months agoelf: Check SFrame on tst-dl_find_object.c
Adhemerval Zanella [Tue, 22 Jul 2025 15:55:52 +0000 (12:55 -0300)] 
elf: Check SFrame on tst-dl_find_object.c

If SFrame is enable check if DLFO_FLAG_SFRAME is set (since sframe
support is added by default) and if dlfo_sframe has the expected
value.

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

Reviewed-by: Sam James <sam@gentoo.org>
3 months agosframe: Add support for SFRAME_F_FDE_FUNC_START_PCREL flag
Claudiu Zissulescu [Tue, 22 Jul 2025 15:55:51 +0000 (12:55 -0300)] 
sframe: Add support for SFRAME_F_FDE_FUNC_START_PCREL flag

The Sframe V2 has a new errata which introduces the
SFRAME_F_FDE_FUNC_START_PCREL flag. This flag indicates the encoding
of the SFrame FDE function start address field like this:

- if set, sfde_func_start_address field contains the offset in bytes
to the start PC of the associated function from the field itself.

- if unset, sfde_func_start_address field contains the offset in bytes
to the start PC of the associated function from the start of the
SFrame section.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Reviewed-by: Sam James <sam@gentoo.org>
3 months agoDisable SFrame support by default
Adhemerval Zanella [Tue, 22 Jul 2025 15:55:50 +0000 (12:55 -0300)] 
Disable SFrame support by default

And add extra checks to enable for binutils 2.45 and if the architecture
explicitly enables it.  When SFrame is disabled, all the related code
is also not enabled for backtrace() and _dl_find_object(), so SFrame
backtracking is not used even if the binary has the SFrame segment.

This patch also adds some other related fixes:

  * Fixed an issue with AC_CHECK_PROG_VER, where the READELF_SFRAME
    usage prevented specifying a different readelf through READELF
    environment variable at configure time.

  * Add an extra arch-specific internal definition,
    libc_cv_support_sframe, to disable --enable-sframe on architectures
    that have binutils but not glibc support (s390x).

  * Renamed the tests without the .sframe segment and move the
    tst-backtrace1 from pthread to debug.

  * Use the built compiler strip to remove the .sframe segment,
    instead of the system one (which might not support SFrame).

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

Reviewed-by: Sam James <sam@gentoo.org>
3 months agomath: xfail some pown and compoundn tests for ibm128-libgcc
Sachin Monga [Wed, 23 Jul 2025 16:43:52 +0000 (11:43 -0500)] 
math: xfail some pown and compoundn tests for ibm128-libgcc

On powerpc math/test-ibm128-pown shows below failures:

testing long double (without inline functions)
infinity has wrong sign.
Failure: Test: pown_downward (-inf, 0x7fffffffffffffffLL)
Result:
 is:          inf   inf
 should be:  -inf  -inf
Failure: Test: pown_downward (-0, 9223372036854775807LL)
Result:
 is:          0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  16.0000
Failure: pown_downward (-0x1p+0, 9223372036854775807LL): Exception "Invalid operation" set
Failure: pown_downward (-0x1p+0, 9223372036854775807LL): errno set to 34, expected 0 (unchanged)
Failure: Test: pown_downward (-0x1p+0, 9223372036854775807LL)
Result:
 is:         qNaN
 should be:  -1.00000000000000000000000000000000e+00  -0x1.000000000000000000000000000p+0
infinity has wrong sign.
Failure: Test: pown_towardzero (-0, -0x7fffffffffffffffLL)
Result:
 is:          inf   inf
 should be:  -inf  -inf
infinity has wrong sign.
Failure: Test: pown_towardzero (-inf, 0x7fffffffffffffffLL)
Result:
 is:          inf   inf
 should be:  -inf  -inf
Failure: Test: pown_towardzero (-inf, -0x7fffffffffffffffLL)
Result:
 is:          0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  16.0000
Failure: Test: pown_towardzero (-0, 9223372036854775807LL)
Result:
 is:          0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  16.0000
Failure: pown_towardzero (-0x1p+0, -9223372036854775807LL): Exception "Invalid operation" set
Failure: pown_towardzero (-0x1p+0, -9223372036854775807LL): errno set to 34, expected 0 (unchanged)
Failure: Test: pown_towardzero (-0x1p+0, -9223372036854775807LL)
Result:
 is:         qNaN
 should be:  -1.00000000000000000000000000000000e+00  -0x1.000000000000000000000000000p+0
Failure: pown_towardzero (-0x1p+0, 9223372036854775807LL): Exception "Invalid operation" set
Failure: pown_towardzero (-0x1p+0, 9223372036854775807LL): errno set to 34, expected 0 (unchanged)
Failure: Test: pown_towardzero (-0x1p+0, 9223372036854775807LL)
Result:
 is:         qNaN
 should be:  -1.00000000000000000000000000000000e+00  -0x1.000000000000000000000000000p+0
infinity has wrong sign.
Failure: Test: pown_upward (-0, -0x7fffffffffffffffLL)
Result:
 is:          inf   inf
 should be:  -inf  -inf
Failure: Test: pown_upward (-inf, -0x7fffffffffffffffLL)
Result:
 is:          0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  16.0000
Failure: pown_upward (-0x1p+0, -9223372036854775807LL): Exception "Invalid operation" set
Failure: pown_upward (-0x1p+0, -9223372036854775807LL): errno set to 34, expected 0 (unchanged)
Failure: Test: pown_upward (-0x1p+0, -9223372036854775807LL)
Result:
 is:         qNaN
 should be:  -1.00000000000000000000000000000000e+00  -0x1.000000000000000000000000000p+0

Likewise, math/test-ibm128-compoundn shows below failure:

testing long double (without inline functions)
Failure: compoundn_upward (0xf.ffffffffffff8p+1020, 1LL): Exception "Overflow" set
Failure: compoundn_upward (0xf.ffffffffffff8p+1020, 1LL): errno set to 34, expected 0 (unchanged)
Failure: Test: compoundn_upward (0xf.ffffffffffff8p+1020, 1LL)
Result:
 is:          inf   inf
 should be:   1.79769313486231570814527423731707e+308   0x1.fffffffffffff00000000000008p+1023

Signed-off-by: Sachin Monga <smonga@linux.ibm.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agomanual: Use @Theglibc{} at sentence start in terminal documentation
Florian Weimer [Tue, 22 Jul 2025 21:28:16 +0000 (23:28 +0200)] 
manual: Use @Theglibc{} at sentence start in terminal documentation

Fixes commit 5dd2a19ad5218261cee064 ("termios: manual: improve the
explanation of various tty concepts") and commit c744519bad8106769760
("termios: manual: document the SPEED_MAX and BAUD_MAX constants").

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agoUpdate Fix-Commit list for advisory GLIBC-SA-2025-0002
Carlos O'Donell [Thu, 24 Jul 2025 15:12:02 +0000 (11:12 -0400)] 
Update Fix-Commit list for advisory GLIBC-SA-2025-0002

3 months agodebug: Link tst-sprintf-fortify-rdonly-static with -Wl,-z,relro [BZ 33183]
John David Anglin [Thu, 24 Jul 2025 14:53:35 +0000 (10:53 -0400)] 
debug: Link tst-sprintf-fortify-rdonly-static with -Wl,-z,relro [BZ 33183]

This test requires relro_format be placed in the PT_GNU_RELRO segment.
The ELF linker enables -z relro support by default on all Linux targets
except FRV, HPPA, IA64 and MIPS. On these targets, we need to explicitly
link with -z relro to place relro_format in the PT_GNU_RELRO segment.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
3 months agoAdvisory text for CVE-2025-8058
Adhemerval Zanella [Wed, 23 Jul 2025 19:09:19 +0000 (16:09 -0300)] 
Advisory text for CVE-2025-8058

The fix is already installed (7ea06e994093fa0bcca0d0ee2c1db271d8d7885d).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agoMakeconfig: The hash character # confuses old make, use $(dir instead of sed
Andreas K. Hüttel [Mon, 21 Jul 2025 21:48:43 +0000 (23:48 +0200)] 
Makeconfig: The hash character # confuses old make, use $(dir instead of sed

Up to Make 4.2, # is treated as the start of a comment even in
function invocations. This leads to a syntax error. Fixed in Make 4.3,
but we still support versions back to 4.0 at the moment.

Tested on Gentoo (x86-64) and Debian (loongarch64)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agopo: Incorporate translations
Andreas K. Hüttel [Mon, 21 Jul 2025 22:28:48 +0000 (00:28 +0200)] 
po: Incorporate translations

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoposix: Fix double-free after allocation failure in regcomp (bug 33185)
Florian Weimer [Mon, 21 Jul 2025 19:43:49 +0000 (21:43 +0200)] 
posix: Fix double-free after allocation failure in regcomp (bug 33185)

If a memory allocation failure occurs during bracket expression
parsing in regcomp, a double-free error may result.

Reported-by: Anastasia Belova <abelova@astralinux.ru>
Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
3 months agoRevert "Linux: Keep termios ioctl constants strictly internal"
Florian Weimer [Mon, 21 Jul 2025 13:12:44 +0000 (15:12 +0200)] 
Revert "Linux: Keep termios ioctl constants strictly internal"

This reverts commit 3d3572f59059e2b19b8541ea648a6172136ec42e.

Reason for revert: TCGETS etc. work to some extent on at least
a subset of architectures, so there is no pressing need to force
applications off them.  Removal of the macros breaks building
the sanitizers, impacting both GCC and LLVM.

Reviewed-by: Sam James <sam@gentoo.org>
3 months agotermios: manual: document the SPEED_MAX and BAUD_MAX constants
H. Peter Anvin [Sun, 13 Jul 2025 05:19:44 +0000 (22:19 -0700)] 
termios: manual: document the SPEED_MAX and BAUD_MAX constants

Add the SPEED_MAX and BAUD_MAX constants to the manual.

[ v3: drop leading underscores ]

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agotermios: SPEED_MAX and BAUD_MAX constants
H. Peter Anvin [Sun, 13 Jul 2025 05:19:43 +0000 (22:19 -0700)] 
termios: SPEED_MAX and BAUD_MAX constants

Add constants indicating the maximum values of speed_t and baud_t.
Hopefully if and when the baud_t interface is standardized then
BAUD_MAX will be included in the standardization from the start.

Historically, the __MAX_BAUD symbol has indicated the maximum speed_t
value on at least some platforms (including glibc).  However, this
name would be problematic for future standardization, because it
confusingly implies a reference to baud_t, not speed_t, and it is
inconsistent with other limit symbols, which are all of the form *_MAX
(e.g. SIZE_MAX for size_t.)

[ v3: dropped leading underscores, leave __MAX_BAUD outside
      #ifdef __USE_MISC since it is a legacy symbol, and
      namespace-protected with a double underscore.
      (Collin Funk, Adhermerval Zanella Netto) ]

[ v4: moved from __USE_MISC to __USE_GNU (Collin Funk) ]

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agotermios: move the baud_t interface from __USE_MISC to __USE_GNU
H. Peter Anvin [Sun, 13 Jul 2025 05:19:42 +0000 (22:19 -0700)] 
termios: move the baud_t interface from __USE_MISC to __USE_GNU

__USE_MISC refers to interfaces imported from BSD or System V, but the
baud_t interface is (at least for now) a GNU extension, so move it
from __USE_MISC to __USE_GNU.

Suggested-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agotermios: manual: improve the explanation of various tty concepts
H. Peter Anvin [Sun, 13 Jul 2025 02:20:04 +0000 (19:20 -0700)] 
termios: manual: improve the explanation of various tty concepts

It is a lot easier to understand the meaning of the tty interface if
it is explained from the beginning as conceptually emulating an RS232
serial port.  This greatly simplifies the discussions of specific
items like the meaning of line speed.

Distinguish between "modem disconnect request" (deasserting DTR) and
"modem disconnect" (DCD deasserted).  Conflating the two terms is
confusing, especially for non-RS232 devices.  In particular, on most
systems, a pseudo-terminal will *not* respond to a modem disconnect
request by triggering a modem disconnect event for the purpose of the
HUPCL flag.

It is not necessarily true that the line speed has no effect on
non-serial port devices: e.g. an SPI port may interpret it as the
clock frequency to use; however, SPI does not use asynchronous framing
bits, instead synchronization is handled by the SS# wire.  Similarly,
it is common but not by any means universal for interfaces that employ
various forms of fixed data to symbol rate encodings to encode the
data link layer bit rate rather than the physical symbol rate, which
may be higher (e.g. 8B10B) or lower (e.g. QAM/Trellis), without the
encoding or framing overhead.

Finally, a handful of devices use the line rate for entirely
nonstandard purposes.  One example is Arduino USB interfaces, which
often interprets changing the baud rate to 1200 baud as a command to
reset the device.

[ v2: removed a bogus stray chunk from editing ]

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agotermios: manual: remove duplicate cfgetospeed() definition
H. Peter Anvin [Sun, 13 Jul 2025 02:20:03 +0000 (19:20 -0700)] 
termios: manual: remove duplicate cfgetospeed() definition

The function cfsetospeed() is defined twice in the manual. Remove the
one that seems out of place.

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agotermios: manual: fix typo: tcsettattr -> tcsetattr
H. Peter Anvin [Sun, 13 Jul 2025 02:20:02 +0000 (19:20 -0700)] 
termios: manual: fix typo: tcsettattr -> tcsetattr

Fix a typo in the manual: tcsetattr misspelled as tcsettattr.

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
3 months agolibc.pot: regenerate
Andreas K. Hüttel [Sat, 19 Jul 2025 20:23:09 +0000 (22:23 +0200)] 
libc.pot: regenerate

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
3 months agoio/tst-stat.c: Use a temporary directory for symlink test
H.J. Lu [Sat, 19 Jul 2025 00:03:04 +0000 (17:03 -0700)] 
io/tst-stat.c: Use a temporary directory for symlink test

Call support_create_temp_directory to create a temporary directory for
symlink test, instead of a fixed file in the glibc source tree, to avoid
the race condition when there are more than one glibc tests running at the
same time with the same glibc source tree.  This fixes BZ #33178.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
3 months agoelf: Initialize GLRO (dl_read_only_area) after static dlopen (bug 33139)
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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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.

3 months 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>
3 months 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.

3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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>
3 months 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.

3 months 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>
4 months 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

4 months 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")