]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 months agoIncorporate translations
Andreas K. Hüttel [Sun, 7 Jan 2024 10:18:18 +0000 (11:18 +0100)] 
Incorporate translations

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
4 months agox32: Handle displacement overflow in PLT rewrite [BZ #31218]
H.J. Lu [Sat, 6 Jan 2024 22:03:37 +0000 (14:03 -0800)] 
x32: Handle displacement overflow in PLT rewrite [BZ #31218]

PLT rewrite calculated displacement with

ElfW(Addr) disp = value - branch_start - JMP32_INSN_SIZE;

On x32, displacement from 0xf7fbe060 to 0x401030 was calculated as

unsigned int disp = 0x401030 - 0xf7fbe060 - 5;

with disp == 0x8442fcb and caused displacement overflow. The PLT entry
was changed to:

0xf7fbe060 <+0>: e9 cb 2f 44 08      jmp    0x401030
0xf7fbe065 <+5>: cc                  int3
0xf7fbe066 <+6>: cc                  int3
0xf7fbe067 <+7>: cc                  int3
0xf7fbe068 <+8>: cc                  int3
0xf7fbe069 <+9>: cc                  int3
0xf7fbe06a <+10>: cc                  int3
0xf7fbe06b <+11>: cc                  int3
0xf7fbe06c <+12>: cc                  int3
0xf7fbe06d <+13>: cc                  int3
0xf7fbe06e <+14>: cc                  int3
0xf7fbe06f <+15>: cc                  int3

x32 has 32-bit address range, but it doesn't wrap address around at 4GB,
JMP target was changed to 0x100401030 (0xf7fbe060LL + 0x8442fcbLL + 5),
which is above 4GB.

Always use uint64_t to calculate displacement.  This fixes BZ #31218.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
4 months agox86: Fixup some nits in longjmp asm implementation
Noah Goldstein [Fri, 5 Jan 2024 22:00:30 +0000 (14:00 -0800)] 
x86: Fixup some nits in longjmp asm implementation

Replace a stray `nop` with a `.p2align` directive.

4 months agostdlib: Fix stdbit.h with -Wconversion for clang
Adhemerval Zanella [Thu, 4 Jan 2024 17:59:28 +0000 (14:59 -0300)] 
stdlib: Fix stdbit.h with -Wconversion for clang

With clang 14 and also with main the tst-stdbit-Wconversion
issues the warnings:

  ../stdlib/stdbit.h:701:40: error: implicit conversion loses integer
  precision: 'int' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    return __x == 0 ? 0 : ((uint16_t) 1) << (__bw16_inline (__x) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../stdlib/stdbit.h:707:39: error: implicit conversion loses integer
  precision: 'int' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    return __x == 0 ? 0 : ((uint8_t) 1) << (__bw8_inline (__x) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../stdlib/stdbit.h:751:40: error: implicit conversion loses integer
  precision: 'int' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../stdlib/stdbit.h:757:39: error: implicit conversion loses integer
  precision: 'int' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);
    ~~~~~~                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  tst-stdbit-Wconversion.c:45:31: error: implicit conversion loses integer
  precision: 'unsigned short' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (us);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:164:30: note: expanded from macro
  'stdc_trailing_zeros'
     : stdc_trailing_zeros_uc (x))
       ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:191:52: note: expanded from macro
  'stdc_trailing_zeros_uc'
  # define stdc_trailing_zeros_uc(x) (__ctz8_inline (x))
                                      ~~~~~~~~~~~~~  ^
  tst-stdbit-Wconversion.c:46:31: error: implicit conversion loses integer
  precision: 'unsigned int' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (ui);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:163:48: note: expanded from macro
  'stdc_trailing_zeros'
     : sizeof (x) == 2 ? stdc_trailing_zeros_us (x)       \
                         ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:192:53: note: expanded from macro
  'stdc_trailing_zeros_us'
  # define stdc_trailing_zeros_us(x) (__ctz16_inline (x))
                                      ~~~~~~~~~~~~~~  ^
  tst-stdbit-Wconversion.c:46:31: error: implicit conversion loses integer
  precision: 'unsigned int' to 'uint8_t' (aka 'unsigned char')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (ui);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:164:30: note: expanded from macro
  'stdc_trailing_zeros'
     : stdc_trailing_zeros_uc (x))
       ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:191:52: note: expanded from macro
  'stdc_trailing_zeros_uc'
  # define stdc_trailing_zeros_uc(x) (__ctz8_inline (x))
                                      ~~~~~~~~~~~~~  ^
  tst-stdbit-Wconversion.c:47:31: error: implicit conversion loses integer
  precision: 'unsigned long' to 'uint16_t' (aka 'unsigned short')
  [-Werror,-Wimplicit-int-conversion]
    (void) stdc_trailing_zeros (ul);
           ~~~~~~~~~~~~~~~~~~~~~^~~
  ../stdlib/stdbit.h:163:48: note: expanded from macro
  'stdc_trailing_zeros'
     : sizeof (x) == 2 ? stdc_trailing_zeros_us (x)       \
                         ~~~~~~~~~~~~~~~~~~~~~~~~^~
  ../stdlib/stdbit.h:192:53: note: expanded from macro
  'stdc_trailing_zeros_us'
  # define stdc_trailing_zeros_us(x) (__ctz16_inline (x))
                                      ~~~~~~~~~~~~~~  ^
  [...]

It seems to boiler down to __builtin_clz not having a variant for 8 or
16 bits.  Fix it by explicit casting to the expected types.  Although
not strickly required for older gcc, using the same __pacify macro
simpify the required code.

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

4 months agostdlib: Fix stdbit.h with -Wconversion for older gcc
Adhemerval Zanella [Thu, 4 Jan 2024 17:44:42 +0000 (14:44 -0300)] 
stdlib: Fix stdbit.h with -Wconversion for older gcc

With gcc 6.5.0, 7.5.0, 8.5.0, and 9.5.0 the tst-stdbit-Wconversion
issues the warnings:

../stdlib/stdbit.h: In function ‘__clo16_inline’:
../stdlib/stdbit.h:128:26: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __clz16_inline (~__x);
                          ^
../stdlib/stdbit.h: In function ‘__clo8_inline’:
../stdlib/stdbit.h:134:25: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __clz8_inline (~__x);
                         ^
../stdlib/stdbit.h: In function ‘__cto16_inline’:
../stdlib/stdbit.h:232:26: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __ctz16_inline (~__x);
                          ^
../stdlib/stdbit.h: In function ‘__cto8_inline’:
../stdlib/stdbit.h:238:25: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __ctz8_inline (~__x);
                         ^
../stdlib/stdbit.h: In function ‘__bf16_inline’:
../stdlib/stdbit.h:701:23: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x == 0 ? 0 : ((uint16_t) 1) << (__bw16_inline (__x) - 1);
          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../stdlib/stdbit.h: In function ‘__bf8_inline’:
../stdlib/stdbit.h:707:23: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x == 0 ? 0 : ((uint8_t) 1) << (__bw8_inline (__x) - 1);
          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../stdlib/stdbit.h: In function ‘__bc16_inline’:
../stdlib/stdbit.h:751:59: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) -
1);
                                                           ^~~
../stdlib/stdbit.h:751:23: error: conversion to ‘uint16_t {aka short
unsigned int}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint16_t) 2) << (__bw16_inline (__x - 1) -
1);
          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../stdlib/stdbit.h: In function ‘__bc8_inline’:
../stdlib/stdbit.h:757:57: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);
                                                         ^~~
../stdlib/stdbit.h:757:23: error: conversion to ‘uint8_t {aka unsigned
char}’ from ‘int’ may alter its value [-Werror=conversion]
   return __x <= 1 ? 1 : ((uint8_t) 2) << (__bw8_inline (__x - 1) - 1);

It seems to boiler down to __builtin_clz not having a variant for 8 or
16 bits.  Fix it by explicit casting to the expected types.

