platform/upstream/glibc.git
5 months agoIncorporate translations (zh_CN)
Andreas K. Hüttel [Thu, 11 Jan 2024 18:46:43 +0000 (19:46 +0100)]
Incorporate translations (zh_CN)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
5 months agoDefine ISO 639-3 "glk" (Gilaki)
Mike FABIAN [Thu, 11 Jan 2024 15:34:49 +0000 (16:34 +0100)]
Define ISO 639-3 "glk" (Gilaki)

Resolves: BZ # 27163

References:
https://iso639-3.sil.org/code/glk
https://en.wikipedia.org/wiki/Gilaki_language

5 months agoresolv: Fix endless loop in __res_context_query
Stefan Liebler [Thu, 11 Jan 2024 13:01:18 +0000 (14:01 +0100)]
resolv: Fix endless loop in __res_context_query

Starting with commit 40c0add7d48739f5d89ebba255c1df26629a76e2
"resolve: Remove __res_context_query alloca usage"
there is an endless loop in __res_context_query if
__res_context_mkquery fails e.g. if type is invalid.  Then the
scratch buffer is resized to MAXPACKET size and it is retried again.

Before the mentioned commit, it was retried only once and with the
mentioned commit, there is no check and it retries in an endless loop.

This is observable with xtest resolv/tst-resolv-qtypes which times out
after 300s.

This patch retries mkquery only once as before the mentioned commit.
Furthermore, scratch_buffer_set_array_size is now only called with
nelem=2 if type is T_QUERY_A_AND_AAAA (also see mentioned commit).
The test tst-resolv-qtypes is also adjusted to verify that <func>
is really returning with -1 in case of an invalid type.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agolocaledata: revert all the remaining locale sources to UTF-8
Mike FABIAN [Thu, 11 Jan 2024 13:17:55 +0000 (14:17 +0100)]
localedata: revert all the remaining locale sources to UTF-8

5 months agolocaledata: am_ET ber_DZ en_GB en_PH en_US fil_PH kab_DZ om_ET om_KE ti_ET tl_PH...
Mike FABIAN [Thu, 11 Jan 2024 08:14:45 +0000 (09:14 +0100)]
localedata: am_ET ber_DZ en_GB en_PH en_US fil_PH kab_DZ om_ET om_KE ti_ET tl_PH: convert to UTF-8

5 months agolocaledata: resolve cyclic dependencies
Mike FABIAN [Wed, 10 Jan 2024 17:00:26 +0000 (18:00 +0100)]
localedata: resolve cyclic dependencies

Resolves: BZ # 24006

5 months agolocaledata: kv_RU: convert to UTF-8
Mike FABIAN [Thu, 11 Jan 2024 08:33:08 +0000 (09:33 +0100)]
localedata: kv_RU: convert to UTF-8

5 months agolocaledata: add new locale kv_RU
Mike FABIAN [Tue, 9 Jan 2024 13:29:20 +0000 (14:29 +0100)]
localedata: add new locale kv_RU

Resolves: BZ # 30605

5 months agoelf: Fix tst-nodeps2 test failure.
Carlos O'Donell [Wed, 10 Jan 2024 15:46:03 +0000 (10:46 -0500)]
elf: Fix tst-nodeps2 test failure.

After 78ca44da0160a0b442f0ca1f253e3360f044b2ec
("elf: Relocate libc.so early during startup and dlmopen (bug 31083)")
we start seeing tst-nodeps2 failures when building the testsuite with
--enable-hard-coded-path-in-tests.

When building the testsuite with --enable-hard-coded-path-in-tests
the tst-nodeps2-mod.so is not built with the required DT_RUNPATH
values and the test escapes the test framework and loads the system
libraries and aborts. The fix is to use the existing
$(link-test-modules-rpath-link) variable to set DT_RUNPATH correctly.

No regressions on x86_64.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
5 months agolocaledata: Sort Makefile variables.
Carlos O'Donell [Tue, 9 Jan 2024 13:29:45 +0000 (08:29 -0500)]
localedata: Sort Makefile variables.

Sort Makefile variables using scrips/sort-makefile-lines.py.

No regressions on x86_64.

5 months agolocale: Sort Makefile variables.
Carlos O'Donell [Fri, 1 Dec 2023 13:55:59 +0000 (08:55 -0500)]
locale: Sort Makefile variables.

Sort Makefile variables using scrips/sort-makefile-lines.py.

No regressions on x86_64.

5 months agoi386: Remove CET support bits
H.J. Lu [Tue, 9 Jan 2024 20:23:27 +0000 (12:23 -0800)]
i386: Remove CET support bits

