]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
22 months agoDocument CVE-2023-4806 and CVE-2023-5156 in NEWS
Siddhesh Poyarekar [Tue, 26 Sep 2023 11:38:07 +0000 (07:38 -0400)] 
Document CVE-2023-4806 and CVE-2023-5156 in NEWS

These are tracked in BZ #30884 and BZ #30843.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit fd134feba35fa839018965733b34d28a09a075dd)

22 months agoFix leak in getaddrinfo introduced by the fix for CVE-2023-4806 [BZ #30843]
Romain Geissler [Mon, 25 Sep 2023 00:21:51 +0000 (01:21 +0100)] 
Fix leak in getaddrinfo introduced by the fix for CVE-2023-4806 [BZ #30843]

This patch fixes a very recently added leak in getaddrinfo.

This was assigned CVE-2023-5156.

Resolves: BZ #30884
Related: BZ #30842

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit ec6b95c3303c700eb89eebeda2d7264cc184a796)

22 months agomanual/jobs.texi: Add missing @item EPERM for getpgid
Mark Wielaard [Thu, 24 Aug 2023 19:36:34 +0000 (21:36 +0200)] 
manual/jobs.texi: Add missing @item EPERM for getpgid

The missing @item makes it look like errno will be set to ESRCH
if a cross-session getpgid is not permitted.

Found by ulfvonbelow on irc.

(cherry picked from commit 5a21cefd5abab1b99eda1fbf84204a9bf41662ab)

22 months agostring: Fix tester build with fortify enable with gcc < 12
Mahesh Bodapati [Fri, 11 Aug 2023 15:38:25 +0000 (10:38 -0500)] 
string: Fix tester build with fortify enable with gcc < 12

When building with fortify enabled, GCC < 12 issues a warning on the
fortify strncat wrapper might overflow the destination buffer (the
failure is tied to -Werror).

Checked on ppc64 and x86_64.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit f1c7ed0859a45929136836341741c7cd70f428cb)

22 months agoiconv: restore verbosity with unrecognized encoding names (bug 30694)
Andreas Schwab [Tue, 1 Aug 2023 15:01:37 +0000 (17:01 +0200)] 
iconv: restore verbosity with unrecognized encoding names (bug 30694)

Commit 91927b7c76 ("Rewrite iconv option parsing [BZ #19519]") changed the
iconv program to call __gconv_open directly instead of the iconv_open
wrapper, but the former does not set errno.  Update the caller to
interpret the return codes like iconv_open does.

(cherry picked from commit fc72b6d7d818ab2868920af956d1542d03342a4d)

22 months agogetaddrinfo: Fix use after free in getcanonname (CVE-2023-4806)
Siddhesh Poyarekar [Fri, 15 Sep 2023 17:51:12 +0000 (13:51 -0400)] 
getaddrinfo: Fix use after free in getcanonname (CVE-2023-4806)

When an NSS plugin only implements the _gethostbyname2_r and
_getcanonname_r callbacks, getaddrinfo could use memory that was freed
during tmpbuf resizing, through h_name in a previous query response.

The backing store for res->at->name when doing a query with
gethostbyname3_r or gethostbyname2_r is tmpbuf, which is reallocated in
gethosts during the query.  For AF_INET6 lookup with AI_ALL |
AI_V4MAPPED, gethosts gets called twice, once for a v6 lookup and second
for a v4 lookup.  In this case, if the first call reallocates tmpbuf
enough number of times, resulting in a malloc, th->h_name (that
res->at->name refers to) ends up on a heap allocated storage in tmpbuf.
Now if the second call to gethosts also causes the plugin callback to
return NSS_STATUS_TRYAGAIN, tmpbuf will get freed, resulting in a UAF
reference in res->at->name.  This then gets dereferenced in the
getcanonname_r plugin call, resulting in the use after free.

Fix this by copying h_name over and freeing it at the end.  This
resolves BZ #30843, which is assigned CVE-2023-4806.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 973fe93a5675c42798b2161c6f29c01b0e243994)

22 months agoCVE-2023-4527: Stack read overflow with large TCP responses in no-aaaa mode
Florian Weimer [Wed, 13 Sep 2023 12:10:56 +0000 (14:10 +0200)] 
CVE-2023-4527: Stack read overflow with large TCP responses in no-aaaa mode

Without passing alt_dns_packet_buffer, __res_context_search can only
store 2048 bytes (what fits into dns_packet_buffer).  However,
the function returns the total packet size, and the subsequent
DNS parsing code in _nss_dns_gethostbyname4_r reads beyond the end
of the stack-allocated buffer.