Checked on x86_64-linux-gnu and i686-linux-gnu with gcc 9.5.0.

4 months agoelf: Add ELF_DYNAMIC_AFTER_RELOC to rewrite PLT
H.J. Lu [Fri, 5 Jan 2024 04:19:39 +0000 (20:19 -0800)] 
elf: Add ELF_DYNAMIC_AFTER_RELOC to rewrite PLT

Add ELF_DYNAMIC_AFTER_RELOC to allow target specific processing after
relocation.

For x86-64, add

 #define DT_X86_64_PLT     (DT_LOPROC + 0)
 #define DT_X86_64_PLTSZ   (DT_LOPROC + 1)
 #define DT_X86_64_PLTENT  (DT_LOPROC + 3)

1. DT_X86_64_PLT: The address of the procedure linkage table.
2. DT_X86_64_PLTSZ: The total size, in bytes, of the procedure linkage
table.
3. DT_X86_64_PLTENT: The size, in bytes, of a procedure linkage table
entry.

With the r_addend field of the R_X86_64_JUMP_SLOT relocation set to the
memory offset of the indirect branch instruction.

Define ELF_DYNAMIC_AFTER_RELOC for x86-64 to rewrite the PLT section
with direct branch after relocation when the lazy binding is disabled.

PLT rewrite is disabled by default since SELinux may disallow modifying
code pages and ld.so can't detect it in all cases.  Use

$ export GLIBC_TUNABLES=glibc.cpu.plt_rewrite=1

to enable PLT rewrite with 32-bit direct jump at run-time or

$ export GLIBC_TUNABLES=glibc.cpu.plt_rewrite=2

to enable PLT rewrite with 32-bit direct jump and on APX processors with
64-bit absolute jump at run-time.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
4 months agoaarch64: Make cpu-features definitions not Linux-specific
Sergey Bugaev [Wed, 3 Jan 2024 17:14:45 +0000 (20:14 +0300)] 
aarch64: Make cpu-features definitions not Linux-specific

These describe generic AArch64 CPU features, and are not tied to a
kernel-specific way of determining them. We can share them between
the Linux and Hurd AArch64 ports.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-13-bugaevc@gmail.com>

4 months agohurd: Initializy _dl_pagesize early in static builds
Sergey Bugaev [Wed, 3 Jan 2024 17:14:44 +0000 (20:14 +0300)] 
hurd: Initializy _dl_pagesize early in static builds

We fetch __vm_page_size as the very first RPC that we do, inside
__mach_init (). Propagate that to _dl_pagesize ASAP after that,
before any other initialization.

In dynamic builds, this is already done immediately after
__mach_init (), inside _dl_sysdep_start ().

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-12-bugaevc@gmail.com>

4 months agohurd: Only init early static TLS if it's used to store stack or pointer guards
Sergey Bugaev [Wed, 3 Jan 2024 17:14:43 +0000 (20:14 +0300)] 
hurd: Only init early static TLS if it's used to store stack or pointer guards

This is the case on both x86 architectures, but not on AArch64.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-11-bugaevc@gmail.com>

4 months agohurd: Make init-first.c no longer x86-specific
Sergey Bugaev [Wed, 3 Jan 2024 17:14:42 +0000 (20:14 +0300)] 
hurd: Make init-first.c no longer x86-specific

This will make it usable in other ports.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-10-bugaevc@gmail.com>

4 months agohurd: Drop x86-specific assembly from init-first.c
Sergey Bugaev [Wed, 3 Jan 2024 17:14:41 +0000 (20:14 +0300)] 
hurd: Drop x86-specific assembly from init-first.c

We already have the RETURN_TO macro for this exact use case, and it's already
used in the non-static code path. Use it here too.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-9-bugaevc@gmail.com>

4 months agohurd: Pass the data pointer to _hurd_stack_setup explicitly
Sergey Bugaev [Wed, 3 Jan 2024 17:14:40 +0000 (20:14 +0300)] 
hurd: Pass the data pointer to _hurd_stack_setup explicitly

Instead of relying on the stack frame layout to figure out where the stack
pointer was prior to the _hurd_stack_setup () call, just pass the pointer
as an argument explicitly. This is less brittle and much more portable.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-ID: <20240103171502.1358371-8-bugaevc@gmail.com>

4 months agox86-64/cet: Check the restore token in longjmp
H.J. Lu [Tue, 2 Jan 2024 15:03:29 +0000 (07:03 -0800)] 
x86-64/cet: Check the restore token in longjmp

setcontext and swapcontext put a restore token on the old shadow stack
which is used to restore the target shadow stack when switching user
contexts.  When longjmp from a user context, the target shadow stack
can be different from the current shadow stack and INCSSP can't be
used to restore the shadow stack pointer to the target shadow stack.

Update longjmp to search for a restore token.  If found, use the token
to restore the shadow stack pointer before using INCSSP to pop the
shadow stack.  Stop the token search and use INCSSP if the shadow stack
entry value is the same as the current shadow stack pointer.

It is a user error if there is a shadow stack switch without leaving a
restore token on the old shadow stack.

The only difference between __longjmp.S and __longjmp_chk.S is that
__longjmp_chk.S has a check for invalid longjmp usages.  Merge
__longjmp.S and __longjmp_chk.S by adding the CHECK_INVALID_LONGJMP
macro.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
4 months agolocaledata: ru_RU, ru_UA: convert to UTF-8
Mike FABIAN [Thu, 4 Jan 2024 15:32:44 +0000 (16:32 +0100)] 
localedata: ru_RU, ru_UA: convert to UTF-8

4 months agolocaledata: es_??: convert to UTF-8
Mike FABIAN [Thu, 4 Jan 2024 15:02:24 +0000 (16:02 +0100)] 
localedata: es_??: convert to UTF-8

4 months agolocaledata: miq_NI: convert to UTF-8
Mike FABIAN [Thu, 4 Jan 2024 15:00:33 +0000 (16:00 +0100)] 
localedata: miq_NI: convert to UTF-8

4 months agoi386: Ignore --enable-cet
H.J. Lu [Wed, 3 Jan 2024 20:09:23 +0000 (12:09 -0800)] 
i386: Ignore --enable-cet

Since shadow stack is only supported for x86-64, ignore --enable-cet for
i386.  Always setting $(enable-cet) for i386 to "no" to support

ifneq ($(enable-cet),no)

in x86 Makefiles.  We can't use

ifeq ($(enable-cet),yes)

since $(enable-cet) can be "yes", "no" or "permissive".
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agomach: Drop SNARF_ARGS macro
Sergey Bugaev [Wed, 3 Jan 2024 17:14:39 +0000 (20:14 +0300)] 
mach: Drop SNARF_ARGS macro

We're obtaining arguments from the stack differently, see init-first.c.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
4 months agomach: Drop some unnecessary vm_param.h includes
Sergey Bugaev [Wed, 3 Jan 2024 17:14:37 +0000 (20:14 +0300)] 
mach: Drop some unnecessary vm_param.h includes

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
4 months agohurd: Declare _hurd_intr_rpc_msg* with protected visibility
Sergey Bugaev [Wed, 3 Jan 2024 17:14:35 +0000 (20:14 +0300)] 
hurd: Declare _hurd_intr_rpc_msg* with protected visibility

These symbols are internal and never exported; make sure the compiler
realizes that when compiling hurdsig.c and does not try to emit GOT
reads.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
4 months agohurd: Add some missing includes
Sergey Bugaev [Wed, 3 Jan 2024 17:14:34 +0000 (20:14 +0300)] 
hurd: Add some missing includes

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
4 months agolocaledata: fy_DE: make this "Western Frisian" to agree with the language code "fy"
Mike FABIAN [Wed, 3 Jan 2024 19:55:44 +0000 (20:55 +0100)] 
localedata: fy_DE: make this "Western Frisian" to agree with the language code "fy"