1. Remove _dl_runtime_resolve_shstk and _dl_runtime_profile_shstk.
2. Move CET offsets from x86 cpu-features-offsets.sym to x86-64
features-offsets.sym.
3. Rename x86 cet-control.h to x86-64 feature-control.h since it is only
for x86-64 and also used for PLT rewrite.
4. Add x86-64 ldsodefs.h to include feature-control.h.
5. Change TUNABLE_CALLBACK (set_plt_rewrite) to x86-64 only.
6. Move x86 dl-procruntime.c to x86-64.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agox86-64/cet: Move check-cet.awk to x86_64
H.J. Lu [Tue, 9 Jan 2024 20:23:26 +0000 (12:23 -0800)]
x86-64/cet: Move check-cet.awk to x86_64

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agox86-64/cet: Move dl-cet.[ch] to x86_64 directories
H.J. Lu [Tue, 9 Jan 2024 20:23:25 +0000 (12:23 -0800)]
x86-64/cet: Move dl-cet.[ch] to x86_64 directories

Since CET is only enabled for x86-64, move dl-cet.[ch] to x86_64
directories.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agox86: Move x86-64 shadow stack startup codes
H.J. Lu [Tue, 9 Jan 2024 20:23:24 +0000 (12:23 -0800)]
x86: Move x86-64 shadow stack startup codes

Move sysdeps/x86/libc-start.h to sysdeps/x86_64/libc-start.h and use
sysdeps/generic/libc-start.h for i386.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoFix deprecated utcnow() usage in build-many-glibcs.py
Joseph Myers [Wed, 10 Jan 2024 13:02:16 +0000 (13:02 +0000)]
Fix deprecated utcnow() usage in build-many-glibcs.py

Running build-many-glibcs.py with Python 3.12 or later produces a
warning:

build-many-glibcs.py:566: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  build_time = datetime.datetime.utcnow()

Replace with datetime.datetime.now(datetime.timezone.utc) (the
datetime.UTC constant is new in 3.11, so not suitable for use in this
script at present).

5 months agoFix invalid escape sequence in build-many-glibcs.py
Joseph Myers [Wed, 10 Jan 2024 13:01:39 +0000 (13:01 +0000)]
Fix invalid escape sequence in build-many-glibcs.py

Running build-many-glibcs.py with Python 3.12 or later produces a
warning:

build-many-glibcs.py:173: SyntaxWarning: invalid escape sequence '\.'
  m = re.fullmatch('([0-9]+)\.([0-9]+)[.0-9]*', l)

Use a raw string instead to avoid that warning.  (Note: I haven't
checked whether any other Python scripts included with glibc might
have issues with newer Python versions.)

5 months agomath: Fix test-fenv.c feupdateenv tests
Adhemerval Zanella [Tue, 9 Jan 2024 19:40:33 +0000 (16:40 -0300)]
math: Fix test-fenv.c feupdateenv tests

The feupdateenv tests added by 802aef27b2 do not restore the floating
point mask, which might keep some floating point exception enabled and
thus make the feupdateenv_single_test raise an unexpected signal.

Checked on x86_64-linux-gnu and aarch64-linux-gnu (on Apple M1 trapping
is supported).
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
5 months agoRemove installed header rule on $(..)include/%.h
H.J. Lu [Tue, 9 Jan 2024 18:25:20 +0000 (10:25 -0800)]
Remove installed header rule on $(..)include/%.h

On x86-64 machine with

[hjl@gnu-cfl-3 x86-glibc]$ ls -l /usr/include/asm/prctl.h sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 hjl  hjl   825 Jan  9 09:41 sysdeps/unix/sysv/linux/x86_64/include/asm/prctl.h
-rw-r--r-- 1 root root 1170 Nov 27 16:00 /usr/include/asm/prctl.h
[hjl@gnu-cfl-3 x86-glibc]$

glibc configured with --enable-cet build failed:

make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
../Makerules:327: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/gnu/lib-names-64.stmp
:
../Makeconfig:1216: update target
'/export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.h'
due to: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/libc-modules.stmp
:
../Makerules:1126: update target '/usr/include/asm/prctl.h' due to:
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
force-install
/usr/bin/install -c -m 644
../sysdeps/unix/sysv/linux/x86_64/64/../include/asm/prctl.h
/usr/include/asm/prctl.h
/usr/bin/install: cannot remove '/usr/include/asm/prctl.h': Permission denied
make[2]: *** [../Makerules:1126: /usr/include/asm/prctl.h] Error 1
make[2]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc/iconv'
make[1]: *** [Makefile:484: iconv/subdir_lib] Error 2
make[1]: Leaving directory '/export/gnu/import/git/gitlab/x86-glibc'
make: *** [Makefile:9: all] Error 2