Fixes commit f282cdbe7f436c75864e5640a4 ("resolv: Implement no-aaaa
stub resolver option") and bug 30842.

(cherry picked from commit bd77dd7e73e3530203be1c52c8a29d08270cb25d)

22 months agoNEWS: Add the 2.38.1 bug list
Florian Weimer [Mon, 11 Sep 2023 08:06:15 +0000 (10:06 +0200)] 
NEWS: Add the 2.38.1 bug list

22 months agoelf: Move l_init_called_next to old place of l_text_end in link map
Florian Weimer [Mon, 11 Sep 2023 07:17:52 +0000 (09:17 +0200)] 
elf: Move l_init_called_next to old place of l_text_end in link map

This preserves all member offsets and the GLIBC_PRIVATE ABI
for backporting.

22 months agoelf: Remove unused l_text_end field from struct link_map
Florian Weimer [Fri, 8 Sep 2023 11:02:06 +0000 (13:02 +0200)] 
elf: Remove unused l_text_end field from struct link_map

It is a left-over from commit 52a01100ad011293197637e42b5be1a479a2
("elf: Remove ad-hoc restrictions on dlopen callers [BZ #22787]").

When backporting commmit 6985865bc3ad5b23147ee73466583dd7fdf65892
("elf: Always call destructors in reverse constructor order
(bug 30785)"), we can move the l_init_called_next field to this
place, so that the internal GLIBC_PRIVATE ABI does not change.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 53df2ce6885da3d0e89e87dca7b095622296014f)

22 months agoelf: Always call destructors in reverse constructor order (bug 30785)
Florian Weimer [Fri, 8 Sep 2023 10:32:14 +0000 (12:32 +0200)] 
elf: Always call destructors in reverse constructor order (bug 30785)

The current implementation of dlclose (and process exit) re-sorts the
link maps before calling ELF destructors.  Destructor order is not the
reverse of the constructor order as a result: The second sort takes
relocation dependencies into account, and other differences can result
from ambiguous inputs, such as cycles.  (The force_first handling in
_dl_sort_maps is not effective for dlclose.)  After the changes in
this commit, there is still a required difference due to
dlopen/dlclose ordering by the application, but the previous
discrepancies went beyond that.

A new global (namespace-spanning) list of link maps,
_dl_init_called_list, is updated right before ELF constructors are
called from _dl_init.

In dl_close_worker, the maps variable, an on-stack variable length
array, is eliminated.  (VLAs are problematic, and dlclose should not
call malloc because it cannot readily deal with malloc failure.)
Marking still-used objects uses the namespace list directly, with
next and next_idx replacing the done_index variable.

After marking, _dl_init_called_list is used to call the destructors
of now-unused maps in reverse destructor order.  These destructors
can call dlopen.  Previously, new objects do not have l_map_used set.
This had to change: There is no copy of the link map list anymore,
so processing would cover newly opened (and unmarked) mappings,
unloading them.  Now, _dl_init (indirectly) sets l_map_used, too.
(dlclose is handled by the existing reentrancy guard.)

After _dl_init_called_list traversal, two more loops follow.  The
processing order changes to the original link map order in the
namespace.  Previously, dependency order was used.  The difference
should not matter because relocation dependencies could already
reorder link maps in the old code.

The changes to _dl_fini remove the sorting step and replace it with
a traversal of _dl_init_called_list.  The l_direct_opencount
decrement outside the loader lock is removed because it appears
incorrect: the counter manipulation could race with other dynamic
loader operations.

tst-audit23 needs adjustments to the changes in LA_ACT_DELETE
notifications.  The new approach for checking la_activity should
make it clearer that la_activty calls come in pairs around namespace
updates.

The dependency sorting test cases need updates because the destructor
order is always the opposite order of constructor order, even with
relocation dependencies or cycles present.

There is a future cleanup opportunity to remove the now-constant
force_first and for_fini arguments from the _dl_sort_maps function.

Fixes commit 1df71d32fe5f5905ffd5d100e5e9ca8ad62 ("elf: Implement
force_first handling in _dl_sort_maps_dfs (bug 28937)").

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

22 months agoelf: Do not run constructors for proxy objects
Florian Weimer [Tue, 22 Aug 2023 11:56:25 +0000 (13:56 +0200)] 
elf: Do not run constructors for proxy objects

Otherwise, the ld.so constructor runs for each audit namespace
and each dlmopen namespace.

(cherry picked from commit f6c8204fd7fabf0cf4162eaf10ccf23258e4d10e)

22 months agolibio: Fix oversized __io_vtables
Adam Jackson [Fri, 8 Sep 2023 19:55:19 +0000 (15:55 -0400)] 
libio: Fix oversized __io_vtables

IO_VTABLES_LEN is the size of the struct array in bytes, not the number
of __IO_jump_t's in the array. Drops just under 384kb from .rodata on
LP64 machines.

Fixes: 3020f72618e ("libio: Remove the usage of __libc_IO_vtables")
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Tested-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 8cb69e054386f980f9ff4d93b157861d72b2019e)

23 months agoio: Fix record locking contants for powerpc64 with __USE_FILE_OFFSET64
Aurelien Jarno [Mon, 28 Aug 2023 21:30:37 +0000 (23:30 +0200)] 
io: Fix record locking contants for powerpc64 with __USE_FILE_OFFSET64

Commit 5f828ff824e3b7cd1 ("io: Fix F_GETLK, F_SETLK, and F_SETLKW for
powerpc64") fixed an issue with the value of the lock constants on
powerpc64 when not using __USE_FILE_OFFSET64, but it ended-up also
changing the value when using __USE_FILE_OFFSET64 causing an API change.

Fix that by also checking that define, restoring the pre
4d0fe291aed3a476a commit values:

Default values:
- F_GETLK: 5
- F_SETLK: 6
- F_SETLKW: 7

With -D_FILE_OFFSET_BITS=64:
- F_GETLK: 12
- F_SETLK: 13
- F_SETLKW: 14

At the same time, it has been noticed that there was no test for io lock
with __USE_FILE_OFFSET64, so just add one.

Tested on x86_64-linux-gnu, i686-linux-gnu and
powerpc64le-unknown-linux-gnu.

Resolves: BZ #30804.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 434bf72a94de68f0cc7fbf3c44bf38c1911b70cb)

23 months agosysdeps: tst-bz21269: fix -Wreturn-type
Sam James [Thu, 17 Aug 2023 08:30:29 +0000 (09:30 +0100)] 
sysdeps: tst-bz21269: fix -Wreturn-type

Thanks to Andreas Schwab for reporting.

Fixes: 652b9fdb77d9fd056d4dd26dad2c14142768ab49
Signed-off-by: Sam James <sam@gentoo.org>
(cherry picked from commit 369f373057073c307938da91af16922bda3dff6a)

23 months agosysdeps: tst-bz21269: handle ENOSYS & skip appropriately
Sam James [Fri, 4 Aug 2023 23:04:33 +0000 (00:04 +0100)] 
sysdeps: tst-bz21269: handle ENOSYS & skip appropriately

SYS_modify_ldt requires CONFIG_MODIFY_LDT_SYSCALL to be set in the kernel, which
some distributions may disable for hardening. Check if that's the case (unset)
and mark the test as UNSUPPORTED if so.

Reviewed-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Sam James <sam@gentoo.org>
(cherry picked from commit 652b9fdb77d9fd056d4dd26dad2c14142768ab49)

23 months agosysdeps: tst-bz21269: fix test parameter
Sam James [Fri, 4 Aug 2023 22:58:27 +0000 (23:58 +0100)] 
sysdeps: tst-bz21269: fix test parameter

All callers pass 1 or 0x11 anyway (same meaning according to man page),
but still.

Reviewed-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Sam James <sam@gentoo.org>
(cherry picked from commit e0b712dd9183d527aae4506cd39564c14af3bb28)

23 months agomalloc: Remove bin scanning from memalign (bug 30723)
Florian Weimer [Thu, 10 Aug 2023 17:36:56 +0000 (19:36 +0200)] 
malloc: Remove bin scanning from memalign (bug 30723)

On the test workload (mpv --cache=yes with VP9 video decoding), the
bin scanning has a very poor success rate (less than 2%).  The tcache
scanning has about 50% success rate, so keep that.

Update comments in malloc/tst-memalign-2 to indicate the purpose
of the tests.  Even with the scanning removed, the additional
merging opportunities since commit 542b1105852568c3ebc712225ae78b
("malloc: Enable merging of remainders in memalign (bug 30723)")
are sufficient to pass the existing large bins test.

Remove leftover variables from _int_free from refactoring in the
same commit.

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

23 months agomalloc: Enable merging of remainders in memalign (bug 30723)
Florian Weimer [Fri, 11 Aug 2023 09:18:17 +0000 (11:18 +0200)] 
malloc: Enable merging of remainders in memalign (bug 30723)

Previously, calling _int_free from _int_memalign could put remainders
into the tcache or into fastbins, where they are invisible to the
low-level allocator.  This results in missed merge opportunities
because once these freed chunks become available to the low-level
allocator, further memalign allocations (even of the same size are)
likely obstructing merges.

Furthermore, during forwards merging in _int_memalign, do not
completely give up when the remainder is too small to serve as a
chunk on its own.  We can still give it back if it can be merged
with the following unused chunk.  This makes it more likely that
memalign calls in a loop achieve a compact memory layout,
independently of initial heap layout.

Drop some useless (unsigned long) casts along the way, and tweak
the style to more closely match GNU on changed lines.

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

23 months agoi686: Fix build with --disable-multiarch
Adhemerval Zanella [Tue, 8 Aug 2023 12:27:55 +0000 (09:27 -0300)] 
i686: Fix build with --disable-multiarch

Since i686 provides the fortified wrappers for memcpy, mempcpy,
memmove, and memset on the same string implementation, the static
build tries to optimized it by not tying the fortified wrappers
to string routine (to avoid pulling the fortify function if
they are not required).

Checked on i686-linux-gnu building with different option:
default and --disable-multi-arch plus default, --disable-default-pie,
--enable-fortify-source={2,3}, and --enable-fortify-source={2,3}
with --disable-default-pie.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit c73c96a4a1af1326df7f96eec58209e1e04066d8)

23 months agox86_64: Fix build with --disable-multiarch (BZ 30721)
Adhemerval Zanella [Tue, 8 Aug 2023 12:27:54 +0000 (09:27 -0300)] 
x86_64: Fix build with --disable-multiarch (BZ 30721)

With multiarch disabled, the default memmove implementation provides
the fortify routines for memcpy, mempcpy, and memmove.  However, it
does not provide the internal hidden definitions used when building
with fortify enabled.  The memset has a similar issue.

Checked on x86_64-linux-gnu building with different options:
default and --disable-multi-arch plus default, --disable-default-pie,
--enable-fortify-source={2,3}, and --enable-fortify-source={2,3}
with --disable-default-pie.
Tested-by: Andreas K. Huettel <dilfridge@gentoo.org>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 51cb52214fcd72849c640b12f5099ed3ac776181)