Resolves: BZ # 14522

4 months agolocaledata: fy_DE, fy_NL: convert to UTF-8
Mike FABIAN [Wed, 3 Jan 2024 19:07:21 +0000 (20:07 +0100)] 
localedata: fy_DE, fy_NL: convert to UTF-8

4 months agolocaledata: ast_ES: convert to UTF-8
Mike FABIAN [Wed, 3 Jan 2024 16:44:52 +0000 (17:44 +0100)] 
localedata: ast_ES: convert to UTF-8

4 months agolocaledata: ast_ES: Remove wrong copyright text
Mike FABIAN [Wed, 3 Jan 2024 16:41:01 +0000 (17:41 +0100)] 
localedata: ast_ES: Remove wrong copyright text

Resolves: BZ # 27601

4 months agolocaledata: de_{AT,BE,CH,IT,LU}: convert to UTF-8
Mike FABIAN [Wed, 3 Jan 2024 11:50:20 +0000 (12:50 +0100)] 
localedata: de_{AT,BE,CH,IT,LU}: convert to UTF-8

4 months agolocaledata: lv_LV, it_IT, it_CH: convert to UTF-8
Mike FABIAN [Wed, 3 Jan 2024 11:36:03 +0000 (12:36 +0100)] 
localedata: lv_LV, it_IT, it_CH: convert to UTF-8

4 months agolocaledata: it_IT, lv_LV: currency symbol should follow the amount
Mike FABIAN [Wed, 3 Jan 2024 11:27:23 +0000 (12:27 +0100)] 
localedata: it_IT, lv_LV: currency symbol should follow the amount

Resolves: BZ # 28558

4 months agoImplement C23 <stdbit.h>
Joseph Myers [Wed, 3 Jan 2024 12:07:14 +0000 (12:07 +0000)] 
Implement C23 <stdbit.h>

C23 adds a header <stdbit.h> with various functions and type-generic
macros for bit-manipulation of unsigned integers (plus macro defines
related to endianness).  Implement this header for glibc.

The functions have both inline definitions in the header (referenced
by macros defined in the header) and copies with external linkage in
the library (which are implemented in terms of those macros to avoid
duplication).  They are documented in the glibc manual.  Tests, as
well as verifying results for various inputs (of both the macros and
the out-of-line functions), verify the types of those results (which
showed up a bug in an earlier version with the type-generic macro
stdc_has_single_bit wrongly returning a promoted type), that the
macros can be used at top level in a source file (so don't use ({})),
that they evaluate their arguments exactly once, and that the macros
for the type-specific functions have the expected implicit conversions
to the relevant argument type.

Jakub previously referred to -Wconversion warnings in type-generic
macros, so I've included a test with -Wconversion (but the only
warnings I saw and fixed from that test were actually in inline
functions in the <stdbit.h> header - not anything coming from use of
the type-generic macros themselves).

This implementation of the type-generic macros does not handle
unsigned __int128, or unsigned _BitInt types with a width other than
that of a standard integer type (and C23 doesn't require the header to
handle such types either).  Support for those types, using the new
type-generic built-in functions Jakub's added for GCC 14, can
reasonably be added in a followup (along of course with associated
tests).

This implementation doesn't do anything special to handle C++, or have
any tests of functionality in C++ beyond the existing tests that all
headers can be compiled in C++ code; it's not clear exactly what form
this header should take in C++, but probably not one using macros.

DIS ballot comment AT-107 asks for the word "count" to be added to the
names of the stdc_leading_zeros, stdc_leading_ones,
stdc_trailing_zeros and stdc_trailing_ones functions and macros.  I
don't think it's likely to be accepted (accepting any technical
comments would mean having an FDIS ballot), but if it is accepted at
the WG14 meeting (22-26 January in Strasbourg, starting with DIS
ballot comment handling) then there would still be time to update
glibc for the renaming before the 2.39 release.

The new functions and header are placed in the stdlib/ directory in
glibc, rather than creating a new toplevel stdbit/ or putting them in
string/ alongside ffs.

Tested for x86_64 and x86.

4 months agolocaledata: ms_MY should not use 12-hour format
Mike FABIAN [Wed, 3 Jan 2024 10:07:27 +0000 (11:07 +0100)] 
localedata: ms_MY should not use 12-hour format

Resolves: BZ # 29504

4 months agolocaledata: es_ES: convert to UTF-8
Mike FABIAN [Tue, 2 Jan 2024 16:28:43 +0000 (17:28 +0100)] 
localedata: es_ES: convert to UTF-8

4 months agolocaledata: es_ES: Add am_pm strings
Mike FABIAN [Tue, 2 Jan 2024 16:26:20 +0000 (17:26 +0100)] 
localedata: es_ES: Add am_pm strings

Resolves: BZ # 24013

Use <U202F> instead of a plain space because CLDR also uses that.

4 months agoaarch64: Add longjmp test for SME
Szabolcs Nagy [Tue, 21 Dec 2021 13:49:37 +0000 (13:49 +0000)] 
aarch64: Add longjmp test for SME

Includes test for setcontext too.

The test directly checks after longjmp if ZA got disabled and the
ZA contents got saved following the lazy saving scheme. It does not
use ACLE code to verify that gcc can interoperate with glibc.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agoaarch64: Add setcontext support for SME
Szabolcs Nagy [Fri, 17 Dec 2021 17:14:59 +0000 (17:14 +0000)] 
aarch64: Add setcontext support for SME

For the ZA lazy saving scheme to work, setcontext has to call
__libc_arm_za_disable.

Also fixes swapcontext which uses setcontext internally.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agoaarch64: Add longjmp support for SME
Szabolcs Nagy [Wed, 1 Dec 2021 11:37:44 +0000 (11:37 +0000)] 
aarch64: Add longjmp support for SME

For the ZA lazy saving scheme to work, longjmp has to call
__libc_arm_za_disable.

In ld.so we assume ZA is not used so longjmp does not need
special support there.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agoaarch64: Add SME runtime support
Szabolcs Nagy [Fri, 10 Sep 2021 15:52:17 +0000 (16:52 +0100)] 
aarch64: Add SME runtime support

The runtime support routines for the call ABI of the Scalable Matrix
Extension (SME) are mostly in libgcc. Since libc.so cannot depend on
libgcc_s.so have an implementation of __arm_za_disable in libc for
libc internal use in longjmp and similar APIs.

__libc_arm_za_disable follows the same PCS rules as __arm_za_disable,
but it's a hidden symbol so it does not need variant PCS marking.

Using __libc_fatal instead of abort because it can print a message and
works in ld.so too. But for now we don't need SME routines in ld.so.

To check the SME HWCAP in asm, we need the _dl_hwcap2 member offset in
_rtld_global_ro in the shared libc.so, while in libc.a the _dl_hwcap2
object is accessed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agolocaledata: convert uz_UZ and uz_UZ@cyrillic to UTF-8
Mike FABIAN [Tue, 2 Jan 2024 12:17:49 +0000 (13:17 +0100)] 
localedata: convert uz_UZ and uz_UZ@cyrillic to UTF-8

4 months agolocaledata: uz_UZ and uz_UZ@cyrillic: Fix decimal point and thousands separator
Mike FABIAN [Tue, 2 Jan 2024 12:02:37 +0000 (13:02 +0100)] 
localedata: uz_UZ and uz_UZ@cyrillic: Fix decimal point and thousands separator

Resolves: BZ # 31204

4 months agolibio: Check remaining buffer size in _IO_wdo_write (bug 31183)
Florian Weimer [Tue, 2 Jan 2024 13:36:17 +0000 (14:36 +0100)] 
libio: Check remaining buffer size in _IO_wdo_write (bug 31183)

The multibyte character needs to fit into the remaining buffer space,
not the already-written buffer space.  Without the fix, we were never
moving the write pointer from the start of the buffer, always using
the single-character fallback buffer.

