Sync with upstream branch release/2.34/master

Upstream commit: commit 6484ae5b8c4d4314f748e4d3c9a9baa5385e57c5

- malloc: Fix -Wuse-after-free warning in tst-mallocalign1 [BZ #26779]
- s_sincosf.h: Change pio4 type to float [BZ #28713]
- math: Properly cast X_TLOSS to float [BZ #28713]
- Regenerate ulps on x86_64 with GCC 12
- Avoid -Wuse-after-free in tests [BZ #26779].
- Fix build of nptl/tst-thread_local1.cc with GCC 12
- Fix stdio-common tests for GCC 12 -Waddress
- Fix stdlib/tst-setcontext.c for GCC 12 -Warray-compare
- resolv: Avoid GCC 12 false positive warning [BZ #28439].
- intl: Avoid -Wuse-after-free [BZ #26779]
- elf: Drop elf/tls-macros.h in favor of __thread and tls_model attributes [BZ #28152] [BZ #28205]
- time: Set daylight to 1 for matching DST/offset change (RHBZ#2155352)
- elf/tst-tlsopt-powerpc fails when compiled with -mcpu=power10 (BZ# 29776)
- time: Use 64 bit time on tzfile
- nscd: Use 64 bit time_t on libc nscd routines (BZ# 29402)
- nis: Build libnsl with 64 bit time_t
- Use LFS and 64 bit time for installed programs (BZ #15333)

Resolves: #2155352
Related: #2160734
This commit is contained in:
Florian Weimer 2023-01-17 08:22:32 +01:00
parent 78832d4e7a
commit ad85e10075
18 changed files with 1629 additions and 1 deletions

View File

@ -0,0 +1,241 @@
commit 42eb735a5d3458a24a44ace9eca87c8b61573d97
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu May 20 14:20:18 2021 -0300
Use LFS and 64 bit time for installed programs (BZ #15333)
The installed programs are built with a combination of different
values for MODULE_NAME, as below. To enable both Long File Support
and 64 bt time, -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 is added for
nonlibi, nscd, lddlibc4, libresolv, ldconfig, locale_programs,
iconvprogs, libnss_files, libnss_compat, libnss_db, libnss_hesiod,
libutil, libpcprofile, and libSegFault.
nscd/nscd
nscd/nscd.o MODULE_NAME=nscd
nscd/connections.o MODULE_NAME=nscd
nscd/pwdcache.o MODULE_NAME=nscd
nscd/getpwnam_r.o MODULE_NAME=nscd
nscd/getpwuid_r.o MODULE_NAME=nscd
nscd/grpcache.o MODULE_NAME=nscd
nscd/getgrnam_r.o MODULE_NAME=nscd
nscd/getgrgid_r.o MODULE_NAME=nscd
nscd/hstcache.o MODULE_NAME=nscd
nscd/gethstbyad_r.o MODULE_NAME=nscd
nscd/gethstbynm3_r.o MODULE_NAME=nscd
nscd/getsrvbynm_r.o MODULE_NAME=nscd
nscd/getsrvbypt_r.o MODULE_NAME=nscd
nscd/servicescache.o MODULE_NAME=nscd
nscd/dbg_log.o MODULE_NAME=nscd
nscd/nscd_conf.o MODULE_NAME=nscd
nscd/nscd_stat.o MODULE_NAME=nscd
nscd/cache.o MODULE_NAME=nscd
nscd/mem.o MODULE_NAME=nscd
nscd/nscd_setup_thread.o MODULE_NAME=nscd
nscd/xmalloc.o MODULE_NAME=nscd
nscd/xstrdup.o MODULE_NAME=nscd
nscd/aicache.o MODULE_NAME=nscd
nscd/initgrcache.o MODULE_NAME=nscd
nscd/gai.o MODULE_NAME=nscd
nscd/res_hconf.o MODULE_NAME=nscd
nscd/netgroupcache.o MODULE_NAME=nscd
nscd/cachedumper.o MODULE_NAME=nscd
elf/lddlibc4
elf/lddlibc4 MODULE_NAME=lddlibc4
elf/pldd
elf/pldd.o MODULE_NAME=nonlib
elf/xmalloc.o MODULE_NAME=nonlib
elf/sln
elf/sln.o MODULE_NAME=nonlib
elf/static-stubs.o MODULE_NAME=nonlib
elf/sprof MODULE_NAME=nonlib
elf/ldconfig
elf/ldconfig.o MODULE_NAME=ldconfig
elf/cache.o MODULE_NAME=nonlib
elf/readlib.o MODULE_NAME=nonlib
elf/xmalloc.o MODULE_NAME=nonlib
elf/xstrdup.o MODULE_NAME=nonlib
elf/chroot_canon.o MODULE_NAME=nonlib
elf/static-stubs.o MODULE_NAME=nonlib
elf/stringtable.o MODULE_NAME=nonlib
io/pwd
io/pwd.o MODULE_NAME=nonlib
locale/locale
locale/locale.o MODULE_NAME=locale_programs
locale/locale-spec.o MODULE_NAME=locale_programs
locale/charmap-dir.o MODULE_NAME=locale_programs
locale/simple-hash.o MODULE_NAME=locale_programs
locale/xmalloc.o MODULE_NAME=locale_programs
locale/xstrdup.o MODULE_NAME=locale_programs
locale/record-status.o MODULE_NAME=locale_programs
locale/xasprintf.o MODULE_NAME=locale_programs
locale/localedef
locale/localedef.o MODULE_NAME=locale_programs
locale/ld-ctype.o MODULE_NAME=locale_programs
locale/ld-messages.o MODULE_NAME=locale_programs
locale/ld-monetary.o MODULE_NAME=locale_programs
locale/ld-numeric.o MODULE_NAME=locale_programs
locale/ld-time.o MODULE_NAME=locale_programs
locale/ld-paper.o MODULE_NAME=locale_programs
locale/ld-name.o MODULE_NAME=locale_programs
locale/ld-address.o MODULE_NAME=locale_programs
locale/ld-telephone.o MODULE_NAME=locale_programs
locale/ld-measurement.o MODULE_NAME=locale_programs
locale/ld-identification.o MODULE_NAME=locale_programs
locale/ld-collate.o MODULE_NAME=locale_programs
locale/charmap.o MODULE_NAME=locale_programs
locale/linereader.o MODULE_NAME=locale_programs
locale/locfile.o MODULE_NAME=locale_programs
locale/repertoire.o MODULE_NAME=locale_programs
locale/locarchive.o MODULE_NAME=locale_programs
locale/md5.o MODULE_NAME=locale_programs
locale/charmap-dir.o MODULE_NAME=locale_programs
locale/simple-hash.o MODULE_NAME=locale_programs
locale/xmalloc.o MODULE_NAME=locale_programs
locale/xstrdup.o MODULE_NAME=locale_programs
locale/record-status.o MODULE_NAME=locale_programs
locale/xasprintf.o MODULE_NAME=locale_programs
catgets/gencat
catgets/gencat.o MODULE_NAME=nonlib
catgets/xmalloc.o MODULE_NAME=nonlib
nss/makedb
nss/makedb.o MODULE_NAME=nonlib
nss/xmalloc.o MODULE_NAME=nonlib
nss/hash-string.o MODULE_NAME=nonlib
nss/getent
nss/getent.o MODULE_NAME=nonlib
posix/getconf
posix/getconf.o MODULE_NAME=nonlib
login/utmpdump
login/utmpdump.o MODULE_NAME=nonlib
debug/pcprofiledump
debug/pcprofiledump.o MODULE_NAME=nonlib
timezone/zic
timezone/zic.o MODULE_NAME=nonlib
timezone/zdump
timezone/zdump.o MODULE_NAME=nonlib
iconv/iconv_prog
iconv/iconv_prog.o MODULE_NAME=nonlib
iconv/iconv_charmap.o MODULE_NAME=iconvprogs
iconv/charmap.o MODULE_NAME=iconvprogs
iconv/charmap-dir.o MODULE_NAME=iconvprogs
iconv/linereader.o MODULE_NAME=iconvprogs
iconv/dummy-repertoire.o MODULE_NAME=iconvprogs
iconv/simple-hash.o MODULE_NAME=iconvprogs
iconv/xstrdup.o MODULE_NAME=iconvprogs
iconv/xmalloc.o MODULE_NAME=iconvprogs
iconv/record-status.o MODULE_NAME=iconvprogs
iconv/iconvconfig
iconv/iconvconfig.o MODULE_NAME=nonlib
iconv/strtab.o MODULE_NAME=iconvprogs
iconv/xmalloc.o MODULE_NAME=iconvprogs
iconv/hash-string.o MODULE_NAME=iconvprogs
nss/libnss_files.so MODULE_NAME=libnss_files
nss/libnss_compat.so.2 MODULE_NAME=libnss_compat
nss/libnss_db.so MODULE_NAME=libnss_db
hesiod/libnss_hesiod.so MODULE_NAME=libnss_hesiod
login/libutil.so MODULE_NAME=libutil
debug/libpcprofile.so MODULE_NAME=libpcprofile
debug/libSegFault.so MODULE_NAME=libSegFault
Also, to avoid adding both LFS and 64 bit time support on internal
tests they are moved to a newer 'testsuite-internal' module. It
should be similar to 'nonlib' regarding internal definition and
linking namespace.
This patch also enables LFS and 64 bit support of libsupport container
programs (echo-container, test-container, shell-container, and
true-container).
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit a6d2f948b71adcb5ea395cb04833bc645eab45e6)
diff --git a/Makeconfig b/Makeconfig
index 4e04dafb76a1e1a1..9accb5b38d1d37b3 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -882,6 +882,13 @@ endif
# -fno-math-errno.
+extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
+# Use 64 bit time_t support for installed programs
+installed-modules = nonlib nscd lddlibc4 libresolv ldconfig locale_programs \
+ iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \
+ libutil libpcprofile libSegFault
++extra-time-flags = $(if $(filter $(installed-modules),\
+ $(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64)
+
# We might want to compile with some stack-protection flag.
ifneq ($(stack-protector),)
+stack-protector=$(stack-protector)
@@ -986,7 +993,7 @@ libio-include = -I$(..)libio
built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
libSegFault libpcprofile librpcsvc locale-programs \
memusagestat nonlib nscd extramodules libnldbl libsupport \
- testsuite
+ testsuite testsuite-internal
in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
$(libof-$(<F)) \
@@ -1026,7 +1033,7 @@ endif
override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
$(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
- $(+extra-math-flags) \
+ $(+extra-math-flags) $(+extra-time-flags) \
$(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
$(CFLAGS-$(@F)) $(tls-model) \
$(foreach lib,$(libof-$(basename $(@F))) \
diff --git a/Makerules b/Makerules
index e5916f29fa0d4593..689842ba56c71b0d 100644
--- a/Makerules
+++ b/Makerules
@@ -1266,14 +1266,22 @@ lib := testsuite
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
endif
-all-nonlib := $(strip $(tests-internal) $(test-internal-extras) \
- $(others) $(others-extras))
+all-nonlib := $(strip $(others) $(others-extras))
ifneq (,$(all-nonlib))
cpp-srcs-left = $(all-nonlib)
lib := nonlib
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
endif
+# All internal tests use testsuite-internal module since for 64 bit time
+# support is set as default for MODULE_NAME=nonlib (which include some
+# installed programs).
+all-testsuite-internal := $(strip $(tests-internal) $(test-internal-extras))
+ifneq (,$(all-testsuite-internal))
+cpp-srcs-left = $(all-testsuite-internal)
+lib := testsuite-internal
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+endif
ifeq ($(build-shared),yes)
# Generate normalized lists of symbols, versions, and data sizes.
diff --git a/elf/sotruss-lib.c b/elf/sotruss-lib.c
index e4ebc8dbc697df3f..45dc6d5ffe819475 100644
--- a/elf/sotruss-lib.c
+++ b/elf/sotruss-lib.c
@@ -91,7 +91,7 @@ init (void)
if (which_process == NULL || which_process[0] == '\0')
snprintf (endp, 13, ".%ld", (long int) pid);
- out_fd = open (fullname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ out_fd = open64 (fullname, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (out_fd != -1)
print_pid = 0;
}
@@ -104,7 +104,7 @@ init (void)
program. */
if (out_fd == -1)
{
- out_fd = fcntl (STDERR_FILENO, F_DUPFD, 1000);
+ out_fd = fcntl64 (STDERR_FILENO, F_DUPFD, 1000);
if (out_fd == -1)
out_fd = dup (STDERR_FILENO);
}

View File

@ -0,0 +1,73 @@
commit d910ba48f47158d21c322b9f7e96831c83f69c67
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date: Wed Oct 26 16:04:23 2022 -0300
nis: Build libnsl with 64 bit time_t
And remove the usage of glibc reserved names.
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 545eefc2f5da61801ba82b7a32ca2589b769ec90)
diff --git a/Makeconfig b/Makeconfig
index 9accb5b38d1d37b3..89a2881b1ef605e4 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -885,7 +885,7 @@ endif
# Use 64 bit time_t support for installed programs
installed-modules = nonlib nscd lddlibc4 libresolv ldconfig locale_programs \
iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \
- libutil libpcprofile libSegFault
+ libutil libpcprofile libSegFault libnsl
+extra-time-flags = $(if $(filter $(installed-modules),\
$(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64)
diff --git a/nis/nis_call.c b/nis/nis_call.c
index 043f1bd4316aa284..37feba201c37cbca 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -575,7 +575,7 @@ static struct nis_server_cache
unsigned int size;
unsigned int server_used;
unsigned int current_ep;
- __time64_t expires;
+ time_t expires;
char name[];
} *nis_server_cache[16];
static time_t nis_cold_start_mtime;
@@ -584,7 +584,7 @@ __libc_lock_define_initialized (static, nis_server_cache_lock)
static directory_obj *
nis_server_cache_search (const_nis_name name, int search_parent,
unsigned int *server_used, unsigned int *current_ep,
- struct __timespec64 *now)
+ struct timespec *now)
{
directory_obj *ret = NULL;
int i;
@@ -642,7 +642,7 @@ nis_server_cache_search (const_nis_name name, int search_parent,
static void
nis_server_cache_add (const_nis_name name, int search_parent,
directory_obj *dir, unsigned int server_used,
- unsigned int current_ep, struct __timespec64 *now)
+ unsigned int current_ep, struct timespec *now)
{
struct nis_server_cache **loc;
struct nis_server_cache *new;
@@ -708,7 +708,7 @@ __nisfind_server (const_nis_name name, int search_parent,
nis_error result = NIS_SUCCESS;
nis_error status;
directory_obj *obj;
- struct __timespec64 ts;
+ struct timespec ts;
unsigned int server_used = ~0;
unsigned int current_ep = ~0;
@@ -718,7 +718,7 @@ __nisfind_server (const_nis_name name, int search_parent,
if (*dir != NULL)
return NIS_SUCCESS;
- __clock_gettime64 (CLOCK_REALTIME, &ts);
+ clock_gettime (CLOCK_REALTIME, &ts);
if ((flags & NO_CACHE) == 0)
*dir = nis_server_cache_search (name, search_parent, &server_used,

View File

@ -0,0 +1,38 @@
commit 01c0a0405c5ea63d9b528e062b935d2ff6a6e2ed
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date: Wed Oct 26 16:04:24 2022 -0300
nscd: Use 64 bit time_t on libc nscd routines (BZ# 29402)
Although the nscd module is built with 64 bit time_t, the routines
linked direct to libc.so need to use the internal symbols.
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit fa4a19277842fd09a4815a986f70e0fe0903836f)
diff --git a/nscd/nscd.h b/nscd/nscd.h
index b5da5be98a11d4de..1ce4c1f7fdb215f0 100644
--- a/nscd/nscd.h
+++ b/nscd/nscd.h
@@ -66,7 +66,7 @@ typedef enum
struct traced_file
{
/* Tracks the last modified time of the traced file. */
- time_t mtime;
+ __time64_t mtime;
/* Support multiple registered files per database. */
struct traced_file *next;
int call_res_init;
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index 81bf324256384de7..b6baa8abf881461c 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -113,7 +113,7 @@ __nscd_get_nl_timestamp (void)
if (map == NULL
|| (map != NO_MAPPING
&& map->head->nscd_certainly_running == 0
- && map->head->timestamp + MAPPING_TIMEOUT < time_now ()))
+ && map->head->timestamp + MAPPING_TIMEOUT < time64_now ()))
map = __nscd_get_mapping (GETFDHST, "hosts", &__hst_map_handle.mapped);
if (map == NO_MAPPING)

View File

@ -0,0 +1,24 @@
commit e14a91e59d35bf2fa649a9726ccce838b8c6e4b7
Author: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Date: Wed Oct 26 16:04:25 2022 -0300
time: Use 64 bit time on tzfile
The tzfile_mtime is already compared to 64 bit time_t stat call.
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 4e21c2075193e406a92c0d1cb091a7c804fda4d9)
diff --git a/time/tzfile.c b/time/tzfile.c
index 8668392ad387af05..84fd9df65f76f148 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -32,7 +32,7 @@
int __use_tzfile;
static dev_t tzfile_dev;
static ino64_t tzfile_ino;
-static time_t tzfile_mtime;
+static __time64_t tzfile_mtime;
struct ttinfo
{

View File

@ -0,0 +1,28 @@
commit d0e2ac0c5902bd0e671863cc6cb14024d0365e67
Author: Alan Modra <amodra@gmail.com>
Date: Sat Nov 12 11:20:31 2022 +1030
elf/tst-tlsopt-powerpc fails when compiled with -mcpu=power10 (BZ# 29776)
Supports pcrel addressing of TLS GOT entry. Also tweak the non-pcrel
asm constraint to better reflect how the reg is used.
(cherry picked from commit 94628de77888c3292fc103840731ff85f283368e)
diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
index ee0db12a737d6ab5..51cc502f2860e969 100644
--- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
+++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
@@ -24,7 +24,11 @@ tls_get_addr_opt_test (void)
tls_index *tls_arg;
#ifdef __powerpc64__
register unsigned long thread_pointer __asm__ ("r13");
- asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
+# ifdef __PCREL__
+ asm ("paddi %0,0,foo@got@tlsgd@pcrel,1" : "=b" (tls_arg));
+# else
+ asm ("addi %0,2,foo@got@tlsgd" : "=b" (tls_arg));
+# endif
#else
register unsigned long thread_pointer __asm__ ("r2");
asm ("bcl 20,31,1f\n1:\t"

Binary file not shown.

View File

@ -0,0 +1,526 @@
commit bbe4bbb6e8997b5ff9843bd3f32ac77dbaec7284
Author: Fangrui Song <maskray@google.com>
Date: Mon Aug 16 09:59:30 2021 -0700
elf: Drop elf/tls-macros.h in favor of __thread and tls_model attributes [BZ #28152] [BZ #28205]
elf/tls-macros.h was added for TLS testing when GCC did not support
__thread. __thread and tls_model attributes are mature now and have been
used by many newer tests.
Also delete tst-tls2.c which tests .tls_common (unused by modern GCC and
unsupported by Clang/LLD). .tls_common and .tbss definition are almost
identical after linking, so the runtime test doesn't add additional
coverage. Assembler and linker tests should be on the binutils side.
When LLD 13.0.0 is allowed in configure.ac
(https://sourceware.org/pipermail/libc-alpha/2021-August/129866.html),
`make check` result is on par with glibc built with GNU ld on aarch64
and x86_64.
As a future clean-up, TLS_GD/TLS_LD/TLS_IE/TLS_IE macros can be removed from
sysdeps/*/tls-macros.h. We can add optional -mtls-dialect={gnu2,trad}
tests to ensure coverage.
Tested on aarch64-linux-gnu, powerpc64le-linux-gnu, and x86_64-linux-gnu.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
(cherry picked from commit 33c50ef42878b07ee6ead8b3f1a81d8c2c74697c)
Conflicts:
elf/Makefile
(different backport order)
diff --git a/elf/Makefile b/elf/Makefile
index feec365e4e5fe9b3..3a8590e0d3cc33ab 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -275,7 +275,6 @@ tests-static-internal := \
tst-ptrguard1-static \
tst-stackguard1-static \
tst-tls1-static \
- tst-tls2-static \
tst-tls1-static-non-pie \
# tests-static-internal
@@ -308,7 +307,6 @@ tests := \
tests-internal := \
$(tests-static-internal) \
tst-tls1 \
- tst-tls2 \
# tests-internal
tests-static := $(tests-static-normal) $(tests-static-internal)
diff --git a/elf/tls-macros.h b/elf/tls-macros.h
deleted file mode 100644
index e25e33b0f032099d..0000000000000000
--- a/elf/tls-macros.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Macros to support TLS testing in times of missing compiler support. */
-
-#define COMMON_INT_DEF(x) \
- asm (".tls_common " #x ",4,4")
-/* XXX Until we get compiler support we don't need declarations. */
-#define COMMON_INT_DECL(x)
-
-/* XXX This definition will probably be machine specific, too. */
-#define VAR_INT_DEF(x) \
- asm (".section .tdata\n\t" \
- ".globl " #x "\n" \
- ".balign 4\n" \
- #x ":\t.long 0\n\t" \
- ".size " #x ",4\n\t" \
- ".previous")
-/* XXX Until we get compiler support we don't need declarations. */
-#define VAR_INT_DECL(x)
-
-#include_next <tls-macros.h>
-
- /* XXX Each architecture must have its own asm for now. */
-#if !defined TLS_LE || !defined TLS_IE \
- || !defined TLS_LD || !defined TLS_GD
-# error "No support for this architecture so far."
-#endif
diff --git a/elf/tst-tls1.c b/elf/tst-tls1.c
index c31da56ce9cb3e8f..b3412213ee9eaa7e 100644
--- a/elf/tst-tls1.c
+++ b/elf/tst-tls1.c
@@ -1,13 +1,14 @@
/* glibc test for TLS in ld.so. */
#include <stdio.h>
-#include "tls-macros.h"
-
-
-/* Two common 'int' variables in TLS. */
-COMMON_INT_DEF(foo);
-COMMON_INT_DEF(bar);
+__thread int foo, bar __attribute__ ((tls_model("local-exec")));
+extern __thread int foo_gd asm ("foo") __attribute__ ((tls_model("global-dynamic")));
+extern __thread int foo_ld asm ("foo") __attribute__ ((tls_model("local-dynamic")));
+extern __thread int foo_ie asm ("foo") __attribute__ ((tls_model("initial-exec")));
+extern __thread int bar_gd asm ("bar") __attribute__ ((tls_model("global-dynamic")));
+extern __thread int bar_ld asm ("bar") __attribute__ ((tls_model("local-dynamic")));
+extern __thread int bar_ie asm ("bar") __attribute__ ((tls_model("initial-exec")));
static int
do_test (void)
@@ -18,63 +19,48 @@ do_test (void)
/* Set the variable using the local exec model. */
puts ("set bar to 1 (LE)");
- ap = TLS_LE (bar);
- *ap = 1;
+ bar = 1;
/* Get variables using initial exec model. */
fputs ("get sum of foo and bar (IE)", stdout);
- ap = TLS_IE (foo);
- bp = TLS_IE (bar);
+ ap = &foo_ie;
+ bp = &bar_ie;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
+ if (*ap != 0 || *bp != 1)
{
- printf ("bar = %d\n", *bp);
+ printf ("foo = %d\nbar = %d\n", *ap, *bp);
result = 1;
}
- /* Get variables using local dynamic model. */
- fputs ("get sum of foo and bar (LD)", stdout);
- ap = TLS_LD (foo);
- bp = TLS_LD (bar);
+ /* Get variables using local dynamic model or TLSDESC. */
+ fputs ("get sum of foo and bar (LD or TLSDESC)", stdout);
+ ap = &foo_ld;
+ bp = &bar_ld;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
+ if (*ap != 0 || *bp != 1)
{
- printf ("bar = %d\n", *bp);
+ printf ("foo = %d\nbar = %d\n", *ap, *bp);
result = 1;
}
- /* Get variables using generic dynamic model. */
- fputs ("get sum of foo and bar (GD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
+ /* Get variables using general dynamic model or TLSDESC. */
+ fputs ("get sum of foo and bar (GD or TLSDESC)", stdout);
+ ap = &foo_gd;
+ bp = &bar_gd;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
+ if (*ap != 0 || *bp != 1)
{
- printf ("bar = %d\n", *bp);
+ printf ("foo = %d\nbar = %d\n", *ap, *bp);
result = 1;
}
+
return result;
}
diff --git a/elf/tst-tls2.c b/elf/tst-tls2.c
deleted file mode 100644
index 963b8d6c88bba0b5..0000000000000000
--- a/elf/tst-tls2.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* glibc test for TLS in ld.so. */
-#include <stdio.h>
-
-#include "tls-macros.h"
-
-
-/* Two 'int' variables in TLS. */
-VAR_INT_DEF(foo);
-VAR_INT_DEF(bar);
-
-
-static int
-do_test (void)
-{
- int result = 0;
- int *ap, *bp;
-
-
- /* Set the variable using the local exec model. */
- puts ("set bar to 1 (LE)");
- ap = TLS_LE (bar);
- *ap = 1;
-
-
- /* Get variables using initial exec model. */
- fputs ("get sum of foo and bar (IE)", stdout);
- ap = TLS_IE (foo);
- bp = TLS_IE (bar);
- printf (" = %d\n", *ap + *bp);
- result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
- {
- printf ("bar = %d\n", *bp);
- result = 1;
- }
-
-
- /* Get variables using local dynamic model. */
- fputs ("get sum of foo and bar (LD)", stdout);
- ap = TLS_LD (foo);
- bp = TLS_LD (bar);
- printf (" = %d\n", *ap + *bp);
- result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
- {
- printf ("bar = %d\n", *bp);
- result = 1;
- }
-
-
- /* Get variables using generic dynamic model. */
- fputs ("get sum of foo and bar (GD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
- printf (" = %d\n", *ap + *bp);
- result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
- {
- printf ("bar = %d\n", *bp);
- result = 1;
- }
-
- return result;
-}
-
-
-#include <support/test-driver.c>
diff --git a/elf/tst-tls3.c b/elf/tst-tls3.c
index 7e0abb4c58c8ff50..222b179626161897 100644
--- a/elf/tst-tls3.c
+++ b/elf/tst-tls3.c
@@ -1,13 +1,12 @@
/* glibc test for TLS in ld.so. */
#include <stdio.h>
-#include "tls-macros.h"
-
-/* One define int variable, two externs. */
-COMMON_INT_DECL(foo);
-VAR_INT_DECL(bar);
-VAR_INT_DEF(baz);
+__thread int foo, bar __attribute__ ((tls_model("initial-exec")));
+__thread int baz __attribute__ ((tls_model("local-exec")));
+extern __thread int foo_gd __attribute__ ((alias("foo"), tls_model("global-dynamic")));
+extern __thread int bar_gd __attribute__ ((alias("bar"), tls_model("global-dynamic")));
+extern __thread int baz_ld __attribute__ ((alias("baz"), tls_model("local-dynamic")));
extern int in_dso (void);
@@ -22,23 +21,20 @@ do_test (void)
/* Set the variable using the local exec model. */
puts ("set baz to 3 (LE)");
- ap = TLS_LE (baz);
- *ap = 3;
+ baz = 3;
/* Get variables using initial exec model. */
puts ("set variables foo and bar (IE)");
- ap = TLS_IE (foo);
- *ap = 1;
- bp = TLS_IE (bar);
- *bp = 2;
+ foo = 1;
+ bar = 2;
/* Get variables using local dynamic model. */
fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
- cp = TLS_LD (baz);
+ ap = &foo_gd;
+ bp = &bar_gd;
+ cp = &baz_ld;
printf (" = %d\n", *ap + *bp + *cp);
result |= *ap + *bp + *cp != 6;
if (*ap != 1)
diff --git a/elf/tst-tlsmod1.c b/elf/tst-tlsmod1.c
index 8d9156791be9eabf..a448c4dc37eaf01b 100644
--- a/elf/tst-tlsmod1.c
+++ b/elf/tst-tlsmod1.c
@@ -1,12 +1,12 @@
#include <stdio.h>
-#include "tls-macros.h"
+__thread int foo, bar __attribute__ ((tls_model("global-dynamic")));
+extern __thread int baz __attribute__ ((tls_model("global-dynamic")));
+extern __thread int foo_ie asm ("foo") __attribute__ ((tls_model("initial-exec")));
+extern __thread int bar_ie asm ("bar") __attribute__ ((tls_model("initial-exec")));
+extern __thread int baz_ie asm ("baz") __attribute__ ((tls_model("initial-exec")));
-/* One define int variable, two externs. */
-COMMON_INT_DEF(foo);
-VAR_INT_DEF(bar);
-VAR_INT_DECL(baz);
extern int in_dso (void);
@@ -19,8 +19,8 @@ in_dso (void)
/* Get variables using initial exec model. */
fputs ("get sum of foo and bar (IE)", stdout);
asm ("" ::: "memory");
- ap = TLS_IE (foo);
- bp = TLS_IE (bar);
+ ap = &foo_ie;
+ bp = &bar_ie;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 3;
if (*ap != 1)
@@ -35,11 +35,11 @@ in_dso (void)
}
- /* Get variables using generic dynamic model. */
- fputs ("get sum of foo and bar and baz (GD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
- cp = TLS_GD (baz);
+ /* Get variables using generic dynamic model or TLSDESC. */
+ fputs ("get sum of foo and bar and baz (GD or TLSDESC)", stdout);
+ ap = &foo;
+ bp = &bar;
+ cp = &baz;
printf (" = %d\n", *ap + *bp + *cp);
result |= *ap + *bp + *cp != 6;
if (*ap != 1)
diff --git a/elf/tst-tlsmod2.c b/elf/tst-tlsmod2.c
index 40eb1407f864f64a..3223fe494bb7e1f0 100644
--- a/elf/tst-tlsmod2.c
+++ b/elf/tst-tlsmod2.c
@@ -1,9 +1,7 @@
#include <stdio.h>
-#include "tls-macros.h"
-
-COMMON_INT_DEF(foo);
+__thread int foo;
int
@@ -15,7 +13,7 @@ in_dso (int n, int *caller_foop)
puts ("foo"); /* Make sure PLT is used before macros. */
asm ("" ::: "memory");
- foop = TLS_GD (foo);
+ foop = &foo;
if (caller_foop != NULL && foop != caller_foop)
{
diff --git a/elf/tst-tlsmod3.c b/elf/tst-tlsmod3.c
index 6d186c47ee6ba104..d6e7498fd8331cb7 100644
--- a/elf/tst-tlsmod3.c
+++ b/elf/tst-tlsmod3.c
@@ -1,10 +1,10 @@
#include <stdio.h>
-#include "tls-macros.h"
extern int in_dso (int n, int *caller_foop);
-COMMON_INT_DEF(comm_n);
+extern __thread int foo;
+__thread int comm_n;
@@ -20,8 +20,8 @@ in_dso2 (void)
puts ("foo"); /* Make sure PLT is used before macros. */
asm ("" ::: "memory");
- foop = TLS_GD (foo);
- np = TLS_GD (comm_n);
+ foop = &foo;
+ np = &comm_n;
if (n != *np)
{
diff --git a/elf/tst-tlsmod4.c b/elf/tst-tlsmod4.c
index 86889aac7e58bcf5..f38919a8a94861c1 100644
--- a/elf/tst-tlsmod4.c
+++ b/elf/tst-tlsmod4.c
@@ -1,9 +1,7 @@
#include <stdio.h>
-#include "tls-macros.h"
-
-COMMON_INT_DEF(baz);
+__thread int baz;
int
@@ -15,7 +13,7 @@ in_dso (int n, int *caller_bazp)
puts ("foo"); /* Make sure PLT is used before macros. */
asm ("" ::: "memory");
- bazp = TLS_GD (baz);
+ bazp = &baz;
if (caller_bazp != NULL && bazp != caller_bazp)
{
diff --git a/elf/tst-tlsmod5.c b/elf/tst-tlsmod5.c
index a97c7e5e0c69de26..3f39c5bdb76e0b5c 100644
--- a/elf/tst-tlsmod5.c
+++ b/elf/tst-tlsmod5.c
@@ -1,3 +1 @@
-#include "tls-macros.h"
-
-COMMON_INT_DEF(foo);
+__thread int foo;
diff --git a/elf/tst-tlsmod6.c b/elf/tst-tlsmod6.c
index e968596dd4ef7756..7b3571f428b7243b 100644
--- a/elf/tst-tlsmod6.c
+++ b/elf/tst-tlsmod6.c
@@ -1,3 +1 @@
-#include "tls-macros.h"
-
-COMMON_INT_DEF(bar);
+__thread int bar;
diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
index 51cc502f2860e969..d941024963fc7e6a 100644
--- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
+++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
@@ -1,11 +1,9 @@
/* shared library to test for __tls_get_addr optimization. */
#include <stdio.h>
-#include "../../elf/tls-macros.h"
#include "dl-tls.h"
-/* common 'int' variable in TLS. */
-COMMON_INT_DEF(foo);
+__thread int foo __attribute__ ((tls_model("global-dynamic")));
int
@@ -14,7 +12,7 @@ tls_get_addr_opt_test (void)
int result = 0;
/* Get variable using general dynamic model. */
- int *ap = TLS_GD (foo);
+ int *ap = &foo;
if (*ap != 0)
{
printf ("foo = %d\n", *ap);
diff --git a/sysdeps/powerpc/tst-tlsifunc.c b/sysdeps/powerpc/tst-tlsifunc.c
index 3095d41a68320d72..c8c0bada4547e1a4 100644
--- a/sysdeps/powerpc/tst-tlsifunc.c
+++ b/sysdeps/powerpc/tst-tlsifunc.c
@@ -21,9 +21,9 @@
#include <stdint.h>
#include <inttypes.h>
#include <libc-symbols.h>
-#include <tls-macros.h>
__thread int bar;
+extern __thread int bar_gd asm ("bar") __attribute__ ((tls_model("global-dynamic")));
static int *bar_ptr = NULL;
static uint32_t resolver_platform = 0;
@@ -57,7 +57,7 @@ get_platform (void)
void
init_foo (void)
{
- bar_ptr = TLS_GD (bar);
+ bar_ptr = &bar_gd;
}
int

View File

@ -0,0 +1,39 @@
commit d36f457870a807f6f29880a2f2bde5e9b761f00c
Author: Martin Sebor <msebor@redhat.com>
Date: Tue Jan 25 17:38:31 2022 -0700
intl: Avoid -Wuse-after-free [BZ #26779]
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 7845064d2d5a50e347ee9f4b78ec5e6316190154)
diff --git a/intl/localealias.c b/intl/localealias.c
index 375af2b03153acce..28041f2a48f643fa 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -318,7 +318,15 @@ read_alias_file (const char *fname, int fname_len)
if (string_space_act + alias_len + value_len > string_space_max)
{
- /* Increase size of memory pool. */
+#pragma GCC diagnostic push
+
+#if defined __GNUC__ && __GNUC__ >= 12
+ /* Suppress the valid GCC 12 warning until the code below is changed
+ to avoid using pointers to the reallocated block. */
+# pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
+
+ /* Increase size of memory pool. */
size_t new_size = (string_space_max
+ (alias_len + value_len > 1024
? alias_len + value_len : 1024));
@@ -351,6 +359,8 @@ read_alias_file (const char *fname, int fname_len)
value, value_len);
string_space_act += value_len;
+#pragma GCC diagnostic pop
+
++nmap;
++added;
}

View File

@ -0,0 +1,27 @@
commit 92d5c52aaac0fa8e58b92e96bf2025d6848a2845
Author: Martin Sebor <msebor@redhat.com>
Date: Mon Oct 11 09:36:57 2021 -0600
resolv: Avoid GCC 12 false positive warning [BZ #28439].
Replace a call to sprintf with an equivalent pair of stpcpy/strcpy calls
to avoid a GCC 12 -Wformat-overflow false positive due to recent optimizer
improvements.
(cherry picked from commit eb73b87897798de981dbbf019aa957045d768adb)
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 2f3c28cfc8c0d832..1d2c81737bc889c9 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -626,7 +626,9 @@ __res_context_querydomain (struct resolv_context *ctx,
RES_SET_H_ERRNO(statp, NO_RECOVERY);
return (-1);
}
- sprintf(nbuf, "%s.%s", name, domain);
+ char *p = __stpcpy (nbuf, name);
+ *p++ = '.';
+ strcpy (p, domain);
}
return __res_context_query (ctx, longname, class, type, answer,
anslen, answerp, answerp2, nanswerp2,

View File

@ -0,0 +1,34 @@
commit 26c7c6bac9da305b634a661aa491dae2756581ec
Author: Joseph Myers <joseph@codesourcery.com>
Date: Tue Oct 5 14:25:40 2021 +0000
Fix stdlib/tst-setcontext.c for GCC 12 -Warray-compare
Building stdlib/tst-setcontext.c fails with GCC mainline:
tst-setcontext.c: In function 'f2':
tst-setcontext.c:61:16: error: comparison between two arrays [-Werror=array-compare]
61 | if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
| ^
tst-setcontext.c:61:16: note: use '&on_stack[0] < &st2[0]' to compare the addresses
The comparison in this case is deliberate, so adjust it as suggested
in that note.
Tested with build-many-glibcs.py (GCC mainline) for aarch64-linux-gnu.
(cherry picked from commit a0f0c08e4fe18e78866539b0571f8e4b57dba7a3)
diff --git a/stdlib/tst-setcontext.c b/stdlib/tst-setcontext.c
index 1b511708c1469444..1c2925bb760c9eb4 100644
--- a/stdlib/tst-setcontext.c
+++ b/stdlib/tst-setcontext.c
@@ -58,7 +58,7 @@ f2 (void)
puts ("start f2");
printf ("&on_stack=%p\n", on_stack);
- if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
+ if (&on_stack[0] < &st2[0] || &on_stack[0] >= st2 + sizeof (st2))
{
printf ("%s: memory stack is not where it belongs!", __FUNCTION__);
exit (1);

View File

@ -0,0 +1,86 @@
commit 6ff61a51459d141782fbcc32ae81c0ef1954dad6
Author: Joseph Myers <joseph@codesourcery.com>
Date: Mon Oct 4 19:10:43 2021 +0000
Fix stdio-common tests for GCC 12 -Waddress
My glibc bot shows failures building the testsuite with GCC mainline
across all architectures:
tst-vfprintf-width-prec.c: In function 'do_test':
tst-vfprintf-width-prec.c:90:16: error: the comparison will always evaluate as 'false' for the address of 'result' will never be NULL [-Werror=address]
90 | if (result == NULL)
| ^~
tst-vfprintf-width-prec.c:89:13: note: 'result' declared here
89 | wchar_t result[100];
| ^~~~~~
This is clearly a correct warning; the comparison against NULL is
clearly a cut-and-paste mistake from an earlier case in the test that
does use calloc. Thus, remove the unnecessary check for NULL shown up
by the warning.
Similarly, two other tests have bogus comparisons against NULL; remove
those as well:
scanf14a.c:95:13: error: the comparison will always evaluate as 'false' for the address of 'fname' will never be NULL [-Werror=address]
95 | if (fname == NULL)
| ^~
scanf14a.c:93:8: note: 'fname' declared here
93 | char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
| ^~~~~
scanf16a.c:125:13: error: the comparison will always evaluate as 'false' for the address of 'fname' will never be NULL [-Werror=address]
125 | if (fname == NULL)
| ^~
scanf16a.c:123:8: note: 'fname' declared here
123 | char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
| ^~~~~
Tested with build-many-glibcs.py (GCC mainline) for aarch64-linux-gnu.
(cherry picked from commit a312e8fe6d89f5eae6a4583d5db577121e61c0b5)
diff --git a/stdio-common/scanf14a.c b/stdio-common/scanf14a.c
index 12adcff5a4970da1..b37712d1c673fa3a 100644
--- a/stdio-common/scanf14a.c
+++ b/stdio-common/scanf14a.c
@@ -92,8 +92,6 @@ main (void)
char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
sprintf (fname, "%s/tst-scanf14.XXXXXX", tmpdir);
- if (fname == NULL)
- FAIL ();
/* Create a temporary file. */
int fd = mkstemp (fname);
diff --git a/stdio-common/scanf16a.c b/stdio-common/scanf16a.c
index 400d85a54e81c3cb..74d0295c97f73b14 100644
--- a/stdio-common/scanf16a.c
+++ b/stdio-common/scanf16a.c
@@ -122,8 +122,6 @@ main (void)
char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
sprintf (fname, "%s/tst-scanf16.XXXXXX", tmpdir);
- if (fname == NULL)
- FAIL ();
/* Create a temporary file. */
int fd = mkstemp (fname);
diff --git a/stdio-common/tst-vfprintf-width-prec.c b/stdio-common/tst-vfprintf-width-prec.c
index 3192fd797ad4ea90..278d57f739f576e9 100644
--- a/stdio-common/tst-vfprintf-width-prec.c
+++ b/stdio-common/tst-vfprintf-width-prec.c
@@ -87,12 +87,6 @@ do_test (void)
}
{
wchar_t result[100];
- if (result == NULL)
- {
- printf ("error: calloc (%d, %zu): %m", ret + 1, sizeof (wchar_t));
- return 1;
- }
-
ret = swprintf (result, 100, L"%133000.999999999x", 17);
if (ret >= 0)
{

View File

@ -0,0 +1,33 @@
commit 803c959745fd7c679e00f9bad58822616f0e51cb
Author: Joseph Myers <joseph@codesourcery.com>
Date: Mon Aug 2 16:33:44 2021 +0000
Fix build of nptl/tst-thread_local1.cc with GCC 12
The test nptl/tst-thread_local1.cc fails to build with GCC mainline
because of changes to what libstdc++ headers implicitly include what
other headers:
tst-thread_local1.cc: In function 'int do_test()':
tst-thread_local1.cc:177:5: error: variable 'std::array<std::pair<const char*, std::function<void(void* (*)(void*))> >, 2> do_thread_X' has initializer but incomplete type
177 | do_thread_X
| ^~~~~~~~~~~
Fix this by adding an explicit include of <array>.
Tested with build-many-glibcs.py for aarch64-linux-gnu.
(cherry picked from commit 2ee9b24f47db8d0a8d0ccadb999335a1d4cfc364)
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 9608afa4b739e360..338aafea059e10b7 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
+#include <array>
#include <functional>
#include <string>
#include <thread>

View File

@ -0,0 +1,176 @@
commit 88b3228d9f6322b035fa89bb34f82d93b4190d48
Author: Martin Sebor <msebor@redhat.com>
Date: Tue Jan 25 15:39:38 2022 -0700
Avoid -Wuse-after-free in tests [BZ #26779].
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit c094c232eb3246154265bb035182f92fe1b17ab8)
diff --git a/malloc/tst-malloc-backtrace.c b/malloc/tst-malloc-backtrace.c
index 4eb42e7f32f706e9..2ae3fb11efc245cb 100644
--- a/malloc/tst-malloc-backtrace.c
+++ b/malloc/tst-malloc-backtrace.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <support/support.h>
+#include <libc-diag.h>
#define SIZE 4096
@@ -29,7 +30,15 @@ __attribute__((noinline))
call_free (void *ptr)
{
free (ptr);
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a valid warning about using a pointer made indeterminate
+ by a prior call to free(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
*(size_t *)(ptr - sizeof (size_t)) = 1;
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
}
int
diff --git a/malloc/tst-malloc-check.c b/malloc/tst-malloc-check.c
index 6650d09cf6cdde75..c5c9254a9e8936b0 100644
--- a/malloc/tst-malloc-check.c
+++ b/malloc/tst-malloc-check.c
@@ -87,7 +87,15 @@ do_test (void)
merror ("errno is not set correctly.");
DIAG_POP_NEEDS_COMMENT;
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a valid warning about using a pointer made indeterminate
+ by a prior call to realloc(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
free (p);
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
p = malloc (512);
if (p == NULL)
@@ -105,7 +113,15 @@ do_test (void)
merror ("errno is not set correctly.");
DIAG_POP_NEEDS_COMMENT;
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a valid warning about using a pointer made indeterminate
+ by a prior call to realloc(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
free (p);
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
free (q);
return errors != 0;
diff --git a/malloc/tst-malloc-too-large.c b/malloc/tst-malloc-too-large.c
index a4349a9b4c506dfc..328b4a2a4fd72cf4 100644
--- a/malloc/tst-malloc-too-large.c
+++ b/malloc/tst-malloc-too-large.c
@@ -95,7 +95,15 @@ test_large_allocations (size_t size)
DIAG_POP_NEEDS_COMMENT;
#endif
TEST_VERIFY (errno == ENOMEM);
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a warning about using a pointer made indeterminate by
+ a prior call to realloc(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
free (ptr_to_realloc);
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
for (size_t nmemb = 1; nmemb <= 8; nmemb *= 2)
if ((size % nmemb) == 0)
@@ -113,14 +121,30 @@ test_large_allocations (size_t size)
test_setup ();
TEST_VERIFY (reallocarray (ptr_to_realloc, nmemb, size / nmemb) == NULL);
TEST_VERIFY (errno == ENOMEM);
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a warning about using a pointer made indeterminate by
+ a prior call to realloc(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
free (ptr_to_realloc);
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
ptr_to_realloc = malloc (16);
TEST_VERIFY_EXIT (ptr_to_realloc != NULL);
test_setup ();
TEST_VERIFY (reallocarray (ptr_to_realloc, size / nmemb, nmemb) == NULL);
TEST_VERIFY (errno == ENOMEM);
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a warning about using a pointer made indeterminate by
+ a prior call to realloc(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
free (ptr_to_realloc);
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
}
else
break;
diff --git a/malloc/tst-obstack.c b/malloc/tst-obstack.c
index ee1385d0f764e368..7d700c4f9a86b676 100644
--- a/malloc/tst-obstack.c
+++ b/malloc/tst-obstack.c
@@ -21,8 +21,8 @@ verbose_malloc (size_t size)
static void
verbose_free (void *buf)
{
- free (buf);
printf ("free (%p)\n", buf);
+ free (buf);
}
static int
diff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c
index c89ac07e192d70eb..80711beab1257ed5 100644
--- a/malloc/tst-realloc.c
+++ b/malloc/tst-realloc.c
@@ -138,8 +138,16 @@ do_test (void)
if (ok == 0)
merror ("first 16 bytes were not correct after failed realloc");
+#if __GNUC_PREREQ (12, 0)
+ /* Ignore a valid warning about using a pointer made indeterminate
+ by a prior call to realloc(). */
+ DIAG_IGNORE_NEEDS_COMMENT (12, "-Wuse-after-free");
+#endif
/* realloc (p, 0) frees p (C89) and returns NULL (glibc). */
p = realloc (p, 0);
+#if __GNUC_PREREQ (12, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
if (p != NULL)
merror ("realloc (p, 0) returned non-NULL.");
diff --git a/support/tst-support-open-dev-null-range.c b/support/tst-support-open-dev-null-range.c
index 8e29def1ce780629..80c97e51586bf6ce 100644
--- a/support/tst-support-open-dev-null-range.c
+++ b/support/tst-support-open-dev-null-range.c
@@ -39,10 +39,11 @@ check_path (int fd)
char file_path[PATH_MAX];
ssize_t file_path_length
= readlink (proc_fd_path, file_path, sizeof (file_path));
- free (proc_fd_path);
if (file_path_length < 0)
FAIL_EXIT1 ("readlink (%s, %p, %zu)", proc_fd_path, file_path,
sizeof (file_path));
+
+ free (proc_fd_path);
file_path[file_path_length] = '\0';
TEST_COMPARE_STRING (file_path, "/dev/null");
}

View File

@ -0,0 +1,28 @@
commit dd0c72fb461a8879164588cd870702efae0c7237
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Dec 20 15:15:12 2021 -0800
Regenerate ulps on x86_64 with GCC 12
Fix
FAIL: math/test-float-clog10
FAIL: math/test-float32-clog10
on Intel Core i7-1165G7 with GCC 12.
(cherry picked from commit de8a0897e3c084dc93676e331b610f146000a0ab)
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 312575f93397c4b0..1c75f0ead46819a7 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -705,7 +705,7 @@ ldouble: 3
Function: Real part of "clog10_towardzero":
double: 5
-float: 5
+float: 6
float128: 4
ldouble: 8

View File

@ -0,0 +1,111 @@
commit 80b24b86548eee3d96130a48e760d1d6c2e0c587
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Dec 20 15:00:24 2021 -0800
math: Properly cast X_TLOSS to float [BZ #28713]
Add
#define AS_FLOAT_CONSTANT_1(x) x##f
#define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x)
to cast X_TLOSS to float at compile-time to fix:
FAIL: math/test-float-j0
FAIL: math/test-float-jn
FAIL: math/test-float-y0
FAIL: math/test-float-y1
FAIL: math/test-float-yn
FAIL: math/test-float32-j0
FAIL: math/test-float32-jn
FAIL: math/test-float32-y0
FAIL: math/test-float32-y1
FAIL: math/test-float32-yn
when compiling with GCC 12.
Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
(cherry picked from commit 6e30181b4a3ab6c56da0378b65f4d60504982300)
diff --git a/math/math-svid-compat.h b/math/math-svid-compat.h
index 5c18cb1b039cb3be..876cadde4084dab0 100644
--- a/math/math-svid-compat.h
+++ b/math/math-svid-compat.h
@@ -49,6 +49,8 @@ extern int matherr (struct exception *__exc);
extern int __matherr (struct exception *__exc);
#define X_TLOSS 1.41484755040568800000e+16
+#define AS_FLOAT_CONSTANT_1(x) x##f
+#define AS_FLOAT_CONSTANT(x) AS_FLOAT_CONSTANT_1(x)
/* Types of exceptions in the `type' field. */
#define DOMAIN 1
diff --git a/math/w_j0f_compat.c b/math/w_j0f_compat.c
index a4882eadb33853b2..f35a55219f7baa78 100644
--- a/math/w_j0f_compat.c
+++ b/math/w_j0f_compat.c
@@ -28,7 +28,8 @@
float
__j0f (float x)
{
- if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
+ if (__builtin_expect (isgreater (fabsf (x),
+ AS_FLOAT_CONSTANT (X_TLOSS)), 0)
&& _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
/* j0(|x|>X_TLOSS) */
return __kernel_standard_f (x, x, 134);
@@ -43,7 +44,7 @@ float
__y0f (float x)
{
if (__builtin_expect (islessequal (x, 0.0f)
- || isgreater (x, (float) X_TLOSS), 0)
+ || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
&& _LIB_VERSION != _IEEE_)
{
if (x < 0.0f)
diff --git a/math/w_j1f_compat.c b/math/w_j1f_compat.c
index f2ec7b327d2bc90a..c5e3ccd035031799 100644
--- a/math/w_j1f_compat.c
+++ b/math/w_j1f_compat.c
@@ -28,7 +28,8 @@
float
__j1f (float x)
{
- if (__builtin_expect (isgreater (fabsf (x), X_TLOSS), 0)
+ if (__builtin_expect (isgreater (fabsf (x),
+ AS_FLOAT_CONSTANT (X_TLOSS)), 0)
&& _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
/* j1(|x|>X_TLOSS) */
return __kernel_standard_f (x, x, 136);
@@ -43,7 +44,7 @@ float
__y1f (float x)
{
if (__builtin_expect (islessequal (x, 0.0f)
- || isgreater (x, (float) X_TLOSS), 0)
+ || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
&& _LIB_VERSION != _IEEE_)
{
if (x < 0.0f)
diff --git a/math/w_jnf_compat.c b/math/w_jnf_compat.c
index fb6e5060096fb070..925ccc4cd0988a8f 100644
--- a/math/w_jnf_compat.c
+++ b/math/w_jnf_compat.c
@@ -28,7 +28,8 @@
float
__jnf (int n, float x)
{
- if (__builtin_expect (isgreater (fabsf (x), (float) X_TLOSS), 0)
+ if (__builtin_expect (isgreater (fabsf (x),
+ AS_FLOAT_CONSTANT (X_TLOSS)), 0)
&& _LIB_VERSION != _IEEE_ && _LIB_VERSION != _POSIX_)
/* jn(n,|x|>X_TLOSS) */
return __kernel_standard_f (n, x, 138);
@@ -43,7 +44,7 @@ float
__ynf (int n, float x)
{
if (__builtin_expect (islessequal (x, 0.0f)
- || isgreater (x, (float) X_TLOSS), 0)
+ || isgreater (x, AS_FLOAT_CONSTANT (X_TLOSS)), 0)
&& _LIB_VERSION != _IEEE_)
{
if (x < 0.0f)

View File

@ -0,0 +1,43 @@
commit c5c666f34939d4bbf73aac8b753ab39621ebf33c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Dec 20 14:37:26 2021 -0800
s_sincosf.h: Change pio4 type to float [BZ #28713]
s_cosf.c and s_sinf.c have
if (abstop12 (y) < abstop12 (pio4))
where abstop12 takes a float argument, but pio4 is static const double.
pio4 is used only in calls to abstop12 and never in arithmetic. Apply
-static const double pio4 = 0x1.921FB54442D18p-1;
+static const float pio4 = 0x1.921FB6p-1f;
to fix:
FAIL: math/test-float-cos
FAIL: math/test-float-sin
FAIL: math/test-float-sincos
FAIL: math/test-float32-cos
FAIL: math/test-float32-sin
FAIL: math/test-float32-sincos
when compiling with GCC 12.
Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
(cherry picked from commit d3e4f5a1014db09ff1c62c6506f92cba469e193d)
diff --git a/sysdeps/ieee754/flt-32/s_sincosf.h b/sysdeps/ieee754/flt-32/s_sincosf.h
index 125ab7f846c463c6..372d8542c2c9a9c7 100644
--- a/sysdeps/ieee754/flt-32/s_sincosf.h
+++ b/sysdeps/ieee754/flt-32/s_sincosf.h
@@ -24,7 +24,7 @@
/* 2PI * 2^-64. */
static const double pi63 = 0x1.921FB54442D18p-62;
/* PI / 4. */
-static const double pio4 = 0x1.921FB54442D18p-1;
+static const float pio4 = 0x1.921FB6p-1f;
/* Polynomial data (the cosine polynomial is negated in the 2nd entry). */
extern const sincos_t __sincosf_table[2] attribute_hidden;

View File

@ -0,0 +1,83 @@
commit 6484ae5b8c4d4314f748e4d3c9a9baa5385e57c5
Author: Carlos O'Donell <carlos@redhat.com>
Date: Fri Jan 28 15:14:29 2022 -0500
malloc: Fix -Wuse-after-free warning in tst-mallocalign1 [BZ #26779]
The test leaks bits from the freed pointer via the return value
in ret, and the compiler correctly identifies this issue.
We switch the test to use TEST_VERIFY and terminate the test
if any of the pointers return an unexpected alignment.
This fixes another -Wuse-after-free error when compiling glibc
with gcc 12.
Tested on x86_64 and i686 without regression.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 3a7bed5f5a527dbd87412551f41e42e63aeef07a)
diff --git a/malloc/tst-mallocalign1.c b/malloc/tst-mallocalign1.c
index 294e821afebd25ac..3e09ff30c4aa9f91 100644
--- a/malloc/tst-mallocalign1.c
+++ b/malloc/tst-mallocalign1.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <inttypes.h>
#include <malloc-size.h>
+#include <support/check.h>
static void *
test (size_t s)
@@ -31,41 +32,42 @@ test (size_t s)
return p;
}
+#define ALIGNED(p) (((uintptr_t )p & MALLOC_ALIGN_MASK) == 0)
+
static int
do_test (void)
{
void *p;
- int ret = 0;
p = test (2);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
p = test (8);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
p = test (13);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
p = test (16);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
p = test (23);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
p = test (43);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
p = test (123);
- ret |= (uintptr_t) p & MALLOC_ALIGN_MASK;
+ TEST_VERIFY (ALIGNED (p));
free (p);
- return ret;
+ return 0;
}
#include <support/test-driver.c>

View File

@ -155,7 +155,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 56%{?dist}
Release: 57%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -677,6 +677,23 @@ Patch445: glibc-upstream-2.34-365.patch
Patch446: glibc-rh2149102.patch
Patch447: glibc-upstream-2.34-366.patch
Patch448: glibc-upstream-2.34-367.patch
Patch449: glibc-upstream-2.34-368.patch
Patch450: glibc-upstream-2.34-369.patch
Patch451: glibc-upstream-2.34-370.patch
Patch452: glibc-upstream-2.34-371.patch
Patch453: glibc-upstream-2.34-372.patch
Patch454: glibc-upstream-2.34-373.patch
Patch455: glibc-upstream-2.34-374.patch
Patch456: glibc-upstream-2.34-375.patch
Patch457: glibc-upstream-2.34-376.patch
Patch458: glibc-upstream-2.34-377.patch
Patch459: glibc-upstream-2.34-378.patch
Patch460: glibc-upstream-2.34-379.patch
Patch461: glibc-upstream-2.34-380.patch
Patch462: glibc-upstream-2.34-381.patch
Patch463: glibc-upstream-2.34-382.patch
Patch464: glibc-upstream-2.34-383.patch
Patch465: glibc-upstream-2.34-384.patch
##############################################################################
# Continued list of core "glibc" package information:
@ -2836,6 +2853,27 @@ fi
%endif
%changelog
* Tue Jan 17 2023 Florian Weimer <fweimer@redhat.com> - 2.34-57
- Sync with upstream branch release/2.34/master,
commit 6484ae5b8c4d4314f748e4d3c9a9baa5385e57c5
- malloc: Fix -Wuse-after-free warning in tst-mallocalign1 [BZ #26779]
- s_sincosf.h: Change pio4 type to float [BZ #28713]
- math: Properly cast X_TLOSS to float [BZ #28713]
- Regenerate ulps on x86_64 with GCC 12
- Avoid -Wuse-after-free in tests [BZ #26779].
- Fix build of nptl/tst-thread_local1.cc with GCC 12
- Fix stdio-common tests for GCC 12 -Waddress
- Fix stdlib/tst-setcontext.c for GCC 12 -Warray-compare
- resolv: Avoid GCC 12 false positive warning [BZ #28439].
- intl: Avoid -Wuse-after-free [BZ #26779]
- elf: Drop elf/tls-macros.h in favor of __thread and tls_model attributes [BZ #28152] [BZ #28205]
- time: Set daylight to 1 for matching DST/offset change (RHBZ#2155352)
- elf/tst-tlsopt-powerpc fails when compiled with -mcpu=power10 (BZ# 29776)
- time: Use 64 bit time on tzfile
- nscd: Use 64 bit time_t on libc nscd routines (BZ# 29402)
- nis: Build libnsl with 64 bit time_t
- Use LFS and 64 bit time for installed programs (BZ #15333)
* Mon Dec 12 2022 Tulio Magno Quites Machado Filho <tuliom@redhat.com> - 2.34-56
- Earlier removal of alternative multilibs (#2149994)