This is triggered by the rule in Makerules:

$(inst_includedir)/%.h: $(..)include/%.h $(+force)
  $(do-install)

Since no files under include/ should be installed, remove it from
Makerules.

Tested it on x86-64.  There are no differences in the installed header
files.

5 months agoi386: Fail if configured with --enable-cet
Adhemerval Zanella [Fri, 5 Jan 2024 13:41:03 +0000 (10:41 -0300)]
i386: Fail if configured with --enable-cet

Since it is only supported for x86_64.

Checked on i686-linux-gnu.

5 months agoi386: Remove CET support
Adhemerval Zanella [Fri, 5 Jan 2024 13:36:40 +0000 (10:36 -0300)]
i386: Remove CET support

CET is only support for x86_64, this patch reverts:

  - faaee1f07ed x86: Support shadow stack pointer in setjmp/longjmp.
  - be9ccd27c09 i386: Add _CET_ENDBR to indirect jump targets in
    add_n.S/sub_n.S
  - c02695d7764 x86/CET: Update vfork to prevent child return
  - 5d844e1b725 i386: Enable CET support in ucontext functions
  - 124bcde683 x86: Add _CET_ENDBR to functions in crti.S
  - 562837c002 x86: Add _CET_ENDBR to functions in dl-tlsdesc.S
  - f753fa7dea x86: Support IBT and SHSTK in Intel CET [BZ #21598]
  - 825b58f3fb i386-mcount.S: Add _CET_ENDBR to _mcount and __fentry__
  - 7e119cd582 i386: Use _CET_NOTRACK in i686/memcmp.S
  - 177824e232 i386: Use _CET_NOTRACK in memcmp-sse4.S
  - 0a899af097 i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
  - 7fb613361c i386: Use _CET_NOTRACK in memcpy-ssse3.S
  - 77a8ae0948 i386: Use _CET_NOTRACK in memset-sse2-rep.S
  - 00e7b76a8f i386: Use _CET_NOTRACK in memset-sse2.S
  - 90d15dc577 i386: Use _CET_NOTRACK in strcat-sse2.S
  - f1574581c7 i386: Use _CET_NOTRACK in strcpy-sse2.S
  - 4031d7484a i386/sub_n.S: Add a missing _CET_ENDBR to indirect jump
  - target
  -
Checked on i686-linux-gnu.

5 months agox86: Move CET infrastructure to x86_64
Adhemerval Zanella [Fri, 5 Jan 2024 12:32:37 +0000 (09:32 -0300)]
x86: Move CET infrastructure to x86_64

The CET is only supported for x86_64 and there is no plan to add
kernel support for i386.  Move the Makefile rules and files from the
generic x86 folder to x86_64 one.

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

5 months agolocaledata: su_ID: make lang_name agree with CLDR
Mike FABIAN [Tue, 9 Jan 2024 13:08:08 +0000 (14:08 +0100)]
localedata: su_ID: make lang_name agree with CLDR

5 months agolocaledata: add new locale su_ID
Mike FABIAN [Tue, 9 Jan 2024 12:57:59 +0000 (13:57 +0100)]
localedata: add new locale su_ID

Resolves: BZ # 27312

5 months agolocaledata: add new locale zgh_MA
Mike FABIAN [Tue, 9 Jan 2024 12:43:38 +0000 (13:43 +0100)]
localedata: add new locale zgh_MA

Resolves: BZ # 12908

https://iso639-3.sil.org/code/zgh

5 months agoINSTALL: regenerate
Mark Wielaard [Tue, 9 Jan 2024 00:15:15 +0000 (01:15 +0100)]
INSTALL: regenerate

5 months agolocaledata: add tok/UTF-8 to SUPPORTED
Mike FABIAN [Tue, 9 Jan 2024 09:54:06 +0000 (10:54 +0100)]
localedata: add tok/UTF-8 to SUPPORTED

5 months agolocaledata: tok: add yY and nN to yesexpr and noexpr
Mike FABIAN [Tue, 9 Jan 2024 09:49:07 +0000 (10:49 +0100)]
localedata: tok: add yY and nN to yesexpr and noexpr

See: https://sourceware.org/bugzilla/show_bug.cgi?id=31221#c2

5 months agolocaledata: tok: convert to UTF-8
Mike FABIAN [Tue, 9 Jan 2024 09:46:56 +0000 (10:46 +0100)]
localedata: tok: convert to UTF-8

5 months agolocaledata: add data for tok (Toki Pona)
Janet Blackquill [Sun, 7 Jan 2024 02:38:49 +0000 (21:38 -0500)]
localedata: add data for tok (Toki Pona)

Resolves: BZ # 31221

glibc can recognise its code, but does not have its data.
This patch remedies that.

Signed-off-by: Janet Blackquill <uhhadd@gmail.com>
5 months agoRemove ia64-linux-gnu
Adhemerval Zanella [Mon, 8 Jan 2024 13:21:17 +0000 (10:21 -0300)]
Remove ia64-linux-gnu

Linux 6.7 removed ia64 from the official tree [1], following the general
principle that a glibc port needs upstream support for the architecture
in all the components it depends on (binutils, GCC, and the Linux
kernel).

Apart from the removal of sysdeps/ia64 and sysdeps/unix/sysv/linux/ia64,
there are updates to various comments referencing ia64 for which removal
of those references seemed appropriate. The configuration is removed
from README and build-many-glibcs.py.

The CONTRIBUTED-BY, elf/elf.h, manual/contrib.texi (the porting
mention), *.po files, config.guess, and longlong.h are not changed.

For Linux it allows cleanup some clone2 support on multiple files.

The following bug can be closed as WONTFIX: BZ 22634 [2], BZ 14250 [3],
BZ 21634 [4], BZ 10163 [5], BZ 16401 [6], and BZ 11585 [7].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=43ff221426d33db909f7159fdf620c3b052e2d1c
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=22634
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=14250
[4] https://sourceware.org/bugzilla/show_bug.cgi?id=21634
[5] https://sourceware.org/bugzilla/show_bug.cgi?id=10163
[6] https://sourceware.org/bugzilla/show_bug.cgi?id=16401
[7] https://sourceware.org/bugzilla/show_bug.cgi?id=11585
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 months agolocaledata: dz_BT, bo_CN: convert to UTF-8
Mike FABIAN [Mon, 8 Jan 2024 16:02:09 +0000 (17:02 +0100)]
localedata: dz_BT, bo_CN: convert to UTF-8

5 months agolocaledata: dz_BT, bo_CN: Fix spelling of "phur bu" in both Tibetan and Dzongkha
Valery Ushakov [Mon, 8 Jan 2024 15:44:28 +0000 (16:44 +0100)]
localedata: dz_BT, bo_CN: Fix spelling of "phur bu" in both Tibetan and Dzongkha

Resolves: BZ # 31086

5 months agolocaledata: bo_CN: Fix spelling errors in Tibetan data
Valery Ushakov [Mon, 8 Jan 2024 15:39:31 +0000 (16:39 +0100)]
localedata: bo_CN: Fix spelling errors in Tibetan data

Resolves: BZ # 31086

5 months agolocaledata: bo_CN: Fix incomplete edit in Tibetan yesexpr
Valery Ushakov [Mon, 8 Jan 2024 15:08:07 +0000 (16:08 +0100)]
localedata: bo_CN: Fix incomplete edit in Tibetan yesexpr

Resolves: BZ # 31086

5 months agolocaledata: dz_BT: Fix spelling errors in Dzongha data
Valery Ushakov [Mon, 8 Jan 2024 15:04:59 +0000 (16:04 +0100)]
localedata: dz_BT: Fix spelling errors in Dzongha data

Resolves: BZ # 31086

5 months agolocaledata: unicode-gen: Remove redundant \s* from regexp, fix comments
Mike FABIAN [Mon, 8 Jan 2024 09:05:13 +0000 (10:05 +0100)]
localedata: unicode-gen: Remove redundant \s* from regexp, fix comments

5 months agolocaledata: convert the remaining *_RU locales to UTF-8
Mike FABIAN [Fri, 5 Jan 2024 11:15:50 +0000 (12:15 +0100)]
localedata: convert the remaining *_RU locales to UTF-8

5 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>
5 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>
5 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.

5 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.

5 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.

5 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>
5 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>

5 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>

5 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>

5 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>

5 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>

5 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>

5 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>
5 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

5 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

5 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

5 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>
5 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>
5 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>
5 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>
5 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>
5 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

5 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

5 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

5 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

5 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

5 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

5 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

5 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.

5 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

5 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

5 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.

5 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>
5 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>
5 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>
5 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>
5 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

5 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

5 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)").

5 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.

5 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>
5 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>
5 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>
5 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>
5 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.

5 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.

5 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"

5 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

5 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

5 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.

5 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.

5 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.

5 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.

5 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.

6 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>
6 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.

6 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>
6 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>
6 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>
6 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>
6 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

6 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