Fixes commit 04b76b5aa8b2d1d19066e42dd1 ("Don't error out writing
a multibyte character to an unbuffered stream (bug 17522)").

4 months agogetaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)
Andreas Schwab [Wed, 6 Dec 2023 13:48:22 +0000 (14:48 +0100)] 
getaddrinfo: translate ENOMEM to EAI_MEMORY (bug 31163)

When __resolv_context_get returns NULL due to out of memory, translate it
to a return value of EAI_MEMORY.

4 months agostring: Add additional output in test-strchr failure
Noah Goldstein [Wed, 27 Dec 2023 19:29:32 +0000 (11:29 -0800)] 
string: Add additional output in test-strchr failure

Seeing occasional failures in `__strchrnul_evex512` that are not
consistently reproducible. Hopefully by adding this the next failure
will provide enough information to debug.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 months agoAdd a setjmp/longjmp test between user contexts
H.J. Lu [Wed, 20 Dec 2023 15:34:42 +0000 (07:34 -0800)] 
Add a setjmp/longjmp test between user contexts

Verify that setjmp and longjmp work correctly between user contexts.
Arrange stacks for uctx_func1 and uctx_func2 so that ____longjmp_chk
works when setjmp and longjmp are called from different user contexts.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
4 months agox86/cet: Add -fcf-protection=none before -fcf-protection=branch
H.J. Lu [Mon, 1 Jan 2024 15:55:18 +0000 (07:55 -0800)] 
x86/cet: Add -fcf-protection=none before -fcf-protection=branch

When shadow stack is enabled, some CET tests failed when compiled with
GCC 14:

FAIL: elf/tst-cet-legacy-4
FAIL: elf/tst-cet-legacy-5a
FAIL: elf/tst-cet-legacy-6a

which are caused by

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113039

These tests use -fcf-protection -fcf-protection=branch and assume that
-fcf-protection=branch will override -fcf-protection.  But this GCC 14
commit:

https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1c6231c05bdcca

changed the -fcf-protection behavior such that

-fcf-protection -fcf-protection=branch

is treated the same as

-fcf-protection

Use

-fcf-protection -fcf-protection=none -fcf-protection=branch

as the workaround.  This fixes BZ #31187.

Tested with GCC 13 and GCC 14 on Intel Tiger Lake.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
4 months agoRegenerate libc.pot
Andreas K. Hüttel [Mon, 1 Jan 2024 20:09:13 +0000 (21:09 +0100)] 
Regenerate libc.pot

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
4 months agoOmit regex.c pragmas no longer needed
Paul Eggert [Mon, 1 Jan 2024 18:40:37 +0000 (10:40 -0800)] 
Omit regex.c pragmas no longer needed

* posix/regex.c: [!_LIBC && __GNUC_PREREQ (4, 3)]:
Omit GCC pragmas no longer needed when this file is used as part of Gnulib.
-Wold-style-definition no longer needs to be ignored because the regex
code no longer uses old style definitions.  -Wtype-limits no longer
needs to be ignored because Gnulib already arranges for it to be
ignored in the C compiler flags.  This patch is taken from Gnulib.

4 months agoUpdate copyright dates not handled by scripts/update-copyrights
Paul Eggert [Mon, 1 Jan 2024 18:35:28 +0000 (10:35 -0800)] 
Update copyright dates not handled by scripts/update-copyrights

I've updated copyright dates in glibc for 2024.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.

4 months agoUpdate copyright in generated files by running "make"
Paul Eggert [Mon, 1 Jan 2024 18:25:06 +0000 (10:25 -0800)] 
Update copyright in generated files by running "make"

4 months agoUpdate copyright dates with scripts/update-copyrights
Paul Eggert [Mon, 1 Jan 2024 18:12:26 +0000 (10:12 -0800)] 
Update copyright dates with scripts/update-copyrights

4 months agox86/cet: Run some CET tests with shadow stack
H.J. Lu [Fri, 29 Dec 2023 16:43:54 +0000 (08:43 -0800)] 
x86/cet: Run some CET tests with shadow stack

When CET is disabled by default, run some CET tests with shadow stack
enabled using

$ export GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK

4 months agox86/cet: Don't set CET active by default
H.J. Lu [Fri, 29 Dec 2023 16:43:53 +0000 (08:43 -0800)] 
x86/cet: Don't set CET active by default

Not all CET enabled applications and libraries have been properly tested
in CET enabled environments.  Some CET enabled applications or libraries
will crash or misbehave when CET is enabled.  Don't set CET active by
default so that all applications and libraries will run normally regardless
of whether CET is active or not.  Shadow stack can be enabled by

$ export GLIBC_TUNABLES=glibc.cpu.hwcaps=SHSTK

at run-time if shadow stack can be enabled by kernel.

NB: This commit can be reverted if it is OK to enable CET by default for
all applications and libraries.

4 months agox86/cet: Check feature_1 in TCB for active IBT and SHSTK
H.J. Lu [Fri, 29 Dec 2023 16:43:52 +0000 (08:43 -0800)] 
x86/cet: Check feature_1 in TCB for active IBT and SHSTK

Initially, IBT and SHSTK are marked as active when CPU supports them
and CET are enabled in glibc.  They can be disabled early by tunables
before relocation.  Since after relocation, GLRO(dl_x86_cpu_features)
becomes read-only, we can't update GLRO(dl_x86_cpu_features) to mark
IBT and SHSTK as inactive.  Instead, check the feature_1 field in TCB
to decide if IBT and SHST are active.

4 months agox86/cet: Enable shadow stack during startup
H.J. Lu [Fri, 29 Dec 2023 16:43:51 +0000 (08:43 -0800)] 
x86/cet: Enable shadow stack during startup

Previously, CET was enabled by kernel before passing control to user
space and the startup code must disable CET if applications or shared
libraries aren't CET enabled.  Since the current kernel only supports
shadow stack and won't enable shadow stack before passing control to
user space, we need to enable shadow stack during startup if the
application and all shared library are shadow stack enabled.  There
is no need to disable shadow stack at startup.  Shadow stack can only
be enabled in a function which will never return.  Otherwise, shadow
stack will underflow at the function return.

1. GL(dl_x86_feature_1) is set to the CET features which are supported
by the processor and are not disabled by the tunable.  Only non-zero
features in GL(dl_x86_feature_1) should be enabled.  After enabling
shadow stack with ARCH_SHSTK_ENABLE, ARCH_SHSTK_STATUS is used to check
if shadow stack is really enabled.
2. Use ARCH_SHSTK_ENABLE in RTLD_START in dynamic executable.  It is
safe since RTLD_START never returns.
3. Call arch_prctl (ARCH_SHSTK_ENABLE) from ARCH_SETUP_TLS in static
executable.  Since the start function using ARCH_SETUP_TLS never returns,
it is safe to enable shadow stack in ARCH_SETUP_TLS.

4 months agoelf: Always provide _dl_get_dl_main_map in libc.a
H.J. Lu [Fri, 29 Dec 2023 16:43:50 +0000 (08:43 -0800)] 
elf: Always provide _dl_get_dl_main_map in libc.a

Always provide _dl_get_dl_main_map in libc.a.  It will be used by x86
to process PT_GNU_PROPERTY segment.

4 months agox86/cet: Sync with Linux kernel 6.6 shadow stack interface
H.J. Lu [Fri, 29 Dec 2023 16:43:49 +0000 (08:43 -0800)] 
x86/cet: Sync with Linux kernel 6.6 shadow stack interface

Sync with Linux kernel 6.6 shadow stack interface.  Since only x86-64 is
supported, i386 shadow stack codes are unchanged and CET shouldn't be
enabled for i386.

