Commit Graph

40982 Commits

Author SHA1 Message Date
Adhemerval Zanella
58f8b01276 Use -frounding-math iff compiler supports it 2024-04-17 16:12:40 -03:00
Adhemerval Zanella
5e40fc5900 string: Use asm alias instead of symbol redirections for stpcpy and mempcpy
Commit 939da41143 added symbols redirections to handle ISO C
namespace, however some compiler does not support to redeclare the
function prototype.  Moving these defintions to exported header
it not a good practice (it exposes a internal implementation and
it would require to add macros to define it only internally).

Instead this patch replaces the symbol redirections by direct asm
aliases, as done to handle libcall generation done by compiler on
some loop optimizations. The only issue is sparc binutils generates
an extra __mempcpy plt not called anywhere in the code, which indicates
a binutils issue (this is added in the localplt.data for now).

Checked on all affected ABIs.
2024-04-17 16:12:40 -03:00
Adhemerval Zanella
706b3d7a47 math: Use -fexcess-precision=standard iff compiler supports it 2024-04-17 16:12:40 -03:00
Adhemerval Zanella
66a42a7099 configure: Use -Wno-ignored-attributes if compiler warns about multiple aliases
clang emits an warning when a double alias redirection is used, to warn
the the original symbol will be used even when weak definition is
overridden.  Howerver, this is a common pattern for weak_alias, where
multiple alias are set to same symbol.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
5bcc666d76 math: Suppress clang -Wincompatible-library-redeclaration on s_llround
Clang issues:

  ../sysdeps/ieee754/dbl-64/s_llround.c:83:30: error: incompatible
  redeclaration of library function 'lround'
  [-Werror,-Wincompatible-library-redeclaration]
  libm_alias_double (__lround, lround)
                               ^
  ../sysdeps/ieee754/dbl-64/s_llround.c:83:30: note: 'lround' is a builtin
  with type 'long (double)'
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
9cdf90ef2c math: use fabs on __ieee754_lgamma_r 2024-04-17 16:12:10 -03:00
Adhemerval Zanella
7cfc8eda54 math: Suppress clang warning on math_check_force_underflow
Clang warns:

  ../sysdeps/x86/fpu/powl_helper.c:233:3: error: absolute value function
  '__builtin_fabsf' given an argument of type 'typeof (res)' (aka 'long
  double') but has parameter of type 'float' which may cause truncation of
  value [-Werror,-Wabsolute-value]
    math_check_force_underflow (res);
    ^
  ./math-underflow.h:45:11: note: expanded from macro
  'math_check_force_underflow'
        if (fabs_tg (force_underflow_tmp)                         \
            ^
  ./math-underflow.h:27:20: note: expanded from macro 'fabs_tg'
  #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
                     ^
  ../math/math.h:899:16: note: expanded from macro '__MATH_TG'
                 float: FUNC ## f ARGS,           \
                        ^
  <scratch space>:73:1: note: expanded from here
  __builtin_fabsf
  ^
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
f68d36c788 catgets: Remove catgets/config.h
It simplifies the code a bit and avoid the clang warning:

  ./config.h:12:2: error: #include_next in file found relative to primary
  source file or found by absolute path; will search from start of include
  path [-Werror,-Winclude-next-absolute-path]
  #include_next <config.h>
   ^
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
cd7206deed iconvdata: Remove use of GNU old-style field designator extension
Use the C99 syntax instead.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
ac0163c991 iconvdata: Suppress clang warning on locale definitions
clang issues an warning adding '{unsigned} int' to a string does not
append to the string, however it is exactly what code means here.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
0c8480a269 locale: Fix implicit conversion on collate_finish
Clang issues:

programs/ld-collate.c:1824:55: error: implicit conversion from 'unsigned
long' to 'unsigned int' changes value from 18446744073709551615 to
4294967295 [-Werror,-Wconstant-conversion]
  collate->undefined.used_in_level = need_undefined ? ~0ul : 0;
                                   ~                  ^~~~
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
3d7304378b elf: Suppress clang -Wstring-plus-int on rtld.c
clang issues an warning adding 'const unsigned char' to a string
does not append to the string, however it is exactly what code
means here.
2024-04-17 16:12:10 -03:00
Fangrui Song
d2161cbdbb configure: Fix check for -fno-tree-loop-distribute-patterns
clang does not support -fno-tree-loop-distribute-patterns and using
on __attribute__ ((__optimize__ (...))) only triggers a warning
with AC_TRY_COMMAND.  Add -Werror so the tests fails if compiler
does not support it.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
e4dfd4cc55 elf: Supress clang -Wsometimes-uninitialized on _dl_debug_initialize
clang issues an warning where variable 'r' is used uninitialized
whenever 'if' condition is false.  The _dl_debug_initialize is called
for static case always with LM_ID_BASE (csu/libc-start.c and
elf/dl-reloc-static-pie.c) and DL_NSS will be always larger than 1
for shared case.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
583f8d7fd4 sunrpc: Suppress clang warning on struct cmessage
clang complains if a flexible array member (struct cmsghdr) is not a
the end of the struct (since it is a GNU extension).  The __msgread
explicit expects that 'struct ucred' is after the 'cmsg', so suppress
the warning.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
5d3b33803f sunrpc: Remove extra parenthesis on comparison
clang issues a 'equality comparison with extraneous parentheses
[-Werror,-Wparentheses-equality]' in this.  Instead of suppress
the warning, just follow the next comparison style.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
2d94174fd1 nss: Suppress nss_module.c warning on clang
clang issues an warning adding 'unsigned long' to a string does not
append to the string, however it is exactly what code means here.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
35cdd59852 argp: Expand argp_usage, _option_is_short, and _option_is_end
The argp code uses some clever macro redefine to avoid need to
duplicate the optimized static inline implementations for
argp_usage, _option_is_short, and _option_is_end.  This however
leads to some build issues with clang, since some function
prototypes are redefined to add the hidden attribute with
libc_hidden_proto.

To avoid extensive changes on internal headers, just expand the
function implementations and avoid the macro redefine tricks.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
ed63857295 misc: Suppress clang warnings on syslog
clang complains that adding a 'int_t' to a string does not append
to it, but the idea is to print the pid conditionally.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
79be9c6153 posix: Suppress clang confstr -Wignored-attributes
clang warns that alias will be always resolve to _GI___confstr even
if weak definition of __GI_confstr is overridden, which is really the
intention.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
817b755cce resolv: Suppress clang -Wsometimes-uninitialized on getaddrinfo
clang warns that endp is used uninitialized whenever '||' condition
is true:

getaddrinfo.c:1888:11: error: variable 'endp' is used uninitialized
whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
 1888 |       && (cp == NULL
      |           ^~~~~~~~~~
getaddrinfo.c:1891:11: note: uninitialized use occurs here
 1891 |       && *endp == '\0'
      |           ^~~~
getaddrinfo.c:1888:11: note: remove the '||' if its condition is always
false
 1888 |       && (cp == NULL
      |           ^~~~~~~~~~
 1889 |           || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
      |           ~~
getaddrinfo.c:1875:13: note: initialize the variable 'endp' to silence
this warning
 1875 |   char *endp;
      |             ^
      |              = NULL
1 error generated.

However it will be evaluated after strtoul call.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
413a452b5c elf: Suppress unused function clang for __ifunc_resolver
The __ifunc_resolver macro expands to:

  extern __typeof (__redirect_name) name __attribute__ ((ifunc ("iname_ifunc")));
  static __typeof (__redirect_name) *name_ifunc (void) { [...] };

And although NAME_IFUNC is and alias for NAME, clang still emits
an 'unused function 'name_ifunc' [-Werror,-Wunused-function]'
warning.  The static is used to avoid name pollution on static
linkage.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
68cbe438b5 Fix inhibit_stack_protector for clang 2024-04-17 16:12:10 -03:00
Adhemerval Zanella
fe8a949c64 nptl: Fix Wincompatible-pointer-types on clang
Clang issues:

error: incompatible pointer types passing 'struct pthread **' to
parameter of type 'void **' [-Werror,-Wincompatible-pointer-types]
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
db3ab211d1 configure: Use -Wno-maybe-uninitialized iff compiler supports it
clang does not support the flag.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
279ce84045 Suppress -Wmaybe-uninitialized only for gcc
The warning is not supported by clang.
2024-04-17 16:12:10 -03:00
Adhemerval Zanella
d2765f0fa2 Disable __USE_EXTERN_INLINES for clang
clang does not allow to redefine attributes after function declaration.
Although it work for external usage, its breaks the build for internal
symbol that glibc provides as optimization (for instance bsearch
with stdlib-bsearch.h or __cmsg_nxthdr).

Disable such optimization for clang while building glibc.
2024-04-17 16:12:09 -03:00
Adhemerval Zanella
e182dc08d7 Add clang specific warnings suppress macros
Four new macros are added:

  * DIAG_{PUSH,POP}_NEEDS_COMMENT_CLANG are similar to
    DIAG_{PUSH,POP}_NEEDS_COMMENT, but enable clang specific pragmas to
    handle warnings for options only supported by clang.

  * DIAG_IGNORE_NEEDS_COMMENT_{CLANG,GCC} are similar to
    DIAG_IGNORE_NEEDS_COMMENT, but enable the warning suppression only
    for the referenced compiler.
2024-04-17 16:12:09 -03:00
Adhemerval Zanella
9a30e8cf4f stdlib: longlong.h: Do no use asm input cast for clang
clang by default rejects the input casts with:

  error: invalid use of a cast in a inline asm context requiring an
  lvalue: remove the cast or build with -fheinous-gnu-extensions

And even with -fheinous-gnu-extensions clang still throws an warning
and also states that this option might be removed in the future.
For gcc the cast are still useful [1] as type-checking.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581722.html
2024-04-17 16:12:09 -03:00
Adhemerval Zanella
a7df44378e stdlib: Remove -Wmaybe-uninitialized supression on setenv.c
It is not required on current supported gcc.
2024-04-17 16:12:09 -03:00
Adhemerval Zanella
d7101bde41 stdlib: Improve fortify with clang
It improve fortify checks for realpath, ptsname_r, wctomb, mbstowcs,
and wcstombs.  The runtime and compile checks have similar coverage as
with GCC.

Checked on aarch64, armhf, x86_64, and i686.
2024-04-17 16:12:09 -03:00
Adhemerval Zanella
0e53e7cdf5 Fix 'Reported-By' to use Camel Case for commit 6a98f4640e 2024-04-17 14:27:42 -03:00
Adhemerval Zanella
6a98f4640e Document CVE-2024-2961
This commit adds "advisories" entries for the above three CVEs.
2024-04-17 14:24:26 -03:00
Charles Fol
f9dc609e06 iconv: ISO-2022-CN-EXT: fix out-of-bound writes when writing escape sequence (CVE-2024-2961)
ISO-2022-CN-EXT uses escape sequences to indicate character set changes
(as specified by RFC 1922).  While the SOdesignation has the expected
bounds checks, neither SS2designation nor SS3designation have its;
allowing a write overflow of 1, 2, or 3 bytes with fixed values:
'$+I', '$+J', '$+K', '$+L', '$+M', or '$*H'.

Checked on aarch64-linux-gnu.

Co-authored-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2024-04-17 09:21:40 -03:00
Joe Simmons-Talbott
59974938fe elf/rtld: Count skipped environment variables for enable_secure
When using the glibc.rtld.enable_secure tunable we need to keep track of
the count of environment variables we skip due to __libc_enable_secure
being set and adjust the auxv section of the stack.  This fixes an
assertion when running ld.so directly with glibc.rtld.enable_secure set.
Add a testcase that ensures the assert is not hit.

elf/rtld.c:1324   assert (auxv == sp + 1);

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-04-16 20:32:10 +00:00
Florian Weimer
14e56bd4ce powerpc: Fix ld.so address determination for PCREL mode (bug 31640)
This seems to have stopped working with some GCC 14 versions,
which clobber r2.  With other compilers, the kernel-provided
r2 value is still available at this point.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2024-04-14 08:24:51 +02:00
Florian Weimer
aea52e3d2b Revert "x86_64: Suppress false positive valgrind error"
This reverts commit a1735e0aa8.

The test failure is a real valgrind bug that needs to be fixed before
valgrind is usable with a glibc that has been built with
CC="gcc -march=x86-64-v3".  The proposed valgrind patch teaches
valgrind to replace ld.so strcmp with an unoptimized scalar
implementation, thus avoiding any AVX2-related problems.

Valgrind bug: <https://bugs.kde.org/show_bug.cgi?id=485487>

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-13 17:42:13 +02:00
Adhemerval Zanella
cf11e74b0d wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865)
It uses the same two-way algorithm used on strstr, strcasestr, and
memmem.  Different than strstr, neither the "shift table" optimization
nor the self-adapting filtering check is used because it would result in
a too-large shift table (and it also simplifies the implementation bit).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
2024-04-11 14:21:32 -03:00
Adhemerval Zanella
4b717562c4 wcsmbs: Add test-wcsstr
Parametrize test-strstr.c so it can be used to check wcsstr.

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

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-04-11 14:21:32 -03:00
Adhemerval Zanella
686d542025 posix: Sync tempname with gnulib
The gnulib version contains an important change (9ce573cde), which
fixes some problems with multithreading, entropy loss, and ASLR leak
nfo.  It also fixes an issue where getrandom is not being used
on some new files generation (only for __GT_NOCREATE on first try).

The 044bf893ac removed __path_search, which is now moved to another
gnulib shared files (stdio-common/tmpdir.{c,h}).  Tthis patch
also fixes direxists to use __stat64_time64 instead of __xstat64,
and move the include of pathmax.h for !_LIBC (since it is not used
by glibc).  The license is also changed from GPL 3.0 to 2.1, with
permission from the authors (Bruno Haible and Paul Eggert).

The sync also removed the clock fallback, since clock_gettime
with CLOCK_REALTIME is expected to always succeed.

It syncs with gnulib commit 323834962817af7b115187e8c9a833437f8d20ec.

Checked on x86_64-linux-gnu.

Co-authored-by: Bruno Haible <bruno@clisp.org>
Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Bruno Haible <bruno@clisp.org>
2024-04-10 14:53:39 -03:00
Sergey Kolosov
3a83f79024 socket: Add new test for connect
This commit adds a simple bind/accept/connect test for an IPv4 TCP
connection to a local process via the loopback interface.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2024-04-10 18:10:22 +02:00
Sergey Kolosov
6687a6e3f9 libsupport: Add xgetpeername
The patch adds redirections for getpeername.

Reviewed-by: Arjun Shankar <arjun@redhat.com>
2024-04-10 18:10:22 +02:00
H.J. Lu
42e48e720c nptl: Add tst-pthread-key1-static for BZ #21777
Add a static pthread static tests to verify that BZ #21777 is fixed.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2024-04-09 05:27:03 -07:00
Florian Weimer
ae7468a7b0 elf: Add ld.so test with non-existing program name
None of the existing tests seem to cover the case where
_dl_signal_error is called without an active error handler.
The new elf/tst-rtld-does-not-exist test triggers such a
_dl_signal_error call from _dl_map_object.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-08 19:19:09 +02:00
H.J. Lu
1cce91d8ae elf: Check objname before calling fatal_error
_dl_signal_error may be called with objname == NULL.  _dl_exception_create
checks objname == NULL.  But fatal_error doesn't.  Check objname before
calling fatal_error.  This fixes BZ #31596.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
2024-04-08 09:41:02 -07:00
H.J. Lu
727aacfd66 Use crtbeginT.o and crtend.o for non-PIE static executables
When static PIE is enabled by default, we shouldn't use crtbeginS.o and
crtendS.o for non-PIE static executables.  Check $($(@F)-no-pie) to use
crtbeginT.o and crtend.o to create non-PIE static executables.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
2024-04-08 09:25:36 -07:00
Florian Weimer
f8d8b1b1e6 aarch64: Enhanced CPU diagnostics for ld.so
This prints some information from struct cpu_features, and the midr_el1
and dczid_el0 system register contents on every CPU.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2024-04-08 16:48:55 +02:00
Florian Weimer
7a430f40c4 x86: Add generic CPUID data dumper to ld.so --list-diagnostics
This is surprisingly difficult to implement if the goal is to produce
reasonably sized output.  With the current approaches to output
compression (suppressing zeros and repeated results between CPUs,
folding ranges of identical subleaves, dealing with the %ecx
reflection issue), the output is less than 600 KiB even for systems
with 256 logical CPUs.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-08 16:48:55 +02:00
Florian Weimer
5653ccd847 elf: Add CPU iteration support for future use in ld.so diagnostics
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2024-04-08 16:48:55 +02:00
Paul Eggert
1f94147a79 timezone: sync to TZDB 2024a
Sync tzselect, zdump, zic to TZDB 2024a.
This patch incorporates the following TZDB source code changes,
listed roughly in descending order of importance.

  zic now supports links to links, needed for future tzdata
  zic now defaults to '-b slim'
  zic now updates output files atomically
  zic has new options -R, -l -, -p -
  zic -r now uses -00 for unspecified timestamps
  zdump now uses [lo,hi) for both -c and -t
  Fix several integer overflow bugs
  zic now checks input bytes more carefully
  Simplify and fix new TZDIR setup
  Default time_t to 64 bits on glibc 2.34+ 32-bit
  zic now generates TZ strings that conform to POSIX when all-year DST
  zic -v now shows extreme-int tm_year transitions
  Fix zic bug in last time type of Asia/Gaza etc.
  Fix zic bug with Palestine after 2075
  Fix bug uncovered by recent change to Iran history
  Fix 'zic -b fat' bug with Port Moresby 32-bit data
  Fix zic bug with -r @X where X is deduced from TZ
  Fix bug with zic -r cutoff before 1st transition
  Fix leap second expiry and truncation
  Fix zic bug on Linux 2.6.16 and 2.6.17
  Fix bug with 'zic -d /a/b/c' if /a is unwriteable
  Don't mistruncate TZif files at leap seconds
  Fix zdump undefined behavior if !USE_LTZ
  zdump -v reports localtime+gmtime failures better
  Fix zdump diagnostic for missing timezone
  Don't assume nonempty argv
  Port better to C23
  Do not assume negative >> behavior
  I18nize zdump a bit better
  Port zdump to right_only installations
  New tzselect menu option 'now'
  tzselect can now use current time to help choose
  Improve tzselect behavior for Turkey etc.
  tzselect: do not create temporary files
  tzselect: work around mawk bug with {2,}
  tzselect: Port to POSIX awk, which prohibits -v newlines
  Do not use empty RE in tzselect
  Don't set TZ in tzselect
  Avoid sed, expr in tzselect
  tzselect: Fix problems with spaces in TZDIR
  Improve tzselect diagnostics
  Remove zic workaround for Qt bug 53071
  Remove zic support for "min" in Rule lines
  Remove zic support for zic -y, Rule TYPEs, pacificnew
  Remove tzselect workaround for Bash 1.14.7 bug

* SHARED-FILES: Update to match current sync.
* config.h.in (HAVE_STRERROR): Remove; no longer needed.
* timezone/Makefile ($(objpfx)zic.o): Depend on tzdir.h.
($(objpfx)tzdir.h): New rule to build a placeholder.
* timezone/private.h, timezone/tzfile.h, timezone/version:
* timezone/zdump.c, timezone/zic.c: Copy verbatim from TZDB 2024a.
2024-04-07 13:35:48 -07:00