23 months agox86: Fix incorrect scope of setting `shared_per_thread` [BZ# 30745]
Noah Goldstein [Fri, 11 Aug 2023 00:28:24 +0000 (19:28 -0500)] 
x86: Fix incorrect scope of setting `shared_per_thread` [BZ# 30745]

The:

```
    if (shared_per_thread > 0 && threads > 0)
      shared_per_thread /= threads;
```

Code was accidentally moved to inside the else scope.  This doesn't
match how it was previously (before af992e7abd).

This patch fixes that by putting the division after the `else` block.

(cherry picked from commit 084fb31bc2c5f95ae0b9e6df4d3cf0ff43471ede)

23 months agonscd: Do not rebuild getaddrinfo (bug 30709)
Florian Weimer [Fri, 11 Aug 2023 08:10:16 +0000 (10:10 +0200)] 
nscd: Do not rebuild getaddrinfo (bug 30709)

The nscd daemon caches hosts data from NSS modules verbatim, without
filtering protocol families or sorting them (otherwise separate caches
would be needed for certain ai_flags combinations).  The cache
implementation is complete separate from the getaddrinfo code.  This
means that rebuilding getaddrinfo is not needed.  The only function
actually used is __bump_nl_timestamp from check_pf.c, and this change
moves it into nscd/connections.c.

Tested on x86_64-linux-gnu with -fexceptions, built with
build-many-glibcs.py.  I also backported this patch into a distribution
that still supports nscd and verified manually that caching still works.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 039ff51ac7e02db1cfc0c23e38ac7bfbb00221d1)

2 years agox86: Fix for cache computation on AMD legacy cpus.
Sajan Karumanchi [Tue, 1 Aug 2023 15:20:55 +0000 (15:20 +0000)] 
x86: Fix for cache computation on AMD legacy cpus.

Some legacy AMD CPUs and hypervisors have the _cpuid_ '0x8000_001D'
set to Zero, thus resulting in zeroed-out computed cache values.
This patch reintroduces the old way of cache computation as a
fail-safe option to handle these exceptions.
Fixed 'level4_cache_size' value through handle_amd().

Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
Tested-by: Florian Weimer <fweimer@redhat.com>
2 years agostdlib: Improve tst-realpath compatibility with source fortification
Florian Weimer [Tue, 1 Aug 2023 08:27:15 +0000 (10:27 +0200)] 
stdlib: Improve tst-realpath compatibility with source fortification

On GCC before 11, IPA can make the fortified realpath aware that the
buffer size is not large enough (8 bytes instead of PATH_MAX bytes).
Fix this by using a buffer that is large enough.

(cherry picked from commit 510fc20d73de12c85823d9996faac74666e9c2e7)

2 years agoNEWS: Fix typos glibc-2.38
Andreas K. Hüttel [Mon, 31 Jul 2023 17:54:16 +0000 (19:54 +0200)] 
NEWS: Fix typos

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoCreate ChangeLog.old/ChangeLog.27
Andreas K. Hüttel [Sun, 30 Jul 2023 19:45:27 +0000 (21:45 +0200)] 
Create ChangeLog.old/ChangeLog.27

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoIncrease version numbers
Andreas K. Hüttel [Sun, 30 Jul 2023 19:35:28 +0000 (21:35 +0200)] 
Increase version numbers

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoINSTALL: regenerate
Andreas K. Hüttel [Sun, 30 Jul 2023 19:16:02 +0000 (21:16 +0200)] 
INSTALL: regenerate

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoNEWS: minor wording fixes
Andreas K. Hüttel [Sun, 30 Jul 2023 17:43:50 +0000 (19:43 +0200)] 
NEWS: minor wording fixes

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoinstall.texi: Build was tested with binutils 2.41 (just released)
Andreas K. Hüttel [Sun, 30 Jul 2023 17:31:04 +0000 (19:31 +0200)] 
install.texi: Build was tested with binutils 2.41 (just released)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoinstall.texi: Update versions of most recent build tools
Andreas K. Hüttel [Thu, 27 Jul 2023 21:00:59 +0000 (23:00 +0200)] 
install.texi: Update versions of most recent build tools

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agocontrib.texi: Update for 2.38
Andreas K. Hüttel [Tue, 25 Jul 2023 23:51:03 +0000 (01:51 +0200)] 
contrib.texi: Update for 2.38

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years ago<sys/platform/x86.h>: Add APX support
H.J. Lu [Wed, 26 Jul 2023 15:20:16 +0000 (08:20 -0700)] 
<sys/platform/x86.h>: Add APX support

Add support for Intel Advanced Performance Extensions:

https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html

to <sys/platform/x86.h>.

2 years agotranslations: update cs, nl, vi
Andreas K. Hüttel [Wed, 26 Jul 2023 22:21:13 +0000 (00:21 +0200)] 
translations: update cs, nl, vi

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agostring: Fix tester build with fortify enable with gcc 6
Adhemerval Zanella Netto [Tue, 25 Jul 2023 15:16:41 +0000 (12:16 -0300)] 
string: Fix tester build with fortify enable with gcc 6

When building with fortify enabled, GCC 6 issues an warning the fortify
wrapper might overflow the destination buffer.  However, GCC does not
provide a specific flag to disable the warning (the failure is tied to
-Werror).  So to avoid disable all errors, only enable the check for
GCC 7 or newer.

Checked on i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agolinux: Fix i686 with gcc6
Adhemerval Zanella Netto [Tue, 25 Jul 2023 15:16:40 +0000 (12:16 -0300)] 
linux: Fix i686 with gcc6

On __convert_scm_timestamps GCC 6 issues an warning that tvts[0]/tvts[1]
maybe be used uninitialized, however it would be used if type is set to a
value different than 0 (done by either COMPAT_SO_TIMESTAMP_OLD or
COMPAT_SO_TIMESTAMPNS_OLD) which will fallthrough to 'common' label.

It does not show with gcc 7 or more recent versions.

Checked on i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoi386: Remove memset_chk-nonshared.S
Adhemerval Zanella Netto [Tue, 25 Jul 2023 15:16:39 +0000 (12:16 -0300)] 
i386: Remove memset_chk-nonshared.S

Similar to memcpy, mempcpy, and memmove there is no need for an
specific memset_chk-nonshared.S.  It can be provided by
memset-ia32.S itself for static library.

Checked on i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoi386: Fix build with --enable-fortify=3
Adhemerval Zanella Netto [Tue, 25 Jul 2023 15:16:38 +0000 (12:16 -0300)] 
i386: Fix build with --enable-fortify=3

The i386 string routines provide multiple internal definitions
for memcpy, memmove, and mempcpy chk routines:

  $ objdump -t libc.a | grep __memcpy_chk
  00000000 g     F .text  0000000e __memcpy_chk
  00000000 g     F .text  00000013 __memcpy_chk
  $ objdump -t libc.a | grep __mempcpy_chk
  00000000 g     F .text  0000000e __mempcpy_chk
  00000000 g     F .text  00000013 __mempcpy_chk
  $ objdump -t libc.a | grep __memmove_chk
  00000000 g     F .text  0000000e __memmove_chk
  00000000 g     F .text  00000013 __memmove_chk

Although is not an issue for normal static builds, with fortify=3
glibc itself might use the fortify chk functions and thus static
build might fail with multiple definitions.  For instance:

x86_64-glibc-linux-gnu-gcc -m32 -march=i686 -o [...]math/test-signgam-uchar-static -nostdlib -nostartfiles -static -static-pie [...]
x86_64-glibc-linux-gnu/bin/ld: [...]/libc.a(mempcpy-ia32.o):
in function `__mempcpy_chk': [...]/glibc-git/string/../sysdeps/i386/i686/mempcpy.S:32: multiple definition of `__mempcpy_chk';
[...]/libc.a(mempcpy_chk-nonshared.o):[...]/debug/../sysdeps/i386/mempcpy_chk.S:28: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [../Rules:298:

There is no need for mem*-nonshared.S, the __mem*_chk routines
are already provided by the assembly routines.

Checked on i686-linux-gnu with gcc 13 built with fortify=1,2,3 and
without fortify.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoposix: Fix test-errno build with fortify enable
Adhemerval Zanella Netto [Mon, 24 Jul 2023 19:38:17 +0000 (16:38 -0300)] 
posix: Fix test-errno build with fortify enable

With gcc 11.3.1, building with -D_FORTIFY_SOURCE=2 shows:

In function ‘getgroups’,
    inlined from ‘do_test’ at test-errno.c:129:12:
../misc/sys/cdefs.h:195:6: error: argument 1 value -1 is negative
[-Werror=stringop-overflow=]
  195 |    ? __ ## f ## _alias (__VA_ARGS__)
      \
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../posix/bits/unistd.h:115:10: note: in expansion of macro
‘__glibc_fortify’
  115 |   return __glibc_fortify (getgroups, __size, sizeof (__gid_t),
      |          ^~~~~~~~~~~~~~~
../posix/bits/unistd.h: In function ‘do_test’:
../posix/bits/unistd-decl.h:135:28: note: in a call to function
‘__getgroups_alias’ declared with attribute ‘access (write_only, 2, 1)’
  135 | extern int __REDIRECT_NTH (__getgroups_alias, (int __size,
      __gid_t __list[]),
      |                            ^~~~~~~~~~~~~~~~~
../misc/sys/cdefs.h:264:6: note: in definition of macro ‘__REDIRECT_NTH’
  264 |      name proto __asm__ (__ASMNAME (#alias)) __THROW

It builds fine with gcc 12 and gcc 13.

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agopowerpc: Fix powerpc64 strchrnul build with old gcc
Adhemerval Zanella Netto [Mon, 24 Jul 2023 17:15:24 +0000 (14:15 -0300)] 
powerpc: Fix powerpc64 strchrnul build with old gcc

The compiler might not see that internal definition is an alias
due the libc_ifunc macro, which redefines __strchrnul.  With
gcc 6 it fails with:

In file included from <command-line>:0:0:
./../include/libc-symbols.h:472:33: error: ‘__EI___strchrnul’ aliased to
undefined symbol ‘__GI___strchrnul’
   extern thread __typeof (name) __EI_##name \
                                 ^
./../include/libc-symbols.h:468:3: note: in expansion of macro
‘__hidden_ver2’
   __hidden_ver2 (, local, internal, name)
   ^~~~~~~~~~~~~
./../include/libc-symbols.h:476:29: note: in expansion of macro
‘__hidden_ver1’
 #  define hidden_def(name)  __hidden_ver1(__GI_##name, name, name);
                             ^~~~~~~~~~~~~
./../include/libc-symbols.h:557:32: note: in expansion of macro
‘hidden_def’
 # define libc_hidden_def(name) hidden_def (name)
                                ^~~~~~~~~~
../sysdeps/powerpc/powerpc64/multiarch/strchrnul.c:38:1: note: in
expansion of macro ‘libc_hidden_def’
 libc_hidden_def (__strchrnul)
 ^~~~~~~~~~~~~~~

Use libc_ifunc_hidden as stpcpy.  Checked on powerpc64 with
gcc 6 and gcc 13.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agosunrpc: Fix netname build with older gcc
Adhemerval Zanella Netto [Mon, 24 Jul 2023 17:15:23 +0000 (14:15 -0300)] 
sunrpc: Fix netname build with older gcc

The -Wformat-overflow was added by gcc 8.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agomalloc: Fix set-freeres.c with gcc 6
Adhemerval Zanella Netto [Mon, 24 Jul 2023 17:15:22 +0000 (14:15 -0300)] 
malloc: Fix set-freeres.c with gcc 6

Old GCC might trigger the the comparison will always evaluate as ‘true’
warnig for static build:

set-freeres.c:87:14: error: the comparison will always evaluate as
‘true’ for the address of ‘__libc_getgrgid_freemem_ptr’ will never be
NULL [-Werror=address]
   if (&__ptr != NULL)      \

So add pragma weak for all affected usages.

Checked on x86_64 and i686 with gcc 6 and 13.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoNEWS: Insert autogenerated list of fixed bugs
Andreas K. Hüttel [Tue, 25 Jul 2023 21:59:25 +0000 (23:59 +0200)] 
NEWS: Insert autogenerated list of fixed bugs

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoNEWS: Mention AArch64 libmvec under build requirements again
Andreas K. Hüttel [Tue, 25 Jul 2023 21:55:17 +0000 (23:55 +0200)] 
NEWS: Mention AArch64 libmvec under build requirements again

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoNEWS: Minor editorial changes
Andreas K. Hüttel [Tue, 25 Jul 2023 21:49:07 +0000 (23:49 +0200)] 
NEWS: Minor editorial changes

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoMIPS: Update mips32 and mip64 libm test ulps
Aurelien Jarno [Tue, 25 Jul 2023 20:20:51 +0000 (22:20 +0200)] 
MIPS: Update mips32 and mip64 libm test ulps

Generated on a Cavium Octeon III 2 board running Linux version 4.19.249
and GCC 13.1.0.

Needed due to commit cf7ffdd8a5f6 ("added pair of inputs for hypotf in
binary32").

2 years agonscd: cleanup obsolete _FORTIFY_SOURCE setting
Sam James [Tue, 25 Jul 2023 20:04:31 +0000 (21:04 +0100)] 
nscd: cleanup obsolete _FORTIFY_SOURCE setting

This was added in 233399bce2e79e5af3b344782e9943d5f1a9cdcb just for warn_if_unused
warnings rather than anything substantial.

Now that we have a proper configure argument for F_S (--enable-fortify-source),
just drop this entirely, to avoid conflicting with e.g. detected --enable-fortify-source
finding F_S=3, then nscd's Makefile setting F_S=2, resulting in a build-failure
because of the redefinition.

Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoInclude sys/rseq.h in tst-rseq-disable.c
Stefan Liebler [Tue, 25 Jul 2023 09:34:30 +0000 (11:34 +0200)] 
Include sys/rseq.h in tst-rseq-disable.c

Starting with commit 2c6b4b272e6b4d07303af25709051c3e96288f2d
"nptl: Unconditionally use a 32-byte rseq area", the testcase
misc/tst-rseq-disable is UNSUPPORTED as RSEQ_SIG is not defined.

The mentioned commit removes inclusion of sys/rseq.h in nptl/descr.h.
Thus just include sys/rseq.h in the tst-rseq-disable.c as also done
in tst-rseq.c and tst-rseq-nptl.c.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agostring: Fix tester with fortify enabled
Adhemerval Zanella Netto [Fri, 21 Jul 2023 12:18:17 +0000 (09:18 -0300)] 
string: Fix tester with fortify enabled

If fortify is enabled, the truncated output warning is issued by
the wrapper itself:

In function ‘strncpy’,
    inlined from ‘test_strncpy’ at tester.c:505:10:
../string/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’
destination unchanged after copying no bytes from a string of length 3
[-Werror=stringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/bits/string_fortified.h:1,
                 from ../string/string.h:548,
                 from ../include/string.h:60,
                 from tester.c:33,
                 from inl-tester.c:6:
In function ‘strncpy’,
    inlined from ‘test_strncpy’ at tester.c:505:10:

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agostring: Fix bug-strncat1 with fortify enabled
Adhemerval Zanella Netto [Fri, 21 Jul 2023 12:18:16 +0000 (09:18 -0300)] 
string: Fix bug-strncat1 with fortify enabled

If fortify is enabled, the truncated output warning is issued by
the wrapper itself:

bug-strncat1.c: In function ‘main’:
bug-strncat1.c:14:3: error: ‘__builtin___strncat_chk’ output truncated
copying 1 byte from a string of length 2 [-Werror=stringop-truncation]
   14 |   strncat (d, "\5\6", 1);
      |   ^

Checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agonscd: Use errval, not errno to guide cache update (bug 30662)
Florian Weimer [Mon, 24 Jul 2023 13:12:26 +0000 (15:12 +0200)] 
nscd: Use errval, not errno to guide cache update (bug 30662)

The errno variable is potentially clobbered by the preceding
send call.  It is not related to the to-be-cached information.
The parallel code in hstcache.c and servicescache.c already uses
errval.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoRestore lookup of IPv4 mapped addresses in files database (bug 25457)
Andreas Schwab [Wed, 19 Jul 2023 07:55:31 +0000 (09:55 +0200)] 
Restore lookup of IPv4 mapped addresses in files database (bug 25457)

This was broken by commit 9c02d0784d ("nss_files: Remove RES_USE_INET6
from hosts processing"), which removed too much.

2 years agoRevert "MIPS: Sync elf.h from binutils"
Andreas K. Hüttel [Sat, 22 Jul 2023 14:42:50 +0000 (16:42 +0200)] 
Revert "MIPS: Sync elf.h from binutils"

Leads to build failures (preprocessor redefinitions), and there is not
enough time to address this properly. Deferred until after 2.38 release.

This reverts commit 59dc07637fa1a693bd7599a98b0735697544077b.

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoriscv: Update rvd libm test ulps
Aurelien Jarno [Thu, 20 Jul 2023 16:58:42 +0000 (18:58 +0200)] 
riscv: Update rvd libm test ulps

Generated on a VisionFive 2 board running Linux version 6.4.2 and
GCC 13.1.0.

Needed due to commit cf7ffdd8a5f6 ("added pair of inputs for hypotf in
binary32").

2 years agoMIPS: Sync elf.h from binutils
Ying Huang [Thu, 15 Jun 2023 07:50:21 +0000 (03:50 -0400)] 
MIPS: Sync elf.h from binutils

Add new definitions for the MIPS target, specifically: relocation
types, machine flags, section type names, and object attribute tags
and values.  On MIPS64, up to three relocations may be specified
within r_info, by the r_type, r_type2, and r_type3 fields, so add new
macros to get the respective reloc types for MIPS64.

2 years agoMerge translations (bg, hr, pl, sv)
Andreas K. Hüttel [Fri, 21 Jul 2023 22:38:31 +0000 (00:38 +0200)] 
Merge translations (bg, hr, pl, sv)

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agonptl: Unconditionally use a 32-byte rseq area
Florian Weimer [Fri, 21 Jul 2023 14:18:18 +0000 (16:18 +0200)] 
nptl: Unconditionally use a 32-byte rseq area

If the kernel headers provide a larger struct rseq, we used that
size as the argument to the rseq system call.  As a result,
rseq registration would fail on older kernels which only accept
size 32.

2 years agohurd: Fix tst-openloc
Samuel Thibault [Thu, 20 Jul 2023 21:38:24 +0000 (23:38 +0200)] 
hurd: Fix tst-openloc

On GNU/Hurd, O_RDWR actually is O_WRONLY|O_RDONLY, so checking through
bitness really is wrong. O_ACCMODE is there for this.

Fixes: 5324d258427f ("fileops: Don't process ,ccs= as individual mode flags (BZ#18906)")
2 years agoscripts: Fix fortify checks if compiler does not support _FORTIFY_SOURCE=3
Adhemerval Zanella [Thu, 20 Jul 2023 14:35:54 +0000 (11:35 -0300)] 
scripts: Fix fortify checks if compiler does not support _FORTIFY_SOURCE=3

The 30379efad1 added _FORTIFY_SOURCE checks without check if compiler
does support all used fortify levels.  This patch fixes it by first
checking at configure time the maximum support fortify level and using
it instead of a pre-defined one.

Checked on x86_64 with gcc 11, 12, and 13.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Tested-by: Florian Weimer <fweimer@redhat.com>
2 years agoconfigure: Disable building libcrypt by default
Siddhesh Poyarekar [Mon, 17 Jul 2023 16:44:17 +0000 (12:44 -0400)] 
configure: Disable building libcrypt by default

We mentioned eventual dropping of libcrypt in the 2.28 NEWS.  Actually
put that plan in motion by first disabling building libcrypt by default.
note in NEWS that the library will be dropped completely in a future
release.

Also add a couple of builds into build-many-glibcs.py.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agonptl: Make tst-tls3mod.so explicitly lazy
Arsen Arsenović [Wed, 19 Jul 2023 19:24:37 +0000 (21:24 +0200)] 
nptl: Make tst-tls3mod.so explicitly lazy

Fixes the following test-time errors, that lead to FAILs, on toolchains
that set -z now out o the box, such as the one used on Gentoo Hardened:

  .../build-x86-x86_64-pc-linux-gnu-nptl $ grep '' nptl/tst-tls3*.out
  nptl/tst-tls3.out:dlopen failed
  nptl/tst-tls3-malloc.out:dlopen failed

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agomake ‘struct pthread’ a complete type
Paul Eggert [Wed, 19 Jul 2023 21:09:26 +0000 (14:09 -0700)] 
make ‘struct pthread’ a complete type

* nptl/descr.h (struct pthread): Remove end_padding member, which
made this type incomplete.
(PTHREAD_STRUCT_END_PADDING): Stop using end_padding.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoscripts: Add fortify checks on installed headers
Adhemerval Zanella [Wed, 19 Jul 2023 14:37:01 +0000 (11:37 -0300)] 
scripts: Add fortify checks on installed headers

The _FORTIFY_SOURCE is used as default by some system compilers,
and there is no way to check if some fortify extension does not
trigger any conformance issue.

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoUpdate x86_64 libm-test-ulps (x32 ABI)
Andreas K. Hüttel [Wed, 19 Jul 2023 14:56:54 +0000 (16:56 +0200)] 
Update x86_64 libm-test-ulps (x32 ABI)

Based on feedback by Mike Gilbert <floppym@gentoo.org>
Linux-6.1.38-dist x86_64 AMD Phenom-tm- II X6 1055T Processor
-march=amdfam10
failures occur for x32 ABI

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoFix getting return address in elf/tst-audit28.c.
Stefan Liebler [Thu, 13 Jul 2023 13:13:48 +0000 (15:13 +0200)] 
Fix getting return address in elf/tst-audit28.c.

Starting with commit 1bcfe0f732066ae5336b252295591ebe7e51c301, the
test was enhanced and the object for __builtin_return_address (0)
is searched with _dl_find_object.

Unfortunately on e.g. s390 (31bit), a postprocessing step is needed
as the highest bit has to be masked out.  This can be done with
__builtin_extract_return_addr.

Without this postprocessing, _dl_find_object returns with -1 and the
content of dlfo is invalid, which may lead to segfaults in basename.
Therefore those checks are now only done on success.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years ago[PATCH v1] x86: Use `3/4*sizeof(per-thread-L3)` as low bound for NT threshold.
Noah Goldstein [Tue, 18 Jul 2023 15:27:59 +0000 (10:27 -0500)] 
[PATCH v1] x86: Use `3/4*sizeof(per-thread-L3)` as low bound for NT threshold.

On some machines we end up with incomplete cache information. This can
make the new calculation of `sizeof(total-L3)/custom-divisor` end up
lower than intended (and lower than the prior value). So reintroduce
the old bound as a lower bound to avoid potentially regressing code
where we don't have complete information to make the decision.
Reviewed-by: DJ Delorie <dj@redhat.com>
2 years agox86: Fix slight bug in `shared_per_thread` cache size calculation.
Noah Goldstein [Tue, 18 Jul 2023 04:14:33 +0000 (23:14 -0500)] 
x86: Fix slight bug in `shared_per_thread` cache size calculation.

After:
```
    commit af992e7abdc9049714da76cae1e5e18bc4838fb8
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Wed Jun 7 13:18:01 2023 -0500

        x86: Increase `non_temporal_threshold` to roughly `sizeof_L3 / 4`
```

Split `shared` (cumulative cache size) from `shared_per_thread` (cache
size per socket), the `shared_per_thread` *can* be slightly off from
the previous calculation.

Previously we added `core` even if `threads_l2` was invalid, and only
used `threads_l2` to divide `core` if it was present. The changed
version only included `core` if `threads_l2` was valid.

This change restores the old behavior if `threads_l2` is invalid by
adding the entire value of `core`.
Reviewed-by: DJ Delorie <dj@redhat.com>
2 years agoUpdate i686 libm-test-ulps (again)
Andreas K. Hüttel [Tue, 18 Jul 2023 23:32:13 +0000 (01:32 +0200)] 
Update i686 libm-test-ulps (again)

Based on feedback by Arsen Arsenović <arsen@gentoo.org>
Linux-6.1.38-gentoo-dist-hardened x86_64 AMD Ryzen 7 3800X 8-Core Processor
-march=x86-64-v2

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoUpdate i686 libm-test-ulps
Andreas K. Hüttel [Tue, 18 Jul 2023 21:12:24 +0000 (23:12 +0200)] 
Update i686 libm-test-ulps

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoMerge translations (de, ro, uk, zh_TW)
Andreas K. Hüttel [Tue, 18 Jul 2023 19:22:19 +0000 (21:22 +0200)] 
Merge translations (de, ro, uk, zh_TW)

Line numbers, version numbers, template date changed everywhere
Nontrivial changes in de, ro, uk, zh_TW

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoRegenerate libc.pot
Andreas K. Hüttel [Mon, 17 Jul 2023 18:39:38 +0000 (20:39 +0200)] 
Regenerate libc.pot

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2 years agoconfigure: Use autoconf 2.71
Siddhesh Poyarekar [Thu, 29 Jun 2023 18:34:16 +0000 (14:34 -0400)] 
configure: Use autoconf 2.71

Bump autoconf requirement to 2.71 to allow regenerating configure on
more recent distributions.  autoconf 2.71 has been in Fedora since F36
and is the current version in Debian stable (bookworm).  It appears to
be current in Gentoo as well.

All sysdeps configure and preconfigure scripts have also been
regenerated; all changes are trivial transformations that do not affect
functionality.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoUpdate sparc libm-test-ulps
Adhemerval Zanella [Mon, 17 Jul 2023 13:09:44 +0000 (10:09 -0300)] 
Update sparc libm-test-ulps

2 years agos390: Add the clone3 wrapper
Adhemerval Zanella [Thu, 13 Jul 2023 13:26:34 +0000 (10:26 -0300)] 
s390: Add the clone3 wrapper

It follows the internal signature:

  extern int clone3 (struct clone_args *__cl_args, size_t __size,
                     int (*__func) (void *__arg), void *__arg);

Checked on s390x-linux-gnu and s390-linux-gnu.

2 years agomanual: Fix typos in struct dl_find_object
Bert Wesarg [Thu, 13 Jul 2023 10:26:59 +0000 (12:26 +0200)] 
manual: Fix typos in struct dl_find_object

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agosparc: Fix la_symbind for bind-now (BZ 23734)
Adhemerval Zanella [Mon, 10 Jul 2023 20:01:00 +0000 (17:01 -0300)] 
sparc: Fix la_symbind for bind-now (BZ 23734)

The sparc ABI has multiple cases on how to handle JMP_SLOT relocations,
(sparc_fixup_plt/sparc64_fixup_plt).  For BINDNOW, _dl_audit_symbind
will be responsible to setup the final relocation value; while for
lazy binding _dl_fixup/_dl_profile_fixup will call the audit callback
and tail cail elf_machine_fixup_plt (which will call
sparc64_fixup_plt).

This patch fixes by issuing the SPARC specific routine on bindnow and
forwarding the audit value to elf_machine_fixup_plt for lazy resolution.
It fixes the la_symbind for bind-now tests on sparc64 and sparcv9:

  elf/tst-audit24a
  elf/tst-audit24b
  elf/tst-audit24c
  elf/tst-audit24d

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2 years agoi386: make debug wrappers compatible with static PIE
Andreas Schwab [Wed, 12 Jul 2023 09:29:34 +0000 (11:29 +0200)] 
i386: make debug wrappers compatible with static PIE

Static PIE requires the use of PLT relocation.

2 years agoLoongArch: Fix soft-float bug about _dl_runtime_resolve{,lsx,lasx}
caiyinyu [Tue, 11 Jul 2023 03:57:12 +0000 (11:57 +0800)] 
LoongArch: Fix soft-float bug about _dl_runtime_resolve{,lsx,lasx}

2 years agoLoongArch: Add vector implementation for _dl_runtime_resolve.
caiyinyu [Wed, 5 Jul 2023 08:38:05 +0000 (16:38 +0800)] 
LoongArch: Add vector implementation for _dl_runtime_resolve.

2 years agoLoongArch: config: Added HAVE_LOONGARCH_VEC_ASM.
caiyinyu [Thu, 6 Jul 2023 08:30:52 +0000 (16:30 +0800)] 
LoongArch: config: Added HAVE_LOONGARCH_VEC_ASM.

This patch checks if assembler supports vector instructions to
generate LASX/LSX code or not, and then define HAVE_LOONGARCH_VEC_ASM macro

We have added support for vector instructions in binutils-2.41
See:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=75b2f521b101d974354f6ce9ed7c054d8b2e3b7a

commit 75b2f521b101d974354f6ce9ed7c054d8b2e3b7a
Author: mengqinggang <mengqinggang@loongson.cn>
Date:   Thu Jun 22 10:35:28 2023 +0800

LoongArch: gas: Add lsx and lasx instructions support

gas/ChangeLog:

        * config/tc-loongarch.c (md_parse_option): Add lsx and lasx option.
        (loongarch_after_parse_args): Add lsx and lasx option.

opcodes/ChangeLog:

        * loongarch-opc.c (struct loongarch_ase): Add lsx and lasx
        instructions.

2 years agosysdeps: Add missing hidden definitions for i386
Frédéric Bérat [Thu, 6 Jul 2023 17:14:59 +0000 (19:14 +0200)] 
sysdeps: Add missing hidden definitions for i386

Add missing libc_hidden_builtin_def for memset_chk and MEMCPY_CHK on
i386.

2 years agosysdeps/s390: Exclude fortified routines from being built with _FORTIFY_SOURCE
Frédéric Bérat [Fri, 7 Jul 2023 14:20:48 +0000 (16:20 +0200)] 
sysdeps/s390: Exclude fortified routines from being built with _FORTIFY_SOURCE

Depending on build configuration, the [routine]-c.c files may be chosen
to provide fortified routines implementation. While [routines].c
implementation were automatically excluded, the [routines]-c.c ones were
not. This patch fixes that by adding these file to the list to be
filtered.

2 years agoTranslations: Add new ro support and update others.
Carlos O'Donell [Fri, 7 Jul 2023 15:27:08 +0000 (11:27 -0400)] 
Translations: Add new ro support and update others.

This brings in the new Romanian language translations, and updates
nine other translations. Important translations in this update
include the Italian and Japanese translations for ESTALE which
remove the mention of "NFS" from the error message translation.

2 years agoelf: _dl_find_object may return 1 during early startup (bug 30515)
Florian Weimer [Fri, 7 Jul 2023 08:11:26 +0000 (10:11 +0200)] 
elf: _dl_find_object may return 1 during early startup (bug 30515)

Success is reported with a 0 return value, and failure is -1.
Enhance the kitchen sink test elf/tst-audit28 to cover
_dl_find_object as well.

Fixes commit 5d28a8962dcb ("elf: Add _dl_find_object function")
and bug 30515.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agoLoongArch: config: Rewrite check on static PIE.
caiyinyu [Thu, 6 Jul 2023 09:25:43 +0000 (17:25 +0800)] 
LoongArch: config: Rewrite check on static PIE.

It's better to add "\" before "EOF" and remove "\"
before "$".

2 years agoRevert "hppa: Drop 16-byte pthread lock alignment"
John David Anglin [Thu, 6 Jul 2023 15:47:50 +0000 (15:47 +0000)] 
Revert "hppa: Drop 16-byte pthread lock alignment"

This change reverts commits c4468cd3995b4236ea886901109b194641132b08
and ab991a3d1b401ded6bd4f027352da8262b021a11.

2 years agorealloc: Limit chunk reuse to only growing requests [BZ #30579]
Siddhesh Poyarekar [Thu, 6 Jul 2023 15:09:44 +0000 (11:09 -0400)] 
realloc: Limit chunk reuse to only growing requests [BZ #30579]

The trim_threshold is too aggressive a heuristic to decide if chunk
reuse is OK for reallocated memory; for repeated small, shrinking
allocations it leads to internal fragmentation and for repeated larger
allocations that fragmentation may blow up even worse due to the dynamic
nature of the threshold.

Limit reuse only when it is within the alignment padding, which is 2 *
size_t for heap allocations and a page size for mmapped allocations.
There's the added wrinkle of THP, but this fix ignores it for now,
pessimizing that case in favor of keeping fragmentation low.

This resolves BZ #30579.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reported-by: Nicolas Dusart <nicolas@freedelity.be>
Reported-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
2 years agovfscanf-internal: Remove potentially unbounded allocas
Adhemerval Zanella [Tue, 27 Jun 2023 18:05:56 +0000 (14:05 -0400)] 
vfscanf-internal: Remove potentially unbounded allocas

Some locales define a list of mapping pairs of alternate digits and
separators for input digits (to_inpunct).  This require the scanf
to create a list of all possible inputs for the optional type
modifier 'I'.

Checked on x86_64-linux-gnu.

Reviewed-by: Joe Simmons-Talbott <josimmon@redhat.com>
2 years agofileops: Don't process ,ccs= as individual mode flags (BZ#18906)
Joe Simmons-Talbott [Wed, 5 Jul 2023 21:23:28 +0000 (21:23 +0000)] 
fileops: Don't process ,ccs= as individual mode flags (BZ#18906)

In processing the first 7 individual characters of the mode for fopen
if ,ccs= is used those characters will be processed as well.  Stop
processing individual mode flags once a comma is encountered.  This has
the effect of requiring ,ccs= to be the last mode flag in the mode
string.  Add a testcase to check that the ,ccs= mode flag is not
processed as individual mode flags.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 years agosysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result
Frédéric Bérat [Mon, 19 Jun 2023 12:56:49 +0000 (14:56 +0200)] 
sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result

Return value from *scanf and *asprintf routines are now properly checked
in test-scanf-ldbl-compat-template.c and test-printf-ldbl-compat.c.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agolibio/bits/stdio2-decl.h: Avoid PLT entries with _FORTIFY_SOURCE
Frédéric Bérat [Wed, 28 Jun 2023 07:08:44 +0000 (09:08 +0200)] 
libio/bits/stdio2-decl.h: Avoid PLT entries with _FORTIFY_SOURCE

The change is meant to avoid unwanted PLT entry for the fgets_unlocked
routine when _FORTIFY_SOURCE is set.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agolibio/bits/stdio2.h: Clearly separate declaration from definitions
Frédéric Bérat [Wed, 28 Jun 2023 07:07:26 +0000 (09:07 +0200)] 
libio/bits/stdio2.h: Clearly separate declaration from definitions

Move declarations from libio/bits/stdio.h to existing
libio/bits/stdio2-decl.h. This will enable future use of
__REDIRECT_FORTIFY in place of some __REDIRECT.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agomisc/bits/syslog.h: Clearly separate declaration from definition
Frédéric Bérat [Wed, 26 Apr 2023 09:59:08 +0000 (11:59 +0200)] 
misc/bits/syslog.h: Clearly separate declaration from definition

This allows to include bits/syslog-decl.h in include/sys/syslog.h and
therefore be able to create the libc_hidden_builtin_proto (__syslog_chk)
prototype.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agomisc/bits/select2.h: Clearly separate declaration from definitions
Frédéric Bérat [Wed, 26 Apr 2023 09:48:56 +0000 (11:48 +0200)] 
misc/bits/select2.h: Clearly separate declaration from definitions

The __fdelt_chk declaration needs to be available so that
libc_hidden_proto can be used while not redefining __FD_ELT.
Thus, misc/bits/select-decl.h is created to hold the corresponding
prototypes.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agounistd: Avoid PLT entries with _FORTIFY_SOURCE
Frédéric Bérat [Wed, 7 Jun 2023 09:34:36 +0000 (11:34 +0200)] 
unistd: Avoid PLT entries with _FORTIFY_SOURCE

The change is meant to avoid unwanted PLT entries for the read_chk,
getdomainname_chk and getlogin_r_chk routines when _FORTIFY_SOURCE is set.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoposix/bits/unistd.h: Clearly separate declaration from definitions
Frédéric Bérat [Wed, 26 Apr 2023 09:45:11 +0000 (11:45 +0200)] 
posix/bits/unistd.h: Clearly separate declaration from definitions

This change is similar to what was done for bits/wchar2.h.
Routines declaration are moved into a dedicated bits/unistd-decl.h file
which is then included into the bits/unistd.h file.

This will allow to adapt the files so that PLT entries are not created when
_FORTIFY_SOURCE is enabled.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agowchar: Avoid PLT entries with _FORTIFY_SOURCE
Frédéric Bérat [Wed, 7 Jun 2023 09:06:50 +0000 (11:06 +0200)] 
wchar: Avoid PLT entries with _FORTIFY_SOURCE

The change is meant to avoid unwanted PLT entries for the wmemset and
wcrtomb routines when _FORTIFY_SOURCE is set.

On top of that, ensure that *_chk routines have their hidden builtin
definitions available.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agomisc/sys/cdefs.h: Create FORTIFY redirects for internal calls
Frédéric Bérat [Wed, 26 Apr 2023 09:32:04 +0000 (11:32 +0200)] 
misc/sys/cdefs.h: Create FORTIFY redirects for internal calls

The __REDIRECT* macros are creating aliases which may lead to unwanted
PLT entries when fortification is enabled.
To prevent these entries, the REDIRECT alias should be set to point to the
existing __GI_* aliases.
This is done transparently by creating a __REDIRECT_FORTIFY* version of
these macros, that can be overwritten internally when necessary.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agostdio: Ensure *_chk routines have their hidden builtin definition available
Frédéric Bérat [Wed, 26 Apr 2023 15:26:51 +0000 (17:26 +0200)] 
stdio: Ensure *_chk routines have their hidden builtin definition available

If libc_hidden_builtin_{def,proto} isn't properly set for *_chk routines,
there are unwanted PLT entries in libc.so.

There is a special case with __asprintf_chk:
If ldbl_* macros are used for asprintf, ABI gets broken on s390x,
if it isn't, ppc64le isn't building due to multiple asm redirections.

This is due to the inclusion of bits/stdio-lbdl.h for ppc64le whereas it
isn't for s390x. This header creates redirections, which are not
compatible with the ones generated using libc_hidden_def.
Yet, we can't use libc_hidden_ldbl_proto on s390x since it will not
create a simple strong alias (e.g. as done on x86_64), but a versioned
alias, leading to ABI breakage.

This results in errors on s390x:
/usr/bin/ld: glibc/iconv/../libio/bits/stdio2.h:137: undefined reference
to `__asprintf_chk'

Original __asprintf_chk symbols:
00000000001395b0 T __asprintf_chk
0000000000177e90 T __nldbl___asprintf_chk

__asprintf_chk symbols with ldbl_* macros:
000000000012d590 t ___asprintf_chk
000000000012d590 t __asprintf_chk@@GLIBC_2.4
000000000012d590 t __GI___asprintf_chk
000000000012d590 t __GL____asprintf_chk___asprintf_chk
0000000000172240 T __nldbl___asprintf_chk

__asprintf_chk symbols with the patch:
000000000012d590 t ___asprintf_chk
000000000012d590 T __asprintf_chk
000000000012d590 t __GI___asprintf_chk
0000000000172240 T __nldbl___asprintf_chk

Reviewed-by: Carlos O'Donell <carlos@redhat.com>