1. When the shadow stack base in TCB is unset, the default shadow stack
is in use.  Use the current shadow stack pointer as the marker for the
default shadow stack. It is used to identify if the current shadow stack
is the same as the target shadow stack when switching ucontexts.  If yes,
INCSSP will be used to unwind shadow stack.  Otherwise, shadow stack
restore token will be used.
2. Allocate shadow stack with the map_shadow_stack syscall.  Since there
is no function to explicitly release ucontext, there is no place to
release shadow stack allocated by map_shadow_stack in ucontext functions.
Such shadow stacks will be leaked.
3. Rename arch_prctl CET commands to ARCH_SHSTK_XXX.
4. Rewrite the CET control functions with the current kernel shadow stack
interface.

Since CET is no longer enabled by kernel, a separate patch will enable
shadow stack during startup.

5 months agoRISC-V: Add support for dl_runtime_profile (BZ #31151)
Aurelien Jarno [Sat, 30 Dec 2023 10:00:10 +0000 (11:00 +0100)] 
RISC-V: Add support for dl_runtime_profile (BZ #31151)

Code is mostly inspired from the LoongArch one, which has a similar ABI,
with minor changes to support riscv32 and register differences.

This fixes elf/tst-sprof-basic. This also fixes elf/tst-audit1,
elf/tst-audit2 and elf/tst-audit8 with recent binutils snapshots when
--enable-bind-now is used.

Resolves: BZ #31151

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
5 months agodebug: Add fortify wprintf tests
Adhemerval Zanella [Thu, 21 Dec 2023 18:59:19 +0000 (15:59 -0300)] 
debug: Add fortify wprintf tests

Similar to other printf-like ones.  It requires to be in a different
process so we can change the orientation of stdout.

Checked on aarch64, armhf, x86_64, and i686.

5 months agodebug: Add fortify syslog tests
Adhemerval Zanella [Thu, 21 Dec 2023 18:59:18 +0000 (15:59 -0300)] 
debug: Add fortify syslog tests

It requires to be in a container tests to avoid logging bogus
information on the system.  The syslog also requires to be checked in
a different process because the internal printf call will abort with
the internal syslog lock taken (which makes subsequent syslog calls
deadlock).

Checked on aarch64, armhf, x86_64, and i686.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agodebug: Add fortify dprintf tests
Adhemerval Zanella [Thu, 21 Dec 2023 18:59:17 +0000 (15:59 -0300)] 
debug: Add fortify dprintf tests

Similar to other printf-like ones.

Checked on aarch64, armhf, x86_64, and i686.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agodebug: Increase tst-fortify checks for compiler without __va_arg_pack support
Adhemerval Zanella [Thu, 21 Dec 2023 18:59:16 +0000 (15:59 -0300)] 
debug: Increase tst-fortify checks for compiler without __va_arg_pack support

The fortify wrappers for varargs functions already add fallbacks to
builtins calls if __va_arg_pack is not supported.

Checked on aarch64, armhf, x86_64, and i686.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agodebug: Adapt fortify tests to libsupport
Adhemerval Zanella [Thu, 21 Dec 2023 18:59:15 +0000 (15:59 -0300)] 
debug: Adapt fortify tests to libsupport

Checked on aarch64, armhf, x86_64, and i686.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agolocaledata: yo_NT: remove redundant comments
Mike FABIAN [Tue, 26 Dec 2023 12:27:07 +0000 (13:27 +0100)] 
localedata: yo_NT: remove redundant comments

See: https://sourceware.org/pipermail/libc-alpha/2023-December/153538.html

5 months agolocaledata: convert en_AU, en_NZ, mi_NZ, niu_NZ to UTF-8
Mike FABIAN [Tue, 26 Dec 2023 09:05:50 +0000 (10:05 +0100)] 
localedata: convert en_AU, en_NZ, mi_NZ, niu_NZ to UTF-8

5 months agolocaledata: First day of the week in AU is Monday, LC_TIME in en_NZ is identical...
Mike FABIAN [Tue, 26 Dec 2023 08:59:10 +0000 (09:59 +0100)] 
localedata: First day of the week in AU is Monday, LC_TIME in en_NZ is identical to LC_TIME in en_AU then

Resolves: BZ # 24877

5 months agolocaledata: convert yo_NG to UTF-8, check that language name in Yoruba agrees with...
Mike FABIAN [Tue, 19 Dec 2023 16:58:35 +0000 (17:58 +0100)] 
localedata: convert yo_NG to UTF-8, check that language name in Yoruba agrees with CLDR

Related: BZ # 24878

5 months agox86-64: Fix the tcb field load for x32 [BZ #31185]
H.J. Lu [Thu, 21 Dec 2023 03:42:12 +0000 (19:42 -0800)] 
x86-64: Fix the tcb field load for x32 [BZ #31185]

_dl_tlsdesc_undefweak and _dl_tlsdesc_dynamic access the thread pointer
via the tcb field in TCB:

_dl_tlsdesc_undefweak:
        _CET_ENDBR
        movq    8(%rax), %rax
        subq    %fs:0, %rax
        ret

_dl_tlsdesc_dynamic:
...
        subq    %fs:0, %rax
        movq    -8(%rsp), %rdi
        ret

Since the tcb field in TCB is a pointer, %fs:0 is a 32-bit location,
not 64-bit. It should use "sub %fs:0, %RAX_LP" instead.  Since
_dl_tlsdesc_undefweak returns ptrdiff_t and _dl_make_tlsdesc_dynamic
returns void *, RAX_LP is appropriate here for x32 and x86-64.  This
fixes BZ #31185.

5 months agox86-64: Fix the dtv field load for x32 [BZ #31184]
H.J. Lu [Thu, 21 Dec 2023 00:31:43 +0000 (16:31 -0800)] 
x86-64: Fix the dtv field load for x32 [BZ #31184]

On x32, I got

FAIL: elf/tst-tlsgap

$ gdb elf/tst-tlsgap
...
open tst-tlsgap-mod1.so

Thread 2 "tst-tlsgap" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 2268754]
_dl_tlsdesc_dynamic () at ../sysdeps/x86_64/dl-tlsdesc.S:108
108 movq (%rsi), %rax
(gdb) p/x $rsi
$4 = 0xf7dbf9005655fb18
(gdb)

This is caused by

_dl_tlsdesc_dynamic:
        _CET_ENDBR
        /* Preserve call-clobbered registers that we modify.
           We need two scratch regs anyway.  */
        movq    %rsi, -16(%rsp)
        movq    %fs:DTV_OFFSET, %rsi

Since the dtv field in TCB is a pointer, %fs:DTV_OFFSET is a 32-bit
location, not 64-bit.  Load the dtv field to RSI_LP instead of rsi.
This fixes BZ #31184.

5 months agonss: Remove unused allocation from get_nscd_addresses in getaddrinfo
Florian Weimer [Wed, 20 Dec 2023 15:14:33 +0000 (16:14 +0100)] 
nss: Remove unused allocation from get_nscd_addresses in getaddrinfo

No bug because this is not visible if glibc is built with
optimization.  Otherwise this would be a critical resource leak.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agox86/cet: Don't disable CET if not single threaded
H.J. Lu [Fri, 28 Jul 2023 21:06:01 +0000 (14:06 -0700)] 
x86/cet: Don't disable CET if not single threaded

In permissive mode, don't disable IBT nor SHSTK when dlopening a legacy
shared library if not single threaded since IBT and SHSTK may be still
enabled in other threads.  Other threads with IBT or SHSTK enabled will
crash when calling functions in the legacy shared library.  Instead, an
error will be issued.

5 months agox86: Modularize sysdeps/x86/dl-cet.c
H.J. Lu [Fri, 24 Mar 2023 20:20:06 +0000 (13:20 -0700)] 
x86: Modularize sysdeps/x86/dl-cet.c

Improve readability and make maintenance easier for dl-feature.c by
modularizing sysdeps/x86/dl-cet.c:
1. Support processors with:
   a. Only IBT.  Or
   b. Only SHSTK.  Or
   c. Both IBT and SHSTK.
2. Lock CET features only if IBT or SHSTK are enabled and are not
enabled permissively.

5 months agox86/cet: Update tst-cet-vfork-1
H.J. Lu [Sun, 16 Jan 2022 20:09:57 +0000 (12:09 -0800)] 
x86/cet: Update tst-cet-vfork-1

Change tst-cet-vfork-1.c to verify that vfork child return triggers
SIGSEGV due to shadow stack mismatch.

5 months agoelf: Add TLS modid reuse test for bug 29039
Szabolcs Nagy [Wed, 29 Nov 2023 11:31:37 +0000 (11:31 +0000)] 
elf: Add TLS modid reuse test for bug 29039

This is a minimal regression test for bug 29039 which only affects
targets with TLSDESC and a reproducer requires that

1) Have modid gaps (closed modules) with old generation.
2) Update a DTV to a newer generation (needs a newer dlopen).
3) But do not update the closed gap entry in that DTV.
4) Reuse the modid gap for a new module (another dlopen).
5) Use dynamic TLSDESC in that new module with old generation (bug).
6) Access TLS via this TLSDESC and the now outdated DTV.

