Import glibc-2.34-29.fc35 from f35
* Tue Mar 15 2022 Florian Weimer <fweimer@redhat.com> - 2.34-29 - Sync with upstream branch release/2.34/master, commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704: - debug: Synchronize feature guards in fortified functions [BZ #28746] - debug: Autogenerate _FORTIFY_SOURCE tests - Enable _FORTIFY_SOURCE=3 for gcc 12 and above - fortify: Fix spurious warning with realpath - __glibc_unsafe_len: Fix comment - debug: Add tests for _FORTIFY_SOURCE=3 - Make sure that the fortified function conditionals are constant - Don't add access size hints to fortifiable functions - nss: Protect against errno changes in function lookup (bug 28953) - nss: Do not mention NSS test modules in <gnu/lib-names.h> - io: Add fsync call in tst-stat - hppa: Fix warnings from _dl_lookup_address - nptl: Fix cleanups for stack grows up [BZ# 28899] - hppa: Revise gettext trampoline design - hppa: Fix swapcontext - Fix elf/tst-audit2 on hppa - localedef: Handle symbolic links when generating locale-archive - NEWS: Add a bug fix entry for BZ #28896 - x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c - x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896] - x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896] - string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] - linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865] - Add reference to BZ#28860 on NEWS - linux: Fix missing __convert_scm_timestamps (BZ #28860) Resolves: #2063230 Resolves: #2033683 Resolves: #2063041 Resolves: #2063142
This commit is contained in:
parent
d6cd878dc9
commit
42eb238e49
2914
ChangeLog.old
2914
ChangeLog.old
File diff suppressed because it is too large
Load Diff
32
glibc-upstream-2.34-108.patch
Normal file
32
glibc-upstream-2.34-108.patch
Normal file
@ -0,0 +1,32 @@
|
||||
commit 0351c75c5f94134fcec0e778e8cf86d149f8bbfb
|
||||
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
Date: Thu Feb 3 16:52:52 2022 -0300
|
||||
|
||||
linux: Fix missing __convert_scm_timestamps (BZ #28860)
|
||||
|
||||
Commit 948ce73b31 made recvmsg/recvmmsg to always call
|
||||
__convert_scm_timestamps for 64 bit time_t symbol, so adjust it to
|
||||
always build it for __TIMESIZE != 64.
|
||||
|
||||
It fixes build for architecture with 32 bit time_t support when
|
||||
configured with minimum kernel of 5.1.
|
||||
|
||||
(cherry-picked from 798d716df71fb23dc89d1d5dba1fc26a1b5c0024)
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
|
||||
index 5d3c4199e0b32944..953ce97bd2e03849 100644
|
||||
--- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
|
||||
+++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
|
||||
@@ -16,9 +16,10 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
-#include <kernel-features.h>
|
||||
+#include <bits/wordsize.h>
|
||||
+#include <bits/timesize.h>
|
||||
|
||||
-#ifndef __ASSUME_TIME64_SYSCALLS
|
||||
+#if __TIMESIZE != 64
|
||||
# include <stdint.h>
|
||||
# include <string.h>
|
||||
# include <sys/socket.h>
|
192
glibc-upstream-2.34-110.patch
Normal file
192
glibc-upstream-2.34-110.patch
Normal file
@ -0,0 +1,192 @@
|
||||
commit 007e054d786be340699c634e3a3b30ab1fde1a7a
|
||||
Author: Dmitry V. Levin <ldv@altlinux.org>
|
||||
Date: Sat Feb 5 08:00:00 2022 +0000
|
||||
|
||||
linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]
|
||||
|
||||
get_nprocs() and get_nprocs_conf() use various methods to obtain an
|
||||
accurate number of processors. Re-introduce __get_nprocs_sched() as
|
||||
a source of information, and fix the order in which these methods are
|
||||
used to return the most accurate information. The primary source of
|
||||
information used in both functions remains unchanged.
|
||||
|
||||
This also changes __get_nprocs_sched() error return value from 2 to 0,
|
||||
but all its users are already prepared to handle that.
|
||||
|
||||
Old fallback order:
|
||||
get_nprocs:
|
||||
/sys/devices/system/cpu/online -> /proc/stat -> 2
|
||||
get_nprocs_conf:
|
||||
/sys/devices/system/cpu/ -> /proc/stat -> 2
|
||||
|
||||
New fallback order:
|
||||
get_nprocs:
|
||||
/sys/devices/system/cpu/online -> /proc/stat -> sched_getaffinity -> 2
|
||||
get_nprocs_conf:
|
||||
/sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2
|
||||
|
||||
Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc")
|
||||
Closes: BZ #28865
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
|
||||
(cherry picked from commit e1d32b836410767270a3adf1f82b1a47e6e4cd51)
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
|
||||
index 7babd947aa902e77..327802b14c7326a3 100644
|
||||
--- a/sysdeps/unix/sysv/linux/getsysstats.c
|
||||
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
|
||||
@@ -51,9 +51,8 @@ __get_nprocs_sched (void)
|
||||
is an arbitrary values assuming such systems should be rare and there
|
||||
is no offline cpus. */
|
||||
return max_num_cpus;
|
||||
- /* Some other error. 2 is conservative (not a uniprocessor system, so
|
||||
- atomics are needed). */
|
||||
- return 2;
|
||||
+ /* Some other error. */
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -109,22 +108,19 @@ next_line (int fd, char *const buffer, char **cp, char **re,
|
||||
}
|
||||
|
||||
static int
|
||||
-get_nproc_stat (char *buffer, size_t buffer_size)
|
||||
+get_nproc_stat (void)
|
||||
{
|
||||
+ enum { buffer_size = 1024 };
|
||||
+ char buffer[buffer_size];
|
||||
char *buffer_end = buffer + buffer_size;
|
||||
char *cp = buffer_end;
|
||||
char *re = buffer_end;
|
||||
-
|
||||
- /* Default to an SMP system in case we cannot obtain an accurate
|
||||
- number. */
|
||||
- int result = 2;
|
||||
+ int result = 0;
|
||||
|
||||
const int flags = O_RDONLY | O_CLOEXEC;
|
||||
int fd = __open_nocancel ("/proc/stat", flags);
|
||||
if (fd != -1)
|
||||
{
|
||||
- result = 0;
|
||||
-
|
||||
char *l;
|
||||
while ((l = next_line (fd, buffer, &cp, &re, buffer_end)) != NULL)
|
||||
/* The current format of /proc/stat has all the cpu* entries
|
||||
@@ -140,8 +136,8 @@ get_nproc_stat (char *buffer, size_t buffer_size)
|
||||
return result;
|
||||
}
|
||||
|
||||
-int
|
||||
-__get_nprocs (void)
|
||||
+static int
|
||||
+get_nprocs_cpu_online (void)
|
||||
{
|
||||
enum { buffer_size = 1024 };
|
||||
char buffer[buffer_size];
|
||||
@@ -180,7 +176,8 @@ __get_nprocs (void)
|
||||
}
|
||||
}
|
||||
|
||||
- result += m - n + 1;
|
||||
+ if (m >= n)
|
||||
+ result += m - n + 1;
|
||||
|
||||
l = endp;
|
||||
if (l < re && *l == ',')
|
||||
@@ -189,28 +186,18 @@ __get_nprocs (void)
|
||||
while (l < re && *l != '\n');
|
||||
|
||||
__close_nocancel_nostatus (fd);
|
||||
-
|
||||
- if (result > 0)
|
||||
- return result;
|
||||
}
|
||||
|
||||
- return get_nproc_stat (buffer, buffer_size);
|
||||
+ return result;
|
||||
}
|
||||
-libc_hidden_def (__get_nprocs)
|
||||
-weak_alias (__get_nprocs, get_nprocs)
|
||||
-
|
||||
|
||||
-/* On some architectures it is possible to distinguish between configured
|
||||
- and active cpus. */
|
||||
-int
|
||||
-__get_nprocs_conf (void)
|
||||
+static int
|
||||
+get_nprocs_cpu (void)
|
||||
{
|
||||
- /* Try to use the sysfs filesystem. It has actual information about
|
||||
- online processors. */
|
||||
+ int count = 0;
|
||||
DIR *dir = __opendir ("/sys/devices/system/cpu");
|
||||
if (dir != NULL)
|
||||
{
|
||||
- int count = 0;
|
||||
struct dirent64 *d;
|
||||
|
||||
while ((d = __readdir64 (dir)) != NULL)
|
||||
@@ -225,12 +212,57 @@ __get_nprocs_conf (void)
|
||||
|
||||
__closedir (dir);
|
||||
|
||||
- return count;
|
||||
}
|
||||
+ return count;
|
||||
+}
|
||||
|
||||
- enum { buffer_size = 1024 };
|
||||
- char buffer[buffer_size];
|
||||
- return get_nproc_stat (buffer, buffer_size);
|
||||
+static int
|
||||
+get_nprocs_fallback (void)
|
||||
+{
|
||||
+ int result;
|
||||
+
|
||||
+ /* Try /proc/stat first. */
|
||||
+ result = get_nproc_stat ();
|
||||
+ if (result != 0)
|
||||
+ return result;
|
||||
+
|
||||
+ /* Try sched_getaffinity. */
|
||||
+ result = __get_nprocs_sched ();
|
||||
+ if (result != 0)
|
||||
+ return result;
|
||||
+
|
||||
+ /* We failed to obtain an accurate number. Be conservative: return
|
||||
+ the smallest number meaning that this is not a uniprocessor system,
|
||||
+ so atomics are needed. */
|
||||
+ return 2;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+__get_nprocs (void)
|
||||
+{
|
||||
+ /* Try /sys/devices/system/cpu/online first. */
|
||||
+ int result = get_nprocs_cpu_online ();
|
||||
+ if (result != 0)
|
||||
+ return result;
|
||||
+
|
||||
+ /* Fall back to /proc/stat and sched_getaffinity. */
|
||||
+ return get_nprocs_fallback ();
|
||||
+}
|
||||
+libc_hidden_def (__get_nprocs)
|
||||
+weak_alias (__get_nprocs, get_nprocs)
|
||||
+
|
||||
+/* On some architectures it is possible to distinguish between configured
|
||||
+ and active cpus. */
|
||||
+int
|
||||
+__get_nprocs_conf (void)
|
||||
+{
|
||||
+ /* Try /sys/devices/system/cpu/ first. */
|
||||
+ int result = get_nprocs_cpu ();
|
||||
+ if (result != 0)
|
||||
+ return result;
|
||||
+
|
||||
+ /* Fall back to /proc/stat and sched_getaffinity. */
|
||||
+ return get_nprocs_fallback ();
|
||||
}
|
||||
libc_hidden_def (__get_nprocs_conf)
|
||||
weak_alias (__get_nprocs_conf, get_nprocs_conf)
|
60
glibc-upstream-2.34-111.patch
Normal file
60
glibc-upstream-2.34-111.patch
Normal file
@ -0,0 +1,60 @@
|
||||
commit 04d60ce0f21ffe2a4add148cb37a1942dbad64e2
|
||||
Author: H.J. Lu <hjl.tools@gmail.com>
|
||||
Date: Thu Feb 17 08:10:35 2022 -0800
|
||||
|
||||
string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
|
||||
|
||||
Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test
|
||||
fails without
|
||||
|
||||
commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
|
||||
Author: Noah Goldstein <goldstein.w.n@gmail.com>
|
||||
Date: Sun Jan 9 16:02:21 2022 -0600
|
||||
|
||||
x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
|
||||
|
||||
and
|
||||
|
||||
commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
|
||||
Author: Noah Goldstein <goldstein.w.n@gmail.com>
|
||||
Date: Sun Jan 9 16:02:28 2022 -0600
|
||||
|
||||
x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
|
||||
|
||||
This is for BZ #28755.
|
||||
|
||||
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
|
||||
|
||||
(cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
|
||||
|
||||
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
|
||||
index 10b34de8d2acb2a1..97e831d88fd24316 100644
|
||||
--- a/string/test-strncmp.c
|
||||
+++ b/string/test-strncmp.c
|
||||
@@ -435,6 +435,18 @@ check3 (void)
|
||||
}
|
||||
}
|
||||
|
||||
+static void
|
||||
+check4 (void)
|
||||
+{
|
||||
+ const CHAR *s1 = L ("abc");
|
||||
+ CHAR *s2 = STRDUP (s1);
|
||||
+
|
||||
+ FOR_EACH_IMPL (impl, 0)
|
||||
+ check_result (impl, s1, s2, SIZE_MAX, 0);
|
||||
+
|
||||
+ free (s2);
|
||||
+}
|
||||
+
|
||||
int
|
||||
test_main (void)
|
||||
{
|
||||
@@ -445,6 +457,7 @@ test_main (void)
|
||||
check1 ();
|
||||
check2 ();
|
||||
check3 ();
|
||||
+ check4 ();
|
||||
|
||||
printf ("%23s", "");
|
||||
FOR_EACH_IMPL (impl, 0)
|
120
glibc-upstream-2.34-112.patch
Normal file
120
glibc-upstream-2.34-112.patch
Normal file
@ -0,0 +1,120 @@
|
||||
commit 38e0d2479413ccdbc02b4c9e9e246eca31e956c9
|
||||
Author: Noah Goldstein <goldstein.w.n@gmail.com>
|
||||
Date: Tue Feb 15 08:18:15 2022 -0600
|
||||
|
||||
x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896]
|
||||
|
||||
In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
|
||||
call strcmp-avx2 and wcscmp-avx2 respectively. This would have
|
||||
not checks around vzeroupper and would trigger spurious
|
||||
aborts. This commit fixes that.
|
||||
|
||||
test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
|
||||
AVX2 machines with and without RTM.
|
||||
|
||||
Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
|
||||
|
||||
(cherry picked from commit c6272098323153db373f2986c67786ea8c85f1cf)
|
||||
|
||||
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
|
||||
index 36ca1a7126047b86..af934d6ccf1fa337 100644
|
||||
--- a/sysdeps/x86/Makefile
|
||||
+++ b/sysdeps/x86/Makefile
|
||||
@@ -105,7 +105,7 @@ CFLAGS-tst-memset-rtm.c += -mrtm
|
||||
CFLAGS-tst-strchr-rtm.c += -mrtm
|
||||
CFLAGS-tst-strcpy-rtm.c += -mrtm
|
||||
CFLAGS-tst-strlen-rtm.c += -mrtm
|
||||
-CFLAGS-tst-strncmp-rtm.c += -mrtm
|
||||
+CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error
|
||||
CFLAGS-tst-strrchr-rtm.c += -mrtm
|
||||
endif
|
||||
|
||||
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
|
||||
index 236ad951b5b59cd1..4d0004b58aae428d 100644
|
||||
--- a/sysdeps/x86/tst-strncmp-rtm.c
|
||||
+++ b/sysdeps/x86/tst-strncmp-rtm.c
|
||||
@@ -16,6 +16,7 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
+#include <stdint.h>
|
||||
#include <tst-string-rtm.h>
|
||||
|
||||
#define LOOP 3000
|
||||
@@ -45,8 +46,22 @@ function (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
+__attribute__ ((noinline, noclone))
|
||||
+static int
|
||||
+function_overflow (void)
|
||||
+{
|
||||
+ if (strncmp (string1, string2, SIZE_MAX) == 0)
|
||||
+ return 0;
|
||||
+ else
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
- return do_test_1 ("strncmp", LOOP, prepare, function);
|
||||
+ int status = do_test_1 ("strncmp", LOOP, prepare, function);
|
||||
+ if (status != EXIT_SUCCESS)
|
||||
+ return status;
|
||||
+ status = do_test_1 ("strncmp", LOOP, prepare, function_overflow);
|
||||
+ return status;
|
||||
}
|
||||
diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
|
||||
index 3dfcb1bf803cf9ec..fa70c994fc25dfd8 100644
|
||||
--- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
|
||||
+++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
|
||||
@@ -95,7 +95,7 @@ ENTRY (STRCMP)
|
||||
length to bound a valid memory region. In these cases just use
|
||||
'wcscmp'. */
|
||||
shrq $56, %rcx
|
||||
- jnz __wcscmp_avx2
|
||||
+ jnz OVERFLOW_STRCMP
|
||||
# endif
|
||||
/* Convert units: from wide to byte char. */
|
||||
shl $2, %RDX_LP
|
||||
diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
|
||||
index 37d1224bb9b7056b..68bad365ba728eec 100644
|
||||
--- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
|
||||
+++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
|
||||
@@ -1,3 +1,4 @@
|
||||
#define STRCMP __strncmp_avx2_rtm
|
||||
#define USE_AS_STRNCMP 1
|
||||
+#define OVERFLOW_STRCMP __strcmp_avx2_rtm
|
||||
#include "strcmp-avx2-rtm.S"
|
||||
diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S
|
||||
index 1678bcc235a4bc6a..f138e9f1fdcf277c 100644
|
||||
--- a/sysdeps/x86_64/multiarch/strncmp-avx2.S
|
||||
+++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S
|
||||
@@ -1,3 +1,4 @@
|
||||
#define STRCMP __strncmp_avx2
|
||||
#define USE_AS_STRNCMP 1
|
||||
+#define OVERFLOW_STRCMP __strcmp_avx2
|
||||
#include "strcmp-avx2.S"
|
||||
diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
|
||||
index 4e88c70cc696b82d..f467582cbedd4535 100644
|
||||
--- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
|
||||
+++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
|
||||
@@ -1,5 +1,5 @@
|
||||
#define STRCMP __wcsncmp_avx2_rtm
|
||||
#define USE_AS_STRNCMP 1
|
||||
#define USE_AS_WCSCMP 1
|
||||
-
|
||||
+#define OVERFLOW_STRCMP __wcscmp_avx2_rtm
|
||||
#include "strcmp-avx2-rtm.S"
|
||||
diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
|
||||
index 4fa1de4d3f1f97ff..e9ede522b8bde27d 100644
|
||||
--- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
|
||||
+++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
|
||||
@@ -1,5 +1,5 @@
|
||||
#define STRCMP __wcsncmp_avx2
|
||||
#define USE_AS_STRNCMP 1
|
||||
#define USE_AS_WCSCMP 1
|
||||
-
|
||||
+#define OVERFLOW_STRCMP __wcscmp_avx2
|
||||
#include "strcmp-avx2.S"
|
139
glibc-upstream-2.34-113.patch
Normal file
139
glibc-upstream-2.34-113.patch
Normal file
@ -0,0 +1,139 @@
|
||||
commit d093b677c36ef4b360bf30483b68b95d9f0ad1d2
|
||||
Author: Noah Goldstein <goldstein.w.n@gmail.com>
|
||||
Date: Fri Feb 18 14:19:15 2022 -0600
|
||||
|
||||
x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896]
|
||||
|
||||
In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
|
||||
call strcmp-avx2 and wcscmp-avx2 respectively. This would have
|
||||
not checks around vzeroupper and would trigger spurious
|
||||
aborts. This commit fixes that.
|
||||
|
||||
test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
|
||||
AVX2 machines with and without RTM.
|
||||
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
|
||||
|
||||
(cherry picked from commit 7835d611af0854e69a0c71e3806f8fe379282d6f)
|
||||
|
||||
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
|
||||
index af934d6ccf1fa337..cd94e683afd5b4a4 100644
|
||||
--- a/sysdeps/x86/Makefile
|
||||
+++ b/sysdeps/x86/Makefile
|
||||
@@ -95,7 +95,9 @@ tests += \
|
||||
tst-strcpy-rtm \
|
||||
tst-strlen-rtm \
|
||||
tst-strncmp-rtm \
|
||||
- tst-strrchr-rtm
|
||||
+ tst-strrchr-rtm \
|
||||
+ tst-wcsncmp-rtm \
|
||||
+# tests
|
||||
|
||||
CFLAGS-tst-memchr-rtm.c += -mrtm
|
||||
CFLAGS-tst-memcmp-rtm.c += -mrtm
|
||||
@@ -107,6 +109,7 @@ CFLAGS-tst-strcpy-rtm.c += -mrtm
|
||||
CFLAGS-tst-strlen-rtm.c += -mrtm
|
||||
CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error
|
||||
CFLAGS-tst-strrchr-rtm.c += -mrtm
|
||||
+CFLAGS-tst-wcsncmp-rtm.c += -mrtm -Wno-error
|
||||
endif
|
||||
|
||||
ifneq ($(enable-cet),no)
|
||||
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
|
||||
index 4d0004b58aae428d..4e9f094f39c72f67 100644
|
||||
--- a/sysdeps/x86/tst-strncmp-rtm.c
|
||||
+++ b/sysdeps/x86/tst-strncmp-rtm.c
|
||||
@@ -19,18 +19,32 @@
|
||||
#include <stdint.h>
|
||||
#include <tst-string-rtm.h>
|
||||
|
||||
+#ifdef WIDE
|
||||
+# define CHAR wchar_t
|
||||
+# define MEMSET wmemset
|
||||
+# define STRNCMP wcsncmp
|
||||
+# define TEST_NAME wcsncmp
|
||||
+#else /* !WIDE */
|
||||
+# define CHAR char
|
||||
+# define MEMSET memset
|
||||
+# define STRNCMP strncmp
|
||||
+# define TEST_NAME strncmp
|
||||
+#endif /* !WIDE */
|
||||
+
|
||||
+
|
||||
+
|
||||
#define LOOP 3000
|
||||
#define STRING_SIZE 1024
|
||||
-char string1[STRING_SIZE];
|
||||
-char string2[STRING_SIZE];
|
||||
+CHAR string1[STRING_SIZE];
|
||||
+CHAR string2[STRING_SIZE];
|
||||
|
||||
__attribute__ ((noinline, noclone))
|
||||
static int
|
||||
prepare (void)
|
||||
{
|
||||
- memset (string1, 'a', STRING_SIZE - 1);
|
||||
- memset (string2, 'a', STRING_SIZE - 1);
|
||||
- if (strncmp (string1, string2, STRING_SIZE) == 0)
|
||||
+ MEMSET (string1, 'a', STRING_SIZE - 1);
|
||||
+ MEMSET (string2, 'a', STRING_SIZE - 1);
|
||||
+ if (STRNCMP (string1, string2, STRING_SIZE) == 0)
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
@@ -40,7 +54,7 @@ __attribute__ ((noinline, noclone))
|
||||
static int
|
||||
function (void)
|
||||
{
|
||||
- if (strncmp (string1, string2, STRING_SIZE) == 0)
|
||||
+ if (STRNCMP (string1, string2, STRING_SIZE) == 0)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
@@ -50,7 +64,7 @@ __attribute__ ((noinline, noclone))
|
||||
static int
|
||||
function_overflow (void)
|
||||
{
|
||||
- if (strncmp (string1, string2, SIZE_MAX) == 0)
|
||||
+ if (STRNCMP (string1, string2, SIZE_MAX) == 0)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
@@ -59,9 +73,9 @@ function_overflow (void)
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
- int status = do_test_1 ("strncmp", LOOP, prepare, function);
|
||||
+ int status = do_test_1 (TEST_NAME, LOOP, prepare, function);
|
||||
if (status != EXIT_SUCCESS)
|
||||
return status;
|
||||
- status = do_test_1 ("strncmp", LOOP, prepare, function_overflow);
|
||||
+ status = do_test_1 (TEST_NAME, LOOP, prepare, function_overflow);
|
||||
return status;
|
||||
}
|
||||
diff --git a/sysdeps/x86/tst-wcsncmp-rtm.c b/sysdeps/x86/tst-wcsncmp-rtm.c
|
||||
new file mode 100644
|
||||
index 0000000000000000..bad3b863782c5e56
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/x86/tst-wcsncmp-rtm.c
|
||||
@@ -0,0 +1,21 @@
|
||||
+/* Test case for wcsncmp inside a transactionally executing RTM region.
|
||||
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#define WIDE 1
|
||||
+#include <wchar.h>
|
||||
+#include "tst-strncmp-rtm.c"
|
32
glibc-upstream-2.34-114.patch
Normal file
32
glibc-upstream-2.34-114.patch
Normal file
@ -0,0 +1,32 @@
|
||||
commit 15b00d2af0e56dcc8c244a36d6872d301b0c7185
|
||||
Author: Noah Goldstein <goldstein.w.n@gmail.com>
|
||||
Date: Fri Feb 18 17:00:25 2022 -0600
|
||||
|
||||
x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c
|
||||
|
||||
Previously TEST_NAME was passing a function pointer. This didn't fail
|
||||
because of the -Wno-error flag (to allow for overflow sizes passed
|
||||
to strncmp/wcsncmp)
|
||||
|
||||
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
|
||||
(cherry picked from commit b98d0bbf747f39770e0caba7e984ce9f8f900330)
|
||||
|
||||
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
|
||||
index 4e9f094f39c72f67..aef9866cf2fbe774 100644
|
||||
--- a/sysdeps/x86/tst-strncmp-rtm.c
|
||||
+++ b/sysdeps/x86/tst-strncmp-rtm.c
|
||||
@@ -23,12 +23,12 @@
|
||||
# define CHAR wchar_t
|
||||
# define MEMSET wmemset
|
||||
# define STRNCMP wcsncmp
|
||||
-# define TEST_NAME wcsncmp
|
||||
+# define TEST_NAME "wcsncmp"
|
||||
#else /* !WIDE */
|
||||
# define CHAR char
|
||||
# define MEMSET memset
|
||||
# define STRNCMP strncmp
|
||||
-# define TEST_NAME strncmp
|
||||
+# define TEST_NAME "strncmp"
|
||||
#endif /* !WIDE */
|
||||
|
||||
|
104
glibc-upstream-2.34-117.patch
Normal file
104
glibc-upstream-2.34-117.patch
Normal file
@ -0,0 +1,104 @@
|
||||
commit 3be79b72d556e3ac37075ad6b99eb5eac18e1402
|
||||
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||
Date: Sun Mar 6 15:56:57 2022 +0000
|
||||
|
||||
Fix elf/tst-audit2 on hppa
|
||||
|
||||
The test elf/tst-audit2 fails on hppa with a segmentation fault in the
|
||||
long branch stub used to call malloc from calloc. This occurs because
|
||||
the test is not a PIC executable and calloc is called from the dynamic
|
||||
linker before the dp register is initialized in _dl_start_user.
|
||||
|
||||
The fix is to move the dp register initialization into
|
||||
elf_machine_runtime_setup. Since the address of $global$ can't be
|
||||
loaded directly, we continue to use the DT_PLTGOT value from the
|
||||
the main_map to initialize dp. Since l_main_map is not available
|
||||
in v2.34 and earlier, we use a new function, elf_machine_main_map,
|
||||
to find the main map.
|
||||
|
||||
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
|
||||
index f048fd20728ccde6..24f0f47d8f1e25cd 100644
|
||||
--- a/sysdeps/hppa/dl-machine.h
|
||||
+++ b/sysdeps/hppa/dl-machine.h
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <link.h>
|
||||
#include <errno.h>
|
||||
+#include <ldsodefs.h>
|
||||
#include <dl-fptr.h>
|
||||
#include <abort-instr.h>
|
||||
#include <tls.h>
|
||||
@@ -159,6 +160,24 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
|
||||
return (struct fdesc) { value.ip + reloc->r_addend, value.gp };
|
||||
}
|
||||
|
||||
+static inline struct link_map *
|
||||
+elf_machine_main_map (void)
|
||||
+{
|
||||
+ struct link_map *main_map;
|
||||
+
|
||||
+#if defined SHARED && IS_IN (rtld)
|
||||
+ asm (
|
||||
+" bl 1f,%0\n"
|
||||
+" addil L'_rtld_local - ($PIC_pcrel$0 - 1),%0\n"
|
||||
+"1: ldw R'_rtld_local - ($PIC_pcrel$0 - 5)(%%r1),%0\n"
|
||||
+ : "=r" (main_map) : : "r1");
|
||||
+#else
|
||||
+ main_map = NULL;
|
||||
+#endif
|
||||
+
|
||||
+ return main_map;
|
||||
+}
|
||||
+
|
||||
/* Set up the loaded object described by L so its unrelocated PLT
|
||||
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
||||
|
||||
@@ -174,6 +193,15 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
||||
Elf32_Addr i[2];
|
||||
} sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
|
||||
|
||||
+ /* Initialize dp register for main executable. */
|
||||
+ if (l == elf_machine_main_map ())
|
||||
+ {
|
||||
+ register Elf32_Addr dp asm ("%r27");
|
||||
+
|
||||
+ dp = D_PTR (l, l_info[DT_PLTGOT]);
|
||||
+ asm volatile ("" : : "r" (dp));
|
||||
+ }
|
||||
+
|
||||
/* If we don't have a PLT we can just skip all this... */
|
||||
if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0))
|
||||
return lazy;
|
||||
@@ -336,16 +364,6 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
||||
its return value is the user program's entry point. */
|
||||
|
||||
#define RTLD_START \
|
||||
-/* Set up dp for any non-PIC lib constructors that may be called. */ \
|
||||
-static struct link_map * __attribute__((used)) \
|
||||
-set_dp (struct link_map *map) \
|
||||
-{ \
|
||||
- register Elf32_Addr dp asm ("%r27"); \
|
||||
- dp = D_PTR (map, l_info[DT_PLTGOT]); \
|
||||
- asm volatile ("" : : "r" (dp)); \
|
||||
- return map; \
|
||||
-} \
|
||||
- \
|
||||
asm ( \
|
||||
" .text\n" \
|
||||
" .globl _start\n" \
|
||||
@@ -445,14 +463,11 @@ asm ( \
|
||||
" stw %r24,-44(%sp)\n" \
|
||||
\
|
||||
".Lnofix:\n" \
|
||||
+ /* Call _dl_init(main_map, argc, argv, envp). */ \
|
||||
" addil LT'_rtld_local,%r19\n" \
|
||||
" ldw RT'_rtld_local(%r1),%r26\n" \
|
||||
-" bl set_dp, %r2\n" \
|
||||
" ldw 0(%r26),%r26\n" \
|
||||
\
|
||||
- /* Call _dl_init(_dl_loaded, argc, argv, envp). */ \
|
||||
-" copy %r28,%r26\n" \
|
||||
- \
|
||||
/* envp = argv + argc + 1 */ \
|
||||
" sh2add %r25,%r24,%r23\n" \
|
||||
" bl _dl_init,%r2\n" \
|
146
glibc-upstream-2.34-118.patch
Normal file
146
glibc-upstream-2.34-118.patch
Normal file
@ -0,0 +1,146 @@
|
||||
commit c6f9085ee4e913a0b8260340ac7b75c426b780ce
|
||||
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||
Date: Fri Feb 18 20:38:25 2022 +0000
|
||||
|
||||
hppa: Fix swapcontext
|
||||
|
||||
This change fixes the failure of stdlib/tst-setcontext2 and
|
||||
stdlib/tst-setcontext7 on hppa. The implementation of swapcontext
|
||||
in C is broken. C saves the return pointer (rp) and any non
|
||||
call-clobbered registers (in this case r3, r4 and r5) on the
|
||||
stack. However, the setcontext call in swapcontext pops the
|
||||
stack and subsequent calls clobber the saved registers. When
|
||||
the context in oucp is restored, both tests fault.
|
||||
|
||||
Here we rewrite swapcontext in assembly code to avoid using
|
||||
the stack for register values that need to be used after
|
||||
restoration. The getcontext and setcontext routines are
|
||||
revised to save and restore register ret1 for normal returns.
|
||||
We copy the oucp pointer to ret1. This allows access to
|
||||
the old context after calling getcontext and setcontext.
|
||||
|
||||
(cherry picked from commit 71b108d7eb33b2bf3e61d5e92d2a47f74c1f7d96)
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/getcontext.S b/sysdeps/unix/sysv/linux/hppa/getcontext.S
|
||||
index 1405b42819c38993..c8b690aab8ecc47c 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/getcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/getcontext.S
|
||||
@@ -138,6 +138,8 @@ ENTRY(__getcontext)
|
||||
stw %r19, -32(%sp)
|
||||
.cfi_offset 19, 32
|
||||
#endif
|
||||
+ stw %ret1, -60(%sp)
|
||||
+ .cfi_offset 29, 4
|
||||
|
||||
/* Set up the trampoline registers.
|
||||
r20, r23, r24, r25, r26 and r2 are clobbered
|
||||
@@ -168,6 +170,7 @@ ENTRY(__getcontext)
|
||||
#ifdef PIC
|
||||
ldw -32(%sp), %r19
|
||||
#endif
|
||||
+ ldw -60(%sp), %ret1
|
||||
bv %r0(%r2)
|
||||
ldwm -64(%sp), %r4
|
||||
END(__getcontext)
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/setcontext.S b/sysdeps/unix/sysv/linux/hppa/setcontext.S
|
||||
index 8fc5f5e56cb31f51..e1ae3aefcaac198d 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/setcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/setcontext.S
|
||||
@@ -34,6 +34,8 @@ ENTRY(__setcontext)
|
||||
stw %r19, -32(%sp)
|
||||
.cfi_offset 19, 32
|
||||
#endif
|
||||
+ stw %ret1, -60(%sp)
|
||||
+ .cfi_offset 29, 4
|
||||
|
||||
/* Save ucp. */
|
||||
copy %r26, %r3
|
||||
@@ -155,6 +157,7 @@ ENTRY(__setcontext)
|
||||
#ifdef PIC
|
||||
ldw -32(%r30), %r19
|
||||
#endif
|
||||
+ ldw -60(%r30), %ret1
|
||||
bv %r0(%r2)
|
||||
ldwm -64(%r30), %r3
|
||||
L(pseudo_end):
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/swapcontext.c b/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||
index f9a8207543c164cb..562f00ff0546177d 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||
@@ -18,6 +18,7 @@
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <ucontext.h>
|
||||
+#include "ucontext_i.h"
|
||||
|
||||
extern int __getcontext (ucontext_t *ucp);
|
||||
extern int __setcontext (const ucontext_t *ucp);
|
||||
@@ -25,17 +26,61 @@ extern int __setcontext (const ucontext_t *ucp);
|
||||
int
|
||||
__swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
||||
{
|
||||
+ /* Save ucp in stack argument slot. */
|
||||
+ asm ("stw %r25,-40(%sp)");
|
||||
+ asm (".cfi_offset 25, -40");
|
||||
+
|
||||
+ /* Save rp for debugger. */
|
||||
+ asm ("stw %rp,-20(%sp)");
|
||||
+ asm (".cfi_offset 2, -20");
|
||||
+
|
||||
+ /* Copy rp to ret0 (r28). */
|
||||
+ asm ("copy %rp,%ret0");
|
||||
+
|
||||
+ /* Create a frame. */
|
||||
+ asm ("ldo 64(%sp),%sp");
|
||||
+ asm (".cfi_def_cfa_offset -64");
|
||||
+
|
||||
/* Save the current machine context to oucp. */
|
||||
- __getcontext (oucp);
|
||||
+ asm ("bl __getcontext,%rp");
|
||||
+
|
||||
+ /* Copy oucp to register ret1 (r29). __getcontext saves and restores it
|
||||
+ on a normal return. It is restored from oR29 on reactivation. */
|
||||
+ asm ("copy %r26,%ret1");
|
||||
+
|
||||
+ /* Pop frame. */
|
||||
+ asm ("ldo -64(%sp),%sp");
|
||||
+ asm (".cfi_def_cfa_offset 0");
|
||||
+
|
||||
+ /* Load return pointer from oR28. */
|
||||
+ asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28));
|
||||
+
|
||||
+ /* Return if error. */
|
||||
+ asm ("or,= %r0,%ret0,%r0");
|
||||
+ asm ("bv,n %r0(%rp)");
|
||||
+
|
||||
+ /* Load sc_sar flag. */
|
||||
+ asm ("ldw %0(%%ret1),%%r20" : : "i" (oSAR));
|
||||
+
|
||||
+ /* Return if oucp context has been reactivated. */
|
||||
+ asm ("or,= %r0,%r20,%r0");
|
||||
+ asm ("bv,n %r0(%rp)");
|
||||
+
|
||||
+ /* Mark sc_sar flag. */
|
||||
+ asm ("1: ldi 1,%r20");
|
||||
+ asm ("stw %%r20,%0(%%ret1)" : : "i" (oSAR));
|
||||
+
|
||||
+ /* Activate the machine context in ucp. */
|
||||
+ asm ("bl __setcontext,%rp");
|
||||
+ asm ("ldw -40(%sp),%r26");
|
||||
|
||||
- /* mark sc_sar flag to skip the setcontext call on reactivation. */
|
||||
- if (oucp->uc_mcontext.sc_sar == 0) {
|
||||
- oucp->uc_mcontext.sc_sar++;
|
||||
+ /* Load return pointer. */
|
||||
+ asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28));
|
||||
|
||||
- /* Restore the machine context in ucp. */
|
||||
- __setcontext (ucp);
|
||||
- }
|
||||
+ /* A successful call to setcontext does not return. */
|
||||
+ asm ("bv,n %r0(%rp)");
|
||||
|
||||
+ /* Make gcc happy. */
|
||||
return 0;
|
||||
}
|
||||
|
177
glibc-upstream-2.34-119.patch
Normal file
177
glibc-upstream-2.34-119.patch
Normal file
@ -0,0 +1,177 @@
|
||||
commit f610d2935f041c5f41ddcb96924ea42ca2fb5ea5
|
||||
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||
Date: Tue Feb 22 17:28:46 2022 +0000
|
||||
|
||||
hppa: Revise gettext trampoline design
|
||||
|
||||
The current getcontext return trampoline is overly complex and it
|
||||
unnecessarily clobbers several registers. By saving the context
|
||||
pointer (r26) in the context, __getcontext_ret can restore any
|
||||
registers not restored by setcontext. This allows getcontext to
|
||||
save and restore the entire register context present when getcontext
|
||||
is entered. We use the unused oR0 context slot for the return
|
||||
from __getcontext_ret.
|
||||
|
||||
While this is not directly useful in C, it can be exploited in
|
||||
assembly code. Registers r20, r23, r24 and r25 are not clobbered
|
||||
in the call path to getcontext. This allows a small simplification
|
||||
of swapcontext.
|
||||
|
||||
It also allows saving and restoring the 6-bit SAR register in the
|
||||
LSB of the oSAR context slot. The getcontext flag value can be
|
||||
stored in the MSB of the oSAR slot.
|
||||
|
||||
(cherry picked from commit 9e7e5fda38471e00d1190479ea91d7b08ae3e304)
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/getcontext.S b/sysdeps/unix/sysv/linux/hppa/getcontext.S
|
||||
index c8b690aab8ecc47c..4f2e2587d60effc8 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/getcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/getcontext.S
|
||||
@@ -22,22 +22,28 @@
|
||||
#include "ucontext_i.h"
|
||||
|
||||
|
||||
- /* Trampoline function. Non-standard calling ABI. */
|
||||
+ /* Trampoline function. Non-standard calling ABI. */
|
||||
/* Can not use ENTRY(__getcontext_ret) here. */
|
||||
.type __getcontext_ret, @function
|
||||
.hidden __getcontext_ret
|
||||
__getcontext_ret:
|
||||
.proc
|
||||
.callinfo FRAME=0,NO_CALLS
|
||||
- /* r26-r23 contain original r3-r6, but because setcontext
|
||||
- does not reload r3-r6 (it's using them as temporaries)
|
||||
- we must save them elsewhere and swap them back in. */
|
||||
- copy %r23, %r3
|
||||
- copy %r24, %r4
|
||||
- copy %r25, %r5
|
||||
- copy %r26, %r6
|
||||
- /* r20 contains original return pointer. */
|
||||
- bv 0(%r20)
|
||||
+ /* Because setcontext does not reload r3-r6 (it's using them
|
||||
+ as temporaries), we must load them ourself. */
|
||||
+ ldw oR3(%r26), %r3
|
||||
+ ldw oR4(%r26), %r4
|
||||
+ ldw oR5(%r26), %r5
|
||||
+ ldw oR6(%r26), %r6
|
||||
+
|
||||
+ /* Also reload registers clobbered by $$dyncall. */
|
||||
+ ldw oR21(%r26), %r21
|
||||
+ ldw oR22(%r26), %r22
|
||||
+ ldw oR31(%r26), %r31
|
||||
+
|
||||
+ /* oR0 contains original return pointer. */
|
||||
+ ldw oR0(%r26), %rp
|
||||
+ bv 0(%rp)
|
||||
copy %r0, %ret0
|
||||
.procend
|
||||
.size __getcontext_ret, .-__getcontext_ret
|
||||
@@ -65,13 +71,13 @@ ENTRY(__getcontext)
|
||||
stw %r17, oR17(%r26)
|
||||
stw %r18, oR18(%r26)
|
||||
stw %r19, oR19(%r26)
|
||||
- /* stw %r20, oR20(%r26) - used for trampoline. */
|
||||
+ stw %r20, oR20(%r26)
|
||||
stw %r21, oR21(%r26)
|
||||
stw %r22, oR22(%r26)
|
||||
- /* stw %r23, oR23(%r26) - used for trampoline. */
|
||||
- /* stw %r24, oR24(%r26) - used for trampoline. */
|
||||
- /* stw %r25, oR25(%r26) - used for trampoline. */
|
||||
- /* stw %r26, oR26(%r26) - used for trampoline. */
|
||||
+ stw %r23, oR23(%r26)
|
||||
+ stw %r24, oR24(%r26)
|
||||
+ stw %r25, oR25(%r26)
|
||||
+ stw %r26, oR26(%r26)
|
||||
stw %r27, oR27(%r26)
|
||||
stw %r28, oR28(%r26)
|
||||
stw %r29, oR29(%r26)
|
||||
@@ -90,7 +96,10 @@ ENTRY(__getcontext)
|
||||
stw %r0, oIASQ1(%r26)
|
||||
stw %r0, oIAOQ0(%r26)
|
||||
stw %r0, oIAOQ1(%r26)
|
||||
- stw %r0, oSAR(%r26) /* used as flag in swapcontext(). */
|
||||
+
|
||||
+ /* Save SAR register. */
|
||||
+ mfctl %sar, %r1
|
||||
+ stw %r1, oSAR(%r26) /* MSB used as flag in swapcontext(). */
|
||||
|
||||
|
||||
/* Store floating-point regs. */
|
||||
@@ -142,13 +151,8 @@ ENTRY(__getcontext)
|
||||
.cfi_offset 29, 4
|
||||
|
||||
/* Set up the trampoline registers.
|
||||
- r20, r23, r24, r25, r26 and r2 are clobbered
|
||||
- by call to getcontext() anyway. Reuse them. */
|
||||
- stw %r2, oR20(%r26)
|
||||
- stw %r3, oR23(%r26)
|
||||
- stw %r4, oR24(%r26)
|
||||
- stw %r5, oR25(%r26)
|
||||
- stw %r6, oR26(%r26)
|
||||
+ Use oR0 context slot to save return value. */
|
||||
+ stw %r2, oR0(%r26)
|
||||
#ifdef PIC
|
||||
addil LT%__getcontext_ret, %r19
|
||||
ldw RT%__getcontext_ret(%r1), %r1
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/setcontext.S b/sysdeps/unix/sysv/linux/hppa/setcontext.S
|
||||
index e1ae3aefcaac198d..616405b80c61d531 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/setcontext.S
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/setcontext.S
|
||||
@@ -76,7 +76,7 @@ ENTRY(__setcontext)
|
||||
ldw oR18(%r3), %r18
|
||||
ldw oR19(%r3), %r19
|
||||
ldw oR20(%r3), %r20
|
||||
- ldw oR21(%r3), %r21
|
||||
+ ldw oR21(%r3), %r21 /* maybe clobbered by dyncall */
|
||||
/* ldw oR22(%r3), %r22 - dyncall arg. */
|
||||
ldw oR23(%r3), %r23
|
||||
ldw oR24(%r3), %r24
|
||||
@@ -88,6 +88,10 @@ ENTRY(__setcontext)
|
||||
ldw oR30(%r3), %sp
|
||||
/* ldw oR31(%r3), %r31 - dyncall scratch register */
|
||||
|
||||
+ /* Restore SAR register. */
|
||||
+ ldw oSAR(%r3), %r22
|
||||
+ mtsar %r22
|
||||
+
|
||||
/* Restore floating-point registers. */
|
||||
ldo oFPREGS31(%r3), %r22
|
||||
fldds 0(%r22), %fr31
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/swapcontext.c b/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||
index 562f00ff0546177d..1664f68c7b9982e8 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/swapcontext.c
|
||||
@@ -26,10 +26,6 @@ extern int __setcontext (const ucontext_t *ucp);
|
||||
int
|
||||
__swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
||||
{
|
||||
- /* Save ucp in stack argument slot. */
|
||||
- asm ("stw %r25,-40(%sp)");
|
||||
- asm (".cfi_offset 25, -40");
|
||||
-
|
||||
/* Save rp for debugger. */
|
||||
asm ("stw %rp,-20(%sp)");
|
||||
asm (".cfi_offset 2, -20");
|
||||
@@ -60,7 +56,7 @@ __swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
||||
asm ("bv,n %r0(%rp)");
|
||||
|
||||
/* Load sc_sar flag. */
|
||||
- asm ("ldw %0(%%ret1),%%r20" : : "i" (oSAR));
|
||||
+ asm ("ldb %0(%%ret1),%%r20" : : "i" (oSAR));
|
||||
|
||||
/* Return if oucp context has been reactivated. */
|
||||
asm ("or,= %r0,%r20,%r0");
|
||||
@@ -68,11 +64,11 @@ __swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
|
||||
|
||||
/* Mark sc_sar flag. */
|
||||
asm ("1: ldi 1,%r20");
|
||||
- asm ("stw %%r20,%0(%%ret1)" : : "i" (oSAR));
|
||||
+ asm ("stb %%r20,%0(%%ret1)" : : "i" (oSAR));
|
||||
|
||||
/* Activate the machine context in ucp. */
|
||||
asm ("bl __setcontext,%rp");
|
||||
- asm ("ldw -40(%sp),%r26");
|
||||
+ asm ("ldw %0(%%ret1),%%r26" : : "i" (oR25));
|
||||
|
||||
/* Load return pointer. */
|
||||
asm ("ldw %0(%%ret1),%%rp" : : "i" (oR28));
|
27
glibc-upstream-2.34-120.patch
Normal file
27
glibc-upstream-2.34-120.patch
Normal file
@ -0,0 +1,27 @@
|
||||
commit 40fc6a74ee3dd600c84d311d91cbb16962f11a71
|
||||
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||
Date: Mon Feb 28 15:47:38 2022 +0000
|
||||
|
||||
nptl: Fix cleanups for stack grows up [BZ# 28899]
|
||||
|
||||
_STACK_GROWS_DOWN is defined to 0 when the stack grows up. The
|
||||
code in unwind.c used `#ifdef _STACK_GROWS_DOWN' to selct the
|
||||
stack grows down define for FRAME_LEFT. As a result, the
|
||||
_STACK_GROWS_DOWN define was always selected and cleanups were
|
||||
incorrectly sequenced when the stack grows up.
|
||||
|
||||
(cherry picked from commit 2bbc694df279020a6620096d31c1e05c93966f9b)
|
||||
|
||||
diff --git a/nptl/unwind.c b/nptl/unwind.c
|
||||
index f50997f728ccde0d..404fab46d00e9f10 100644
|
||||
--- a/nptl/unwind.c
|
||||
+++ b/nptl/unwind.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <jmpbuf-unwind.h>
|
||||
#include <shlib-compat.h>
|
||||
|
||||
-#ifdef _STACK_GROWS_DOWN
|
||||
+#if _STACK_GROWS_DOWN
|
||||
# define FRAME_LEFT(frame, other, adj) \
|
||||
((uintptr_t) frame - adj >= (uintptr_t) other - adj)
|
||||
#elif _STACK_GROWS_UP
|
122
glibc-upstream-2.34-121.patch
Normal file
122
glibc-upstream-2.34-121.patch
Normal file
@ -0,0 +1,122 @@
|
||||
commit 6c9c2307657529e52c5fa7037618835f2a50b916
|
||||
Author: John David Anglin <danglin@gcc.gnu.org>
|
||||
Date: Sun Mar 6 16:04:32 2022 +0000
|
||||
|
||||
hppa: Fix warnings from _dl_lookup_address
|
||||
|
||||
This change fixes two warnings from _dl_lookup_address.
|
||||
|
||||
The first warning comes from dropping the volatile keyword from
|
||||
desc in the call to _dl_read_access_allowed. We now have a full
|
||||
atomic barrier between loading desc[0] and the access check, so
|
||||
desc no longer needs to be declared as volatile.
|
||||
|
||||
The second warning comes from the implicit declaration of
|
||||
_dl_fix_reloc_arg. This is fixed by including dl-runtime.h and
|
||||
declaring _dl_fix_reloc_arg in dl-runtime.h.
|
||||
|
||||
diff --git a/sysdeps/hppa/dl-fptr.c b/sysdeps/hppa/dl-fptr.c
|
||||
index 62ef68b62bd601f4..cd4f77c0ecfd376f 100644
|
||||
--- a/sysdeps/hppa/dl-fptr.c
|
||||
+++ b/sysdeps/hppa/dl-fptr.c
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ldsodefs.h>
|
||||
#include <elf/dynamic-link.h>
|
||||
#include <dl-fptr.h>
|
||||
+#include <dl-runtime.h>
|
||||
#include <dl-unmap-segments.h>
|
||||
#include <atomic.h>
|
||||
#include <libc-pointer-arith.h>
|
||||
@@ -351,21 +352,20 @@ _dl_lookup_address (const void *address)
|
||||
{
|
||||
ElfW(Addr) addr = (ElfW(Addr)) address;
|
||||
ElfW(Word) reloc_arg;
|
||||
- volatile unsigned int *desc;
|
||||
- unsigned int *gptr;
|
||||
+ unsigned int *desc, *gptr;
|
||||
|
||||
/* Return ADDR if the least-significant two bits of ADDR are not consistent
|
||||
with ADDR being a linker defined function pointer. The normal value for
|
||||
a code address in a backtrace is 3. */
|
||||
- if (((unsigned int) addr & 3) != 2)
|
||||
+ if (((uintptr_t) addr & 3) != 2)
|
||||
return addr;
|
||||
|
||||
/* Handle special case where ADDR points to page 0. */
|
||||
- if ((unsigned int) addr < 4096)
|
||||
+ if ((uintptr_t) addr < 4096)
|
||||
return addr;
|
||||
|
||||
/* Clear least-significant two bits from descriptor address. */
|
||||
- desc = (unsigned int *) ((unsigned int) addr & ~3);
|
||||
+ desc = (unsigned int *) ((uintptr_t) addr & ~3);
|
||||
if (!_dl_read_access_allowed (desc))
|
||||
return addr;
|
||||
|
||||
@@ -376,7 +376,7 @@ _dl_lookup_address (const void *address)
|
||||
/* Then load first word of candidate descriptor. It should be a pointer
|
||||
with word alignment and point to memory that can be read. */
|
||||
gptr = (unsigned int *) desc[0];
|
||||
- if (((unsigned int) gptr & 3) != 0
|
||||
+ if (((uintptr_t) gptr & 3) != 0
|
||||
|| !_dl_read_access_allowed (gptr))
|
||||
return addr;
|
||||
|
||||
@@ -400,10 +400,11 @@ _dl_lookup_address (const void *address)
|
||||
|
||||
/* If gp has been resolved, we need to hunt for relocation offset. */
|
||||
if (!(reloc_arg & PA_GP_RELOC))
|
||||
- reloc_arg = _dl_fix_reloc_arg (addr, l);
|
||||
+ reloc_arg = _dl_fix_reloc_arg ((struct fdesc *) addr, l);
|
||||
|
||||
_dl_fixup (l, reloc_arg);
|
||||
}
|
||||
|
||||
return (ElfW(Addr)) desc[0];
|
||||
}
|
||||
+rtld_hidden_def (_dl_lookup_address)
|
||||
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
|
||||
index a9a927f26c6fec09..2f6991aa16e87a00 100644
|
||||
--- a/sysdeps/hppa/dl-lookupcfg.h
|
||||
+++ b/sysdeps/hppa/dl-lookupcfg.h
|
||||
@@ -30,6 +30,7 @@ rtld_hidden_proto (_dl_symbol_address)
|
||||
#define DL_SYMBOL_ADDRESS(map, ref) _dl_symbol_address(map, ref)
|
||||
|
||||
Elf32_Addr _dl_lookup_address (const void *address);
|
||||
+rtld_hidden_proto (_dl_lookup_address)
|
||||
|
||||
#define DL_LOOKUP_ADDRESS(addr) _dl_lookup_address ((const void *) addr)
|
||||
|
||||
diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c
|
||||
index e7fbb7417d866bb0..a71b5b2013abf723 100644
|
||||
--- a/sysdeps/hppa/dl-runtime.c
|
||||
+++ b/sysdeps/hppa/dl-runtime.c
|
||||
@@ -25,8 +25,7 @@
|
||||
return that to the caller. The caller will continue on to call
|
||||
_dl_fixup with the relocation offset. */
|
||||
|
||||
-ElfW(Word)
|
||||
-attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
|
||||
+ElfW(Word) __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
|
||||
_dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
|
||||
{
|
||||
Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type;
|
||||
@@ -52,3 +51,4 @@ _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
|
||||
ABORT_INSTRUCTION;
|
||||
return 0;
|
||||
}
|
||||
+rtld_hidden_def (_dl_fix_reloc_arg)
|
||||
diff --git a/sysdeps/hppa/dl-runtime.h b/sysdeps/hppa/dl-runtime.h
|
||||
index 5d6ee53b076d5e0e..9913539b5f0e7435 100644
|
||||
--- a/sysdeps/hppa/dl-runtime.h
|
||||
+++ b/sysdeps/hppa/dl-runtime.h
|
||||
@@ -17,6 +17,9 @@
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
+ElfW(Word) _dl_fix_reloc_arg (struct fdesc *, struct link_map *);
|
||||
+rtld_hidden_proto (_dl_fix_reloc_arg)
|
||||
+
|
||||
/* Clear PA_GP_RELOC bit in relocation offset. */
|
||||
static inline uintptr_t
|
||||
reloc_offset (uintptr_t plt0, uintptr_t pltn)
|
26
glibc-upstream-2.34-122.patch
Normal file
26
glibc-upstream-2.34-122.patch
Normal file
@ -0,0 +1,26 @@
|
||||
commit b5032c3d37aa614644c7afbad33bb8226a52e6da
|
||||
Author: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Mon Feb 28 11:50:41 2022 +0100
|
||||
|
||||
io: Add fsync call in tst-stat
|
||||
|
||||
io/tst-stat and io/tst-stat-lfs fail sporadically on the Fedora
|
||||
builders, and this change hopefully helps to avoid the issue.
|
||||
|
||||
(cherry picked from commit ae132284092edc5885315b44cd17d5ea91177e49)
|
||||
|
||||
diff --git a/io/tst-stat.c b/io/tst-stat.c
|
||||
index 82e965de6ad87f61..be20cf16d70d05cc 100644
|
||||
--- a/io/tst-stat.c
|
||||
+++ b/io/tst-stat.c
|
||||
@@ -69,6 +69,10 @@ do_test (void)
|
||||
TEST_VERIFY_EXIT (fd >= 0);
|
||||
support_write_file_string (path, "abc");
|
||||
|
||||
+ /* This should help to prevent delayed allocation, which may result
|
||||
+ in a spurious stx_blocks/st_blocks difference. */
|
||||
+ fsync (fd);
|
||||
+
|
||||
bool check_ns = support_stat_nanoseconds (path);
|
||||
if (!check_ns)
|
||||
printf ("warning: timestamp with nanoseconds not supported\n");
|
56
glibc-upstream-2.34-123.patch
Normal file
56
glibc-upstream-2.34-123.patch
Normal file
@ -0,0 +1,56 @@
|
||||
commit b53f0c11de409b04560a70570178d1a9d03d5860
|
||||
Author: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Fri Mar 11 08:23:56 2022 +0100
|
||||
|
||||
nss: Do not mention NSS test modules in <gnu/lib-names.h>
|
||||
|
||||
They are not actually installed. Use the nss_files version instead
|
||||
in nss/Makefile, similar to how __nss_shlib_revision is derived
|
||||
from LIBNSS_FILES_SO.
|
||||
|
||||
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
||||
(cherry picked from commit aefc79ab5ad4bb9feea2876720cec70dca7cd8ed)
|
||||
|
||||
diff --git a/nss/Makefile b/nss/Makefile
|
||||
index bccf9f2806c15651..e223243d9d62041c 100644
|
||||
--- a/nss/Makefile
|
||||
+++ b/nss/Makefile
|
||||
@@ -171,17 +171,14 @@ $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
|
||||
$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
|
||||
$(build-module)
|
||||
$(objpfx)nss_test2.os : nss_test1.c
|
||||
-ifdef libnss_test1.so-version
|
||||
-$(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
|
||||
+# Use the nss_files suffix for these objects as well.
|
||||
+$(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so
|
||||
$(make-link)
|
||||
-endif
|
||||
-ifdef libnss_test2.so-version
|
||||
-$(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
|
||||
+$(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so
|
||||
$(make-link)
|
||||
-endif
|
||||
$(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
|
||||
- $(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
|
||||
- $(objpfx)/libnss_test2.so$(libnss_test2.so-version)
|
||||
+ $(objpfx)/libnss_test1.so$(libnss_files.so-version) \
|
||||
+ $(objpfx)/libnss_test2.so$(libnss_files.so-version)
|
||||
|
||||
ifeq (yes,$(have-thread-library))
|
||||
$(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
|
||||
diff --git a/shlib-versions b/shlib-versions
|
||||
index df6603e6992b8382..b87ab50c59af1bfd 100644
|
||||
--- a/shlib-versions
|
||||
+++ b/shlib-versions
|
||||
@@ -47,11 +47,6 @@ libnss_ldap=2
|
||||
libnss_hesiod=2
|
||||
libnss_db=2
|
||||
|
||||
-# Tests for NSS. They must have the same NSS_SHLIB_REVISION number as
|
||||
-# the rest.
|
||||
-libnss_test1=2
|
||||
-libnss_test2=2
|
||||
-
|
||||
# Version for libnsl with YP and NIS+ functions.
|
||||
libnsl=1
|
||||
|
224
glibc-upstream-2.34-124.patch
Normal file
224
glibc-upstream-2.34-124.patch
Normal file
@ -0,0 +1,224 @@
|
||||
commit 54b12733959238204d7b0e46e69fc7f7d8890b20
|
||||
Author: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Fri Mar 11 08:23:56 2022 +0100
|
||||
|
||||
nss: Protect against errno changes in function lookup (bug 28953)
|
||||
|
||||
dlopen may clobber errno. The nss_test_errno module uses an ELF
|
||||
constructor to achieve that, but there could be internal errors
|
||||
during dlopen that cause this, too. Therefore, the NSS framework
|
||||
has to guard against such errno clobbers.
|
||||
|
||||
__nss_module_get_function is currently the only function that calls
|
||||
__nss_module_load, so it is sufficient to save and restore errno
|
||||
around this call.
|
||||
|
||||
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
||||
(cherry picked from commit 9bdf92c79d63b42f931101bb6df87129c408b0c4)
|
||||
|
||||
diff --git a/nss/Makefile b/nss/Makefile
|
||||
index e223243d9d62041c..716bc8f6ef5276b0 100644
|
||||
--- a/nss/Makefile
|
||||
+++ b/nss/Makefile
|
||||
@@ -60,7 +60,8 @@ tests = test-netdb test-digits-dots tst-nss-getpwent bug17079 \
|
||||
tst-nss-test1 \
|
||||
tst-nss-test2 \
|
||||
tst-nss-test4 \
|
||||
- tst-nss-test5
|
||||
+ tst-nss-test5 \
|
||||
+ tst-nss-test_errno
|
||||
xtests = bug-erange
|
||||
|
||||
tests-container = \
|
||||
@@ -132,7 +133,7 @@ libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
|
||||
ifeq ($(build-static-nss),yes)
|
||||
tests-static += tst-nss-static
|
||||
endif
|
||||
-extra-test-objs += nss_test1.os nss_test2.os
|
||||
+extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os
|
||||
|
||||
include ../Rules
|
||||
|
||||
@@ -166,19 +167,26 @@ rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
|
||||
|
||||
libof-nss_test1 = extramodules
|
||||
libof-nss_test2 = extramodules
|
||||
+libof-nss_test_errno = extramodules
|
||||
$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
|
||||
$(build-module)
|
||||
$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
|
||||
$(build-module)
|
||||
+$(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
|
||||
+ $(build-module)
|
||||
$(objpfx)nss_test2.os : nss_test1.c
|
||||
# Use the nss_files suffix for these objects as well.
|
||||
$(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so
|
||||
$(make-link)
|
||||
$(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so
|
||||
$(make-link)
|
||||
+$(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \
|
||||
+ $(objpfx)/libnss_test_errno.so
|
||||
+ $(make-link)
|
||||
$(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
|
||||
$(objpfx)/libnss_test1.so$(libnss_files.so-version) \
|
||||
- $(objpfx)/libnss_test2.so$(libnss_files.so-version)
|
||||
+ $(objpfx)/libnss_test2.so$(libnss_files.so-version) \
|
||||
+ $(objpfx)/libnss_test_errno.so$(libnss_files.so-version)
|
||||
|
||||
ifeq (yes,$(have-thread-library))
|
||||
$(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
|
||||
diff --git a/nss/nss_module.c b/nss/nss_module.c
|
||||
index b28cb94a6a0aeb41..3a4a464256121e41 100644
|
||||
--- a/nss/nss_module.c
|
||||
+++ b/nss/nss_module.c
|
||||
@@ -330,8 +330,18 @@ name_search (const void *left, const void *right)
|
||||
void *
|
||||
__nss_module_get_function (struct nss_module *module, const char *name)
|
||||
{
|
||||
+ /* A successful dlopen might clobber errno. */
|
||||
+ int saved_errno = errno;
|
||||
+
|
||||
if (!__nss_module_load (module))
|
||||
- return NULL;
|
||||
+ {
|
||||
+ /* Reporting module load failure is currently inaccurate. See
|
||||
+ bug 22041. Not changing errno is the conservative choice. */
|
||||
+ __set_errno (saved_errno);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ __set_errno (saved_errno);
|
||||
|
||||
function_name *name_entry = bsearch (name, nss_function_name_array,
|
||||
array_length (nss_function_name_array),
|
||||
diff --git a/nss/nss_test_errno.c b/nss/nss_test_errno.c
|
||||
new file mode 100644
|
||||
index 0000000000000000..680f8a07b97fe263
|
||||
--- /dev/null
|
||||
+++ b/nss/nss_test_errno.c
|
||||
@@ -0,0 +1,58 @@
|
||||
+/* NSS service provider with errno clobber.
|
||||
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#include <errno.h>
|
||||
+#include <nss.h>
|
||||
+#include <stdlib.h>
|
||||
+
|
||||
+/* Catch misnamed and functions. */
|
||||
+#pragma GCC diagnostic error "-Wmissing-prototypes"
|
||||
+NSS_DECLARE_MODULE_FUNCTIONS (test_errno)
|
||||
+
|
||||
+static void __attribute__ ((constructor))
|
||||
+init (void)
|
||||
+{
|
||||
+ /* An arbitrary error code which is otherwise not used. */
|
||||
+ errno = ELIBBAD;
|
||||
+}
|
||||
+
|
||||
+/* Lookup functions for pwd follow that do not return any data. */
|
||||
+
|
||||
+/* Catch misnamed function definitions. */
|
||||
+
|
||||
+enum nss_status
|
||||
+_nss_test_errno_setpwent (int stayopen)
|
||||
+{
|
||||
+ setenv ("_nss_test_errno_setpwent", "yes", 1);
|
||||
+ return NSS_STATUS_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+enum nss_status
|
||||
+_nss_test_errno_getpwent_r (struct passwd *result,
|
||||
+ char *buffer, size_t size, int *errnop)
|
||||
+{
|
||||
+ setenv ("_nss_test_errno_getpwent_r", "yes", 1);
|
||||
+ return NSS_STATUS_NOTFOUND;
|
||||
+}
|
||||
+
|
||||
+enum nss_status
|
||||
+_nss_test_errno_endpwent (void)
|
||||
+{
|
||||
+ setenv ("_nss_test_errno_endpwent", "yes", 1);
|
||||
+ return NSS_STATUS_SUCCESS;
|
||||
+}
|
||||
diff --git a/nss/tst-nss-test_errno.c b/nss/tst-nss-test_errno.c
|
||||
new file mode 100644
|
||||
index 0000000000000000..d2c42dd363a38b0e
|
||||
--- /dev/null
|
||||
+++ b/nss/tst-nss-test_errno.c
|
||||
@@ -0,0 +1,61 @@
|
||||
+/* getpwent failure when dlopen clobbers errno (bug 28953).
|
||||
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#include <nss.h>
|
||||
+#include <support/check.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <errno.h>
|
||||
+#include <stdbool.h>
|
||||
+#include <pwd.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+static int
|
||||
+do_test (void)
|
||||
+{
|
||||
+ __nss_configure_lookup ("passwd", "files test_errno");
|
||||
+
|
||||
+ errno = 0;
|
||||
+ setpwent ();
|
||||
+ TEST_COMPARE (errno, 0);
|
||||
+
|
||||
+ bool root_seen = false;
|
||||
+ while (true)
|
||||
+ {
|
||||
+ errno = 0;
|
||||
+ struct passwd *e = getpwent ();
|
||||
+ if (e == NULL)
|
||||
+ break;
|
||||
+ if (strcmp (e->pw_name, "root"))
|
||||
+ root_seen = true;
|
||||
+ }
|
||||
+
|
||||
+ TEST_COMPARE (errno, 0);
|
||||
+ TEST_VERIFY (root_seen);
|
||||
+
|
||||
+ errno = 0;
|
||||
+ endpwent ();
|
||||
+ TEST_COMPARE (errno, 0);
|
||||
+
|
||||
+ TEST_COMPARE_STRING (getenv ("_nss_test_errno_setpwent"), "yes");
|
||||
+ TEST_COMPARE_STRING (getenv ("_nss_test_errno_getpwent_r"), "yes");
|
||||
+ TEST_COMPARE_STRING (getenv ("_nss_test_errno_endpwent"), "yes");
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#include <support/test-driver.c>
|
345
glibc-upstream-2.34-125.patch
Normal file
345
glibc-upstream-2.34-125.patch
Normal file
@ -0,0 +1,345 @@
|
||||
commit c82bdf033f93a710044e25f721340c26e89a3769
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Tue Oct 12 12:29:13 2021 +0530
|
||||
|
||||
Don't add access size hints to fortifiable functions
|
||||
|
||||
In the context of a function definition, the size hints imply that the
|
||||
size of an object pointed to by one parameter is another parameter.
|
||||
This doesn't make sense for the fortified versions of the functions
|
||||
since that's the bit it's trying to validate.
|
||||
|
||||
This is harmless with __builtin_object_size since it has fairly simple
|
||||
semantics when it comes to objects passed as function parameters.
|
||||
With __builtin_dynamic_object_size we could (as my patchset for gcc[1]
|
||||
already does) use the access attribute to determine the object size in
|
||||
the general case but it misleads the fortified functions.
|
||||
|
||||
Basically the problem occurs when access attributes are present on
|
||||
regular functions that have inline fortified definitions to generate
|
||||
_chk variants; the attributes get inherited by these definitions,
|
||||
causing problems when analyzing them. For example with poll(fds, nfds,
|
||||
timeout), nfds is hinted using the __attr_access as being the size of
|
||||
fds.
|
||||
|
||||
Now, when analyzing the inline function definition in bits/poll2.h, the
|
||||
compiler sees that nfds is the size of fds and tries to use that
|
||||
information in the function body. In _FORTIFY_SOURCE=3 case, where the
|
||||
object size could be a non-constant expression, this information results
|
||||
in the conclusion that nfds is the size of fds, which defeats the
|
||||
purpose of the implementation because we're trying to check here if nfds
|
||||
does indeed represent the size of fds. Hence for this case, it is best
|
||||
to not have the access attribute.
|
||||
|
||||
With the attributes gone, the expression evaluation should get delayed
|
||||
until the function is actually inlined into its destinations.
|
||||
|
||||
Disable the access attribute for fortified function inline functions
|
||||
when building at _FORTIFY_SOURCE=3 to make this work better. The
|
||||
access attributes remain for the _chk variants since they can be used
|
||||
by the compiler to warn when the caller is passing invalid arguments.
|
||||
|
||||
[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581125.html
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
(cherry picked from commit e938c02748402c50f60ba0eb983273e7b52937d1)
|
||||
|
||||
diff --git a/io/bits/poll2.h b/io/bits/poll2.h
|
||||
index a623678c09f9f04f..be74d020f2e0e434 100644
|
||||
--- a/io/bits/poll2.h
|
||||
+++ b/io/bits/poll2.h
|
||||
@@ -33,7 +33,7 @@ extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
|
||||
__poll_chk)
|
||||
__warnattr ("poll called with fds buffer too small file nfds entries");
|
||||
|
||||
-__fortify_function __attr_access ((__write_only__, 1, 2)) int
|
||||
+__fortify_function __fortified_attr_access (__write_only__, 1, 2) int
|
||||
poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
|
||||
{
|
||||
if (__glibc_objsize (__fds) != (__SIZE_TYPE__) -1)
|
||||
@@ -64,7 +64,7 @@ extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
|
||||
__ppoll_chk)
|
||||
__warnattr ("ppoll called with fds buffer too small file nfds entries");
|
||||
|
||||
-__fortify_function __attr_access ((__write_only__, 1, 2)) int
|
||||
+__fortify_function __fortified_attr_access (__write_only__, 1, 2) int
|
||||
ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
|
||||
const __sigset_t *__ss)
|
||||
{
|
||||
diff --git a/io/sys/poll.h b/io/sys/poll.h
|
||||
index e640efb2bce7ea67..751c7f5f72db8be2 100644
|
||||
--- a/io/sys/poll.h
|
||||
+++ b/io/sys/poll.h
|
||||
@@ -52,7 +52,7 @@ __BEGIN_DECLS
|
||||
This function is a cancellation point and therefore not marked with
|
||||
__THROW. */
|
||||
extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
/* Like poll, but before waiting the threads signal mask is replaced
|
||||
@@ -64,7 +64,7 @@ extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
|
||||
extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
|
||||
const struct timespec *__timeout,
|
||||
const __sigset_t *__ss)
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
|
||||
# ifdef __USE_TIME_BITS64
|
||||
# ifdef __REDIRECT
|
||||
@@ -72,7 +72,7 @@ extern int __REDIRECT (ppoll, (struct pollfd *__fds, nfds_t __nfds,
|
||||
const struct timespec *__timeout,
|
||||
const __sigset_t *__ss),
|
||||
__ppoll64)
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
# else
|
||||
# define ppoll __ppoll64
|
||||
# endif
|
||||
diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h
|
||||
index 3f0cab1254b02c43..4f016a563857a137 100644
|
||||
--- a/libio/bits/stdio2.h
|
||||
+++ b/libio/bits/stdio2.h
|
||||
@@ -258,7 +258,7 @@ extern char *__REDIRECT (__fgets_chk_warn,
|
||||
__wur __warnattr ("fgets called with bigger size than length "
|
||||
"of destination buffer");
|
||||
|
||||
-__fortify_function __wur __attr_access ((__write_only__, 1, 2)) char *
|
||||
+__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) char *
|
||||
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
|
||||
{
|
||||
if (__glibc_objsize (__s) != (size_t) -1)
|
||||
@@ -320,7 +320,7 @@ extern char *__REDIRECT (__fgets_unlocked_chk_warn,
|
||||
__wur __warnattr ("fgets_unlocked called with bigger size than length "
|
||||
"of destination buffer");
|
||||
|
||||
-__fortify_function __wur __attr_access ((__write_only__, 1, 2)) char *
|
||||
+__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) char *
|
||||
fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
|
||||
{
|
||||
if (__glibc_objsize (__s) != (size_t) -1)
|
||||
diff --git a/libio/stdio.h b/libio/stdio.h
|
||||
index 497da016ffa2e230..abefe640e52d18d5 100644
|
||||
--- a/libio/stdio.h
|
||||
+++ b/libio/stdio.h
|
||||
@@ -584,7 +584,7 @@ extern int putw (int __w, FILE *__stream);
|
||||
This function is a possible cancellation point and therefore not
|
||||
marked with __THROW. */
|
||||
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
|
||||
- __wur __attr_access ((__write_only__, 1, 2));
|
||||
+ __wur __fortified_attr_access (__write_only__, 1, 2);
|
||||
|
||||
#if __GLIBC_USE (DEPRECATED_GETS)
|
||||
/* Get a newline-terminated string from stdin, removing the newline.
|
||||
@@ -608,7 +608,7 @@ extern char *gets (char *__s) __wur __attribute_deprecated__;
|
||||
therefore not marked with __THROW. */
|
||||
extern char *fgets_unlocked (char *__restrict __s, int __n,
|
||||
FILE *__restrict __stream) __wur
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
#endif
|
||||
|
||||
|
||||
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
|
||||
index e490fc1aebeadc3d..cd836441a9807d6a 100644
|
||||
--- a/misc/sys/cdefs.h
|
||||
+++ b/misc/sys/cdefs.h
|
||||
@@ -603,12 +603,22 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
|
||||
size-index is not provided:
|
||||
access (access-mode, <ref-index> [, <size-index>]) */
|
||||
# define __attr_access(x) __attribute__ ((__access__ x))
|
||||
+/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
|
||||
+ use the access attribute to get object sizes from function definition
|
||||
+ arguments, so we can't use them on functions we fortify. Drop the object
|
||||
+ size hints for such functions. */
|
||||
+# if __USE_FORTIFY_LEVEL == 3
|
||||
+# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
|
||||
+# else
|
||||
+# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
|
||||
+# endif
|
||||
# if __GNUC_PREREQ (11, 0)
|
||||
# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
|
||||
# else
|
||||
# define __attr_access_none(argno)
|
||||
# endif
|
||||
#else
|
||||
+# define __fortified_attr_access(a, o, s)
|
||||
# define __attr_access(x)
|
||||
# define __attr_access_none(argno)
|
||||
#endif
|
||||
diff --git a/posix/unistd.h b/posix/unistd.h
|
||||
index 8224c5fbc956306f..7a61ff5e868c3456 100644
|
||||
--- a/posix/unistd.h
|
||||
+++ b/posix/unistd.h
|
||||
@@ -369,7 +369,7 @@ extern void closefrom (int __lowfd) __THROW;
|
||||
This function is a cancellation point and therefore not marked with
|
||||
__THROW. */
|
||||
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
|
||||
- __attr_access ((__write_only__, 2, 3));
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
|
||||
/* Write N bytes of BUF to FD. Return the number written, or -1.
|
||||
|
||||
@@ -388,7 +388,7 @@ extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
|
||||
__THROW. */
|
||||
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
|
||||
__off_t __offset) __wur
|
||||
- __attr_access ((__write_only__, 2, 3));
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
|
||||
/* Write N bytes of BUF to FD at the given position OFFSET without
|
||||
changing the file pointer. Return the number written, or -1.
|
||||
@@ -404,7 +404,7 @@ extern ssize_t pwrite (int __fd, const void *__buf, size_t __n,
|
||||
extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes,
|
||||
__off64_t __offset),
|
||||
pread64) __wur
|
||||
- __attr_access ((__write_only__, 2, 3));
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf,
|
||||
size_t __nbytes, __off64_t __offset),
|
||||
pwrite64) __wur
|
||||
@@ -421,7 +421,7 @@ extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf,
|
||||
or 0 for EOF. */
|
||||
extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
|
||||
__off64_t __offset) __wur
|
||||
- __attr_access ((__write_only__, 2, 3));
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
/* Write N bytes of BUF to FD at the given position OFFSET without
|
||||
changing the file pointer. Return the number written, or -1. */
|
||||
extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
|
||||
@@ -642,7 +642,7 @@ extern long int sysconf (int __name) __THROW;
|
||||
#ifdef __USE_POSIX2
|
||||
/* Get the value of the string-valued system variable NAME. */
|
||||
extern size_t confstr (int __name, char *__buf, size_t __len) __THROW
|
||||
- __attr_access ((__write_only__, 2, 3));
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -709,7 +709,7 @@ extern __gid_t getegid (void) __THROW;
|
||||
the calling process is in. Otherwise, fill in the group IDs
|
||||
of its supplementary groups in LIST and return the number written. */
|
||||
extern int getgroups (int __size, __gid_t __list[]) __THROW __wur
|
||||
- __attr_access ((__write_only__, 2, 1));
|
||||
+ __fortified_attr_access (__write_only__, 2, 1);
|
||||
#ifdef __USE_GNU
|
||||
/* Return nonzero iff the calling process is in group GID. */
|
||||
extern int group_member (__gid_t __gid) __THROW;
|
||||
@@ -801,7 +801,8 @@ extern char *ttyname (int __fd) __THROW;
|
||||
/* Store at most BUFLEN characters of the pathname of the terminal FD is
|
||||
open on in BUF. Return 0 on success, otherwise an error number. */
|
||||
extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
|
||||
- __THROW __nonnull ((2)) __wur __attr_access ((__write_only__, 2, 3));
|
||||
+ __THROW __nonnull ((2)) __wur
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
|
||||
/* Return 1 if FD is a valid descriptor associated
|
||||
with a terminal, zero if not. */
|
||||
@@ -836,7 +837,8 @@ extern int symlink (const char *__from, const char *__to)
|
||||
Returns the number of characters read, or -1 for errors. */
|
||||
extern ssize_t readlink (const char *__restrict __path,
|
||||
char *__restrict __buf, size_t __len)
|
||||
- __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
|
||||
+ __THROW __nonnull ((1, 2)) __wur
|
||||
+ __fortified_attr_access (__write_only__, 2, 3);
|
||||
|
||||
#endif /* Use POSIX.1-2001. */
|
||||
|
||||
@@ -848,7 +850,8 @@ extern int symlinkat (const char *__from, int __tofd,
|
||||
/* Like readlink but a relative PATH is interpreted relative to FD. */
|
||||
extern ssize_t readlinkat (int __fd, const char *__restrict __path,
|
||||
char *__restrict __buf, size_t __len)
|
||||
- __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
|
||||
+ __THROW __nonnull ((2, 3)) __wur
|
||||
+ __fortified_attr_access (__write_only__, 3, 4);
|
||||
#endif
|
||||
|
||||
/* Remove the link NAME. */
|
||||
@@ -884,7 +887,7 @@ extern char *getlogin (void);
|
||||
This function is a possible cancellation point and therefore not
|
||||
marked with __THROW. */
|
||||
extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1))
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
#endif
|
||||
|
||||
#ifdef __USE_MISC
|
||||
@@ -906,7 +909,7 @@ extern int setlogin (const char *__name) __THROW __nonnull ((1));
|
||||
The result is null-terminated if LEN is large enough for the full
|
||||
name and the terminator. */
|
||||
extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1))
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -925,7 +928,8 @@ extern int sethostid (long int __id) __THROW __wur;
|
||||
Called just like `gethostname' and `sethostname'.
|
||||
The NIS domain name is usually the empty string when not using NIS. */
|
||||
extern int getdomainname (char *__name, size_t __len)
|
||||
- __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
|
||||
+ __THROW __nonnull ((1)) __wur
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
extern int setdomainname (const char *__name, size_t __len)
|
||||
__THROW __nonnull ((1)) __wur __attr_access ((__read_only__, 1, 2));
|
||||
|
||||
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
|
||||
index 0481c1235514f6e7..74c00eee73e4009d 100644
|
||||
--- a/stdlib/stdlib.h
|
||||
+++ b/stdlib/stdlib.h
|
||||
@@ -943,7 +943,8 @@ extern size_t mbstowcs (wchar_t *__restrict __pwcs,
|
||||
extern size_t wcstombs (char *__restrict __s,
|
||||
const wchar_t *__restrict __pwcs, size_t __n)
|
||||
__THROW
|
||||
- __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 3)
|
||||
+ __attr_access ((__read_only__, 2));
|
||||
|
||||
#ifdef __USE_MISC
|
||||
/* Determine whether the string value of RESPONSE matches the affirmation
|
||||
@@ -997,7 +998,7 @@ extern char *ptsname (int __fd) __THROW __wur;
|
||||
terminal associated with the master FD is open on in BUF.
|
||||
Return 0 on success, otherwise an error number. */
|
||||
extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
|
||||
- __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
|
||||
+ __THROW __nonnull ((2)) __fortified_attr_access (__write_only__, 2, 3);
|
||||
|
||||
/* Open a master pseudo terminal and return its file descriptor. */
|
||||
extern int getpt (void);
|
||||
diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
|
||||
index 67ae2c6b50435368..5731274848260ad2 100644
|
||||
--- a/string/bits/string_fortified.h
|
||||
+++ b/string/bits/string_fortified.h
|
||||
@@ -64,7 +64,7 @@ __NTH (memset (void *__dest, int __ch, size_t __len))
|
||||
# include <bits/strings_fortified.h>
|
||||
|
||||
void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen)
|
||||
- __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
|
||||
+ __THROW __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 2);
|
||||
|
||||
__fortify_function void
|
||||
__NTH (explicit_bzero (void *__dest, size_t __len))
|
||||
@@ -106,7 +106,8 @@ __NTH (stpncpy (char *__dest, const char *__src, size_t __n))
|
||||
#else
|
||||
extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
|
||||
size_t __destlen) __THROW
|
||||
- __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
|
||||
+ __fortified_attr_access ((__write_only__, 1, 3))
|
||||
+ __attr_access ((__read_only__, 2));
|
||||
extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src,
|
||||
size_t __n), stpncpy);
|
||||
|
||||
diff --git a/string/string.h b/string/string.h
|
||||
index 04e1b7067dc31d3c..8dcafb4ac4952853 100644
|
||||
--- a/string/string.h
|
||||
+++ b/string/string.h
|
||||
@@ -448,7 +448,7 @@ extern char *strerror_l (int __errnum, locale_t __l) __THROW;
|
||||
/* Set N bytes of S to 0. The compiler will not delete a call to this
|
||||
function, even if S is dead after the call. */
|
||||
extern void explicit_bzero (void *__s, size_t __n) __THROW __nonnull ((1))
|
||||
- __attr_access ((__write_only__, 1, 2));
|
||||
+ __fortified_attr_access (__write_only__, 1, 2);
|
||||
|
||||
/* Return the next DELIM-delimited token from *STRINGP,
|
||||
terminating it with a '\0', and update *STRINGP to point past it. */
|
1038
glibc-upstream-2.34-126.patch
Normal file
1038
glibc-upstream-2.34-126.patch
Normal file
File diff suppressed because it is too large
Load Diff
358
glibc-upstream-2.34-127.patch
Normal file
358
glibc-upstream-2.34-127.patch
Normal file
@ -0,0 +1,358 @@
|
||||
commit 536910724d30a38eeecd14cdbe2c93c78ea67646
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Wed Oct 20 18:13:05 2021 +0530
|
||||
|
||||
debug: Add tests for _FORTIFY_SOURCE=3
|
||||
|
||||
Add some testing coverage for _FORTIFY_SOURCE=3.
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
(cherry picked from commit ad6f2a010c2ce759936de4747f6e0d53991912f8)
|
||||
|
||||
diff --git a/debug/Makefile b/debug/Makefile
|
||||
index 6893111cbfaa0900..357f888246061e15 100644
|
||||
--- a/debug/Makefile
|
||||
+++ b/debug/Makefile
|
||||
@@ -120,6 +120,8 @@ CFLAGS-tst-chk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
CFLAGS-tst-chk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
CFLAGS-tst-chk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
CFLAGS-tst-chk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
+CFLAGS-tst-chk7.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
+CFLAGS-tst-chk8.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
CFLAGS-tst-lfschk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
CFLAGS-tst-lfschk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
CFLAGS-tst-lfschk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
@@ -129,6 +131,7 @@ CFLAGS-tst-lfschk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
LDLIBS-tst-chk4 = -lstdc++
|
||||
LDLIBS-tst-chk5 = -lstdc++
|
||||
LDLIBS-tst-chk6 = -lstdc++
|
||||
+LDLIBS-tst-chk8 = -lstdc++
|
||||
LDLIBS-tst-lfschk4 = -lstdc++
|
||||
LDLIBS-tst-lfschk5 = -lstdc++
|
||||
LDLIBS-tst-lfschk6 = -lstdc++
|
||||
@@ -150,16 +153,16 @@ CFLAGS-tst-ssp-1.c += -fstack-protector-all
|
||||
|
||||
tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
|
||||
tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
|
||||
- tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \
|
||||
- tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 tst-backtrace4 \
|
||||
- tst-backtrace5 tst-backtrace6
|
||||
+ tst-chk4 tst-chk5 tst-chk6 tst-chk7 tst-chk8 tst-lfschk4 tst-lfschk5 \
|
||||
+ tst-lfschk6 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 \
|
||||
+ tst-backtrace4 tst-backtrace5 tst-backtrace6
|
||||
|
||||
ifeq ($(have-ssp),yes)
|
||||
tests += tst-ssp-1
|
||||
endif
|
||||
|
||||
ifeq (,$(CXX))
|
||||
-tests-unsupported = tst-chk4 tst-chk5 tst-chk6 \
|
||||
+tests-unsupported = tst-chk4 tst-chk5 tst-chk6 tst-chk8 \
|
||||
tst-lfschk4 tst-lfschk5 tst-lfschk6
|
||||
endif
|
||||
|
||||
@@ -193,6 +196,8 @@ $(objpfx)tst-chk3.out: $(gen-locales)
|
||||
$(objpfx)tst-chk4.out: $(gen-locales)
|
||||
$(objpfx)tst-chk5.out: $(gen-locales)
|
||||
$(objpfx)tst-chk6.out: $(gen-locales)
|
||||
+$(objpfx)tst-chk7.out: $(gen-locales)
|
||||
+$(objpfx)tst-chk8.out: $(gen-locales)
|
||||
$(objpfx)tst-lfschk1.out: $(gen-locales)
|
||||
$(objpfx)tst-lfschk2.out: $(gen-locales)
|
||||
$(objpfx)tst-lfschk3.out: $(gen-locales)
|
||||
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
|
||||
index 6c1d32cc62c3a964..68ac00d1808382b8 100644
|
||||
--- a/debug/tst-chk1.c
|
||||
+++ b/debug/tst-chk1.c
|
||||
@@ -83,8 +83,14 @@ handler (int sig)
|
||||
_exit (127);
|
||||
}
|
||||
|
||||
+#if __USE_FORTIFY_LEVEL == 3
|
||||
+volatile size_t buf_size = 10;
|
||||
+#else
|
||||
char buf[10];
|
||||
wchar_t wbuf[10];
|
||||
+#define buf_size sizeof (buf)
|
||||
+#endif
|
||||
+
|
||||
volatile size_t l0;
|
||||
volatile char *p;
|
||||
volatile wchar_t *wp;
|
||||
@@ -123,6 +129,10 @@ int num2 = 987654;
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
+#if __USE_FORTIFY_LEVEL == 3
|
||||
+ char *buf = (char *) malloc (buf_size);
|
||||
+ wchar_t *wbuf = (wchar_t *) malloc (buf_size * sizeof (wchar_t));
|
||||
+#endif
|
||||
set_fortify_handler (handler);
|
||||
|
||||
struct A { char buf1[9]; char buf2[1]; } a;
|
||||
@@ -947,93 +957,93 @@ do_test (void)
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fgets (buf, sizeof (buf), stdin) != buf
|
||||
+ if (fgets (buf, buf_size, stdin) != buf
|
||||
|| memcmp (buf, "abcdefgh\n", 10))
|
||||
FAIL ();
|
||||
- if (fgets (buf, sizeof (buf), stdin) != buf || memcmp (buf, "ABCDEFGHI", 10))
|
||||
+ if (fgets (buf, buf_size, stdin) != buf || memcmp (buf, "ABCDEFGHI", 10))
|
||||
FAIL ();
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fgets (buf, l0 + sizeof (buf), stdin) != buf
|
||||
+ if (fgets (buf, l0 + buf_size, stdin) != buf
|
||||
|| memcmp (buf, "abcdefgh\n", 10))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (fgets (buf, sizeof (buf) + 1, stdin) != buf)
|
||||
+ if (fgets (buf, buf_size + 1, stdin) != buf)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (fgets (buf, l0 + sizeof (buf) + 1, stdin) != buf)
|
||||
+ if (fgets (buf, l0 + buf_size + 1, stdin) != buf)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fgets_unlocked (buf, sizeof (buf), stdin) != buf
|
||||
+ if (fgets_unlocked (buf, buf_size, stdin) != buf
|
||||
|| memcmp (buf, "abcdefgh\n", 10))
|
||||
FAIL ();
|
||||
- if (fgets_unlocked (buf, sizeof (buf), stdin) != buf
|
||||
+ if (fgets_unlocked (buf, buf_size, stdin) != buf
|
||||
|| memcmp (buf, "ABCDEFGHI", 10))
|
||||
FAIL ();
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fgets_unlocked (buf, l0 + sizeof (buf), stdin) != buf
|
||||
+ if (fgets_unlocked (buf, l0 + buf_size, stdin) != buf
|
||||
|| memcmp (buf, "abcdefgh\n", 10))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (fgets_unlocked (buf, sizeof (buf) + 1, stdin) != buf)
|
||||
+ if (fgets_unlocked (buf, buf_size + 1, stdin) != buf)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (fgets_unlocked (buf, l0 + sizeof (buf) + 1, stdin) != buf)
|
||||
+ if (fgets_unlocked (buf, l0 + buf_size + 1, stdin) != buf)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fread (buf, 1, sizeof (buf), stdin) != sizeof (buf)
|
||||
+ if (fread (buf, 1, buf_size, stdin) != buf_size
|
||||
|| memcmp (buf, "abcdefgh\nA", 10))
|
||||
FAIL ();
|
||||
- if (fread (buf, sizeof (buf), 1, stdin) != 1
|
||||
+ if (fread (buf, buf_size, 1, stdin) != 1
|
||||
|| memcmp (buf, "BCDEFGHI\na", 10))
|
||||
FAIL ();
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fread (buf, l0 + 1, sizeof (buf), stdin) != sizeof (buf)
|
||||
+ if (fread (buf, l0 + 1, buf_size, stdin) != buf_size
|
||||
|| memcmp (buf, "abcdefgh\nA", 10))
|
||||
FAIL ();
|
||||
- if (fread (buf, sizeof (buf), l0 + 1, stdin) != 1
|
||||
+ if (fread (buf, buf_size, l0 + 1, stdin) != 1
|
||||
|| memcmp (buf, "BCDEFGHI\na", 10))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (fread (buf, 1, sizeof (buf) + 1, stdin) != sizeof (buf) + 1)
|
||||
+ if (fread (buf, 1, buf_size + 1, stdin) != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (fread (buf, sizeof (buf) + 1, l0 + 1, stdin) != 1)
|
||||
+ if (fread (buf, buf_size + 1, l0 + 1, stdin) != 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fread_unlocked (buf, 1, sizeof (buf), stdin) != sizeof (buf)
|
||||
+ if (fread_unlocked (buf, 1, buf_size, stdin) != buf_size
|
||||
|| memcmp (buf, "abcdefgh\nA", 10))
|
||||
FAIL ();
|
||||
- if (fread_unlocked (buf, sizeof (buf), 1, stdin) != 1
|
||||
+ if (fread_unlocked (buf, buf_size, 1, stdin) != 1
|
||||
|| memcmp (buf, "BCDEFGHI\na", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -1048,100 +1058,100 @@ do_test (void)
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
- if (fread_unlocked (buf, l0 + 1, sizeof (buf), stdin) != sizeof (buf)
|
||||
+ if (fread_unlocked (buf, l0 + 1, buf_size, stdin) != buf_size
|
||||
|| memcmp (buf, "abcdefgh\nA", 10))
|
||||
FAIL ();
|
||||
- if (fread_unlocked (buf, sizeof (buf), l0 + 1, stdin) != 1
|
||||
+ if (fread_unlocked (buf, buf_size, l0 + 1, stdin) != 1
|
||||
|| memcmp (buf, "BCDEFGHI\na", 10))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (fread_unlocked (buf, 1, sizeof (buf) + 1, stdin) != sizeof (buf) + 1)
|
||||
+ if (fread_unlocked (buf, 1, buf_size + 1, stdin) != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (fread_unlocked (buf, sizeof (buf) + 1, l0 + 1, stdin) != 1)
|
||||
+ if (fread_unlocked (buf, buf_size + 1, l0 + 1, stdin) != 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
|
||||
lseek (fileno (stdin), 0, SEEK_SET);
|
||||
|
||||
- if (read (fileno (stdin), buf, sizeof (buf) - 1) != sizeof (buf) - 1
|
||||
+ if (read (fileno (stdin), buf, buf_size - 1) != buf_size - 1
|
||||
|| memcmp (buf, "abcdefgh\n", 9))
|
||||
FAIL ();
|
||||
- if (read (fileno (stdin), buf, sizeof (buf) - 1) != sizeof (buf) - 1
|
||||
+ if (read (fileno (stdin), buf, buf_size - 1) != buf_size - 1
|
||||
|| memcmp (buf, "ABCDEFGHI", 9))
|
||||
FAIL ();
|
||||
|
||||
lseek (fileno (stdin), 0, SEEK_SET);
|
||||
|
||||
- if (read (fileno (stdin), buf, l0 + sizeof (buf) - 1) != sizeof (buf) - 1
|
||||
+ if (read (fileno (stdin), buf, l0 + buf_size - 1) != buf_size - 1
|
||||
|| memcmp (buf, "abcdefgh\n", 9))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (read (fileno (stdin), buf, sizeof (buf) + 1) != sizeof (buf) + 1)
|
||||
+ if (read (fileno (stdin), buf, buf_size + 1) != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (read (fileno (stdin), buf, l0 + sizeof (buf) + 1) != sizeof (buf) + 1)
|
||||
+ if (read (fileno (stdin), buf, l0 + buf_size + 1) != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
|
||||
- if (pread (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 2)
|
||||
- != sizeof (buf) - 1
|
||||
+ if (pread (fileno (stdin), buf, buf_size - 1, buf_size - 2)
|
||||
+ != buf_size - 1
|
||||
|| memcmp (buf, "\nABCDEFGH", 9))
|
||||
FAIL ();
|
||||
- if (pread (fileno (stdin), buf, sizeof (buf) - 1, 0) != sizeof (buf) - 1
|
||||
+ if (pread (fileno (stdin), buf, buf_size - 1, 0) != buf_size - 1
|
||||
|| memcmp (buf, "abcdefgh\n", 9))
|
||||
FAIL ();
|
||||
- if (pread (fileno (stdin), buf, l0 + sizeof (buf) - 1, sizeof (buf) - 3)
|
||||
- != sizeof (buf) - 1
|
||||
+ if (pread (fileno (stdin), buf, l0 + buf_size - 1, buf_size - 3)
|
||||
+ != buf_size - 1
|
||||
|| memcmp (buf, "h\nABCDEFG", 9))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (pread (fileno (stdin), buf, sizeof (buf) + 1, 2 * sizeof (buf))
|
||||
- != sizeof (buf) + 1)
|
||||
+ if (pread (fileno (stdin), buf, buf_size + 1, 2 * buf_size)
|
||||
+ != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (pread (fileno (stdin), buf, l0 + sizeof (buf) + 1, 2 * sizeof (buf))
|
||||
- != sizeof (buf) + 1)
|
||||
+ if (pread (fileno (stdin), buf, l0 + buf_size + 1, 2 * buf_size)
|
||||
+ != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
|
||||
- if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 2)
|
||||
- != sizeof (buf) - 1
|
||||
+ if (pread64 (fileno (stdin), buf, buf_size - 1, buf_size - 2)
|
||||
+ != buf_size - 1
|
||||
|| memcmp (buf, "\nABCDEFGH", 9))
|
||||
FAIL ();
|
||||
- if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, 0) != sizeof (buf) - 1
|
||||
+ if (pread64 (fileno (stdin), buf, buf_size - 1, 0) != buf_size - 1
|
||||
|| memcmp (buf, "abcdefgh\n", 9))
|
||||
FAIL ();
|
||||
- if (pread64 (fileno (stdin), buf, l0 + sizeof (buf) - 1, sizeof (buf) - 3)
|
||||
- != sizeof (buf) - 1
|
||||
+ if (pread64 (fileno (stdin), buf, l0 + buf_size - 1, buf_size - 3)
|
||||
+ != buf_size - 1
|
||||
|| memcmp (buf, "h\nABCDEFG", 9))
|
||||
FAIL ();
|
||||
|
||||
#if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
- if (pread64 (fileno (stdin), buf, sizeof (buf) + 1, 2 * sizeof (buf))
|
||||
- != sizeof (buf) + 1)
|
||||
+ if (pread64 (fileno (stdin), buf, buf_size + 1, 2 * buf_size)
|
||||
+ != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
|
||||
CHK_FAIL_START
|
||||
- if (pread64 (fileno (stdin), buf, l0 + sizeof (buf) + 1, 2 * sizeof (buf))
|
||||
- != sizeof (buf) + 1)
|
||||
+ if (pread64 (fileno (stdin), buf, l0 + buf_size + 1, 2 * buf_size)
|
||||
+ != buf_size + 1)
|
||||
FAIL ();
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
@@ -1179,7 +1189,7 @@ do_test (void)
|
||||
CHK_FAIL2_END
|
||||
|
||||
CHK_FAIL2_START
|
||||
- snprintf (buf, sizeof (buf), "%3$d\n", 1, 2, 3, 4);
|
||||
+ snprintf (buf, buf_size, "%3$d\n", 1, 2, 3, 4);
|
||||
CHK_FAIL2_END
|
||||
|
||||
int sp[2];
|
||||
diff --git a/debug/tst-chk7.c b/debug/tst-chk7.c
|
||||
new file mode 100644
|
||||
index 0000000000000000..2a7b32381268135c
|
||||
--- /dev/null
|
||||
+++ b/debug/tst-chk7.c
|
||||
@@ -0,0 +1,2 @@
|
||||
+#define _FORTIFY_SOURCE 3
|
||||
+#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk8.cc b/debug/tst-chk8.cc
|
||||
new file mode 100644
|
||||
index 0000000000000000..2a7b32381268135c
|
||||
--- /dev/null
|
||||
+++ b/debug/tst-chk8.cc
|
||||
@@ -0,0 +1,2 @@
|
||||
+#define _FORTIFY_SOURCE 3
|
||||
+#include "tst-chk1.c"
|
24
glibc-upstream-2.34-128.patch
Normal file
24
glibc-upstream-2.34-128.patch
Normal file
@ -0,0 +1,24 @@
|
||||
commit 98ea9372cc8d60b12aa33e007fdd5f5fb042a651
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Thu Dec 16 07:19:14 2021 +0530
|
||||
|
||||
__glibc_unsafe_len: Fix comment
|
||||
|
||||
We know that the length is *unsafe*.
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
(cherry picked from commit ae23fa3e5fe24daf94fc7f8e5268bb8ceeda7477)
|
||||
|
||||
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
|
||||
index 4825ff0351c1e5d4..3bb9f38916e30295 100644
|
||||
--- a/misc/sys/cdefs.h
|
||||
+++ b/misc/sys/cdefs.h
|
||||
@@ -168,7 +168,7 @@
|
||||
__s, __osz)) \
|
||||
&& __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
|
||||
|
||||
-/* Conversely, we know at compile time that the length is safe if the
|
||||
+/* Conversely, we know at compile time that the length is unsafe if the
|
||||
__L * __S <= __OBJSZ condition can be folded to a constant and if it is
|
||||
false. */
|
||||
#define __glibc_unsafe_len(__l, __s, __osz) \
|
91
glibc-upstream-2.34-129.patch
Normal file
91
glibc-upstream-2.34-129.patch
Normal file
@ -0,0 +1,91 @@
|
||||
commit 10f7bdebe570e42d1f7a43de4f90eda8ccb4f0da
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Fri Dec 17 18:35:44 2021 +0530
|
||||
|
||||
fortify: Fix spurious warning with realpath
|
||||
|
||||
The length and object size arguments were swapped around for realpath.
|
||||
Also add a smoke test so that any changes in this area get caught in
|
||||
future.
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
(cherry picked from commit 2bbd07c715275eb6c616988925738a0517180d57)
|
||||
|
||||
diff --git a/debug/Makefile b/debug/Makefile
|
||||
index 357f888246061e15..bc37e466eed490fa 100644
|
||||
--- a/debug/Makefile
|
||||
+++ b/debug/Makefile
|
||||
@@ -108,6 +108,7 @@ CFLAGS-tst-longjmp_chk2.c += -fexceptions -fasynchronous-unwind-tables
|
||||
CPPFLAGS-tst-longjmp_chk2.c += -D_FORTIFY_SOURCE=1
|
||||
CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables
|
||||
CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1
|
||||
+CPPFLAGS-tst-realpath-chk.c += -D_FORTIFY_SOURCE=2
|
||||
|
||||
# We know these tests have problems with format strings, this is what
|
||||
# we are testing. Disable that warning. They are also testing
|
||||
@@ -155,7 +156,7 @@ tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
|
||||
tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
|
||||
tst-chk4 tst-chk5 tst-chk6 tst-chk7 tst-chk8 tst-lfschk4 tst-lfschk5 \
|
||||
tst-lfschk6 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 \
|
||||
- tst-backtrace4 tst-backtrace5 tst-backtrace6
|
||||
+ tst-backtrace4 tst-backtrace5 tst-backtrace6 tst-realpath-chk
|
||||
|
||||
ifeq ($(have-ssp),yes)
|
||||
tests += tst-ssp-1
|
||||
diff --git a/debug/tst-realpath-chk.c b/debug/tst-realpath-chk.c
|
||||
new file mode 100644
|
||||
index 0000000000000000..a8fcb327c43fb34d
|
||||
--- /dev/null
|
||||
+++ b/debug/tst-realpath-chk.c
|
||||
@@ -0,0 +1,37 @@
|
||||
+/* Smoke test to verify that realpath does not cause spurious warnings.
|
||||
+ Copyright The GNU Toolchain Authors.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#include <limits.h>
|
||||
+#include <stdlib.h>
|
||||
+
|
||||
+#include <support/check.h>
|
||||
+#include <support/support.h>
|
||||
+
|
||||
+static int
|
||||
+do_test (void)
|
||||
+{
|
||||
+#ifdef PATH_MAX
|
||||
+ char buf[PATH_MAX + 1];
|
||||
+ char *res = realpath (".", buf);
|
||||
+ TEST_VERIFY (res == buf);
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#include <support/test-driver.c>
|
||||
diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
|
||||
index 067115eeca123c6d..ccacbdf76a08225a 100644
|
||||
--- a/stdlib/bits/stdlib.h
|
||||
+++ b/stdlib/bits/stdlib.h
|
||||
@@ -42,7 +42,7 @@ __NTH (realpath (const char *__restrict __name, char *__restrict __resolved))
|
||||
return __realpath_alias (__name, __resolved);
|
||||
|
||||
#if defined _LIBC_LIMITS_H_ && defined PATH_MAX
|
||||
- if (__glibc_unsafe_len (sz, sizeof (char), PATH_MAX))
|
||||
+ if (__glibc_unsafe_len (PATH_MAX, sizeof (char), sz))
|
||||
return __realpath_chk_warn (__name, __resolved, sz);
|
||||
#endif
|
||||
return __realpath_chk (__name, __resolved, sz);
|
42
glibc-upstream-2.34-130.patch
Normal file
42
glibc-upstream-2.34-130.patch
Normal file
@ -0,0 +1,42 @@
|
||||
commit d6a58bd81d07322ff5da8f419d8620ef037b6a36
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Wed Jan 12 18:46:28 2022 +0530
|
||||
|
||||
Enable _FORTIFY_SOURCE=3 for gcc 12 and above
|
||||
|
||||
gcc 12 now has support for the __builtin_dynamic_object_size builtin.
|
||||
Adapt the macro checks to enable _FORTIFY_SOURCE=3 on gcc 12 and above.
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
(cherry picked from commit 86bf0feb0e3ec8e37872f72499d6ae33406561d7)
|
||||
|
||||
diff --git a/include/features.h b/include/features.h
|
||||
index d974eabfafc24ffb..933499bcff8f1449 100644
|
||||
--- a/include/features.h
|
||||
+++ b/include/features.h
|
||||
@@ -412,7 +412,9 @@
|
||||
# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
|
||||
# elif !__GNUC_PREREQ (4, 1)
|
||||
# warning _FORTIFY_SOURCE requires GCC 4.1 or later
|
||||
-# elif _FORTIFY_SOURCE > 2 && __glibc_clang_prereq (9, 0)
|
||||
+# elif _FORTIFY_SOURCE > 2 && (__glibc_clang_prereq (9, 0) \
|
||||
+ || __GNUC_PREREQ (12, 0))
|
||||
+
|
||||
# if _FORTIFY_SOURCE > 3
|
||||
# warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform
|
||||
# endif
|
||||
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
|
||||
index 3bb9f38916e30295..515fb681a0547217 100644
|
||||
--- a/misc/sys/cdefs.h
|
||||
+++ b/misc/sys/cdefs.h
|
||||
@@ -142,7 +142,8 @@
|
||||
#define __bos0(ptr) __builtin_object_size (ptr, 0)
|
||||
|
||||
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
|
||||
-#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
|
||||
+#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
|
||||
+ || __GNUC_PREREQ (12, 0))
|
||||
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
|
||||
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
|
||||
#else
|
293
glibc-upstream-2.34-131.patch
Normal file
293
glibc-upstream-2.34-131.patch
Normal file
@ -0,0 +1,293 @@
|
||||
commit f8c2f620f1929ad78cb0a247601bec972f140c51
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Wed Jan 12 23:34:23 2022 +0530
|
||||
|
||||
debug: Autogenerate _FORTIFY_SOURCE tests
|
||||
|
||||
Rename debug/tst-chk1.c to debug/tst-fortify.c and add make hackery to
|
||||
autogenerate tests with different macros enabled to build and run the
|
||||
same test with different configurations as well as different
|
||||
fortification levels.
|
||||
|
||||
The change also ends up expanding the -lfs tests to include
|
||||
_FORTIFY_SOURCE=3.
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
(cherry picked from commit db27f1251b008280a29d540b4f8ab2a38a0d80af)
|
||||
|
||||
diff --git a/Makerules b/Makerules
|
||||
index 596fa68376f45298..7fbe85719aacc230 100644
|
||||
--- a/Makerules
|
||||
+++ b/Makerules
|
||||
@@ -424,6 +424,12 @@ $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
|
||||
endef
|
||||
object-suffixes-left := $(all-object-suffixes)
|
||||
include $(o-iterator)
|
||||
+
|
||||
+define o-iterator-doit
|
||||
+$(objpfx)%$o: $(objpfx)%.cc $(before-compile); $$(compile-command.cc)
|
||||
+endef
|
||||
+object-suffixes-left := $(all-object-suffixes)
|
||||
+include $(o-iterator)
|
||||
endif
|
||||
|
||||
# Generate .dT files as we compile.
|
||||
diff --git a/debug/Makefile b/debug/Makefile
|
||||
index bc37e466eed490fa..acc1b8f6ad029c62 100644
|
||||
--- a/debug/Makefile
|
||||
+++ b/debug/Makefile
|
||||
@@ -1,4 +1,5 @@
|
||||
-# Copyright (C) 1998-2021 Free Software Foundation, Inc.
|
||||
+# Copyright (C) 1998-2022 Free Software Foundation, Inc.
|
||||
+# Copyright The GNU Toolchain Authors.
|
||||
# This file is part of the GNU C Library.
|
||||
|
||||
# The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -110,32 +111,60 @@ CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables
|
||||
CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1
|
||||
CPPFLAGS-tst-realpath-chk.c += -D_FORTIFY_SOURCE=2
|
||||
|
||||
+# _FORTIFY_SOURCE tests.
|
||||
+# Auto-generate tests for _FORTIFY_SOURCE for different levels, compilers and
|
||||
+# preprocessor conditions based on tst-fortify.c.
|
||||
+#
|
||||
+# To add a new test condition, define a cflags-$(cond) make variable to set
|
||||
+# CFLAGS for the file.
|
||||
+
|
||||
+tests-all-chk = tst-fortify
|
||||
+tests-c-chk =
|
||||
+tests-cc-chk =
|
||||
+
|
||||
+CFLAGS-tst-fortify.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
+
|
||||
+# No additional flags for the default tests.
|
||||
+define cflags-default
|
||||
+endef
|
||||
+
|
||||
+define cflags-lfs
|
||||
+CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64
|
||||
+endef
|
||||
+
|
||||
# We know these tests have problems with format strings, this is what
|
||||
# we are testing. Disable that warning. They are also testing
|
||||
# deprecated functions (notably gets) so disable that warning as well.
|
||||
# And they also generate warnings from warning attributes, which
|
||||
# cannot be disabled via pragmas, so require -Wno-error to be used.
|
||||
-CFLAGS-tst-chk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk7.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-chk8.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-lfschk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-lfschk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-lfschk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-lfschk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-lfschk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-CFLAGS-tst-lfschk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
||||
-LDLIBS-tst-chk4 = -lstdc++
|
||||
-LDLIBS-tst-chk5 = -lstdc++
|
||||
-LDLIBS-tst-chk6 = -lstdc++
|
||||
-LDLIBS-tst-chk8 = -lstdc++
|
||||
-LDLIBS-tst-lfschk4 = -lstdc++
|
||||
-LDLIBS-tst-lfschk5 = -lstdc++
|
||||
-LDLIBS-tst-lfschk6 = -lstdc++
|
||||
+define gen-chk-test
|
||||
+tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3)
|
||||
+CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
|
||||
+ -Wno-deprecated-declarations \
|
||||
+ -Wno-error
|
||||
+$(eval $(call cflags-$(2),$(1),$(3)))
|
||||
+$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
|
||||
+ ( echo "/* Autogenerated from Makefile. */"; \
|
||||
+ echo ""; \
|
||||
+ echo "#include \"tst-fortify.c\"" ) > $$@.tmp
|
||||
+ mv $$@.tmp $$@
|
||||
+endef
|
||||
+
|
||||
+chk-extensions = c cc
|
||||
+chk-types = default lfs
|
||||
+chk-levels = 1 2 3
|
||||
+
|
||||
+$(foreach e,$(chk-extensions), \
|
||||
+ $(foreach t,$(chk-types), \
|
||||
+ $(foreach l,$(chk-levels), \
|
||||
+ $(eval $(call gen-chk-test,$(e),$(t),$(l))))))
|
||||
+
|
||||
+tests-all-chk += $(tests-c-chk) $(tests-cc-chk)
|
||||
+
|
||||
+define link-cc
|
||||
+LDLIBS-$(1) = -lstdc++
|
||||
+endef
|
||||
+$(foreach t,$(tests-cc-chk), $(eval $(call link-cc,$(t))))
|
||||
|
||||
# backtrace_symbols only works if we link with -rdynamic. backtrace
|
||||
# requires unwind tables on most architectures.
|
||||
@@ -152,19 +181,25 @@ LDFLAGS-tst-backtrace6 = -rdynamic
|
||||
|
||||
CFLAGS-tst-ssp-1.c += -fstack-protector-all
|
||||
|
||||
-tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
|
||||
- tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
|
||||
- tst-chk4 tst-chk5 tst-chk6 tst-chk7 tst-chk8 tst-lfschk4 tst-lfschk5 \
|
||||
- tst-lfschk6 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 \
|
||||
- tst-backtrace4 tst-backtrace5 tst-backtrace6 tst-realpath-chk
|
||||
+tests = backtrace-tst \
|
||||
+ tst-longjmp_chk \
|
||||
+ test-strcpy_chk \
|
||||
+ test-stpcpy_chk \
|
||||
+ tst-longjmp_chk2 \
|
||||
+ tst-backtrace2 \
|
||||
+ tst-backtrace3 \
|
||||
+ tst-backtrace4 \
|
||||
+ tst-backtrace5 \
|
||||
+ tst-backtrace6 \
|
||||
+ tst-realpath-chk \
|
||||
+ $(tests-all-chk)
|
||||
|
||||
ifeq ($(have-ssp),yes)
|
||||
tests += tst-ssp-1
|
||||
endif
|
||||
|
||||
ifeq (,$(CXX))
|
||||
-tests-unsupported = tst-chk4 tst-chk5 tst-chk6 tst-chk8 \
|
||||
- tst-lfschk4 tst-lfschk5 tst-lfschk6
|
||||
+tests-unsupported = $(tests-cc-chk)
|
||||
endif
|
||||
|
||||
extra-libs = libSegFault libpcprofile
|
||||
@@ -191,20 +226,10 @@ ifeq ($(run-built-tests),yes)
|
||||
LOCALES := de_DE.UTF-8
|
||||
include ../gen-locales.mk
|
||||
|
||||
-$(objpfx)tst-chk1.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk2.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk3.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk4.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk5.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk6.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk7.out: $(gen-locales)
|
||||
-$(objpfx)tst-chk8.out: $(gen-locales)
|
||||
-$(objpfx)tst-lfschk1.out: $(gen-locales)
|
||||
-$(objpfx)tst-lfschk2.out: $(gen-locales)
|
||||
-$(objpfx)tst-lfschk3.out: $(gen-locales)
|
||||
-$(objpfx)tst-lfschk4.out: $(gen-locales)
|
||||
-$(objpfx)tst-lfschk5.out: $(gen-locales)
|
||||
-$(objpfx)tst-lfschk6.out: $(gen-locales)
|
||||
+define chk-gen-locales
|
||||
+$(objpfx)$(1).out: $(gen-locales)
|
||||
+endef
|
||||
+$(foreach t, $(tests-all-chk), $(eval $(call chk-gen-locales,$(t))))
|
||||
endif
|
||||
|
||||
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
|
||||
diff --git a/debug/tst-chk2.c b/debug/tst-chk2.c
|
||||
deleted file mode 100644
|
||||
index be37ce2d22f0760a..0000000000000000
|
||||
--- a/debug/tst-chk2.c
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FORTIFY_SOURCE 1
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk3.c b/debug/tst-chk3.c
|
||||
deleted file mode 100644
|
||||
index 38b8e4fb360ba722..0000000000000000
|
||||
--- a/debug/tst-chk3.c
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FORTIFY_SOURCE 2
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk4.cc b/debug/tst-chk4.cc
|
||||
deleted file mode 100644
|
||||
index c82e6aac86038791..0000000000000000
|
||||
--- a/debug/tst-chk4.cc
|
||||
+++ /dev/null
|
||||
@@ -1 +0,0 @@
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk5.cc b/debug/tst-chk5.cc
|
||||
deleted file mode 100644
|
||||
index be37ce2d22f0760a..0000000000000000
|
||||
--- a/debug/tst-chk5.cc
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FORTIFY_SOURCE 1
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk6.cc b/debug/tst-chk6.cc
|
||||
deleted file mode 100644
|
||||
index 38b8e4fb360ba722..0000000000000000
|
||||
--- a/debug/tst-chk6.cc
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FORTIFY_SOURCE 2
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk7.c b/debug/tst-chk7.c
|
||||
deleted file mode 100644
|
||||
index 2a7b32381268135c..0000000000000000
|
||||
--- a/debug/tst-chk7.c
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FORTIFY_SOURCE 3
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk8.cc b/debug/tst-chk8.cc
|
||||
deleted file mode 100644
|
||||
index 2a7b32381268135c..0000000000000000
|
||||
--- a/debug/tst-chk8.cc
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FORTIFY_SOURCE 3
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-chk1.c b/debug/tst-fortify.c
|
||||
similarity index 100%
|
||||
rename from debug/tst-chk1.c
|
||||
rename to debug/tst-fortify.c
|
||||
diff --git a/debug/tst-lfschk1.c b/debug/tst-lfschk1.c
|
||||
deleted file mode 100644
|
||||
index f3e6d47d5e4484c3..0000000000000000
|
||||
--- a/debug/tst-lfschk1.c
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FILE_OFFSET_BITS 64
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-lfschk2.c b/debug/tst-lfschk2.c
|
||||
deleted file mode 100644
|
||||
index 95d4db1d32d2eeb3..0000000000000000
|
||||
--- a/debug/tst-lfschk2.c
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FILE_OFFSET_BITS 64
|
||||
-#include "tst-chk2.c"
|
||||
diff --git a/debug/tst-lfschk3.c b/debug/tst-lfschk3.c
|
||||
deleted file mode 100644
|
||||
index 50a1ae1258f1553d..0000000000000000
|
||||
--- a/debug/tst-lfschk3.c
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FILE_OFFSET_BITS 64
|
||||
-#include "tst-chk3.c"
|
||||
diff --git a/debug/tst-lfschk4.cc b/debug/tst-lfschk4.cc
|
||||
deleted file mode 100644
|
||||
index f3e6d47d5e4484c3..0000000000000000
|
||||
--- a/debug/tst-lfschk4.cc
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FILE_OFFSET_BITS 64
|
||||
-#include "tst-chk1.c"
|
||||
diff --git a/debug/tst-lfschk5.cc b/debug/tst-lfschk5.cc
|
||||
deleted file mode 100644
|
||||
index 95d4db1d32d2eeb3..0000000000000000
|
||||
--- a/debug/tst-lfschk5.cc
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FILE_OFFSET_BITS 64
|
||||
-#include "tst-chk2.c"
|
||||
diff --git a/debug/tst-lfschk6.cc b/debug/tst-lfschk6.cc
|
||||
deleted file mode 100644
|
||||
index 50a1ae1258f1553d..0000000000000000
|
||||
--- a/debug/tst-lfschk6.cc
|
||||
+++ /dev/null
|
||||
@@ -1,2 +0,0 @@
|
||||
-#define _FILE_OFFSET_BITS 64
|
||||
-#include "tst-chk3.c"
|
356
glibc-upstream-2.34-132.patch
Normal file
356
glibc-upstream-2.34-132.patch
Normal file
@ -0,0 +1,356 @@
|
||||
commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704
|
||||
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Date: Wed Jan 12 23:34:48 2022 +0530
|
||||
|
||||
debug: Synchronize feature guards in fortified functions [BZ #28746]
|
||||
|
||||
Some functions (e.g. stpcpy, pread64, etc.) had moved to POSIX in the
|
||||
main headers as they got incorporated into the standard, but their
|
||||
fortified variants remained under __USE_GNU. As a result, these
|
||||
functions did not get fortified when _GNU_SOURCE was not defined.
|
||||
|
||||
Add test wrappers that check all functions tested in tst-chk0 at all
|
||||
levels with _GNU_SOURCE undefined and then use the failures to (1)
|
||||
exclude checks for _GNU_SOURCE functions in these tests and (2) Fix
|
||||
feature macro guards in the fortified function headers so that they're
|
||||
the same as the ones in the main headers.
|
||||
|
||||
This fixes BZ #28746.
|
||||
|
||||
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||
(cherry picked from commit fcfc9086815bf0d277ad47a90ee3fda4c37acca8)
|
||||
|
||||
diff --git a/debug/Makefile b/debug/Makefile
|
||||
index acc1b8f6ad029c62..71248e0d457a5b12 100644
|
||||
--- a/debug/Makefile
|
||||
+++ b/debug/Makefile
|
||||
@@ -132,6 +132,12 @@ define cflags-lfs
|
||||
CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64
|
||||
endef
|
||||
|
||||
+define cflags-nongnu
|
||||
+CFLAGS-tst-fortify-$(1)-nongnu-$(2).$(1) += -D_LARGEFILE64_SOURCE=1
|
||||
+endef
|
||||
+
|
||||
+src-chk-nongnu = \#undef _GNU_SOURCE
|
||||
+
|
||||
# We know these tests have problems with format strings, this is what
|
||||
# we are testing. Disable that warning. They are also testing
|
||||
# deprecated functions (notably gets) so disable that warning as well.
|
||||
@@ -145,13 +151,13 @@ CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
|
||||
$(eval $(call cflags-$(2),$(1),$(3)))
|
||||
$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
|
||||
( echo "/* Autogenerated from Makefile. */"; \
|
||||
- echo ""; \
|
||||
+ echo "$(src-chk-$(2))"; \
|
||||
echo "#include \"tst-fortify.c\"" ) > $$@.tmp
|
||||
mv $$@.tmp $$@
|
||||
endef
|
||||
|
||||
chk-extensions = c cc
|
||||
-chk-types = default lfs
|
||||
+chk-types = default lfs nongnu
|
||||
chk-levels = 1 2 3
|
||||
|
||||
$(foreach e,$(chk-extensions), \
|
||||
diff --git a/debug/tst-fortify.c b/debug/tst-fortify.c
|
||||
index 68ac00d1808382b8..8b5902423cf0ad88 100644
|
||||
--- a/debug/tst-fortify.c
|
||||
+++ b/debug/tst-fortify.c
|
||||
@@ -1,4 +1,5 @@
|
||||
-/* Copyright (C) 2004-2021 Free Software Foundation, Inc.
|
||||
+/* Copyright (C) 2004-2022 Free Software Foundation, Inc.
|
||||
+ Copyright The GNU Toolchain Authors.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
|
||||
|
||||
@@ -37,6 +38,17 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
+#ifndef _GNU_SOURCE
|
||||
+# define MEMPCPY memcpy
|
||||
+# define WMEMPCPY wmemcpy
|
||||
+# define MEMPCPY_RET(x) 0
|
||||
+# define WMEMPCPY_RET(x) 0
|
||||
+#else
|
||||
+# define MEMPCPY mempcpy
|
||||
+# define WMEMPCPY wmempcpy
|
||||
+# define MEMPCPY_RET(x) __builtin_strlen (x)
|
||||
+# define WMEMPCPY_RET(x) wcslen (x)
|
||||
+#endif
|
||||
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
@@ -163,7 +175,7 @@ do_test (void)
|
||||
if (memcmp (buf, "aabcdefghi", 10))
|
||||
FAIL ();
|
||||
|
||||
- if (mempcpy (buf + 5, "abcde", 5) != buf + 10
|
||||
+ if (MEMPCPY (buf + 5, "abcde", 5) != buf + 5 + MEMPCPY_RET ("abcde")
|
||||
|| memcmp (buf, "aabcdabcde", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -208,7 +220,7 @@ do_test (void)
|
||||
if (memcmp (buf, "aabcdefghi", 10))
|
||||
FAIL ();
|
||||
|
||||
- if (mempcpy (buf + 5, "abcde", l0 + 5) != buf + 10
|
||||
+ if (MEMPCPY (buf + 5, "abcde", l0 + 5) != buf + 5 + MEMPCPY_RET ("abcde")
|
||||
|| memcmp (buf, "aabcdabcde", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -267,7 +279,8 @@ do_test (void)
|
||||
if (memcmp (a.buf1, "aabcdefghi", 10))
|
||||
FAIL ();
|
||||
|
||||
- if (mempcpy (a.buf1 + 5, "abcde", l0 + 5) != a.buf1 + 10
|
||||
+ if (MEMPCPY (a.buf1 + 5, "abcde", l0 + 5)
|
||||
+ != a.buf1 + 5 + MEMPCPY_RET ("abcde")
|
||||
|| memcmp (a.buf1, "aabcdabcde", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -348,6 +361,7 @@ do_test (void)
|
||||
bcopy (buf + 1, buf + 2, l0 + 9);
|
||||
CHK_FAIL_END
|
||||
|
||||
+#ifdef _GNU_SOURCE
|
||||
CHK_FAIL_START
|
||||
p = (char *) mempcpy (buf + 6, "abcde", 5);
|
||||
CHK_FAIL_END
|
||||
@@ -355,6 +369,7 @@ do_test (void)
|
||||
CHK_FAIL_START
|
||||
p = (char *) mempcpy (buf + 6, "abcde", l0 + 5);
|
||||
CHK_FAIL_END
|
||||
+#endif
|
||||
|
||||
CHK_FAIL_START
|
||||
memset (buf + 9, 'j', 2);
|
||||
@@ -465,6 +480,7 @@ do_test (void)
|
||||
bcopy (a.buf1 + 1, a.buf1 + 2, l0 + 9);
|
||||
CHK_FAIL_END
|
||||
|
||||
+#ifdef _GNU_SOURCE
|
||||
CHK_FAIL_START
|
||||
p = (char *) mempcpy (a.buf1 + 6, "abcde", 5);
|
||||
CHK_FAIL_END
|
||||
@@ -472,6 +488,7 @@ do_test (void)
|
||||
CHK_FAIL_START
|
||||
p = (char *) mempcpy (a.buf1 + 6, "abcde", l0 + 5);
|
||||
CHK_FAIL_END
|
||||
+#endif
|
||||
|
||||
CHK_FAIL_START
|
||||
memset (a.buf1 + 9, 'j', 2);
|
||||
@@ -551,7 +568,7 @@ do_test (void)
|
||||
if (wmemcmp (wbuf, L"aabcdefghi", 10))
|
||||
FAIL ();
|
||||
|
||||
- if (wmempcpy (wbuf + 5, L"abcde", 5) != wbuf + 10
|
||||
+ if (WMEMPCPY (wbuf + 5, L"abcde", 5) != wbuf + 5 + WMEMPCPY_RET (L"abcde")
|
||||
|| wmemcmp (wbuf, L"aabcdabcde", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -584,7 +601,8 @@ do_test (void)
|
||||
if (wmemcmp (wbuf, L"aabcdefghi", 10))
|
||||
FAIL ();
|
||||
|
||||
- if (wmempcpy (wbuf + 5, L"abcde", l0 + 5) != wbuf + 10
|
||||
+ if (WMEMPCPY (wbuf + 5, L"abcde", l0 + 5)
|
||||
+ != wbuf + 5 + WMEMPCPY_RET (L"abcde")
|
||||
|| wmemcmp (wbuf, L"aabcdabcde", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -626,7 +644,8 @@ do_test (void)
|
||||
if (wmemcmp (wa.buf1, L"aabcdefghi", 10))
|
||||
FAIL ();
|
||||
|
||||
- if (wmempcpy (wa.buf1 + 5, L"abcde", l0 + 5) != wa.buf1 + 10
|
||||
+ if (WMEMPCPY (wa.buf1 + 5, L"abcde", l0 + 5)
|
||||
+ != wa.buf1 + 5 + WMEMPCPY_RET (L"abcde")
|
||||
|| wmemcmp (wa.buf1, L"aabcdabcde", 10))
|
||||
FAIL ();
|
||||
|
||||
@@ -695,6 +714,7 @@ do_test (void)
|
||||
wmemmove (wbuf + 2, wbuf + 1, l0 + 9);
|
||||
CHK_FAIL_END
|
||||
|
||||
+#ifdef _GNU_SOURCE
|
||||
CHK_FAIL_START
|
||||
wp = wmempcpy (wbuf + 6, L"abcde", 5);
|
||||
CHK_FAIL_END
|
||||
@@ -702,6 +722,7 @@ do_test (void)
|
||||
CHK_FAIL_START
|
||||
wp = wmempcpy (wbuf + 6, L"abcde", l0 + 5);
|
||||
CHK_FAIL_END
|
||||
+#endif
|
||||
|
||||
CHK_FAIL_START
|
||||
wmemset (wbuf + 9, L'j', 2);
|
||||
@@ -769,6 +790,7 @@ do_test (void)
|
||||
wmemmove (wa.buf1 + 2, wa.buf1 + 1, l0 + 9);
|
||||
CHK_FAIL_END
|
||||
|
||||
+#ifdef _GNU_SOURCE
|
||||
CHK_FAIL_START
|
||||
wp = wmempcpy (wa.buf1 + 6, L"abcde", 5);
|
||||
CHK_FAIL_END
|
||||
@@ -776,6 +798,7 @@ do_test (void)
|
||||
CHK_FAIL_START
|
||||
wp = wmempcpy (wa.buf1 + 6, L"abcde", l0 + 5);
|
||||
CHK_FAIL_END
|
||||
+#endif
|
||||
|
||||
CHK_FAIL_START
|
||||
wmemset (wa.buf1 + 9, L'j', 2);
|
||||
@@ -907,6 +930,7 @@ do_test (void)
|
||||
if (fprintf (fp, buf2 + 4, str5) != 7)
|
||||
FAIL ();
|
||||
|
||||
+#ifdef _GNU_SOURCE
|
||||
char *my_ptr = NULL;
|
||||
strcpy (buf2 + 2, "%n%s%n");
|
||||
/* When the format string is writable and contains %n,
|
||||
@@ -936,6 +960,7 @@ do_test (void)
|
||||
if (obstack_printf (&obs, "%s%n%s%n", str4, &n1, str5, &n1) != 14)
|
||||
FAIL ();
|
||||
obstack_free (&obs, NULL);
|
||||
+#endif
|
||||
|
||||
if (freopen (temp_filename, "r", stdin) == NULL)
|
||||
{
|
||||
@@ -983,6 +1008,7 @@ do_test (void)
|
||||
|
||||
rewind (stdin);
|
||||
|
||||
+#ifdef _GNU_SOURCE
|
||||
if (fgets_unlocked (buf, buf_size, stdin) != buf
|
||||
|| memcmp (buf, "abcdefgh\n", 10))
|
||||
FAIL ();
|
||||
@@ -1009,6 +1035,7 @@ do_test (void)
|
||||
#endif
|
||||
|
||||
rewind (stdin);
|
||||
+#endif
|
||||
|
||||
if (fread (buf, 1, buf_size, stdin) != buf_size
|
||||
|| memcmp (buf, "abcdefgh\nA", 10))
|
||||
@@ -1579,7 +1606,10 @@ do_test (void)
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
- int fd = posix_openpt (O_RDWR);
|
||||
+ int fd;
|
||||
+
|
||||
+#ifdef _GNU_SOURCE
|
||||
+ fd = posix_openpt (O_RDWR);
|
||||
if (fd != -1)
|
||||
{
|
||||
char enough[1000];
|
||||
@@ -1595,6 +1625,7 @@ do_test (void)
|
||||
#endif
|
||||
close (fd);
|
||||
}
|
||||
+#endif
|
||||
|
||||
#if PATH_MAX > 0
|
||||
confstr (_CS_GNU_LIBC_VERSION, largebuf, sizeof (largebuf));
|
||||
@@ -1712,8 +1743,9 @@ do_test (void)
|
||||
poll (fds, l0 + 2, 0);
|
||||
CHK_FAIL_END
|
||||
#endif
|
||||
+#ifdef _GNU_SOURCE
|
||||
ppoll (fds, 1, NULL, NULL);
|
||||
-#if __USE_FORTIFY_LEVEL >= 1
|
||||
+# if __USE_FORTIFY_LEVEL >= 1
|
||||
CHK_FAIL_START
|
||||
ppoll (fds, 2, NULL, NULL);
|
||||
CHK_FAIL_END
|
||||
@@ -1721,6 +1753,7 @@ do_test (void)
|
||||
CHK_FAIL_START
|
||||
ppoll (fds, l0 + 2, NULL, NULL);
|
||||
CHK_FAIL_END
|
||||
+# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h
|
||||
index 697dcbbf7b4b26f6..1df7e5ceef3e1fd4 100644
|
||||
--- a/posix/bits/unistd.h
|
||||
+++ b/posix/bits/unistd.h
|
||||
@@ -40,7 +40,7 @@ read (int __fd, void *__buf, size_t __nbytes)
|
||||
__fd, __buf, __nbytes);
|
||||
}
|
||||
|
||||
-#ifdef __USE_UNIX98
|
||||
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
|
||||
extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
|
||||
__off_t __offset, size_t __bufsize)
|
||||
__wur __attr_access ((__write_only__, 2, 3));
|
||||
diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
|
||||
index 5731274848260ad2..218006c9ba882d9c 100644
|
||||
--- a/string/bits/string_fortified.h
|
||||
+++ b/string/bits/string_fortified.h
|
||||
@@ -79,7 +79,7 @@ __NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
|
||||
return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest));
|
||||
}
|
||||
|
||||
-#ifdef __USE_GNU
|
||||
+#ifdef __USE_XOPEN2K8
|
||||
__fortify_function char *
|
||||
__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src))
|
||||
{
|
||||
@@ -96,14 +96,15 @@ __NTH (strncpy (char *__restrict __dest, const char *__restrict __src,
|
||||
__glibc_objsize (__dest));
|
||||
}
|
||||
|
||||
-#if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6)
|
||||
+#ifdef __USE_XOPEN2K8
|
||||
+# if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6)
|
||||
__fortify_function char *
|
||||
__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
|
||||
{
|
||||
return __builtin___stpncpy_chk (__dest, __src, __n,
|
||||
__glibc_objsize (__dest));
|
||||
}
|
||||
-#else
|
||||
+# else
|
||||
extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
|
||||
size_t __destlen) __THROW
|
||||
__fortified_attr_access ((__write_only__, 1, 3))
|
||||
@@ -119,6 +120,7 @@ __NTH (stpncpy (char *__dest, const char *__src, size_t __n))
|
||||
return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
|
||||
return __stpncpy_alias (__dest, __src, __n);
|
||||
}
|
||||
+# endif
|
||||
#endif
|
||||
|
||||
|
||||
diff --git a/support/xsignal.h b/support/xsignal.h
|
||||
index 8ee1fa6b4dceeadf..692e0f2c4242d848 100644
|
||||
--- a/support/xsignal.h
|
||||
+++ b/support/xsignal.h
|
||||
@@ -28,7 +28,9 @@ __BEGIN_DECLS
|
||||
terminate the process on error. */
|
||||
|
||||
void xraise (int sig);
|
||||
+#ifdef _GNU_SOURCE
|
||||
sighandler_t xsignal (int sig, sighandler_t handler);
|
||||
+#endif
|
||||
void xsigaction (int sig, const struct sigaction *newact,
|
||||
struct sigaction *oldact);
|
||||
|
||||
diff --git a/wcsmbs/bits/wchar2.h b/wcsmbs/bits/wchar2.h
|
||||
index 26012ef9366c0b88..88c1fdfcd34292f4 100644
|
||||
--- a/wcsmbs/bits/wchar2.h
|
||||
+++ b/wcsmbs/bits/wchar2.h
|
||||
@@ -457,7 +457,7 @@ __NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
|
||||
}
|
||||
|
||||
|
||||
-#ifdef __USE_GNU
|
||||
+#ifdef __USE_XOPEN2K8
|
||||
extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst,
|
||||
const char **__restrict __src, size_t __nmc,
|
||||
size_t __len, mbstate_t *__restrict __ps,
|
2970
glibc.spec
2970
glibc.spec
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user