However step (3) in practice rarely happens: during DTV update the
entries for closed modids are initialized to "unallocated" and then
dynamic TLSDESC calls __tls_get_addr independently of its generation.
The only exception to this is DTV setup at thread creation (gaps are
initialized to NULL instead of unallocated) or DTV resize where the
gap entries are outside the previous DTV array (again NULL instead
of unallocated, and this requires loading > DTV_SURPLUS modules).

So the bug can only cause NULL (+ offset) dereference, not use after
free. And the easiest way to get (3) is via thread creation.

Note that step (5) requires that the newly loaded module has larger
TLS than the remaining optional static TLS. And for (6) there cannot
be other TLS access or dlopen in the thread that updates the DTV.

Tested on aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoaarch64: Add SIMD attributes to math functions with vector versions
Joe Ramsay [Mon, 18 Dec 2023 15:51:16 +0000 (15:51 +0000)] 
aarch64: Add SIMD attributes to math functions with vector versions

Added annotations for autovec by GCC and GFortran - this enables GCC
>= 9 to autovectorise math calls at -Ofast.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
5 months agoaarch64: Add half-width versions of AdvSIMD f32 libmvec routines
Joe Ramsay [Tue, 19 Dec 2023 16:44:01 +0000 (16:44 +0000)] 
aarch64: Add half-width versions of AdvSIMD f32 libmvec routines

Compilers may emit calls to 'half-width' routines (two-lane
single-precision variants). These have been added in the form of
wrappers around the full-width versions, where the low half of the
vector is simply duplicated. This will perform poorly when one lane
triggers the special-case handler, as there will be a redundant call
to the scalar version, however this is expected to be rare at Ofast.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
5 months agoFix elf/tst-env-setuid[-static] if test needs to be rerun.
Stefan Liebler [Wed, 13 Dec 2023 11:44:50 +0000 (12:44 +0100)] 
Fix elf/tst-env-setuid[-static] if test needs to be rerun.

If /tmp is mounted nosuid and make xcheck is run,
then tst-env-setuid fails UNSUPPORTED with "SGID failed: GID and EGID match"
and /var/tmp/tst-sonamemove-runmod1.so.profile is created.

If you then try to rerun the test with a suid mounted test-dir
(the SGID binary is created in test-dir which defaults to /tmp)
with something like that:
make tst-env-setuid-ENV="TMPDIR=..." t=elf/tst-env-setuid test
the test fails as the LD_PROFILE output file is still available
from the previous run.

Thus this patch removes the LD_PROFILE output file in parent
before spawning the SGID binary.

Even if LD_PROFILE is not supported anymore in static binaries,
use a different library and thus output file for tst-env-setuid
and tst-env-setuid-static in order to not interfere if both
tests are run in parallel.

Furthermore the checks in test_child are now more verbose.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoFix elf: Do not duplicate the GLIBC_TUNABLES string
H.J. Lu [Wed, 20 Dec 2023 00:01:33 +0000 (16:01 -0800)] 
Fix elf: Do not duplicate the GLIBC_TUNABLES string

commit 2a969b53c0b02fed7e43473a92f219d737fd217a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Dec 6 10:24:01 2023 -0300

    elf: Do not duplicate the GLIBC_TUNABLES string

has

@@ -38,7 +39,7 @@
    which isn't available.  */
 #define CHECK_GLIBC_IFUNC_PREFERRED_OFF(f, cpu_features, name, len) \
   _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \
-  if (memcmp (f, #name, len) == 0)             \
+  if (tunable_str_comma_strcmp_cte (&f, #name) == 0)       \
     {                           \
       cpu_features->preferred[index_arch_##name]        \
   &= ~bit_arch_##name;                \
@@ -46,12 +47,11 @@

Fix it by removing "== 0" after tunable_str_comma_strcmp_cte.

5 months agotst-setcontext10.c: Undef _FORTIFY_SOURCE
H.J. Lu [Tue, 19 Dec 2023 17:55:25 +0000 (09:55 -0800)] 
tst-setcontext10.c: Undef _FORTIFY_SOURCE

When _FORTIFY_SOURCE is defined to 2, ____longjmp_chk is called,
instead of longjmp.  ____longjmp_chk compares the relative stack
values to decide if it is called from a stack frame which called
setjmp.  If not, ____longjmp_chk assumes that an alternate signal
stack is used.  Since comparing the relative stack values isn't
reliable with user context, when there is no signal, ____longjmp_chk
will fail.  Undefine _FORTIFY_SOURCE to avoid ____longjmp_chk in
user context test.

5 months agoFix elf: Do not duplicate the GLIBC_TUNABLES string
H.J. Lu [Tue, 19 Dec 2023 21:21:06 +0000 (13:21 -0800)] 
Fix elf: Do not duplicate the GLIBC_TUNABLES string

Fix issues in sysdeps/x86/tst-hwcap-tunables.c added by

Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Dec 6 10:24:01 2023 -0300

    elf: Do not duplicate the GLIBC_TUNABLES string

1. -AVX,-AVX2,-AVX512F should be used to disable AVX, AVX2 and AVX512.
2. AVX512 IFUNC functions check AVX512VL.  -AVX512VL should be added
to disable these functions.

This fixed:

FAIL: elf/tst-hwcap-tunables
...
[0] Spawned test for -Prefer_ERMS,-Prefer_FSRM,-AVX,-AVX2,-AVX_Usable,-AVX2_Usable,-AVX512F_Usable,-SSE4_1,-SSE4_2,-SSSE3,-Fast_Unaligned_Load,-ERMS,-AVX_Fast_Unaligned_Load
error: subprocess failed: tst-tunables
error:   unexpected output from subprocess
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false

[1] Spawned test for ,-,-Prefer_ERMS,-Prefer_FSRM,-AVX,-AVX2,-AVX_Usable,-AVX2_Usable,-AVX512F_Usable,-SSE4_1,-SSE4_2,,-SSSE3,-Fast_Unaligned_Load,,-,-ERMS,-AVX_Fast_Unaligned_Load,-,
error: subprocess failed: tst-tunables
error:   unexpected output from subprocess
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false
../sysdeps/x86/tst-hwcap-tunables.c:91: numeric comparison failure
   left: 1 (0x1); from: impls[i].usable
  right: 0 (0x0); from: false

error: 2 test failures

on Intel Tiger Lake.

5 months agohppa: Fix undefined behaviour in feclearexcept (BZ 30983)
Bruno Haible [Thu, 2 Nov 2023 19:19:44 +0000 (16:19 -0300)] 
hppa: Fix undefined behaviour in feclearexcept (BZ 30983)

The expression

  (excepts & FE_ALL_EXCEPT) << 27

produces a signed integer overflow when 'excepts' is specified as
FE_INVALID (= 0x10), because
  - excepts is of type 'int',
  - FE_ALL_EXCEPT is of type 'int',
  - thus (excepts & FE_ALL_EXCEPT) is (int) 0x10,
  - 'int' is 32 bits wide.

The patched code produces the same instruction sequence as
previosuly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agoalpha: Fix fesetexceptflag (BZ 30998)
Bruno Haible [Thu, 2 Nov 2023 14:23:48 +0000 (11:23 -0300)] 
alpha: Fix fesetexceptflag (BZ 30998)

It clears some exception flags that are outside the EXCEPTS argument.

It fixes math/test-fexcept on qemu-user.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agoriscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)
Adhemerval Zanella [Thu, 2 Nov 2023 14:15:55 +0000 (11:15 -0300)] 
riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)

libc_feupdateenv_riscv should check for FE_DFL_ENV, similar to
libc_fesetenv_riscv.

Also extend the test-fenv.c to test fenvupdate.

Checked on riscv under qemu-system.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agomanual: Clarify undefined behavior of feenableexcept (BZ 31019)
Bruno Haible [Wed, 1 Nov 2023 01:10:11 +0000 (02:10 +0100)] 
manual: Clarify undefined behavior of feenableexcept (BZ 31019)

Explain undefined behavior of feenableexcept in a special case.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agox86: Do not raises floating-point exception traps on fesetexceptflag (BZ 30990)
Bruno Haible [Tue, 24 Oct 2023 11:37:16 +0000 (08:37 -0300)] 
x86: Do not raises floating-point exception traps on fesetexceptflag (BZ 30990)

According to ISO C23 (7.6.4.4), fesetexcept is supposed to set
floating-point exception flags without raising a trap (unlike
feraiseexcept, which is supposed to raise a trap if feenableexcept
was called with the appropriate argument).

The flags can be set in the 387 unit or in the SSE unit.  When we need
to clear a flag, we need to do so in both units, due to the way
fetestexcept is implemented.

When we need to set a flag, it is sufficient to do it in the SSE unit,
because that is guaranteed to not trap.  However, on i386 CPUs that have
only a 387 unit, set the flags in the 387, as long as this cannot trap.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agoi686: Do not raise exception traps on fesetexcept (BZ 30989)
Adhemerval Zanella [Tue, 24 Oct 2023 11:37:15 +0000 (08:37 -0300)] 
i686: Do not raise exception traps on fesetexcept (BZ 30989)

According to ISO C23 (7.6.4.4), fesetexcept is supposed to set
floating-point exception flags without raising a trap (unlike
feraiseexcept, which is supposed to raise a trap if feenableexcept
was called with the appropriate argument).

The flags can be set in the 387 unit or in the SSE unit.  To set
a flag, it is sufficient to do it in the SSE unit, because that is
guaranteed to not trap.  However, on i386 CPUs that have only a
387 unit, set the flags in the 387, as long as this cannot trap.

Checked on i686-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agopowerpc: Do not raise exception traps for fesetexcept/fesetexceptflag (BZ 30988)
Adhemerval Zanella [Tue, 24 Oct 2023 11:37:14 +0000 (08:37 -0300)] 
powerpc: Do not raise exception traps for fesetexcept/fesetexceptflag (BZ 30988)

According to ISO C23 (7.6.4.4), fesetexcept is supposed to set
floating-point exception flags without raising a trap (unlike
feraiseexcept, which is supposed to raise a trap if feenableexcept was
called with the appropriate argument).

This is a side-effect of how we implement the GNU extension
feenableexcept, where feenableexcept/fesetenv/fesetmode/feupdateenv
might issue prctl (PR_SET_FPEXC, PR_FP_EXC_PRECISE) depending of the
argument.  And on PR_FP_EXC_PRECISE, setting a floating-point exception
flag triggers a trap.

To make the both functions follow the C23, fesetexcept and
fesetexceptflag now fail if the argument may trigger a trap.

The math tests now check for an value different than 0, instead
of bail out as unsupported for EXCEPTION_SET_FORCES_TRAP.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agoelf: Do not set invalid tunables values
Adhemerval Zanella [Wed, 6 Dec 2023 13:24:02 +0000 (10:24 -0300)] 
elf: Do not set invalid tunables values

The loader now warns for invalid and out-of-range tunable values. The
patch also fixes the parsing of size_t maximum values, where
_dl_strtoul was failing for large values close to SIZE_MAX.

Checked on x86_64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agoelf: Do not duplicate the GLIBC_TUNABLES string
Adhemerval Zanella [Wed, 6 Dec 2023 13:24:01 +0000 (10:24 -0300)] 
elf: Do not duplicate the GLIBC_TUNABLES string

The tunable parsing duplicates the tunable environment variable so it
null-terminates each one since it simplifies the later parsing. It has
the drawback of adding another point of failure (__minimal_malloc
failing), and the memory copy requires tuning the compiler to avoid mem
operations calls.

The parsing now tracks the tunable start and its size. The
dl-tunable-parse.h adds helper functions to help parsing, like a strcmp
that also checks for size and an iterator for suboptions that are
comma-separated (used on hwcap parsing by x86, powerpc, and s390x).

Since the environment variable is allocated on the stack by the kernel,
it is safe to keep the references to the suboptions for later parsing
of string tunables (as done by set_hwcaps by multiple architectures).

Checked on x86_64-linux-gnu, powerpc64le-linux-gnu, and
aarch64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agoDo not build sparc32 libgcc functions into static libc
Joseph Myers [Tue, 19 Dec 2023 16:00:11 +0000 (16:00 +0000)] 
Do not build sparc32 libgcc functions into static libc

Since GCC commit f31a019d1161ec78846473da743aedf49cca8c27 "Emit
funcall external declarations only if actually used.", the glibc
testsuite has failed to build for 32-bit SPARC with GCC mainline.

/scratch/jmyers/glibc-bot/install/compilers/sparc64-linux-gnu/lib/gcc/sparc64-glibc-linux-gnu/14.0.0/../../../../sparc64-glibc-linux-gnu/bin/ld: /scratch/jmyers/glibc-bot/install/compilers/sparc64-linux-gnu/lib/gcc/sparc64-glibc-linux-gnu/14.0.0/32/libgcc.a(_divsi3.o): in function `.div':
/scratch/jmyers/glibc-bot/src/gcc/libgcc/config/sparc/lb1spc.S:138: multiple definition of `.div'; /scratch/jmyers/glibc-bot/build/glibcs/sparcv9-linux-gnu/glibc/libc.a(sdiv.o):/scratch/jmyers/glibc-bot/src/glibc/gnulib/../sysdeps/sparc/sparc32/sparcv9/sdiv.S:13: first defined here
/scratch/jmyers/glibc-bot/install/compilers/sparc64-linux-gnu/lib/gcc/sparc64-glibc-linux-gnu/14.0.0/../../../../sparc64-glibc-linux-gnu/bin/ld: disabling relaxation; it will not work with multiple definitions
collect2: error: ld returned 1 exit status
make[3]: *** [../Rules:298: /scratch/jmyers/glibc-bot/build/glibcs/sparcv9-linux-gnu/glibc/nptl/tst-cancel24-static] Error 1

https://sourceware.org/pipermail/libc-testresults/2023q4/012154.html

I'm not sure of the exact sequence of undefined references that cause
first the glibc object file defining .div and then the libgcc object
file defining both .div and .udiv to be pulled in (which must have
been perturbed by that GCC change in a way that introduced the build
failure), but I think the failure illustrates that it's inherently
fragile for glibc to define symbols in separate object files that
libgcc defines in the same object file - and indeed for glibc to
redefine libgcc symbols at all, since the division into object files
shouldn't really be part of the interface between libgcc and libc.

These symbols appear to be in libc only for compatibility, maybe one
of the cases where they were accidentally exported from shared libc in
glibc 2.0 before the introduction of symbol versioning and so programs
started expecting shared libc to provide them.  Thus, there is no need
to have them in static libc.  Add this set of libgcc functions to
shared-only-routines so they are no longer provided in static libc.
(No change is made regarding .mul - dotmul source file - since unlike
the other symbols in this grouping, it doesn't actually appear to be a
libgcc symbol, at least in current GCC.)

Tested with build-many-glibcs.py for sparcv9-linux-gnu with GCC
mainline.

5 months agox86/cet: Check CPU_FEATURE_ACTIVE in permissive mode
H.J. Lu [Tue, 28 Mar 2023 20:52:36 +0000 (13:52 -0700)] 
x86/cet: Check CPU_FEATURE_ACTIVE in permissive mode

Verify that CPU_FEATURE_ACTIVE works properly in permissive mode.

5 months agox86/cet: Check legacy shadow stack code in .init_array section
H.J. Lu [Wed, 22 Mar 2023 20:34:55 +0000 (13:34 -0700)] 
x86/cet: Check legacy shadow stack code in .init_array section

Verify that legacy shadow stack code in .init_array section in application
and shared library, which are marked as shadow stack enabled, will trigger
segfault.

5 months agox86/cet: Add tests for GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK
H.J. Lu [Fri, 17 Mar 2023 23:21:49 +0000 (16:21 -0700)] 
x86/cet: Add tests for GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK

Verify that GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK turns off shadow
stack properly.

5 months agox86/cet: Check CPU_FEATURE_ACTIVE when CET is disabled
H.J. Lu [Fri, 10 Mar 2023 21:18:10 +0000 (13:18 -0800)] 
x86/cet: Check CPU_FEATURE_ACTIVE when CET is disabled

Verify that CPU_FEATURE_ACTIVE (SHSTK) works properly when CET is
disabled.

5 months agox86/cet: Check legacy shadow stack applications
H.J. Lu [Tue, 21 Mar 2023 19:53:24 +0000 (12:53 -0700)] 
x86/cet: Check legacy shadow stack applications

Add tests to verify that legacy shadow stack applications run properly
when shadow stack is enabled in Linux kernel.

5 months agolocaledata: id_ID: change first weekday to Sunday
Mike FABIAN [Tue, 19 Dec 2023 09:48:42 +0000 (10:48 +0100)] 
localedata: id_ID: change first weekday to Sunday

Resolves: BZ # 30412

See: https://sourceware.org/bugzilla/show_bug.cgi?id=30412#c7

CLDR also has ID in the list of territories which have Sunday as the
first day of the week.

5 months agos390: Set psw addr field in getcontext and friends.
Stefan Liebler [Fri, 15 Dec 2023 08:26:40 +0000 (09:26 +0100)] 
s390: Set psw addr field in getcontext and friends.

So far if the ucontext structure was obtained by getcontext and co,
the return address was stored in general purpose register 14 as
it is defined as return address in the ABI.

In contrast, the context passed to a signal handler contains the address
in psw.addr field.

If somebody e.g. wants to dump the address of the context, the origin
needs to be known.

Now this patch adjusts getcontext and friends and stores the return address
also in psw.addr field.

Note that setcontext isn't adjusted and it is not supported to pass a
ucontext structure from signal-handler to setcontext.  We are not able to
restore all registers and branching to psw.addr without clobbering one
register.

5 months agox86: Unifies 'strlen-evex' and 'strlen-evex512' implementations.
Matthew Sterrett [Fri, 15 Dec 2023 20:04:05 +0000 (12:04 -0800)] 
x86: Unifies 'strlen-evex' and 'strlen-evex512' implementations.

This commit uses a common implementation 'strlen-evex-base.S' for both
'strlen-evex' and 'strlen-evex512'

The motivation is to reduce the number of implementations to maintain.
This incidentally gives a small performance improvement.

All tests pass on x86.

Benchmarks were taken on SKX.
https://www.intel.com/content/www/us/en/products/sku/123613/intel-core-i97900x-xseries-processor-13-75m-cache-up-to-4-30-ghz/specifications.html

Geometric mean for strlen-evex512 over all benchmarks (N=10) was (new/old) 0.939
Geometric mean for wcslen-evex512 over all benchmarks (N=10) was (new/old) 0.965

Code Size Changes:
    strlen-evex512.S    :  +24 bytes
    wcslen-evex512.S    :  +54 bytes

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
5 months agox86/cet: Don't assume that SHSTK implies IBT
H.J. Lu [Sat, 16 Dec 2023 16:53:12 +0000 (08:53 -0800)] 
x86/cet: Don't assume that SHSTK implies IBT

Since shadow stack (SHSTK) is enabled in the Linux kernel without
enabling indirect branch tracking (IBT), don't assume that SHSTK
implies IBT.  Use "CPU_FEATURE_ACTIVE (IBT)" to check if IBT is active
and "CPU_FEATURE_ACTIVE (SHSTK)" to check if SHSTK is active.

5 months agoid_ID: Update Time Locales
RushingAlien [Mon, 21 Aug 2023 03:55:30 +0000 (10:55 +0700)] 
id_ID: Update Time Locales

Hello! I am Indonesian, was born and raised in Indonesia and still do live in
Indonesia.

This patch brings a few changes to the time locales of id_ID, which
includes :
\- Defining am_pm and time_fmpt_ampm
\- Changing time_fmt and d_t_fmt to use the 24-hour format
\- Changing first_weekday to Monday
This is a squashed version of what is previously a 5 patch set

Here are reasons and details of the changes :

Change 1 part 1

id_ID: Define `am_pm` string

Current formatting does not define am_pm string, leading to AM and PM
not being specified in 12 H time format. This change defines the string
by changing it from an empty string to "AM";"PM".

output of `date +%r`:
before commit: 01:23
after commit: 01:23 PM

Change 1 part 2

id_ID: Define time_fmt_ampm, change from an empty string

Currently, time_fmpt_ampm is set to an empty string, causing some
programs to not be able to display time in the 12-hour format, for
example, glib: https://gitlab.gnome.org/GNOME/glib/-/issues/2967.
This commit changes it from an empty string to "%I:%M:%S %p"

Change 2 part 1

id_ID: Use 24-hour format for time_fmt

Indonesian standard and formal time format uses the 24-hour format inst-
ead of the 12-hour format. This commit aims to change the id_ID locale's
time_fmt to match that accordingly.

Change 2 part 2

id_ID: Use 24-hour format for d_t_fmt.

Indonesian standard and formal time format uses the 24-hour format inst-
ead of the 12-hour format. This commit aims to change the id_ID locale's
d_t_fmt to match that accordingly.

Change 3

id_ID: Change first_weekday to monday

Indonesian calendar starts of the week with Monday, let's comply

Message-ID: <20230821035530.9075-1-rushing27alien@gmail.com>
Resolves: BZ # 30412
Reviewed-by: Mike Fabian <mfabian@redhat.com>
5 months agoUpdate code to handle the new ABI for sending inlined port rights.
Flavio Cruz [Thu, 14 Dec 2023 06:02:28 +0000 (01:02 -0500)] 
Update code to handle the new ABI for sending inlined port rights.

For i686, this change is no op but for x86_64 it forces all inlined port
rights to be 8 bytes long.

5 months agox86/cet: Check user_shstk in /proc/cpuinfo
H.J. Lu [Sat, 16 Dec 2023 16:53:10 +0000 (08:53 -0800)] 
x86/cet: Check user_shstk in /proc/cpuinfo

Linux kernel reports CPU shadow stack feature in /proc/cpuinfo as
user_shstk, instead of shstk.

5 months agoAdd a test for setjmp/longjmp within user context
H.J. Lu [Thu, 14 Dec 2023 19:37:03 +0000 (11:37 -0800)] 
Add a test for setjmp/longjmp within user context

Verify that setjmp/longjmp works correctly within a user context.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>