Clean up patches, sync with upstream

glibc's upstream has git branches where important fixes are backported.
Let's use them instead of applying most of commits as patches.
Automate updates by script upd.sh.

Deleted strange patches without propper description.
glibc is a core component where we should avoid not properly audited and/or tested code.
Removed all Clear Linux patches, removed patches "from Fedora" which do not exist in fc37 and current rawhide.

We do not need to build glibc with clang, drop clang-related patches.
This commit is contained in:
Mikhail Novosyolov 2023-01-09 20:45:23 +03:00
parent 57fdafec17
commit f7b2d28a94
54 changed files with 67 additions and 3848 deletions

View file

@ -1,3 +1,3 @@
sources:
glibc-2.36.tar.xz: 1477f605f419c439c03ef90e7851c0856ea679ea
glibc-4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c.tar.xz: 0e335e549849de97636e63b030e6e444586adbd0
glibc-manpages.tar.bz2: ca54bfb832b703c8e35170fcc1c1f5470b45ff0f

View file

@ -1,51 +0,0 @@
From c3fda489cfdb2260f9fec706e6fd7259858c4467 Mon Sep 17 00:00:00 2001
From: Tom Honermann <tom@honermann.net>
Date: Sun, 24 Jul 2022 01:11:43 -0400
Subject: [PATCH 01/15] stdlib: Suppress gcc diagnostic that char8_t is a
keyword in C++20 in uchar.h.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
gcc 13 issues the following diagnostic for the uchar.h header when the
-Wc++20-compat option is enabled in C++ modes that do not enable char8_t
as a builtin type (C++17 and earlier by default; subject to _GNU_SOURCE
and the gcc -f[no-]char8_t option).
warning: identifier char8_t is a keyword in C++20 [-Wc++20-compat]
This change modifies the uchar.h header to suppress the diagnostic through
the use of '#pragma GCC diagnostic' directives for gcc 10 and later (the
-Wc++20-compat option was added in gcc version 10). Unfortunately, a bug
in gcc currently prevents those directives from having the intended effect
as reported at https://gcc.gnu.org/PR106423. A patch for that issue has
been submitted and is available in the email thread archive linked below.
https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598736.html
(cherry picked from commit 825f84f133bd840347dc49229b6d831f07d04775)
---
wcsmbs/uchar.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/wcsmbs/uchar.h b/wcsmbs/uchar.h
index c37e8619a0..5f7139f279 100644
--- a/wcsmbs/uchar.h
+++ b/wcsmbs/uchar.h
@@ -34,8 +34,16 @@
/* Declare the C2x char8_t typedef in C2x modes, but only if the C++
__cpp_char8_t feature test macro is not defined. */
#if __GLIBC_USE (ISOC2X) && !defined __cpp_char8_t
+#if __GNUC_PREREQ (10, 0) && defined __cplusplus
+/* Suppress the diagnostic regarding char8_t being a keyword in C++20. */
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wc++20-compat"
+#endif
/* Define the 8-bit character type. */
typedef unsigned char char8_t;
+#if __GNUC_PREREQ (10, 0) && defined __cplusplus
+# pragma GCC diagnostic pop
+#endif
#endif
#ifndef __USE_ISOCXX11
--
2.37.2

View file

@ -1,34 +0,0 @@
From 33f1b4c1452b33991e670f636ebe98b90a405e10 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 29 Jul 2022 10:50:56 -0700
Subject: [PATCH 02/15] wcsmbs: Add missing test-c8rtomb/test-mbrtoc8
dependency
Make test-c8rtomb.out and test-mbrtoc8.out depend on $(gen-locales) for
xsetlocale (LC_ALL, "de_DE.UTF-8");
xsetlocale (LC_ALL, "zh_HK.BIG5-HKSCS");
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit e03f5ccd6cc8f829416156eac75acee501626c1f)
---
wcsmbs/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index e6b9e8743a..3d19d5556f 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -73,6 +73,8 @@ $(objpfx)tst-wcstol-locale.out: $(gen-locales)
$(objpfx)tst-wcstod-nan-locale.out: $(gen-locales)
$(objpfx)tst-c16-surrogate.out: $(gen-locales)
$(objpfx)tst-c32-state.out: $(gen-locales)
+$(objpfx)test-c8rtomb.out: $(gen-locales)
+$(objpfx)test-mbrtoc8.out: $(gen-locales)
endif
$(objpfx)tst-wcstod-round: $(libm)
--
2.37.2

View file

@ -1,49 +0,0 @@
From c74bb93cfdb04d49155b0e30983a3c866167bbca Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Thu, 4 Aug 2022 17:54:48 +0200
Subject: [PATCH 03/15] dlfcn: Pass caller pointer to static dlopen
implementation (bug 29446)
Fixes commit 0c1c3a771eceec46e66ce1183cf988e2303bd373 ("dlfcn: Move
dlopen into libc").
(cherry picked from commit ed0185e4129130cbe081c221efb758fb400623ce)
---
NEWS | 7 +++++++
dlfcn/dlopen.c | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index f61e521fc8..15f3dd2cdb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,13 @@ See the end for copying conditions.
Please send GNU C library bug reports via <https://sourceware.org/bugzilla/>
using `glibc' in the "product" field.
+
+Version 2.36.1
+
+The following bugs are resolved with this release:
+
+ [29446] _dlopen now ignores dl_caller argument in static mode
+
Version 2.36
diff --git a/dlfcn/dlopen.c b/dlfcn/dlopen.c
index 2696dde4b1..9b07b4e132 100644
--- a/dlfcn/dlopen.c
+++ b/dlfcn/dlopen.c
@@ -90,7 +90,7 @@ compat_symbol (libdl, ___dlopen, dlopen, GLIBC_2_1);
void *
__dlopen (const char *file, int mode, void *dl_caller)
{
- return dlopen_implementation (file, mode, RETURN_ADDRESS (0));
+ return dlopen_implementation (file, mode, dl_caller);
}
void *
--
2.37.2

View file

@ -1,61 +0,0 @@
From ac47d8f6cf9744139adb12f540fb9cc610cac579 Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Tue, 2 Aug 2022 21:05:07 +0000
Subject: [PATCH 04/15] Update syscall lists for Linux 5.19
Linux 5.19 has no new syscalls, but enables memfd_secret in the uapi
headers for RISC-V. Update the version number in syscall-names.list
to reflect that it is still current for 5.19 and regenerate the
arch-syscall.h headers with build-many-glibcs.py update-syscalls.
Tested with build-many-glibcs.py.
(cherry picked from commit fccadcdf5bed7ee67a6cef4714e0b477d6c8472c)
---
sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h | 1 +
sysdeps/unix/sysv/linux/riscv/rv64/arch-syscall.h | 1 +
sysdeps/unix/sysv/linux/syscall-names.list | 4 ++--
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h b/sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h
index bf4be80f8d..202520ee25 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h
@@ -122,6 +122,7 @@
#define __NR_mbind 235
#define __NR_membarrier 283
#define __NR_memfd_create 279
+#define __NR_memfd_secret 447
#define __NR_migrate_pages 238
#define __NR_mincore 232
#define __NR_mkdirat 34
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/arch-syscall.h b/sysdeps/unix/sysv/linux/riscv/rv64/arch-syscall.h
index d656aedcc2..4e65f337d4 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/arch-syscall.h
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/arch-syscall.h
@@ -127,6 +127,7 @@
#define __NR_mbind 235
#define __NR_membarrier 283
#define __NR_memfd_create 279
+#define __NR_memfd_secret 447
#define __NR_migrate_pages 238
#define __NR_mincore 232
#define __NR_mkdirat 34
diff --git a/sysdeps/unix/sysv/linux/syscall-names.list b/sysdeps/unix/sysv/linux/syscall-names.list
index 6c7b2f7011..028ad3107a 100644
--- a/sysdeps/unix/sysv/linux/syscall-names.list
+++ b/sysdeps/unix/sysv/linux/syscall-names.list
@@ -21,8 +21,8 @@
# This file can list all potential system calls. The names are only
# used if the installed kernel headers also provide them.
-# The list of system calls is current as of Linux 5.18.
-kernel 5.18
+# The list of system calls is current as of Linux 5.19.
+kernel 5.19
FAST_atomic_update
FAST_cmpxchg
--
2.37.2

View file

@ -1,34 +0,0 @@
From 302bc33bc53c787da6e74162a7092e9c0fb964a8 Mon Sep 17 00:00:00 2001
From: Noah Goldstein <goldstein.w.n@gmail.com>
Date: Mon, 8 Aug 2022 11:26:22 +0800
Subject: [PATCH 05/15] elf: Replace `strcpy` call with `memcpy` [BZ #29454]
GCC normally does this optimization for us in
strlen_pass::handle_builtin_strcpy but only for optimized
build. To avoid needing to include strcpy.S in the rtld build to
support the debug build, just do the optimization by hand.
(cherry picked from commit 483cfe1a6a33d6335b1901581b41040d2d412511)
---
elf/dl-cache.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index 8bbf110d02..b97c17b3a9 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
@@ -509,8 +509,9 @@ _dl_load_cache_lookup (const char *name)
we are accessing. Therefore we must make the copy of the
mapping data without using malloc. */
char *temp;
- temp = alloca (strlen (best) + 1);
- strcpy (temp, best);
+ size_t best_len = strlen (best) + 1;
+ temp = alloca (best_len);
+ memcpy (temp, best, best_len);
return __strdup (temp);
}
--
2.37.2

View file

@ -1,46 +0,0 @@
From e982657073c4db21459ffd9e17bc505b1d64b876 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Mon, 15 Aug 2022 16:43:59 +0200
Subject: [PATCH 06/15] Linux: Terminate subprocess on late failure in
tst-pidfd (bug 29485)
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit f82e05ebb295cadd35f7372f652c72264da810ad)
---
NEWS | 1 +
sysdeps/unix/sysv/linux/tst-pidfd.c | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 15f3dd2cdb..f8fb8db510 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Version 2.36.1
The following bugs are resolved with this release:
[29446] _dlopen now ignores dl_caller argument in static mode
+ [29485] Linux: Terminate subprocess on late failure in tst-pidfd
Version 2.36
diff --git a/sysdeps/unix/sysv/linux/tst-pidfd.c b/sysdeps/unix/sysv/linux/tst-pidfd.c
index 037af22290..5711d1c312 100644
--- a/sysdeps/unix/sysv/linux/tst-pidfd.c
+++ b/sysdeps/unix/sysv/linux/tst-pidfd.c
@@ -147,8 +147,11 @@ do_test (void)
may be denied if the process doesn't have CAP_SYS_PTRACE or
if a LSM security_ptrace_access_check denies access. */
if (fd == -1 && errno == EPERM)
- FAIL_UNSUPPORTED ("don't have permission to use pidfd_getfd on pidfd, "
- "skipping test");
+ {
+ TEST_COMPARE (pidfd_send_signal (pidfd, SIGKILL, NULL, 0), 0);
+ FAIL_UNSUPPORTED ("don't have permission to use pidfd_getfd on pidfd, "
+ "skipping test");
+ }
TEST_VERIFY (fd > 0);
char *path = xasprintf ("/proc/%d/fd/%d", pid, remote_fd);
--
2.37.2

View file

@ -1,49 +0,0 @@
From 8b139cd4f1074ae0d95d9bff60db283a1ed72734 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Mon, 22 Aug 2022 11:04:47 +0200
Subject: [PATCH 07/15] alpha: Fix generic brk system call emulation in
__brk_call (bug 29490)
The kernel special-cases the zero argument for alpha brk, and we can
use that to restore the generic Linux error handling behavior.
Fixes commit b57ab258c1140bc45464b4b9908713e3e0ee35aa ("Linux:
Introduce __brk_call for invoking the brk system call").
(cherry picked from commit e7ad26ee3cb74e61d0637c888f24dd478d77af58)
---
NEWS | 1 +
sysdeps/unix/sysv/linux/alpha/brk_call.h | 7 +++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index f8fb8db510..becab3ade9 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ The following bugs are resolved with this release:
[29446] _dlopen now ignores dl_caller argument in static mode
[29485] Linux: Terminate subprocess on late failure in tst-pidfd
+ [29490] alpha: New __brk_call implementation is broken
Version 2.36
diff --git a/sysdeps/unix/sysv/linux/alpha/brk_call.h b/sysdeps/unix/sysv/linux/alpha/brk_call.h
index b8088cf13f..0b851b6c86 100644
--- a/sysdeps/unix/sysv/linux/alpha/brk_call.h
+++ b/sysdeps/unix/sysv/linux/alpha/brk_call.h
@@ -21,8 +21,7 @@ __brk_call (void *addr)
{
unsigned long int result = INTERNAL_SYSCALL_CALL (brk, addr);
if (result == -ENOMEM)
- /* Mimic the default error reporting behavior. */
- return addr;
- else
- return (void *) result;
+ /* Mimic the generic error reporting behavior. */
+ result = INTERNAL_SYSCALL_CALL (brk, 0);
+ return (void *) result;
}
--
2.37.2

View file

@ -1,448 +0,0 @@
From d13a7a6f100576b1e30dc044b2e0c4cbcb6196f6 Mon Sep 17 00:00:00 2001
From: Arjun Shankar <arjun@redhat.com>
Date: Tue, 2 Aug 2022 11:10:25 +0200
Subject: [PATCH 08/15] socket: Check lengths before advancing pointer in
CMSG_NXTHDR
The inline and library functions that the CMSG_NXTHDR macro may expand
to increment the pointer to the header before checking the stride of
the increment against available space. Since C only allows incrementing
pointers to one past the end of an array, the increment must be done
after a length check. This commit fixes that and includes a regression
test for CMSG_FIRSTHDR and CMSG_NXTHDR.
The Linux, Hurd, and generic headers are all changed.
Tested on Linux on armv7hl, i686, x86_64, aarch64, ppc64le, and s390x.
[BZ #28846]
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 9c443ac4559a47ed99859bd80d14dc4b6dd220a1)
---
bits/socket.h | 40 ++++++++++--
socket/Makefile | 1 +
socket/tst-cmsghdr-skeleton.c | 92 +++++++++++++++++++++++++++
socket/tst-cmsghdr.c | 56 ++++++++++++++++
sysdeps/mach/hurd/bits/socket.h | 40 ++++++++++--
sysdeps/unix/sysv/linux/bits/socket.h | 40 ++++++++++--
sysdeps/unix/sysv/linux/cmsg_nxthdr.c | 36 ++++++++---
7 files changed, 276 insertions(+), 29 deletions(-)
create mode 100644 socket/tst-cmsghdr-skeleton.c
create mode 100644 socket/tst-cmsghdr.c
diff --git a/bits/socket.h b/bits/socket.h
index 2b99dea33b..aac8c49b00 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -245,6 +245,12 @@ struct cmsghdr
+ CMSG_ALIGN (sizeof (struct cmsghdr)))
#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+/* Given a length, return the additional padding necessary such that
+ len + __CMSG_PADDING(len) == CMSG_ALIGN (len). */
+#define __CMSG_PADDING(len) ((sizeof (size_t) \
+ - ((len) & (sizeof (size_t) - 1))) \
+ & (sizeof (size_t) - 1))
+
extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
struct cmsghdr *__cmsg) __THROW;
#ifdef __USE_EXTERN_INLINES
@@ -254,18 +260,38 @@ extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
_EXTERN_INLINE struct cmsghdr *
__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
{
+ /* We may safely assume that __cmsg lies between __mhdr->msg_control and
+ __mhdr->msg_controllen because the user is required to obtain the first
+ cmsg via CMSG_FIRSTHDR, set its length, then obtain subsequent cmsgs
+ via CMSG_NXTHDR, setting lengths along the way. However, we don't yet
+ trust the value of __cmsg->cmsg_len and therefore do not use it in any
+ pointer arithmetic until we check its value. */
+
+ unsigned char * __msg_control_ptr = (unsigned char *) __mhdr->msg_control;
+ unsigned char * __cmsg_ptr = (unsigned char *) __cmsg;
+
+ size_t __size_needed = sizeof (struct cmsghdr)
+ + __CMSG_PADDING (__cmsg->cmsg_len);
+
+ /* The current header is malformed, too small to be a full header. */
if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
return (struct cmsghdr *) 0;
+ /* There isn't enough space between __cmsg and the end of the buffer to
+ hold the current cmsg *and* the next one. */
+ if (((size_t)
+ (__msg_control_ptr + __mhdr->msg_controllen - __cmsg_ptr)
+ < __size_needed)
+ || ((size_t)
+ (__msg_control_ptr + __mhdr->msg_controllen - __cmsg_ptr
+ - __size_needed)
+ < __cmsg->cmsg_len))
+
+ return (struct cmsghdr *) 0;
+
+ /* Now, we trust cmsg_len and can use it to find the next header. */
__cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
- /* No more entries. */
- return (struct cmsghdr *) 0;
return __cmsg;
}
#endif /* Use `extern inline'. */
diff --git a/socket/Makefile b/socket/Makefile
index 156eec6c85..2bde78387f 100644
--- a/socket/Makefile
+++ b/socket/Makefile
@@ -34,6 +34,7 @@ routines := accept bind connect getpeername getsockname getsockopt \
tests := \
tst-accept4 \
tst-sockopt \
+ tst-cmsghdr \
# tests
tests-internal := \
diff --git a/socket/tst-cmsghdr-skeleton.c b/socket/tst-cmsghdr-skeleton.c
new file mode 100644
index 0000000000..4c6898569b
--- /dev/null
+++ b/socket/tst-cmsghdr-skeleton.c
@@ -0,0 +1,92 @@
+/* Test ancillary data header creation.
+ 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/>. */
+
+/* We use the preprocessor to generate the function/macro tests instead of
+ using indirection because having all the macro expansions alongside
+ each other lets the compiler warn us about suspicious pointer
+ arithmetic across subsequent CMSG_{FIRST,NXT}HDR expansions. */
+
+#include <stdint.h>
+
+#define RUN_TEST_CONCAT(suffix) run_test_##suffix
+#define RUN_TEST_FUNCNAME(suffix) RUN_TEST_CONCAT (suffix)
+
+static void
+RUN_TEST_FUNCNAME (CMSG_NXTHDR_IMPL) (void)
+{
+ struct msghdr m = {0};
+ struct cmsghdr *cmsg;
+ char cmsgbuf[3 * CMSG_SPACE (sizeof (PAYLOAD))] = {0};
+
+ m.msg_control = cmsgbuf;
+ m.msg_controllen = sizeof (cmsgbuf);
+
+ /* First header should point to the start of the buffer. */
+ cmsg = CMSG_FIRSTHDR (&m);
+ TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
+
+ /* If the first header length consumes the entire buffer, there is no
+ space remaining for additional headers. */
+ cmsg->cmsg_len = sizeof (cmsgbuf);
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg == NULL);
+
+ /* The first header length is so big, using it would cause an overflow. */
+ cmsg = CMSG_FIRSTHDR (&m);
+ TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
+ cmsg->cmsg_len = SIZE_MAX;
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg == NULL);
+
+ /* The first header leaves just enough space to hold another header. */
+ cmsg = CMSG_FIRSTHDR (&m);
+ TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
+ cmsg->cmsg_len = sizeof (cmsgbuf) - sizeof (struct cmsghdr);
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg != NULL);
+
+ /* The first header leaves space but not enough for another header. */
+ cmsg = CMSG_FIRSTHDR (&m);
+ TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
+ cmsg->cmsg_len ++;
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg == NULL);
+
+ /* The second header leaves just enough space to hold another header. */
+ cmsg = CMSG_FIRSTHDR (&m);
+ TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
+ cmsg->cmsg_len = CMSG_LEN (sizeof (PAYLOAD));
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg != NULL);
+ cmsg->cmsg_len = sizeof (cmsgbuf)
+ - CMSG_SPACE (sizeof (PAYLOAD)) /* First header. */
+ - sizeof (struct cmsghdr);
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg != NULL);
+
+ /* The second header leaves space but not enough for another header. */
+ cmsg = CMSG_FIRSTHDR (&m);
+ TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg != NULL);
+ cmsg->cmsg_len ++;
+ cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
+ TEST_VERIFY_EXIT (cmsg == NULL);
+
+ return;
+}
diff --git a/socket/tst-cmsghdr.c b/socket/tst-cmsghdr.c
new file mode 100644
index 0000000000..68c96d3c9d
--- /dev/null
+++ b/socket/tst-cmsghdr.c
@@ -0,0 +1,56 @@
+/* Test ancillary data header creation.
+ 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 <sys/socket.h>
+#include <gnu/lib-names.h>
+#include <support/xdlfcn.h>
+#include <support/check.h>
+
+#define PAYLOAD "Hello, World!"
+
+/* CMSG_NXTHDR is a macro that calls an inline function defined in
+ bits/socket.h. In case the function cannot be inlined, libc.so carries
+ a copy. Both versions need to be tested. */
+
+#define CMSG_NXTHDR_IMPL CMSG_NXTHDR
+#include "tst-cmsghdr-skeleton.c"
+#undef CMSG_NXTHDR_IMPL
+
+static struct cmsghdr * (* cmsg_nxthdr) (struct msghdr *, struct cmsghdr *);
+
+#define CMSG_NXTHDR_IMPL cmsg_nxthdr
+#include "tst-cmsghdr-skeleton.c"
+#undef CMSG_NXTHDR_IMPL
+
+static int
+do_test (void)
+{
+ static void *handle;
+
+ run_test_CMSG_NXTHDR ();
+
+ handle = xdlopen (LIBC_SO, RTLD_LAZY);
+ cmsg_nxthdr = (struct cmsghdr * (*) (struct msghdr *, struct cmsghdr *))
+ xdlsym (handle, "__cmsg_nxthdr");
+
+ run_test_cmsg_nxthdr ();
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h
index 5b35ea81ec..70fce4fb27 100644
--- a/sysdeps/mach/hurd/bits/socket.h
+++ b/sysdeps/mach/hurd/bits/socket.h
@@ -249,6 +249,12 @@ struct cmsghdr
+ CMSG_ALIGN (sizeof (struct cmsghdr)))
#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+/* Given a length, return the additional padding necessary such that
+ len + __CMSG_PADDING(len) == CMSG_ALIGN (len). */
+#define __CMSG_PADDING(len) ((sizeof (size_t) \
+ - ((len) & (sizeof (size_t) - 1))) \
+ & (sizeof (size_t) - 1))
+
extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
struct cmsghdr *__cmsg) __THROW;
#ifdef __USE_EXTERN_INLINES
@@ -258,18 +264,38 @@ extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
_EXTERN_INLINE struct cmsghdr *
__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
{
+ /* We may safely assume that __cmsg lies between __mhdr->msg_control and
+ __mhdr->msg_controllen because the user is required to obtain the first
+ cmsg via CMSG_FIRSTHDR, set its length, then obtain subsequent cmsgs
+ via CMSG_NXTHDR, setting lengths along the way. However, we don't yet
+ trust the value of __cmsg->cmsg_len and therefore do not use it in any
+ pointer arithmetic until we check its value. */
+
+ unsigned char * __msg_control_ptr = (unsigned char *) __mhdr->msg_control;
+ unsigned char * __cmsg_ptr = (unsigned char *) __cmsg;
+
+ size_t __size_needed = sizeof (struct cmsghdr)
+ + __CMSG_PADDING (__cmsg->cmsg_len);
+
+ /* The current header is malformed, too small to be a full header. */
if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
return (struct cmsghdr *) 0;
+ /* There isn't enough space between __cmsg and the end of the buffer to
+ hold the current cmsg *and* the next one. */
+ if (((size_t)
+ (__msg_control_ptr + __mhdr->msg_controllen - __cmsg_ptr)
+ < __size_needed)
+ || ((size_t)
+ (__msg_control_ptr + __mhdr->msg_controllen - __cmsg_ptr
+ - __size_needed)
+ < __cmsg->cmsg_len))
+
+ return (struct cmsghdr *) 0;
+
+ /* Now, we trust cmsg_len and can use it to find the next header. */
__cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
- /* No more entries. */
- return (struct cmsghdr *) 0;
return __cmsg;
}
#endif /* Use `extern inline'. */
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 4f1f810ea1..539b8d7716 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -307,6 +307,12 @@ struct cmsghdr
+ CMSG_ALIGN (sizeof (struct cmsghdr)))
#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+/* Given a length, return the additional padding necessary such that
+ len + __CMSG_PADDING(len) == CMSG_ALIGN (len). */
+#define __CMSG_PADDING(len) ((sizeof (size_t) \
+ - ((len) & (sizeof (size_t) - 1))) \
+ & (sizeof (size_t) - 1))
+
extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
struct cmsghdr *__cmsg) __THROW;
#ifdef __USE_EXTERN_INLINES
@@ -316,18 +322,38 @@ extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
_EXTERN_INLINE struct cmsghdr *
__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
{
+ /* We may safely assume that __cmsg lies between __mhdr->msg_control and
+ __mhdr->msg_controllen because the user is required to obtain the first
+ cmsg via CMSG_FIRSTHDR, set its length, then obtain subsequent cmsgs
+ via CMSG_NXTHDR, setting lengths along the way. However, we don't yet
+ trust the value of __cmsg->cmsg_len and therefore do not use it in any
+ pointer arithmetic until we check its value. */
+
+ unsigned char * __msg_control_ptr = (unsigned char *) __mhdr->msg_control;
+ unsigned char * __cmsg_ptr = (unsigned char *) __cmsg;
+
+ size_t __size_needed = sizeof (struct cmsghdr)
+ + __CMSG_PADDING (__cmsg->cmsg_len);
+
+ /* The current header is malformed, too small to be a full header. */
if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
return (struct cmsghdr *) 0;
+ /* There isn't enough space between __cmsg and the end of the buffer to
+ hold the current cmsg *and* the next one. */
+ if (((size_t)
+ (__msg_control_ptr + __mhdr->msg_controllen - __cmsg_ptr)
+ < __size_needed)
+ || ((size_t)
+ (__msg_control_ptr + __mhdr->msg_controllen - __cmsg_ptr
+ - __size_needed)
+ < __cmsg->cmsg_len))
+
+ return (struct cmsghdr *) 0;
+
+ /* Now, we trust cmsg_len and can use it to find the next header. */
__cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
- /* No more entries. */
- return (struct cmsghdr *) 0;
return __cmsg;
}
#endif /* Use `extern inline'. */
diff --git a/sysdeps/unix/sysv/linux/cmsg_nxthdr.c b/sysdeps/unix/sysv/linux/cmsg_nxthdr.c
index 15b7a3a925..24f72b797a 100644
--- a/sysdeps/unix/sysv/linux/cmsg_nxthdr.c
+++ b/sysdeps/unix/sysv/linux/cmsg_nxthdr.c
@@ -23,18 +23,38 @@
struct cmsghdr *
__cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg)
{
+ /* We may safely assume that cmsg lies between mhdr->msg_control and
+ mhdr->msg_controllen because the user is required to obtain the first
+ cmsg via CMSG_FIRSTHDR, set its length, then obtain subsequent cmsgs
+ via CMSG_NXTHDR, setting lengths along the way. However, we don't yet
+ trust the value of cmsg->cmsg_len and therefore do not use it in any
+ pointer arithmetic until we check its value. */
+
+ unsigned char * msg_control_ptr = (unsigned char *) mhdr->msg_control;
+ unsigned char * cmsg_ptr = (unsigned char *) cmsg;
+
+ size_t size_needed = sizeof (struct cmsghdr)
+ + __CMSG_PADDING (cmsg->cmsg_len);
+
+ /* The current header is malformed, too small to be a full header. */
if ((size_t) cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
- return NULL;
+ return (struct cmsghdr *) 0;
+
+ /* There isn't enough space between cmsg and the end of the buffer to
+ hold the current cmsg *and* the next one. */
+ if (((size_t)
+ (msg_control_ptr + mhdr->msg_controllen - cmsg_ptr)
+ < size_needed)
+ || ((size_t)
+ (msg_control_ptr + mhdr->msg_controllen - cmsg_ptr
+ - size_needed)
+ < cmsg->cmsg_len))
+
+ return (struct cmsghdr *) 0;
+ /* Now, we trust cmsg_len and can use it to find the next header. */
cmsg = (struct cmsghdr *) ((unsigned char *) cmsg
+ CMSG_ALIGN (cmsg->cmsg_len));
- if ((unsigned char *) (cmsg + 1) > ((unsigned char *) mhdr->msg_control
- + mhdr->msg_controllen)
- || ((unsigned char *) cmsg + CMSG_ALIGN (cmsg->cmsg_len)
- > ((unsigned char *) mhdr->msg_control + mhdr->msg_controllen)))
- /* No more entries. */
- return NULL;
return cmsg;
}
libc_hidden_def (__cmsg_nxthdr)
--
2.37.2

View file

@ -1,24 +0,0 @@
From 5c62874f423af93e97b51bc9a57af228a546156f Mon Sep 17 00:00:00 2001
From: Arjun Shankar <arjun@redhat.com>
Date: Mon, 22 Aug 2022 18:21:14 +0200
Subject: [PATCH 09/15] NEWS: Add entry for bug 28846
---
NEWS | 1 +
1 file changed, 1 insertion(+)
diff --git a/NEWS b/NEWS
index becab3ade9..ae30900bbc 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Version 2.36.1
The following bugs are resolved with this release:
+ [28846] CMSG_NXTHDR may trigger -Wstrict-overflow warning
[29446] _dlopen now ignores dl_caller argument in static mode
[29485] Linux: Terminate subprocess on late failure in tst-pidfd
[29490] alpha: New __brk_call implementation is broken
--
2.37.2

View file

@ -1,51 +0,0 @@
From 0062e7dd1c3674ece2daca53a898badd28b60421 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 10 Aug 2022 16:24:06 -0300
Subject: [PATCH 10/15] glibcextract.py: Add compile_c_snippet
It might be used on tests to check if a snippet build with the provided
compiler and flags.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 841afa116e32b3c7195475769c26bf46fd870d32)
---
scripts/glibcextract.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/scripts/glibcextract.py b/scripts/glibcextract.py
index 43ab58ffe2..36d204c9b0 100644
--- a/scripts/glibcextract.py
+++ b/scripts/glibcextract.py
@@ -17,6 +17,7 @@
# License along with the GNU C Library; if not, see
# <https://www.gnu.org/licenses/>.
+import collections
import os.path
import re
import subprocess
@@ -173,3 +174,21 @@ def compare_macro_consts(source_1, source_2, cc, macro_re, exclude_re=None,
if not allow_extra_2:
ret = 1
return ret
+
+CompileResult = collections.namedtuple("CompileResult", "returncode output")
+
+def compile_c_snippet(snippet, cc, extra_cc_args=''):
+ """Compile and return whether the SNIPPET can be build with CC along
+ EXTRA_CC_ARGS compiler flags. Return a CompileResult with RETURNCODE
+ being 0 for success, or the failure value and the compiler output.
+ """
+ with tempfile.TemporaryDirectory() as temp_dir:
+ c_file_name = os.path.join(temp_dir, 'test.c')
+ obj_file_name = os.path.join(temp_dir, 'test.o')
+ with open(c_file_name, 'w') as c_file:
+ c_file.write(snippet + '\n')
+ cmd = cc.split() + extra_cc_args.split() + ['-c', '-o', obj_file_name,
+ c_file_name]
+ r = subprocess.run(cmd, check=False, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ return CompileResult(r.returncode, r.stdout)
--
2.37.2

View file

@ -1,41 +0,0 @@
From 1cc5513114e76083669cba1b11252aad35525e69 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 10 Aug 2022 14:24:44 -0300
Subject: [PATCH 11/15] linux: Use compile_c_snippet to check linux/pidfd.h
availability
Instead of tying to a specific kernel version.
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 1542019b69b7ec7b2cd34357af035e406d153631)
---
sysdeps/unix/sysv/linux/tst-pidfd-consts.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
index 90cbb9be64..d732173abd 100644
--- a/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
+++ b/sysdeps/unix/sysv/linux/tst-pidfd-consts.py
@@ -33,11 +33,13 @@ def main():
help='C compiler (including options) to use')
args = parser.parse_args()
- linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
- # Linux started to provide pidfd.h with 5.10.
- if linux_version_headers < (5, 10):
+ if glibcextract.compile_c_snippet(
+ '#include <linux/pidfd.h>',
+ args.cc).returncode != 0:
sys.exit (77)
- linux_version_glibc = (5, 18)
+
+ linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
+ linux_version_glibc = (5, 19)
sys.exit(glibcextract.compare_macro_consts(
'#include <sys/pidfd.h>\n',
'#include <asm/fcntl.h>\n'
--
2.37.2

View file

@ -1,31 +0,0 @@
From 4dad97e2a2e510c6b53a0add29a2188714fcf4ab Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 10 Aug 2022 14:24:45 -0300
Subject: [PATCH 12/15] linux: Mimic kernel defition for BLOCK_SIZE
To avoid possible warnings if the kernel header is included before
sys/mount.h.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit c68b6044bc7945716431f1adc091b17c39b80a06)
---
sysdeps/unix/sysv/linux/sys/mount.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
index f965986ba8..df6b0dbb42 100644
--- a/sysdeps/unix/sysv/linux/sys/mount.h
+++ b/sysdeps/unix/sysv/linux/sys/mount.h
@@ -27,8 +27,8 @@
#include <stddef.h>
#include <sys/ioctl.h>
-#define BLOCK_SIZE 1024
#define BLOCK_SIZE_BITS 10
+#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
/* These are the fs-independent mount-flags: up to 16 flags are
--
2.37.2

View file

@ -1,33 +0,0 @@
From d48813227b63a0d92ea357ea0733229ed74e31ab Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 10 Aug 2022 14:24:46 -0300
Subject: [PATCH 13/15] linux: Use compile_c_snippet to check linux/mount.h
availability
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit e1226cdc6b209539a92d32d5b620ba53fd35abf3)
---
sysdeps/unix/sysv/linux/tst-mount-consts.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sysdeps/unix/sysv/linux/tst-mount-consts.py b/sysdeps/unix/sysv/linux/tst-mount-consts.py
index a62f803123..be2ef2daf1 100755
--- a/sysdeps/unix/sysv/linux/tst-mount-consts.py
+++ b/sysdeps/unix/sysv/linux/tst-mount-consts.py
@@ -33,6 +33,11 @@ def main():
help='C compiler (including options) to use')
args = parser.parse_args()
+ if glibcextract.compile_c_snippet(
+ '#include <linux/mount.h>',
+ args.cc).returncode != 0:
+ sys.exit (77)
+
linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
# Constants in glibc were updated to match Linux v5.16. When glibc
# constants are updated this value should be updated to match the
--
2.37.2

View file

@ -1,337 +0,0 @@
From bb1e8b0ca99b5cbedfae3e6245528a87d95ff3e2 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 10 Aug 2022 14:24:47 -0300
Subject: [PATCH 14/15] linux: Fix sys/mount.h usage with kernel headers
Now that kernel exports linux/mount.h and includes it on linux/fs.h,
its definitions might clash with glibc exports sys/mount.h. To avoid
the need to rearrange the Linux header to be always after glibc one,
the glibc sys/mount.h is changed to:
1. Undefine the macros also used as enum constants. This covers prior
inclusion of <linux/mount.h> (for instance MS_RDONLY).
2. Include <linux/mount.h> based on the usual __has_include check
(needs to use __has_include ("linux/mount.h") to paper over GCC
bugs.
3. Define enum fsconfig_command only if FSOPEN_CLOEXEC is not defined.
(FSOPEN_CLOEXEC should be a very close proxy.)
4. Define struct mount_attr if MOUNT_ATTR_SIZE_VER0 is not defined.
(Added in the same commit on the Linux side.)
This patch also adds some tests to check if including linux/fs.h and
linux/mount.h after and before sys/mount.h does work.
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 774058d72942249f71d74e7f2b639f77184160a6)
---
sysdeps/unix/sysv/linux/Makefile | 8 +++
sysdeps/unix/sysv/linux/sys/mount.h | 71 +++++++++++++++++---
sysdeps/unix/sysv/linux/tst-mount-compile.py | 66 ++++++++++++++++++
3 files changed, 137 insertions(+), 8 deletions(-)
create mode 100755 sysdeps/unix/sysv/linux/tst-mount-compile.py
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index a139a16532..3ceda9fdbf 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -265,6 +265,14 @@ $(objpfx)tst-mount-consts.out: ../sysdeps/unix/sysv/linux/tst-mount-consts.py
< /dev/null > $@ 2>&1; $(evaluate-test)
$(objpfx)tst-mount-consts.out: $(sysdeps-linux-python-deps)
+tests-special += $(objpfx)tst-mount-compile.out
+$(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py
+ $(sysdeps-linux-python) \
+ ../sysdeps/unix/sysv/linux/tst-mount-compile.py \
+ $(sysdeps-linux-python-cc) \
+ < /dev/null > $@ 2>&1; $(evaluate-test)
+$(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps)
+
tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
endif # $(subdir) == misc
diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
index df6b0dbb42..2e3fd6a7fe 100644
--- a/sysdeps/unix/sysv/linux/sys/mount.h
+++ b/sysdeps/unix/sysv/linux/sys/mount.h
@@ -27,6 +27,13 @@
#include <stddef.h>
#include <sys/ioctl.h>
+#ifdef __has_include
+# if __has_include ("linux/mount.h")
+# include "linux/mount.h"
+# endif
+#endif
+
+
#define BLOCK_SIZE_BITS 10
#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
@@ -35,69 +42,98 @@
supported */
enum
{
+#undef MS_RDONLY
MS_RDONLY = 1, /* Mount read-only. */
#define MS_RDONLY MS_RDONLY
+#undef MS_NOSUID
MS_NOSUID = 2, /* Ignore suid and sgid bits. */
#define MS_NOSUID MS_NOSUID
+#undef MS_NODEV
MS_NODEV = 4, /* Disallow access to device special files. */
#define MS_NODEV MS_NODEV
+#undef MS_NOEXEC
MS_NOEXEC = 8, /* Disallow program execution. */
#define MS_NOEXEC MS_NOEXEC
+#undef MS_SYNCHRONOUS
MS_SYNCHRONOUS = 16, /* Writes are synced at once. */
#define MS_SYNCHRONOUS MS_SYNCHRONOUS
+#undef MS_REMOUNT
MS_REMOUNT = 32, /* Alter flags of a mounted FS. */
#define MS_REMOUNT MS_REMOUNT
+#undef MS_MANDLOCK
MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
#define MS_MANDLOCK MS_MANDLOCK
+#undef MS_DIRSYNC
MS_DIRSYNC = 128, /* Directory modifications are synchronous. */
#define MS_DIRSYNC MS_DIRSYNC
+#undef MS_NOSYMFOLLOW
MS_NOSYMFOLLOW = 256, /* Do not follow symlinks. */
#define MS_NOSYMFOLLOW MS_NOSYMFOLLOW
+#undef MS_NOATIME
MS_NOATIME = 1024, /* Do not update access times. */
#define MS_NOATIME MS_NOATIME
+#undef MS_NODIRATIME
MS_NODIRATIME = 2048, /* Do not update directory access times. */
#define MS_NODIRATIME MS_NODIRATIME
+#undef MS_BIND
MS_BIND = 4096, /* Bind directory at different place. */
#define MS_BIND MS_BIND
+#undef MS_MOVE
MS_MOVE = 8192,
#define MS_MOVE MS_MOVE
+#undef MS_REC
MS_REC = 16384,
#define MS_REC MS_REC
+#undef MS_SILENT
MS_SILENT = 32768,
#define MS_SILENT MS_SILENT
+#undef MS_POSIXACL
MS_POSIXACL = 1 << 16, /* VFS does not apply the umask. */
#define MS_POSIXACL MS_POSIXACL
+#undef MS_UNBINDABLE
MS_UNBINDABLE = 1 << 17, /* Change to unbindable. */
#define MS_UNBINDABLE MS_UNBINDABLE
+#undef MS_PRIVATE
MS_PRIVATE = 1 << 18, /* Change to private. */
#define MS_PRIVATE MS_PRIVATE
+#undef MS_SLAVE
MS_SLAVE = 1 << 19, /* Change to slave. */
#define MS_SLAVE MS_SLAVE
+#undef MS_SHARED
MS_SHARED = 1 << 20, /* Change to shared. */
#define MS_SHARED MS_SHARED
+#undef MS_RELATIME
MS_RELATIME = 1 << 21, /* Update atime relative to mtime/ctime. */
#define MS_RELATIME MS_RELATIME
+#undef MS_KERNMOUNT
MS_KERNMOUNT = 1 << 22, /* This is a kern_mount call. */
#define MS_KERNMOUNT MS_KERNMOUNT
+#undef MS_I_VERSION
MS_I_VERSION = 1 << 23, /* Update inode I_version field. */
#define MS_I_VERSION MS_I_VERSION
+#undef MS_STRICTATIME
MS_STRICTATIME = 1 << 24, /* Always perform atime updates. */
#define MS_STRICTATIME MS_STRICTATIME
+#undef MS_LAZYTIME
MS_LAZYTIME = 1 << 25, /* Update the on-disk [acm]times lazily. */
#define MS_LAZYTIME MS_LAZYTIME
+#undef MS_ACTIVE
MS_ACTIVE = 1 << 30,
#define MS_ACTIVE MS_ACTIVE
+#undef MS_NOUSER
MS_NOUSER = 1 << 31
#define MS_NOUSER MS_NOUSER
};
/* Flags that can be altered by MS_REMOUNT */
+#undef MS_RMT_MASK
#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION \
|MS_LAZYTIME)
/* Magic mount flag number. Has to be or-ed to the flag values. */
+#undef MS_MGC_VAL
#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */
#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */
@@ -106,20 +142,35 @@ enum
is probably as bad and I don't want to create yet another include
file. */
+#undef BLKROSET
#define BLKROSET _IO(0x12, 93) /* Set device read-only (0 = read-write). */
+#undef BLKROGET
#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */
+#undef BLKRRPART
#define BLKRRPART _IO(0x12, 95) /* Re-read partition table. */
+#undef BLKGETSIZE
#define BLKGETSIZE _IO(0x12, 96) /* Return device size. */
+#undef BLKFLSBUF
#define BLKFLSBUF _IO(0x12, 97) /* Flush buffer cache. */
+#undef BLKRASET
#define BLKRASET _IO(0x12, 98) /* Set read ahead for block device. */
+#undef BLKRAGET
#define BLKRAGET _IO(0x12, 99) /* Get current read ahead setting. */
+#undef BLKFRASET
#define BLKFRASET _IO(0x12,100) /* Set filesystem read-ahead. */
+#undef BLKFRAGET
#define BLKFRAGET _IO(0x12,101) /* Get filesystem read-ahead. */
+#undef BLKSECTSET
#define BLKSECTSET _IO(0x12,102) /* Set max sectors per request. */
+#undef BLKSECTGET
#define BLKSECTGET _IO(0x12,103) /* Get max sectors per request. */
+#undef BLKSSZGET
#define BLKSSZGET _IO(0x12,104) /* Get block device sector size. */
+#undef BLKBSZGET
#define BLKBSZGET _IOR(0x12,112,size_t)
+#undef BLKBSZSET
#define BLKBSZSET _IOW(0x12,113,size_t)
+#undef BLKGETSIZE64
#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size. */
@@ -157,6 +208,7 @@ enum
#define MOUNT_ATTR_NOSYMFOLLOW 0x00200000 /* Do not follow symlinks. */
+#ifndef MOUNT_ATTR_SIZE_VER0
/* For mount_setattr. */
struct mount_attr
{
@@ -165,6 +217,7 @@ struct mount_attr
uint64_t propagation;
uint64_t userns_fd;
};
+#endif
#define MOUNT_ATTR_SIZE_VER0 32 /* sizeof first published struct */
@@ -185,26 +238,28 @@ struct mount_attr
#define FSPICK_EMPTY_PATH 0x00000008
+#ifndef FSOPEN_CLOEXEC
/* The type of fsconfig call made. */
enum fsconfig_command
{
FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */
-#define FSCONFIG_SET_FLAG FSCONFIG_SET_FLAG
+# define FSCONFIG_SET_FLAG FSCONFIG_SET_FLAG
FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */
-#define FSCONFIG_SET_STRING FSCONFIG_SET_STRING
+# define FSCONFIG_SET_STRING FSCONFIG_SET_STRING
FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */
-#define FSCONFIG_SET_BINARY FSCONFIG_SET_BINARY
+# define FSCONFIG_SET_BINARY FSCONFIG_SET_BINARY
FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */
-#define FSCONFIG_SET_PATH FSCONFIG_SET_PATH
+# define FSCONFIG_SET_PATH FSCONFIG_SET_PATH
FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */
-#define FSCONFIG_SET_PATH_EMPTY FSCONFIG_SET_PATH_EMPTY
+# define FSCONFIG_SET_PATH_EMPTY FSCONFIG_SET_PATH_EMPTY
FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */
-#define FSCONFIG_SET_FD FSCONFIG_SET_FD
+# define FSCONFIG_SET_FD FSCONFIG_SET_FD
FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */
-#define FSCONFIG_CMD_CREATE FSCONFIG_CMD_CREATE
+# define FSCONFIG_CMD_CREATE FSCONFIG_CMD_CREATE
FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */
-#define FSCONFIG_CMD_RECONFIGURE FSCONFIG_CMD_RECONFIGURE
+# define FSCONFIG_CMD_RECONFIGURE FSCONFIG_CMD_RECONFIGURE
};
+#endif
/* open_tree flags. */
#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
diff --git a/sysdeps/unix/sysv/linux/tst-mount-compile.py b/sysdeps/unix/sysv/linux/tst-mount-compile.py
new file mode 100755
index 0000000000..0ec74d4e0b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-mount-compile.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python3
+# Check if glibc provided sys/mount.h can be used along related kernel
+# headers.
+# 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/>.
+
+import argparse
+import sys
+
+import glibcextract
+
+
+def main():
+ """The main entry point."""
+ parser = argparse.ArgumentParser(
+ description='Check if glibc provided sys/mount.h can be '
+ ' used along related kernel headers.')
+ parser.add_argument('--cc', metavar='CC',
+ help='C compiler (including options) to use')
+ args = parser.parse_args()
+
+ if glibcextract.compile_c_snippet(
+ '#include <linux/mount.h>',
+ args.cc).returncode != 0:
+ sys.exit (77)
+
+ def check(testname, snippet):
+ # Add -Werror to catch macro redefinitions and _ISOMAC to avoid
+ # internal glibc definitions.
+ r = glibcextract.compile_c_snippet(snippet, args.cc,
+ '-Werror -D_ISOMAC')
+ if r.returncode != 0:
+ print('error: test {}:\n{}'.format(testname, r.output.decode()))
+ return r.returncode
+
+ status = max(
+ check("sys/mount.h + linux/mount.h",
+ "#include <sys/mount.h>\n"
+ "#include <linux/mount.h>"),
+ check("sys/mount.h + linux/fs.h",
+ "#include <sys/mount.h>\n"
+ "#include <linux/fs.h>"),
+ check("linux/mount.h + sys/mount.h",
+ "#include <linux/mount.h>\n"
+ "#include <sys/mount.h>"),
+ check("linux/fs.h + sys/mount.h",
+ "#include <linux/fs.h>\n"
+ "#include <sys/mount.h>"))
+ sys.exit(status)
+
+if __name__ == '__main__':
+ main()
--
2.37.2

View file

@ -1,45 +0,0 @@
From 3bd3c612e98a53ce60ed972f5cd2b90628b3cba5 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Tue, 16 Aug 2022 09:25:23 +0200
Subject: [PATCH 15/15] Linux: Fix enum fsconfig_command detection in
<sys/mount.h>
The #ifdef FSOPEN_CLOEXEC check did not work because the macro
was always defined in this header prior to the check, so that
the <linux/mount.h> contents did not matter.
Fixes commit 774058d72942249f71d74e7f2b639f77184160a6
("linux: Fix sys/mount.h usage with kernel headers").
(cherry picked from commit 2955ef4b7c9b56fcd7abfeddef7ee83c60abff98)
---
sysdeps/unix/sysv/linux/sys/mount.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
index 2e3fd6a7fe..19841d0738 100644
--- a/sysdeps/unix/sysv/linux/sys/mount.h
+++ b/sysdeps/unix/sysv/linux/sys/mount.h
@@ -188,9 +188,6 @@ enum
};
-/* fsopen flags. */
-#define FSOPEN_CLOEXEC 0x00000001
-
/* fsmount flags. */
#define FSMOUNT_CLOEXEC 0x00000001
@@ -261,6 +258,9 @@ enum fsconfig_command
};
#endif
+/* fsopen flags. */
+#define FSOPEN_CLOEXEC 0x00000001
+
/* open_tree flags. */
#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
--
2.37.2

View file

@ -1,336 +0,0 @@
From b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Sun, 28 Aug 2022 16:52:53 -0300
Subject: [PATCH 16/22] syslog: Fix large messages (BZ#29536)
The a583b6add407c17cd change did not handle large messages that
would require a heap allocation correctly, where the message itself
is not take in consideration.
This patch fixes it and extend the tst-syslog to check for large
messages as well.
Checked on x86_64-linux-gnu.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 52a5be0df411ef3ff45c10c7c308cb92993d15b1)
---
misc/syslog.c | 18 +++---
misc/tst-syslog.c | 152 +++++++++++++++++++++++++++++++++++++++-------
2 files changed, 142 insertions(+), 28 deletions(-)
diff --git a/misc/syslog.c b/misc/syslog.c
index 554089bfc4..b88f66c835 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -193,28 +193,32 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap,
int vl = __vsnprintf_internal (bufs + l, sizeof bufs - l, fmt, apc,
mode_flags);
if (0 <= vl && vl < sizeof bufs - l)
- {
- buf = bufs;
- bufsize = l + vl;
- }
+ buf = bufs;
+ bufsize = l + vl;
va_end (apc);
}
if (buf == NULL)
{
- buf = malloc (l * sizeof (char));
+ buf = malloc ((bufsize + 1) * sizeof (char));
if (buf != NULL)
{
/* Tell the cancellation handler to free this buffer. */
clarg.buf = buf;
if (has_ts)
- __snprintf (bufs, sizeof bufs,
+ __snprintf (buf, l + 1,
SYSLOG_HEADER (pri, timestamp, &msgoff, pid));
else
- __snprintf (bufs, sizeof bufs,
+ __snprintf (buf, l + 1,
SYSLOG_HEADER_WITHOUT_TS (pri, &msgoff));
+
+ va_list apc;
+ va_copy (apc, ap);
+ __vsnprintf_internal (buf + l, bufsize - l + 1, fmt, apc,
+ mode_flags);
+ va_end (apc);
}
else
{
diff --git a/misc/tst-syslog.c b/misc/tst-syslog.c
index e550d15796..1d332ece53 100644
--- a/misc/tst-syslog.c
+++ b/misc/tst-syslog.c
@@ -68,21 +68,19 @@ static const int priorities[] =
LOG_DEBUG
};
-enum
- {
- ident_length = 64,
- msg_length = 64
- };
+#define IDENT_LENGTH 64
+#define MSG_LENGTH 1024
#define SYSLOG_MSG_BASE "syslog_message"
#define OPENLOG_IDENT "openlog_ident"
+static char large_message[MSG_LENGTH];
struct msg_t
{
int priority;
int facility;
- char ident[ident_length];
- char msg[msg_length];
+ char ident[IDENT_LENGTH];
+ char msg[MSG_LENGTH];
pid_t pid;
};
@@ -147,6 +145,37 @@ check_syslog_message (const struct msg_t *msg, int msgnum, int options,
return true;
}
+static void
+send_syslog_large (int options)
+{
+ int facility = LOG_USER;
+ int priority = LOG_INFO;
+
+ syslog (facility | priority, "%s %d %d", large_message, facility,
+ priority);
+}
+
+static void
+send_vsyslog_large (int options)
+{
+ int facility = LOG_USER;
+ int priority = LOG_INFO;
+
+ call_vsyslog (facility | priority, "%s %d %d", large_message, facility,
+ priority);
+}
+
+static bool
+check_syslog_message_large (const struct msg_t *msg, int msgnum, int options,
+ pid_t pid)
+{
+ TEST_COMPARE (msg->facility, LOG_USER);
+ TEST_COMPARE (msg->priority, LOG_INFO);
+ TEST_COMPARE_STRING (msg->msg, large_message);
+
+ return false;
+}
+
static void
send_openlog (int options)
{
@@ -179,6 +208,17 @@ send_openlog (int options)
closelog ();
}
+static void
+send_openlog_large (int options)
+{
+ /* Define a non-default IDENT and a not default facility. */
+ openlog (OPENLOG_IDENT, options, LOG_LOCAL0);
+
+ syslog (LOG_INFO, "%s %d %d", large_message, LOG_LOCAL0, LOG_INFO);
+
+ closelog ();
+}
+
static bool
check_openlog_message (const struct msg_t *msg, int msgnum,
int options, pid_t pid)
@@ -189,7 +229,7 @@ check_openlog_message (const struct msg_t *msg, int msgnum,
int expected_priority = priorities[msgnum % array_length (priorities)];
TEST_COMPARE (msg->priority, expected_priority);
- char expected_ident[ident_length];
+ char expected_ident[IDENT_LENGTH];
snprintf (expected_ident, sizeof (expected_ident), "%s%s%.0d%s:",
OPENLOG_IDENT,
options & LOG_PID ? "[" : "",
@@ -211,15 +251,38 @@ check_openlog_message (const struct msg_t *msg, int msgnum,
return true;
}
+static bool
+check_openlog_message_large (const struct msg_t *msg, int msgnum,
+ int options, pid_t pid)
+{
+ char expected_ident[IDENT_LENGTH];
+ snprintf (expected_ident, sizeof (expected_ident), "%s%s%.0d%s:",
+ OPENLOG_IDENT,
+ options & LOG_PID ? "[" : "",
+ options & LOG_PID ? pid : 0,
+ options & LOG_PID ? "]" : "");
+
+ TEST_COMPARE_STRING (msg->ident, expected_ident);
+ TEST_COMPARE_STRING (msg->msg, large_message);
+ TEST_COMPARE (msg->priority, LOG_INFO);
+ TEST_COMPARE (msg->facility, LOG_LOCAL0);
+
+ return false;
+}
+
static struct msg_t
parse_syslog_msg (const char *msg)
{
struct msg_t r = { .pid = -1 };
int number;
+#define STRINPUT(size) XSTRINPUT(size)
+#define XSTRINPUT(size) "%" # size "s"
+
/* The message in the form:
- <179>Apr 8 14:51:19 tst-syslog: syslog message 176 3 */
- int n = sscanf (msg, "<%3d>%*s %*d %*d:%*d:%*d %32s %64s %*d %*d",
+ <179>Apr 8 14:51:19 tst-syslog: message 176 3 */
+ int n = sscanf (msg, "<%3d>%*s %*d %*d:%*d:%*d " STRINPUT(IDENT_LENGTH)
+ " " STRINPUT(MSG_LENGTH) " %*d %*d",
&number, r.ident, r.msg);
TEST_COMPARE (n, 3);
@@ -246,7 +309,7 @@ parse_syslog_console (const char *msg)
/* The message in the form:
openlog_ident: syslog_message 128 0 */
- int n = sscanf (msg, "%32s %64s %d %d",
+ int n = sscanf (msg, STRINPUT(IDENT_LENGTH) " " STRINPUT(MSG_LENGTH) " %d %d",
r.ident, r.msg, &facility, &priority);
TEST_COMPARE (n, 4);
@@ -281,7 +344,7 @@ check_syslog_udp (void (*syslog_send)(int), int options,
int msgnum = 0;
while (1)
{
- char buf[512];
+ char buf[2048];
size_t l = xrecvfrom (server_udp, buf, sizeof (buf), 0,
(struct sockaddr *) &addr, &addrlen);
buf[l] = '\0';
@@ -325,7 +388,7 @@ check_syslog_tcp (void (*syslog_send)(int), int options,
int client_tcp = xaccept (server_tcp, NULL, NULL);
- char buf[512], *rb = buf;
+ char buf[2048], *rb = buf;
size_t rbl = sizeof (buf);
size_t prl = 0; /* Track the size of the partial record. */
int msgnum = 0;
@@ -393,20 +456,34 @@ check_syslog_console_read (FILE *fp)
}
static void
-check_syslog_console (void)
+check_syslog_console_read_large (FILE *fp)
+{
+ char buf[2048];
+ TEST_VERIFY (fgets (buf, sizeof (buf), fp) != NULL);
+ struct msg_t msg = parse_syslog_console (buf);
+
+ TEST_COMPARE_STRING (msg.ident, OPENLOG_IDENT ":");
+ TEST_COMPARE_STRING (msg.msg, large_message);
+ TEST_COMPARE (msg.priority, LOG_INFO);
+ TEST_COMPARE (msg.facility, LOG_LOCAL0);
+}
+
+static void
+check_syslog_console (void (*syslog_send)(int),
+ void (*syslog_check)(FILE *fp))
{
xmkfifo (_PATH_CONSOLE, 0666);
pid_t sender_pid = xfork ();
if (sender_pid == 0)
{
- send_openlog (LOG_CONS);
+ syslog_send (LOG_CONS);
_exit (0);
}
{
FILE *fp = xfopen (_PATH_CONSOLE, "r+");
- check_syslog_console_read (fp);
+ syslog_check (fp);
xfclose (fp);
}
@@ -425,16 +502,28 @@ send_openlog_callback (void *clousure)
}
static void
-check_syslog_perror (void)
+send_openlog_callback_large (void *clousure)
+{
+ int options = *(int *) clousure;
+ send_openlog_large (options);
+}
+
+static void
+check_syslog_perror (bool large)
{
struct support_capture_subprocess result;
- result = support_capture_subprocess (send_openlog_callback,
+ result = support_capture_subprocess (large
+ ? send_openlog_callback_large
+ : send_openlog_callback,
&(int){LOG_PERROR});
FILE *mfp = fmemopen (result.err.buffer, result.err.length, "r");
if (mfp == NULL)
FAIL_EXIT1 ("fmemopen: %m");
- check_syslog_console_read (mfp);
+ if (large)
+ check_syslog_console_read_large (mfp);
+ else
+ check_syslog_console_read (mfp);
xfclose (mfp);
support_capture_subprocess_check (&result, "tst-openlog-child", 0,
@@ -462,10 +551,31 @@ do_test (void)
check_syslog_tcp (send_openlog, LOG_PID, check_openlog_message);
/* Check the LOG_CONS option. */
- check_syslog_console ();
+ check_syslog_console (send_openlog, check_syslog_console_read);
/* Check the LOG_PERROR option. */
- check_syslog_perror ();
+ check_syslog_perror (false);
+
+ /* Similar tests as before, but with a large message to trigger the
+ syslog path that uses dynamically allocated memory. */
+ memset (large_message, 'a', sizeof large_message - 1);
+ large_message[sizeof large_message - 1] = '\0';
+
+ check_syslog_udp (send_syslog_large, 0, check_syslog_message_large);
+ check_syslog_tcp (send_syslog_large, 0, check_syslog_message_large);
+
+ check_syslog_udp (send_vsyslog_large, 0, check_syslog_message_large);
+ check_syslog_tcp (send_vsyslog_large, 0, check_syslog_message_large);
+
+ check_syslog_udp (send_openlog_large, 0, check_openlog_message_large);
+ check_syslog_tcp (send_openlog_large, 0, check_openlog_message_large);
+
+ check_syslog_udp (send_openlog_large, LOG_PID, check_openlog_message_large);
+ check_syslog_tcp (send_openlog_large, LOG_PID, check_openlog_message_large);
+
+ check_syslog_console (send_openlog_large, check_syslog_console_read_large);
+
+ check_syslog_perror (true);
return 0;
}
--
2.37.2

View file

@ -1,252 +0,0 @@
From 924e4f3eaa502ce82fccf8537f021a796d158771 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 26 Aug 2022 21:15:43 +0200
Subject: [PATCH 17/22] elf: Call __libc_early_init for reused namespaces (bug
29528)
libc_map is never reset to NULL, neither during dlclose nor on a
dlopen call which reuses the namespace structure. As a result, if a
namespace is reused, its libc is not initialized properly. The most
visible result is a crash in the <ctype.h> functions.
To prevent similar bugs on namespace reuse from surfacing,
unconditionally initialize the chosen namespace to zero using memset.
(cherry picked from commit d0e357ff45a75553dee3b17ed7d303bfa544f6fe)
---
NEWS | 1 +
elf/Makefile | 25 ++++++++++++++++++
elf/dl-open.c | 13 ++++++----
elf/tst-dlmopen-twice-mod1.c | 37 ++++++++++++++++++++++++++
elf/tst-dlmopen-twice-mod2.c | 50 ++++++++++++++++++++++++++++++++++++
elf/tst-dlmopen-twice.c | 34 ++++++++++++++++++++++++
6 files changed, 155 insertions(+), 5 deletions(-)
create mode 100644 elf/tst-dlmopen-twice-mod1.c
create mode 100644 elf/tst-dlmopen-twice-mod2.c
create mode 100644 elf/tst-dlmopen-twice.c
diff --git a/NEWS b/NEWS
index ae30900bbc..6d31e5abba 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ The following bugs are resolved with this release:
[29446] _dlopen now ignores dl_caller argument in static mode
[29485] Linux: Terminate subprocess on late failure in tst-pidfd
[29490] alpha: New __brk_call implementation is broken
+ [29528] elf: Call __libc_early_init for reused namespaces
Version 2.36
diff --git a/elf/Makefile b/elf/Makefile
index fd77d0c7c8..43353a4b08 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -408,6 +408,7 @@ tests += \
tst-dlmopen4 \
tst-dlmopen-dlerror \
tst-dlmopen-gethostbyname \
+ tst-dlmopen-twice \
tst-dlopenfail \
tst-dlopenfail-2 \
tst-dlopenrpath \
@@ -834,6 +835,8 @@ modules-names += \
tst-dlmopen1mod \
tst-dlmopen-dlerror-mod \
tst-dlmopen-gethostbyname-mod \
+ tst-dlmopen-twice-mod1 \
+ tst-dlmopen-twice-mod2 \
tst-dlopenfaillinkmod \
tst-dlopenfailmod1 \
tst-dlopenfailmod2 \
@@ -2967,3 +2970,25 @@ $(objpfx)tst-tls-allocation-failure-static-patched.out: \
grep -q '^Fatal glibc error: Cannot allocate TLS block$$' $@ \
&& grep -q '^status: 127$$' $@; \
$(evaluate-test)
+
+$(objpfx)tst-audit-tlsdesc: $(objpfx)tst-audit-tlsdesc-mod1.so \
+ $(objpfx)tst-audit-tlsdesc-mod2.so \
+ $(shared-thread-library)
+ifeq (yes,$(have-mtls-dialect-gnu2))
+# The test is valid for all TLS types, but we want to exercise GNU2
+# TLS if possible.
+CFLAGS-tst-audit-tlsdesc-mod1.c += -mtls-dialect=gnu2
+CFLAGS-tst-audit-tlsdesc-mod2.c += -mtls-dialect=gnu2
+endif
+$(objpfx)tst-audit-tlsdesc-dlopen: $(shared-thread-library)
+$(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-audit-tlsdesc-mod1.so \
+ $(objpfx)tst-audit-tlsdesc-mod2.so
+$(objpfx)tst-audit-tlsdesc-mod1.so: $(objpfx)tst-audit-tlsdesc-mod2.so
+$(objpfx)tst-audit-tlsdesc.out: $(objpfx)tst-auditmod-tlsdesc.so
+tst-audit-tlsdesc-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
+$(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-auditmod-tlsdesc.so
+tst-audit-tlsdesc-dlopen-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so
+
+$(objpfx)tst-dlmopen-twice.out: \
+ $(objpfx)tst-dlmopen-twice-mod1.so \
+ $(objpfx)tst-dlmopen-twice-mod2.so
diff --git a/elf/dl-open.c b/elf/dl-open.c
index a23e65926b..46e8066fd8 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -844,11 +844,14 @@ _dl_open (const char *file, int mode, const void *caller_dlopen, Lmid_t nsid,
_dl_signal_error (EINVAL, file, NULL, N_("\
no more namespaces available for dlmopen()"));
}
- else if (nsid == GL(dl_nns))
- {
- __rtld_lock_initialize (GL(dl_ns)[nsid]._ns_unique_sym_table.lock);
- ++GL(dl_nns);
- }
+
+ if (nsid == GL(dl_nns))
+ ++GL(dl_nns);
+
+ /* Initialize the new namespace. Most members are
+ zero-initialized, only the lock needs special treatment. */
+ memset (&GL(dl_ns)[nsid], 0, sizeof (GL(dl_ns)[nsid]));
+ __rtld_lock_initialize (GL(dl_ns)[nsid]._ns_unique_sym_table.lock);
_dl_debug_update (nsid)->r_state = RT_CONSISTENT;
}
diff --git a/elf/tst-dlmopen-twice-mod1.c b/elf/tst-dlmopen-twice-mod1.c
new file mode 100644
index 0000000000..0eaf04948c
--- /dev/null
+++ b/elf/tst-dlmopen-twice-mod1.c
@@ -0,0 +1,37 @@
+/* Initialization of libc after dlmopen/dlclose/dlmopen (bug 29528). Module 1.
+ 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 <stdio.h>
+
+static void __attribute__ ((constructor))
+init (void)
+{
+ puts ("info: tst-dlmopen-twice-mod1.so loaded");
+ fflush (stdout);
+}
+
+static void __attribute__ ((destructor))
+fini (void)
+{
+ puts ("info: tst-dlmopen-twice-mod1.so about to be unloaded");
+ fflush (stdout);
+}
+
+/* Large allocation. The second module does not have this, so it
+ should load libc at a different address. */
+char large_allocate[16 * 1024 * 1024];
diff --git a/elf/tst-dlmopen-twice-mod2.c b/elf/tst-dlmopen-twice-mod2.c
new file mode 100644
index 0000000000..40c6c01f96
--- /dev/null
+++ b/elf/tst-dlmopen-twice-mod2.c
@@ -0,0 +1,50 @@
+/* Initialization of libc after dlmopen/dlclose/dlmopen (bug 29528). Module 2.
+ 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 <ctype.h>
+#include <stdio.h>
+
+static void __attribute__ ((constructor))
+init (void)
+{
+ puts ("info: tst-dlmopen-twice-mod2.so loaded");
+ fflush (stdout);
+}
+
+static void __attribute__ ((destructor))
+fini (void)
+{
+ puts ("info: tst-dlmopen-twice-mod2.so about to be unloaded");
+ fflush (stdout);
+}
+
+int
+run_check (void)
+{
+ puts ("info: about to call isalpha");
+ fflush (stdout);
+
+ volatile char ch = 'a';
+ if (!isalpha (ch))
+ {
+ puts ("error: isalpha ('a') is not true");
+ fflush (stdout);
+ return 1;
+ }
+ return 0;
+}
diff --git a/elf/tst-dlmopen-twice.c b/elf/tst-dlmopen-twice.c
new file mode 100644
index 0000000000..449f3c8fa9
--- /dev/null
+++ b/elf/tst-dlmopen-twice.c
@@ -0,0 +1,34 @@
+/* Initialization of libc after dlmopen/dlclose/dlmopen (bug 29528). Main.
+ 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 <support/xdlfcn.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+ void *handle = xdlmopen (LM_ID_NEWLM, "tst-dlmopen-twice-mod1.so", RTLD_NOW);
+ xdlclose (handle);
+ handle = xdlmopen (LM_ID_NEWLM, "tst-dlmopen-twice-mod2.so", RTLD_NOW);
+ int (*run_check) (void) = xdlsym (handle, "run_check");
+ TEST_COMPARE (run_check (), 0);
+ xdlclose (handle);
+ return 0;
+}
+
+#include <support/test-driver.c>
--
2.37.2

View file

@ -1,425 +0,0 @@
From 3c791f2031ca8f6b99e96b774ed1c505ceb93595 Mon Sep 17 00:00:00 2001
From: Raphael Moreira Zinsly <rzinsly@linux.ibm.com>
Date: Wed, 24 Aug 2022 11:43:37 -0300
Subject: [PATCH 18/22] Apply asm redirections in wchar.h before first use
Similar to d0fa09a770, but for wchar.h. Fixes [BZ #27087] by applying
all long double related asm redirections before using functions in
bits/wchar2.h.
Moves the function declarations from wcsmbs/bits/wchar2.h to a new file
wcsmbs/bits/wchar2-decl.h that will be included first in wcsmbs/wchar.h.
Tested with build-many-glibcs.py.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit c7509d49c4e8fa494120c5ead21338559dad16f5)
---
include/bits/wchar2-decl.h | 1 +
wcsmbs/Makefile | 5 +-
wcsmbs/bits/wchar2-decl.h | 124 +++++++++++++++++++++++++++++++++++++
wcsmbs/bits/wchar2.h | 72 ---------------------
wcsmbs/wchar.h | 11 +++-
5 files changed, 137 insertions(+), 76 deletions(-)
create mode 100644 include/bits/wchar2-decl.h
create mode 100644 wcsmbs/bits/wchar2-decl.h
diff --git a/include/bits/wchar2-decl.h b/include/bits/wchar2-decl.h
new file mode 100644
index 0000000000..00b1b93342
--- /dev/null
+++ b/include/bits/wchar2-decl.h
@@ -0,0 +1 @@
+#include <wcsmbs/bits/wchar2-decl.h>
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index 3d19d5556f..4af102a3f6 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -22,8 +22,9 @@ subdir := wcsmbs
include ../Makeconfig
-headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar-ldbl.h uchar.h \
- bits/types/__mbstate_t.h bits/types/mbstate_t.h bits/types/wint_t.h
+headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar2-decl.h \
+ bits/wchar-ldbl.h uchar.h bits/types/__mbstate_t.h \
+ bits/types/mbstate_t.h bits/types/wint_t.h
routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \
diff --git a/wcsmbs/bits/wchar2-decl.h b/wcsmbs/bits/wchar2-decl.h
new file mode 100644
index 0000000000..8e1735c33b
--- /dev/null
+++ b/wcsmbs/bits/wchar2-decl.h
@@ -0,0 +1,124 @@
+/* Checking macros for wchar functions. Declarations only.
+ Copyright (C) 2004-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/>. */
+
+#ifndef _BITS_WCHAR2_DECL_H
+#define _BITS_WCHAR2_DECL_H 1
+
+#ifndef _WCHAR_H
+# error "Never include <bits/wchar2-decl.h> directly; use <wchar.h> instead."
+#endif
+
+
+extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1,
+ const wchar_t *__restrict __s2, size_t __n,
+ size_t __ns1) __THROW;
+extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2,
+ size_t __n, size_t __ns1) __THROW;
+
+
+#ifdef __USE_GNU
+
+extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1,
+ const wchar_t *__restrict __s2, size_t __n,
+ size_t __ns1) __THROW;
+
+#endif
+
+
+extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
+ size_t __ns) __THROW;
+extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest,
+ const wchar_t *__restrict __src,
+ size_t __n) __THROW;
+extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest,
+ const wchar_t *__restrict __src,
+ size_t __destlen) __THROW;
+extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest,
+ const wchar_t *__restrict __src, size_t __n,
+ size_t __destlen) __THROW;
+extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest,
+ const wchar_t *__restrict __src, size_t __n,
+ size_t __destlen) __THROW;
+extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest,
+ const wchar_t *__restrict __src,
+ size_t __destlen) __THROW;
+extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest,
+ const wchar_t *__restrict __src,
+ size_t __n, size_t __destlen) __THROW;
+extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
+ int __flag, size_t __s_len,
+ const wchar_t *__restrict __format, ...)
+ __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
+extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
+ int __flag, size_t __s_len,
+ const wchar_t *__restrict __format,
+ __gnuc_va_list __arg)
+ __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
+
+#if __USE_FORTIFY_LEVEL > 1
+
+extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
+ const wchar_t *__restrict __format, ...);
+extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
+ ...);
+extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag,
+ const wchar_t *__restrict __format,
+ __gnuc_va_list __ap);
+extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
+ __gnuc_va_list __ap);
+
+#endif
+
+extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n,
+ __FILE *__restrict __stream) __wur;
+
+#ifdef __USE_GNU
+
+extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size,
+ int __n, __FILE *__restrict __stream)
+ __wur;
+
+#endif
+
+extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar,
+ mbstate_t *__restrict __p,
+ size_t __buflen) __THROW __wur;
+extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst,
+ const char **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps,
+ size_t __dstlen) __THROW;
+extern size_t __wcsrtombs_chk (char *__restrict __dst,
+ const wchar_t **__restrict __src,
+ size_t __len, mbstate_t *__restrict __ps,
+ size_t __dstlen) __THROW;
+
+#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,
+ size_t __dstlen) __THROW;
+extern size_t __wcsnrtombs_chk (char *__restrict __dst,
+ const wchar_t **__restrict __src,
+ size_t __nwc, size_t __len,
+ mbstate_t *__restrict __ps, size_t __dstlen)
+ __THROW;
+
+#endif
+
+#endif /* bits/wchar2-decl.h. */
diff --git a/wcsmbs/bits/wchar2.h b/wcsmbs/bits/wchar2.h
index 0e017f458b..3f110efe57 100644
--- a/wcsmbs/bits/wchar2.h
+++ b/wcsmbs/bits/wchar2.h
@@ -21,9 +21,6 @@
#endif
-extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1,
- const wchar_t *__restrict __s2, size_t __n,
- size_t __ns1) __THROW;
extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias,
(wchar_t *__restrict __s1,
const wchar_t *__restrict __s2, size_t __n),
@@ -45,8 +42,6 @@ __NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
}
-extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2,
- size_t __n, size_t __ns1) __THROW;
extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1,
const wchar_t *__s2,
size_t __n), wmemmove);
@@ -66,9 +61,6 @@ __NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n))
#ifdef __USE_GNU
-extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1,
- const wchar_t *__restrict __s2, size_t __n,
- size_t __ns1) __THROW;
extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias,
(wchar_t *__restrict __s1,
const wchar_t *__restrict __s2,
@@ -91,8 +83,6 @@ __NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
#endif
-extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
- size_t __ns) __THROW;
extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
size_t __n), wmemset);
extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn,
@@ -110,9 +100,6 @@ __NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n))
}
-extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest,
- const wchar_t *__restrict __src,
- size_t __n) __THROW;
extern wchar_t *__REDIRECT_NTH (__wcscpy_alias,
(wchar_t *__restrict __dest,
const wchar_t *__restrict __src), wcscpy);
@@ -127,9 +114,6 @@ __NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
}
-extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest,
- const wchar_t *__restrict __src,
- size_t __destlen) __THROW;
extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias,
(wchar_t *__restrict __dest,
const wchar_t *__restrict __src), wcpcpy);
@@ -144,9 +128,6 @@ __NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
}
-extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest,
- const wchar_t *__restrict __src, size_t __n,
- size_t __destlen) __THROW;
extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias,
(wchar_t *__restrict __dest,
const wchar_t *__restrict __src,
@@ -168,9 +149,6 @@ __NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
}
-extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest,
- const wchar_t *__restrict __src, size_t __n,
- size_t __destlen) __THROW;
extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias,
(wchar_t *__restrict __dest,
const wchar_t *__restrict __src,
@@ -192,9 +170,6 @@ __NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
}
-extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest,
- const wchar_t *__restrict __src,
- size_t __destlen) __THROW;
extern wchar_t *__REDIRECT_NTH (__wcscat_alias,
(wchar_t *__restrict __dest,
const wchar_t *__restrict __src), wcscat);
@@ -209,9 +184,6 @@ __NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
}
-extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest,
- const wchar_t *__restrict __src,
- size_t __n, size_t __destlen) __THROW;
extern wchar_t *__REDIRECT_NTH (__wcsncat_alias,
(wchar_t *__restrict __dest,
const wchar_t *__restrict __src,
@@ -228,10 +200,6 @@ __NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
}
-extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
- int __flag, size_t __s_len,
- const wchar_t *__restrict __format, ...)
- __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
extern int __REDIRECT_NTH_LDBL (__swprintf_alias,
(wchar_t *__restrict __s, size_t __n,
@@ -258,11 +226,6 @@ __NTH (swprintf (wchar_t *__restrict __s, size_t __n,
: swprintf (s, n, __VA_ARGS__))
#endif
-extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
- int __flag, size_t __s_len,
- const wchar_t *__restrict __format,
- __gnuc_va_list __arg)
- __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
extern int __REDIRECT_NTH_LDBL (__vswprintf_alias,
(wchar_t *__restrict __s, size_t __n,
@@ -283,16 +246,6 @@ __NTH (vswprintf (wchar_t *__restrict __s, size_t __n,
#if __USE_FORTIFY_LEVEL > 1
-extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
- const wchar_t *__restrict __format, ...);
-extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
- ...);
-extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag,
- const wchar_t *__restrict __format,
- __gnuc_va_list __ap);
-extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
- __gnuc_va_list __ap);
-
# ifdef __va_arg_pack
__fortify_function int
wprintf (const wchar_t *__restrict __fmt, ...)
@@ -328,8 +281,6 @@ vfwprintf (__FILE *__restrict __stream,
#endif
-extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n,
- __FILE *__restrict __stream) __wur;
extern wchar_t *__REDIRECT (__fgetws_alias,
(wchar_t *__restrict __s, int __n,
__FILE *__restrict __stream), fgetws) __wur;
@@ -351,9 +302,6 @@ fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
}
#ifdef __USE_GNU
-extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size,
- int __n, __FILE *__restrict __stream)
- __wur;
extern wchar_t *__REDIRECT (__fgetws_unlocked_alias,
(wchar_t *__restrict __s, int __n,
__FILE *__restrict __stream), fgetws_unlocked)
@@ -379,9 +327,6 @@ fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
#endif
-extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar,
- mbstate_t *__restrict __p,
- size_t __buflen) __THROW __wur;
extern size_t __REDIRECT_NTH (__wcrtomb_alias,
(char *__restrict __s, wchar_t __wchar,
mbstate_t *__restrict __ps), wcrtomb) __wur;
@@ -404,10 +349,6 @@ __NTH (wcrtomb (char *__restrict __s, wchar_t __wchar,
}
-extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst,
- const char **__restrict __src,
- size_t __len, mbstate_t *__restrict __ps,
- size_t __dstlen) __THROW;
extern size_t __REDIRECT_NTH (__mbsrtowcs_alias,
(wchar_t *__restrict __dst,
const char **__restrict __src,
@@ -431,10 +372,6 @@ __NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
}
-extern size_t __wcsrtombs_chk (char *__restrict __dst,
- const wchar_t **__restrict __src,
- size_t __len, mbstate_t *__restrict __ps,
- size_t __dstlen) __THROW;
extern size_t __REDIRECT_NTH (__wcsrtombs_alias,
(char *__restrict __dst,
const wchar_t **__restrict __src,
@@ -458,10 +395,6 @@ __NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
#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,
- size_t __dstlen) __THROW;
extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias,
(wchar_t *__restrict __dst,
const char **__restrict __src, size_t __nmc,
@@ -485,11 +418,6 @@ __NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
}
-extern size_t __wcsnrtombs_chk (char *__restrict __dst,
- const wchar_t **__restrict __src,
- size_t __nwc, size_t __len,
- mbstate_t *__restrict __ps, size_t __dstlen)
- __THROW;
extern size_t __REDIRECT_NTH (__wcsnrtombs_alias,
(char *__restrict __dst,
const wchar_t **__restrict __src,
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 5d6a40853d..c1321c7518 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -864,14 +864,21 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
/* Define some macros helping to catch buffer overflows. */
#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-# include <bits/wchar2.h>
+/* Declare all functions from bits/wchar2-decl.h first. */
+# include <bits/wchar2-decl.h>
#endif
-#include <bits/floatn.h>
+/* The following headers provide asm redirections. These redirections must
+ appear before the first usage of these functions, e.g. in bits/wchar.h. */
#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
# include <bits/wchar-ldbl.h>
#endif
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
+/* Now include the function definitions and redirects too. */
+# include <bits/wchar2.h>
+#endif
+
__END_DECLS
#endif /* wchar.h */
--
2.37.2

View file

@ -1,63 +0,0 @@
From b3736d1a3c60a3ec9959bf3b38794958546bf6a2 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue, 30 Aug 2022 13:35:52 -0300
Subject: [PATCH 19/22] elf: Restore how vDSO dependency is printed with
LD_TRACE_LOADED_OBJECTS (BZ #29539)
The d7703d3176d225d5743b21811d888619eba39e82 changed how vDSO like
dependencies are printed, instead of just the name and address it
follows other libraries mode and prints 'name => path'.
Unfortunately, this broke some ldd consumer that uses the output to
filter out the program's dependencies. For instance CMake
bundleutilities module [1], where GetPrequirite uses the regex to filter
out 'name => path' [2].
This patch restore the previous way to print just the name and the
mapping address.
Checked on x86_64-linux-gnu.
[1] https://github.com/Kitware/CMake/tree/master/Tests/BundleUtilities
[2] https://github.com/Kitware/CMake/blob/master/Modules/GetPrerequisites.cmake#L733
Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 1e903124cec4492463d075c6c061a2a772db77bf)
---
NEWS | 2 +-
elf/rtld.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 6d31e5abba..757ded85e0 100644
--- a/NEWS
+++ b/NEWS
@@ -14,7 +14,7 @@ The following bugs are resolved with this release:
[29485] Linux: Terminate subprocess on late failure in tst-pidfd
[29490] alpha: New __brk_call implementation is broken
[29528] elf: Call __libc_early_init for reused namespaces
-
+ [29539] libc: LD_TRACE_LOADED_OBJECTS changed how vDSO library are
Version 2.36
diff --git a/elf/rtld.c b/elf/rtld.c
index cbbaf4a331..3e771a93d8 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2122,6 +2122,12 @@ dl_main (const ElfW(Phdr) *phdr,
if (l->l_faked)
/* The library was not found. */
_dl_printf ("\t%s => not found\n", l->l_libname->name);
+ else if (strcmp (l->l_libname->name, l->l_name) == 0)
+ /* Print vDSO like libraries without duplicate name. Some
+ consumers depend of this format. */
+ _dl_printf ("\t%s (0x%0*Zx)\n", l->l_libname->name,
+ (int) sizeof l->l_map_start * 2,
+ (size_t) l->l_map_start);
else
_dl_printf ("\t%s => %s (0x%0*Zx)\n",
DSO_FILENAME (l->l_libname->name),
--
2.37.2

View file

@ -1,58 +0,0 @@
From 645d94808aaa90fb1b20a25ff70bb50d9eb1d55b Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon, 5 Sep 2022 09:34:39 -0300
Subject: [PATCH 20/22] syslog: Remove extra whitespace between timestamp and
message (BZ#29544)
The rfc3164 clear states that a single space character must follow
the timestamp field.
Checked on x86_64-linux-gnu.
---
misc/syslog.c | 2 +-
misc/tst-syslog.c | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/misc/syslog.c b/misc/syslog.c
index b88f66c835..f67d4b58a4 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -167,7 +167,7 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap,
_nl_C_locobj_ptr);
#define SYSLOG_HEADER(__pri, __timestamp, __msgoff, pid) \
- "<%d>%s %n%s%s%.0d%s: ", \
+ "<%d>%s%n%s%s%.0d%s: ", \
__pri, __timestamp, __msgoff, \
LogTag == NULL ? __progname : LogTag, \
"[" + (pid == 0), pid, "]" + (pid == 0)
diff --git a/misc/tst-syslog.c b/misc/tst-syslog.c
index 1d332ece53..3560b518a2 100644
--- a/misc/tst-syslog.c
+++ b/misc/tst-syslog.c
@@ -275,16 +275,19 @@ parse_syslog_msg (const char *msg)
{
struct msg_t r = { .pid = -1 };
int number;
+ int wsb, wsa;
#define STRINPUT(size) XSTRINPUT(size)
#define XSTRINPUT(size) "%" # size "s"
/* The message in the form:
- <179>Apr 8 14:51:19 tst-syslog: message 176 3 */
- int n = sscanf (msg, "<%3d>%*s %*d %*d:%*d:%*d " STRINPUT(IDENT_LENGTH)
+ <179>Apr 8 14:51:19 tst-syslog: message 176 3 */
+ int n = sscanf (msg, "<%3d>%*s %*d %*d:%*d:%*d%n %n" STRINPUT(IDENT_LENGTH)
" " STRINPUT(MSG_LENGTH) " %*d %*d",
- &number, r.ident, r.msg);
+ &number, &wsb, &wsa, r.ident, r.msg);
TEST_COMPARE (n, 3);
+ /* It should only one space between timestamp and message. */
+ TEST_COMPARE (wsa - wsb, 1);
r.facility = number & LOG_FACMASK;
r.priority = number & LOG_PRIMASK;
--
2.37.2

View file

@ -1,31 +0,0 @@
From b46412fb17e8bfc6c9e1f144bbcf833320c80f8a Mon Sep 17 00:00:00 2001
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Tue, 6 Sep 2022 09:31:50 -0400
Subject: [PATCH 21/22] Add NEWS entry for CVE-2022-39046
(cherry picked from commit 76fe56020e7ef354685b2284580ac1630c078a2b)
---
NEWS | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/NEWS b/NEWS
index 757ded85e0..10a7613f09 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,13 @@ using `glibc' in the "product" field.
Version 2.36.1
+Security related changes:
+
+ CVE-2022-39046: When the syslog function is passed a crafted input
+ string larger than 1024 bytes, it reads uninitialized memory from the
+ heap and prints it to the target log file, potentially revealing a
+ portion of the contents of the heap.
+
The following bugs are resolved with this release:
[28846] CMSG_NXTHDR may trigger -Wstrict-overflow warning
--
2.37.2

View file

@ -1,59 +0,0 @@
From c399271c10bd00714504e8d4dfbec8aebf996dd4 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fvogt@suse.de>
Date: Wed, 27 Jul 2022 11:44:07 +0200
Subject: [PATCH 22/22] nscd: Fix netlink cache invalidation if epoll is used
[BZ #29415]
Processes cache network interface information such as whether IPv4 or IPv6
are enabled. This is only checked again if the "netlink timestamp" provided
by nscd changed, which is triggered by netlink socket activity.
However, in the epoll handler for the netlink socket, it was missed to
assign the new timestamp to the nscd database. The handler for plain poll
did that properly, copy that over.
This bug caused that e.g. processes which started before network
configuration got unusuable addresses from getaddrinfo, like IPv6 only even
though only IPv4 is available:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1041
It's a bit hard to reproduce, so I verified this by checking the timestamp
on calls to __check_pf manually. Without this patch it's stuck at 1, now
it's increasing on network changes as expected.
Signed-off-by: Fabian Vogt <fvogt@suse.de>
(cherry picked from commit 02ca25fef2785974011e9c5beecc99b900b69fd7)
---
NEWS | 1 +
nscd/connections.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 10a7613f09..9360596fcc 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Security related changes:
The following bugs are resolved with this release:
[28846] CMSG_NXTHDR may trigger -Wstrict-overflow warning
+ [29415] nscd: Fix netlink cache invalidation if epoll is used
[29446] _dlopen now ignores dl_caller argument in static mode
[29485] Linux: Terminate subprocess on late failure in tst-pidfd
[29490] alpha: New __brk_call implementation is broken
diff --git a/nscd/connections.c b/nscd/connections.c
index 61d1674eb4..531d2e83df 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -2284,7 +2284,8 @@ main_loop_epoll (int efd)
sizeof (buf))) != -1)
;
- __bump_nl_timestamp ();
+ dbs[hstdb].head->extra_data[NSCD_HST_IDX_CONF_TIMESTAMP]
+ = __bump_nl_timestamp ();
}
# endif
else
--
2.37.2

View file

@ -1,95 +0,0 @@
From 2efa9591e5e8a129e7b73ad0dad3eecbd69482ff Mon Sep 17 00:00:00 2001
From: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
Date: Tue, 30 Jul 2019 16:44:27 -0700
Subject: [PATCH] HACK: test app for pthread_mutex_lock_any(); should be
tst-mutex* something.
---
multimutextestapp/testapp.c | 78 +++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 multimutextestapp/testapp.c
diff --git a/multimutextestapp/testapp.c b/multimutextestapp/testapp.c
new file mode 100644
index 0000000000..eecf842dbc
--- /dev/null
+++ b/multimutextestapp/testapp.c
@@ -0,0 +1,78 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_mutex_t m[3];
+
+
+static void *
+tf (void *arg)
+{
+ int out;
+ int ret = pthread_mutex_lock_any( m, 3, &out );
+
+ printf("new thread ret %i out %i!\n", ret, out );
+
+ sleep(5);
+ printf("new thread done sleeping!\n");
+
+ pthread_mutex_unlock( &m[out] );
+
+ return NULL;
+}
+
+
+int main(int ac, char**av)
+{
+ pthread_mutex_init (&m[0], NULL);
+ pthread_mutex_init (&m[1], NULL);
+ pthread_mutex_init (&m[2], NULL);
+
+ int out;
+
+ int ret = pthread_mutex_lock_any( m, 3, &out );
+
+ printf("main thread ret %i out %i!\n", ret, out );
+
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ sleep(1);
+
+ ret = pthread_mutex_lock_any( m, 3, &out );
+
+ printf("main thread ret %i out %i!\n", ret, out );
+
+ sleep(1);
+
+ struct timespec timeoutTime;
+ clock_gettime(CLOCK_REALTIME, &timeoutTime);
+ timeoutTime.tv_sec += 1;
+
+ ret = pthread_mutex_timedlock_any( m, 3, &timeoutTime, &out );
+
+ printf("main thread ret %i out %i!\n", ret, out );
+
+ clock_gettime(CLOCK_REALTIME, &timeoutTime);
+ timeoutTime.tv_sec += 3;
+
+ ret = pthread_mutex_timedlock_any( m, 3, &timeoutTime, &out );
+
+ printf("main thread ret %i out %i!\n", ret, out );
+
+ pthread_mutex_unlock( &m[out] );
+ pthread_mutex_unlock( &m[0] );
+ pthread_mutex_unlock( &m[2] );
+
+ printf("DONE unlock!\n");
+
+ return 0;
+}

View file

@ -1,297 +0,0 @@
diff -up glibc-2.35/nptl/pthread_mutex_lock_any.c.46~ glibc-2.35/nptl/pthread_mutex_lock_any.c
--- glibc-2.35/nptl/pthread_mutex_lock_any.c.46~ 2022-02-03 11:21:15.315282335 +0100
+++ glibc-2.35/nptl/pthread_mutex_lock_any.c 2022-02-03 11:21:15.315282335 +0100
@@ -0,0 +1,37 @@
+/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <not-cancel.h>
+#include "pthreadP.h"
+#include <atomic.h>
+#include <lowlevellock.h>
+#include <stap-probe.h>
+
+int
+__pthread_mutex_lock_any (pthread_mutex_t *mutexlist, int mutexcount,
+ int *outlocked)
+{
+ return __pthread_mutex_timedlock_any(mutexlist, mutexcount, NULL, outlocked);
+}
+
+weak_alias (__pthread_mutex_lock_any, pthread_mutex_lock_any)
diff -up glibc-2.35/nptl/pthread_mutex_timedlock_any.c.46~ glibc-2.35/nptl/pthread_mutex_timedlock_any.c
--- glibc-2.35/nptl/pthread_mutex_timedlock_any.c.46~ 2022-02-03 11:21:15.316282339 +0100
+++ glibc-2.35/nptl/pthread_mutex_timedlock_any.c 2022-02-03 11:21:15.316282339 +0100
@@ -0,0 +1,193 @@
+/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <not-cancel.h>
+#include "pthreadP.h"
+#include <atomic.h>
+#include <lowlevellock.h>
+#include <stap-probe.h>
+
+/* TODO: this probably comes from a kernel header when upstream? */
+struct futex_wait_block {
+ int *uaddr;
+ int val;
+ int bitset;
+} __attribute__((packed));
+
+int
+__pthread_mutex_timedlock_any (pthread_mutex_t *mutexlist, int mutexcount,
+ const struct timespec *abstime, int *outlocked)
+{
+ /* This requires futex support */
+#ifndef __NR_futex
+ return ENOTSUP;
+#endif
+
+ if (mutexlist == NULL)
+ {
+ /* User is asking us if kernel supports the feature. */
+
+ /* TODO: how does one check if supported?
+ * I was thinking of trying the ioctl once and then returning the static
+ * cached value, is that OK?
+ */
+ return 0;
+ }
+
+ if (mutexlist != NULL && mutexcount <= 0)
+ return EINVAL;
+
+ if (outlocked == NULL)
+ return EINVAL;
+
+ int type = PTHREAD_MUTEX_TYPE (mutexlist);
+
+ for (int i = 1; i < mutexcount; i++)
+ {
+ /* Types have to match, since the PRIVATE flag is OP-global. */
+ if (PTHREAD_MUTEX_TYPE (&mutexlist[i]) != type)
+ return EINVAL;
+ }
+
+ int kind = type & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ /* TODO: implement recursive, errorcheck and adaptive. */
+ if (kind != PTHREAD_MUTEX_NORMAL)
+ return EINVAL;
+
+ /* TODO: implement robust. */
+ if (type & PTHREAD_MUTEX_ROBUST_NORMAL_NP)
+ return EINVAL;
+
+ /* TODO: implement PI. */
+ if (type & PTHREAD_MUTEX_PRIO_INHERIT_NP)
+ return EINVAL;
+
+ /* TODO: implement PP. */
+ if (type & PTHREAD_MUTEX_PRIO_PROTECT_NP)
+ return EINVAL;
+
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+ int result;
+
+ result = -1;
+
+ for (int i = 0; i < mutexcount; i++)
+ {
+ if (__lll_trylock (&mutexlist[i].__data.__lock) == 0)
+ {
+ result = i;
+ break;
+ }
+ }
+
+ while (result == -1)
+ {
+ for (int i = 0; i < mutexcount; i++)
+ {
+ int oldval = atomic_exchange_acq (&mutexlist[i].__data.__lock, 2);
+
+ if (oldval == 0)
+ {
+ result = i;
+ break;
+ }
+ }
+
+ if (result == -1)
+ {
+ /* Couldn't get one of the locks immediately, we have to sleep now. */
+ struct timespec *timeout = NULL;
+ struct timespec rt;
+
+ if (abstime != NULL)
+ {
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ timeout = &rt;
+ }
+
+ struct futex_wait_block waitblock[mutexcount];
+
+ for (int i = 0; i < mutexcount; i++)
+ {
+ waitblock[i].uaddr = &mutexlist[i].__data.__lock;
+ waitblock[i].val = 2;
+ waitblock[i].bitset = ~0;
+ }
+
+ long int __ret;
+
+ /* Safe to use the flag for the first one, since all their types match. */
+ int private_flag = PTHREAD_MUTEX_PSHARED (&mutexlist[0]);
+
+ __ret = lll_futex_timed_wait_multiple (waitblock, mutexcount, timeout,
+ private_flag);
+
+ if (__ret < 0)
+ return -__ret; /* TODO is this correct? */
+
+ /* Have slept, try grabbing the one that woke us up? */
+ if (atomic_exchange_acq (&mutexlist[__ret].__data.__lock, 2) == 0)
+ {
+ /* We got it, done, loop will end below. */
+ result = __ret;
+ }
+ }
+ }
+
+ if (result != -1)
+ {
+ /* Record the ownership. */
+ mutexlist[result].__data.__owner = id;
+ ++mutexlist[result].__data.__nusers;
+
+ /* Let the user know which mutex is now locked. */
+ *outlocked = result;
+
+ result = 0;
+ }
+
+ return result;
+}
+
+weak_alias (__pthread_mutex_timedlock_any, pthread_mutex_timedlock_any)
diff -up glibc-2.35/sysdeps/nptl/lowlevellock-futex.h.46~ glibc-2.35/sysdeps/nptl/lowlevellock-futex.h
--- glibc-2.35/sysdeps/nptl/lowlevellock-futex.h.46~ 2022-02-03 06:27:54.000000000 +0100
+++ glibc-2.35/sysdeps/nptl/lowlevellock-futex.h 2022-02-03 11:25:49.314310869 +0100
@@ -39,6 +39,7 @@
#define FUTEX_WAIT_REQUEUE_PI 11
#define FUTEX_CMP_REQUEUE_PI 12
#define FUTEX_LOCK_PI2 13
+#define FUTEX_WAIT_MULTIPLE 14
#define FUTEX_PRIVATE_FLAG 128
#define FUTEX_CLOCK_REALTIME 256
@@ -62,6 +63,14 @@
? -INTERNAL_SYSCALL_ERRNO (__ret) : 0); \
})
+# define lll_futex_syscall_ret(nargs, futexp, op, ...) \
+ ({ \
+ long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \
+ __VA_ARGS__); \
+ (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \
+ ? -INTERNAL_SYSCALL_ERRNO (__ret) : __ret); \
+ })
+
/* For most of these macros, the return value is never really used.
Nevertheless, the protocol is that each one returns a negated errno
code for failure or zero for success. (Note that the corresponding
@@ -78,6 +87,11 @@
__lll_private_flag (FUTEX_WAIT, private), \
val, timeout)
+# define lll_futex_timed_wait_multiple(futexp, val, timeout, private) \
+ lll_futex_syscall_ret (4, futexp, \
+ __lll_private_flag (FUTEX_WAIT_MULTIPLE, private), \
+ val, timeout)
+
/* Verify whether the supplied clockid is supported by
lll_futex_clock_wait_bitset. */
# define lll_futex_supported_clockid(clockid) \
diff -up glibc-2.35/sysdeps/nptl/pthread.h.46~ glibc-2.35/sysdeps/nptl/pthread.h
--- glibc-2.35/sysdeps/nptl/pthread.h.46~ 2022-02-03 06:27:54.000000000 +0100
+++ glibc-2.35/sysdeps/nptl/pthread.h 2022-02-03 11:21:15.316282339 +0100
@@ -794,7 +794,17 @@ extern int pthread_mutex_trylock (pthrea
extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
__THROWNL __nonnull ((1));
+/* Lock any one of several mutexes. */
+extern int pthread_mutex_lock_any (pthread_mutex_t *__mutexlist,
+ int mutexcount, int *outlocked);
+
+
#ifdef __USE_XOPEN2K
+/* Lock any one of several mutexes, with timeout. */
+extern int pthread_mutex_timedlock_any (pthread_mutex_t *__mutexlist,
+ int mutexcount,
+ const struct timespec *__restrict
+ __abstime, int *outlocked);
/* Wait until lock becomes available, or specified time passes. */
# ifndef __USE_TIME_BITS64
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,

View file

@ -1,29 +0,0 @@
diff --git a/malloc/malloc.c b/malloc/malloc.c
index f8e7250..de6d7fa 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4146,6 +4146,7 @@ _int_free (mstate av, mchunkptr p, int have_lock)
mchunkptr bck; /* misc temp for linking */
mchunkptr fwd; /* misc temp for linking */
+ static int alternate;
size = chunksize (p);
/* Little security check which won't hurt performance: the
@@ -4364,8 +4365,14 @@ _int_free (mstate av, mchunkptr p, int have_lock)
if (av == &main_arena) {
#ifndef MORECORE_CANNOT_TRIM
if ((unsigned long)(chunksize(av->top)) >=
- (unsigned long)(mp_.trim_threshold))
- systrim(mp_.top_pad, av);
+ (unsigned long)(mp_.trim_threshold)) {
+ if (alternate) {
+ systrim(mp_.top_pad, av);
+ alternate = 0;
+ } else {
+ alternate = 1;
+ }
+ }
#endif
} else {
/* Always try heap_trim(), even if the top chunk is not

View file

@ -1,65 +0,0 @@
--- glibc-2.3.6/mandriva/nsswitch.conf.nsswitch.conf 2006-03-20 10:39:14.000000000 +0100
+++ glibc-2.3.6/mandriva/nsswitch.conf 2006-03-20 10:38:42.000000000 +0100
@@ -0,0 +1,47 @@
+#
+# /etc/nsswitch.conf
+#
+# An example Name Service Switch config file. This file should be
+# sorted with the most-used services at the beginning.
+#
+# The entry '[NOTFOUND=return]' means that the search for an
+# entry should stop if the search in the previous entry turned
+# up nothing. Note that if the search failed due to some other reason
+# (like no NIS server responding) then the search continues with the
+# next entry.
+#
+# Legal entries are:
+#
+# compat Use compatibility setup for NIS
+# db Use the local database (.db) files
+# dns Use DNS (Domain Name Service)
+# files Use the local files
+# hesiod Use Hesiod for user lookups
+# ldap Use LDAP for user lookups
+# mdns Use Multicast DNS (aka Zeroconf/Rendezvous) for host lookups
+# mdns_minimal Like mdns, but only resolve *.local
+# mdns4 Like mdns, but only for IPv4
+# mdns6 Like mdns, but only for IPv6
+# mdns4_minimal Like mdns4, but only resolve *.local
+# mdns6_minimal Like mdns6, but only resolve *.local
+# myhostname Resolves local name
+# nis or yp Use NIS (NIS version 2), also called YP
+# nisplus or nis+ Use NIS+ (NIS version 3)
+# pgsql Use NetBIOS for host lookups
+# sss Use SSSD (System Security Services Daemon)
+# tcb Use TCB for host lookups
+# tinycdb Use a constant database for user lookups
+# wins Use NetBIOS for host lookups
+# winbind Uses a Windows or Samba domain controller for host lookups
+# [NOTFOUND=return] Stop searching if not found so far
+#
+# For more information, please read the nsswitch.conf.5 manual page.
+#
+
+# passwd: files nis
+# shadow: files nis
+# group: files nis
+
+passwd: files compat winbind mymachines systemd
+shadow: files nis
+group: files compat winbind mymachines systemd
+
+hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname nis wins mdns4_minimal
+networks: files
+
+services: files
+protocols: files
+rpc: files
+ethers: files
+netmasks: files
+netgroup: files
+publickey: files
+
+bootparams: files
+automount: files nis
+aliases: files

View file

@ -1,19 +0,0 @@
--- glibc-2.27/stdlib/Makefile.0118~ 2018-02-02 20:31:07.402589690 +0100
+++ glibc-2.27/stdlib/Makefile 2018-02-02 20:31:53.077710331 +0100
@@ -190,9 +190,16 @@ test-canon-ARGS = --test-dir=${common-ob
bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
+isomac-includes = -I../include $(+sysdep-includes) $(sysincludes) -I..
+ifeq (powerpc:8, $(base-machine):$(sizeof-long-double))
+# XXX only necessary for bootstrapping...
+isomac-includes += -I../libio -I../stdlib -I../wcsmbs
+endif
+
$(objpfx)isomac.out: $(objpfx)isomac
$(dir $<)$(notdir $<) '$(CC)' \
'-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
+ '$(isomac-includes)' > $<.out \
$(evaluate-test)
isomac-CFLAGS = -O

View file

@ -1,17 +0,0 @@
diff -up glibc-2.34/rt/Makefile.39~ glibc-2.34/rt/Makefile
--- glibc-2.34/rt/Makefile.39~ 2021-08-02 10:35:18.780415863 +0200
+++ glibc-2.34/rt/Makefile 2021-08-02 10:35:56.864655876 +0200
@@ -114,3 +114,13 @@ endif
endif # !$(pthread-in-libc)
tst-mqueue7-ARGS = -- $(host-test-program-cmd)
+
+# XXX avoid timing issues on fine-grained SMT systems
+ifeq (powerpc, $(base-machine))
+no-parallel-testing = yes
+endif
+ifneq ($(filter %tests,$(MAKECMDGOALS)),)
+ifeq ($(no-parallel-testing),yes)
+.NOTPARALLEL:
+endif
+endif

View file

@ -1,13 +0,0 @@
--- glibc-2.2.4/debug/xtrace.sh.chmou Mon Jul 9 20:56:57 2001
+++ glibc-2.2.4/debug/xtrace.sh Mon Nov 12 14:16:51 2001
@@ -78,8 +78,8 @@
# If the variable COLUMNS is not set do this now.
COLUMNS=${COLUMNS:-80}
-# If `TERMINAL_PROG' is not set, set it to `xterm'.
-TERMINAL_PROG=${TERMINAL_PROG:-xterm}
+# If `TERMINAL_PROG' is not set, set it to `xvt'.
+TERMINAL_PROG=${TERMINAL_PROG:-xvt}
# The data file to process, if any.
data=

View file

@ -1,11 +0,0 @@
--- glibc-2.19/misc/sys/cdefs.h.omv~ 2014-06-22 14:53:05.862531155 +0200
+++ glibc-2.19/misc/sys/cdefs.h 2014-06-22 14:53:21.560531205 +0200
@@ -328,7 +328,7 @@
/* GCC 4.3 and above allow passing all anonymous arguments of an
__extern_always_inline function to some other vararg function. */
-#if __GNUC_PREREQ (4,3)
+#if __GNUC_PREREQ (4,3) && !defined(__clang__)
# define __va_arg_pack() __builtin_va_arg_pack ()
# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
#endif

View file

@ -1,12 +0,0 @@
diff -up glibc-2.29/sysdeps/unix/sysv/linux/x86_64/getcontext.S.omv~ glibc-2.29/sysdeps/unix/sysv/linux/x86_64/getcontext.S
--- glibc-2.29/sysdeps/unix/sysv/linux/x86_64/getcontext.S.omv~ 2019-02-01 12:59:33.458555834 +0100
+++ glibc-2.29/sysdeps/unix/sysv/linux/x86_64/getcontext.S 2019-02-01 13:01:58.194856450 +0100
@@ -19,6 +19,8 @@
#include <sysdep.h>
#include <asm/prctl.h>
+#define __ASSEMBLY__ 1
+#include <asm/signal.h> /* for SIG_BLOCK */
#include "ucontext_i.h"

View file

@ -1,34 +0,0 @@
diff -up glibc-2.29/locale/weight.h.omv~ glibc-2.29/locale/weight.h
diff -up glibc-2.29/string/strcoll_l.c.omv~ glibc-2.29/string/strcoll_l.c
--- glibc-2.29/string/strcoll_l.c.omv~ 2019-02-01 01:52:36.824032337 +0100
+++ glibc-2.29/string/strcoll_l.c 2019-02-01 01:56:42.412484448 +0100
@@ -40,7 +40,11 @@
#define CONCAT1(a,b) a##b
#include "../locale/localeinfo.h"
+/* See Line 178+ */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
#include WEIGHT_H
+DIAG_POP_NEEDS_COMMENT;
/* Track status while looking for sequences in a string. */
typedef struct
@@ -292,7 +296,7 @@ STRCOLL (const STRING_TYPE *s1, const ST
int result = 0, rule = 0;
- /* With GCC 7 when compiling with -Os the compiler warns that
+ /* With GCC 7 and 8 when compiling with -Os the compiler warns that
seq1.back_us and seq2.back_us might be used uninitialized.
Sometimes this warning appears at locations in locale/weightwc.h
where the actual use is, but on architectures other than x86_64,
@@ -300,7 +304,7 @@ STRCOLL (const STRING_TYPE *s1, const ST
seq2. This uninitialized use is impossible for the same reason
as described in comments in locale/weightwc.h. */
DIAG_PUSH_NEEDS_COMMENT;
- DIAG_IGNORE_Os_NEEDS_COMMENT (7, "-Wmaybe-uninitialized");
+ DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
coll_seq seq1, seq2;
DIAG_POP_NEEDS_COMMENT;
seq1.len = 0;

View file

@ -1,11 +0,0 @@
diff -up glibc-2.31.20200621/iconv/Makefile.omv~ glibc-2.31.20200621/iconv/Makefile
--- glibc-2.31.20200621/iconv/Makefile.omv~ 2020-06-27 03:39:53.689509570 +0200
+++ glibc-2.31.20200621/iconv/Makefile 2020-06-27 03:41:42.958406000 +0200
@@ -53,6 +53,7 @@ install-sbin = iconvconfig
CFLAGS-gconv_cache.c += -DGCONV_DIR='"$(gconvdir)"'
CFLAGS-gconv_conf.c += -DGCONV_PATH='"$(gconvdir)"'
CFLAGS-iconvconfig.c += -DGCONV_PATH='"$(gconvdir)"' -DGCONV_DIR='"$(gconvdir)"'
+CFLAGS-gconv_simple.c += -Wno-error=stringop-overflow
# Set libof-* for each routine.
cpp-srcs-left := $(iconv_prog-modules) $(iconvconfig-modules)

View file

@ -1,206 +0,0 @@
diff -up glibc-2.33/bits/floatn-common.h.92~ glibc-2.33/bits/floatn-common.h
--- glibc-2.33/bits/floatn-common.h.92~ 2021-02-01 18:15:33.000000000 +0100
+++ glibc-2.33/bits/floatn-common.h 2021-07-10 03:25:10.190826118 +0200
@@ -145,7 +145,7 @@ typedef _Complex float __cfloat16 __attr
# endif
# if __HAVE_FLOAT32
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
# define __CFLOAT32 _Complex float
# else
# define __CFLOAT32 _Complex _Float32
@@ -153,7 +153,7 @@ typedef _Complex float __cfloat16 __attr
# endif
# if __HAVE_FLOAT64
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
# ifdef __NO_LONG_DOUBLE_MATH
# define __CFLOAT64 _Complex long double
# else
@@ -165,7 +165,7 @@ typedef _Complex float __cfloat16 __attr
# endif
# if __HAVE_FLOAT32X
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
# define __CFLOAT32X _Complex double
# else
# define __CFLOAT32X _Complex _Float32x
@@ -173,7 +173,7 @@ typedef _Complex float __cfloat16 __attr
# endif
# if __HAVE_FLOAT64X
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
# if __HAVE_FLOAT64X_LONG_DOUBLE
# define __CFLOAT64X _Complex long double
# else
@@ -210,11 +210,11 @@ typedef float _Float16 __attribute__ ((_
# if __HAVE_FLOAT32
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef float _Float32;
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf32() (__builtin_huge_valf ())
# define __builtin_inff32() (__builtin_inff ())
# define __builtin_nanf32(x) (__builtin_nanf (x))
@@ -234,11 +234,11 @@ typedef float _Float32;
# ifdef __NO_LONG_DOUBLE_MATH
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef long double _Float64;
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf64() (__builtin_huge_vall ())
# define __builtin_inff64() (__builtin_infl ())
# define __builtin_nanf64(x) (__builtin_nanl (x))
@@ -247,11 +247,11 @@ typedef long double _Float64;
# else
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef double _Float64;
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf64() (__builtin_huge_val ())
# define __builtin_inff64() (__builtin_inf ())
# define __builtin_nanf64(x) (__builtin_nan (x))
@@ -264,11 +264,11 @@ typedef double _Float64;
# if __HAVE_FLOAT32X
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef double _Float32x;
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf32x() (__builtin_huge_val ())
# define __builtin_inff32x() (__builtin_inf ())
# define __builtin_nanf32x(x) (__builtin_nan (x))
@@ -281,11 +281,11 @@ typedef double _Float32x;
# if __HAVE_FLOAT64X_LONG_DOUBLE
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef long double _Float64x;
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf64x() (__builtin_huge_vall ())
# define __builtin_inff64x() (__builtin_infl ())
# define __builtin_nanf64x(x) (__builtin_nanl (x))
@@ -294,11 +294,11 @@ typedef long double _Float64x;
# else
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef _Float128 _Float64x;
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf64x() (__builtin_huge_valf128 ())
# define __builtin_inff64x() (__builtin_inff128 ())
# define __builtin_nanf64x(x) (__builtin_nanf128 (x))
@@ -311,11 +311,11 @@ typedef _Float128 _Float64x;
# if __HAVE_FLOAT128X
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
# error "_Float128x supported but no type"
# endif
-# if !__GNUC_PREREQ (7, 0)
+# if !__GNUC_PREREQ (7, 0) || defined(__clang__)
# define __builtin_huge_valf128x() ((_Float128x) __builtin_huge_val ())
# define __builtin_inff128x() ((_Float128x) __builtin_inf ())
# define __builtin_nanf128x(x) ((_Float128x) __builtin_nan (x))
diff -up glibc-2.33/sysdeps/ieee754/ldbl-128/bits/floatn.h.92~ glibc-2.33/sysdeps/ieee754/ldbl-128/bits/floatn.h
--- glibc-2.33/sysdeps/ieee754/ldbl-128/bits/floatn.h.92~ 2021-02-01 18:15:33.000000000 +0100
+++ glibc-2.33/sysdeps/ieee754/ldbl-128/bits/floatn.h 2021-07-10 03:24:05.274345249 +0200
@@ -55,7 +55,7 @@
/* Defined to concatenate the literal suffix to be used with _Float128
types, if __HAVE_FLOAT128 is 1. */
# if __HAVE_FLOAT128
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
/* The literal suffix f128 exists only since GCC 7.0. */
# define __f128(x) x##l
# else
@@ -65,7 +65,7 @@
/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
# if __HAVE_FLOAT128
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
# define __CFLOAT128 _Complex long double
# else
# define __CFLOAT128 _Complex _Float128
@@ -76,7 +76,7 @@
# if __HAVE_FLOAT128
/* The type _Float128 exists only since GCC 7.0. */
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined __clang__
typedef long double _Float128;
# endif
diff -up glibc-2.33/sysdeps/x86/bits/floatn.h.92~ glibc-2.33/sysdeps/x86/bits/floatn.h
--- glibc-2.33/sysdeps/x86/bits/floatn.h.92~ 2021-02-01 18:15:33.000000000 +0100
+++ glibc-2.33/sysdeps/x86/bits/floatn.h 2021-07-10 03:24:05.274345249 +0200
@@ -58,7 +58,7 @@
/* Defined to concatenate the literal suffix to be used with _Float128
types, if __HAVE_FLOAT128 is 1. */
# if __HAVE_FLOAT128
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
/* The literal suffix f128 exists only since GCC 7.0. */
# define __f128(x) x##q
# else
@@ -68,7 +68,7 @@
/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
# if __HAVE_FLOAT128
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
/* Add a typedef for older GCC compilers which don't natively support
_Complex _Float128. */
typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
@@ -82,7 +82,7 @@ typedef _Complex float __cfloat128 __att
# if __HAVE_FLOAT128
/* The type _Float128 exists only since GCC 7.0. */
-# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+# if !__GNUC_PREREQ (7, 0) || defined __cplusplus || defined(__clang__)
typedef __float128 _Float128;
# endif
@@ -108,7 +108,7 @@ typedef __float128 _Float128;
e.g.: __builtin_signbitf128, before GCC 6. However, there has never
been a __builtin_signbitf128 in GCC and the type-generic builtin is
only available since GCC 6. */
-# if !__GNUC_PREREQ (6, 0)
+# if !__GNUC_PREREQ (6, 0) || defined(__clang__)
# define __builtin_signbitf128 __signbitf128
# endif

View file

@ -1,16 +0,0 @@
diff -up glibc-2.33/sunrpc/netname.c.omv~ glibc-2.33/sunrpc/netname.c
--- glibc-2.33/sunrpc/netname.c.omv~ 2021-05-11 21:34:01.180317491 +0200
+++ glibc-2.33/sunrpc/netname.c 2021-05-11 21:36:17.125314747 +0200
@@ -49,7 +49,12 @@ user2netname (char netname[MAXNETNAMELEN
if ((strlen (dfltdom) + OPSYS_LEN + 3 + MAXIPRINT) > (size_t) MAXNETNAMELEN)
return 0;
+ /* The check above makes sure the line below is actually ok, but
+ * gcc 11.1 spews a warning... */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-overflow"
sprintf (netname, "%s.%d@%s", OPSYS, uid, dfltdom);
+#pragma GCC diagnostic pop
i = strlen (netname);
if (netname[i - 1] == '.')
netname[i - 1] = '\0';

View file

@ -1,24 +0,0 @@
diff -up glibc-2.35/sysdeps/x86/configure.48~ glibc-2.35/sysdeps/x86/configure
--- glibc-2.35/sysdeps/x86/configure.48~ 2022-02-03 11:26:20.165426217 +0100
+++ glibc-2.35/sysdeps/x86/configure 2022-02-03 11:27:41.422729679 +0100
@@ -134,7 +134,7 @@ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS
test $ac_status = 0; }; }; then
count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
if test "$count" = 1; then
- libc_cv_include_x86_isa_level=yes
+ libc_cv_include_x86_isa_level=no # workaround for vbox bug https://forums.gentoo.org/viewtopic-p-8568765.html?sid=563ab671df23b2a550273edc2dea30a2
fi
fi
rm -f conftest*
diff -up glibc-2.35/sysdeps/x86/configure.ac.48~ glibc-2.35/sysdeps/x86/configure.ac
--- glibc-2.35/sysdeps/x86/configure.ac.48~ 2022-02-03 11:26:20.165426217 +0100
+++ glibc-2.35/sysdeps/x86/configure.ac 2022-02-03 11:28:02.375807855 +0100
@@ -101,7 +101,7 @@ libc_cv_include_x86_isa_level=no
if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S); then
count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
if test "$count" = 1; then
- libc_cv_include_x86_isa_level=yes
+ libc_cv_include_x86_isa_level=no # workaround for vbox bug https://forums.gentoo.org/viewtopic-p-8568765.html?sid=563ab671df23b2a550273edc2dea30a2
fi
fi
rm -f conftest*])

View file

@ -1,40 +0,0 @@
diff -up glibc-2.34/include/sys/cdefs.h.omv~ glibc-2.34/include/sys/cdefs.h
diff -up glibc-2.34/misc/sys/cdefs.h.omv~ glibc-2.34/misc/sys/cdefs.h
--- glibc-2.34/misc/sys/cdefs.h.omv~ 2021-08-14 03:10:05.421588243 +0200
+++ glibc-2.34/misc/sys/cdefs.h 2021-08-14 03:13:30.178192179 +0200
@@ -465,7 +465,7 @@
# endif
#endif
-#if __GNUC_PREREQ (8, 0)
+#if __GNUC_PREREQ (8, 0) && !defined(__clang__)
/* Describes a char array whose address can safely be passed as the first
argument to strncpy and strncat, as the char array is not necessarily
a NUL-terminated string. */
@@ -476,7 +476,7 @@
/* Undefine (also defined in libc-symbols.h). */
#undef __attribute_copy__
-#if __GNUC_PREREQ (9, 0)
+#if __GNUC_PREREQ (9, 0) && !defined(__clang__)
/* Copies attributes from the declaration or type referenced by
the argument. */
# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
@@ -596,7 +596,7 @@ _Static_assert (0, "IEEE 128-bits long d
# define __HAVE_GENERIC_SELECTION 0
#endif
-#if __GNUC_PREREQ (10, 0)
+#if __GNUC_PREREQ (10, 0) && !defined(__clang__)
/* Designates a 1-based positional argument ref-index of pointer type
that can be used to access size-index elements of the pointed-to
array according to access mode, or at least one element when
@@ -613,7 +613,7 @@ _Static_assert (0, "IEEE 128-bits long d
# define __attr_access_none(argno)
#endif
-#if __GNUC_PREREQ (11, 0)
+#if __GNUC_PREREQ (11, 0) && !defined(__clang__)
/* Designates dealloc as a function to call to deallocate objects
allocated by the declared function. */
# define __attr_dealloc(dealloc, argno) \

View file

@ -1,13 +0,0 @@
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 997c860..50b37b0 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -295,7 +295,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
# ifndef SHARED
CHECK_STATIC_TLS (map, sym_map);
# else
- if (!TRY_STATIC_TLS (map, sym_map))
+ if (1)
{
td->arg = _dl_make_tlsdesc_dynamic
(sym_map, sym->st_value + reloc->r_addend);

View file

@ -1,20 +0,0 @@
diff -Nrup a/elf/dl-load.c b/elf/dl-load.c
--- a/elf/dl-load.c 2012-06-06 13:07:41.727524312 -0600
+++ b/elf/dl-load.c 2012-06-06 13:11:19.308681002 -0600
@@ -2093,10 +2093,14 @@ _dl_map_object (struct link_map *loader,
soname = ((const char *) D_PTR (l, l_info[DT_STRTAB])
+ l->l_info[DT_SONAME]->d_un.d_val);
if (strcmp (name, soname) != 0)
- continue;
+#ifdef __arm__
+ if (strcmp (name, "ld-linux.so.3")
+ || strcmp (soname, "ld-linux-armhf.so.3"))
+#endif
+ continue;
/* We have a match on a new name -- cache it. */
- add_name_to_object (l, soname);
+ add_name_to_object (l, name);
l->l_soname_added = 1;
}

View file

@ -1,56 +0,0 @@
diff -up glibc-2.33/elf/dl-init.c.12~ glibc-2.33/elf/dl-init.c
--- glibc-2.33/elf/dl-init.c.12~ 2021-02-01 18:15:33.000000000 +0100
+++ glibc-2.33/elf/dl-init.c 2021-02-02 00:10:07.506005790 +0100
@@ -120,8 +120,6 @@ _dl_init (struct link_map *main_map, int
while (i-- > 0)
call_init (main_map->l_initfini[i], argc, argv, env);
-#ifndef HAVE_INLINED_SYSCALLS
/* Finished starting up. */
_dl_starting_up = 0;
-#endif
}
diff -up glibc-2.33/elf/dl-support.c.12~ glibc-2.33/elf/dl-support.c
--- glibc-2.33/elf/dl-support.c.12~ 2021-02-01 18:15:33.000000000 +0100
+++ glibc-2.33/elf/dl-support.c 2021-02-02 00:10:07.506005790 +0100
@@ -126,10 +126,8 @@ struct r_scope_elem _dl_initial_searchli
.r_nlist = 1,
};
-#ifndef HAVE_INLINED_SYSCALLS
/* Nonzero during startup. */
int _dl_starting_up = 1;
-#endif
/* Random data provided by the kernel. */
void *_dl_random;
diff -up glibc-2.33/elf/rtld.c.12~ glibc-2.33/elf/rtld.c
--- glibc-2.33/elf/rtld.c.12~ 2021-02-01 18:15:33.000000000 +0100
+++ glibc-2.33/elf/rtld.c 2021-02-02 00:11:06.989150813 +0100
@@ -299,7 +299,6 @@ dl_main_state_init (struct dl_main_state
state->version_info = false;
}
-#ifndef HAVE_INLINED_SYSCALLS
/* Set nonzero during loading and initialization of executable and
libraries, cleared before the executable's entry point runs. This
must not be initialized to nonzero, because the unused dynamic
@@ -309,7 +308,6 @@ dl_main_state_init (struct dl_main_state
never be called. */
int _dl_starting_up = 0;
rtld_hidden_def (_dl_starting_up)
-#endif
/* This is the structure which defines all variables global to ld.so
(except those which cannot be added for some reason). */
@@ -1159,10 +1157,8 @@ dl_main (const ElfW(Phdr) *phdr,
/* Process the environment variable which control the behaviour. */
process_envvars (&state);
-#ifndef HAVE_INLINED_SYSCALLS
/* Set up a flag which tells we are just starting. */
_dl_starting_up = 1;
-#endif
const char *ld_so_name = _dl_argv[0];
if (*user_entry == (ElfW(Addr)) ENTRY_POINT)

View file

@ -1,48 +0,0 @@
--- glibc-2.25.51/sysdeps/unix/sysv/linux/tcsetattr.c.0025~ 2017-07-11 16:44:14.000000000 +0200
+++ glibc-2.25.51/sysdeps/unix/sysv/linux/tcsetattr.c 2017-07-11 18:32:38.167537430 +0200
@@ -45,6 +45,7 @@ __tcsetattr (int fd, int optional_action
{
struct __kernel_termios k_termios;
unsigned long int cmd;
+ int retval;
switch (optional_actions)
{
@@ -75,7 +76,36 @@ __tcsetattr (int fd, int optional_action
memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
__KERNEL_NCCS * sizeof (cc_t));
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
+ retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
+
+ if (retval == 0 && cmd == TCSETS)
+ {
+ /* The Linux kernel has a bug which silently ignore the invalid
+ c_cflag on pty. We have to check it here. */
+ int save = errno;
+ retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
+ if (retval)
+ {
+ /* We cannot verify if the setting is ok. We don't return
+ an error (?). */
+ __set_errno (save);
+ retval = 0;
+ }
+ else if ((termios_p->c_cflag & (PARENB | CREAD))
+ != (k_termios.c_cflag & (PARENB | CREAD))
+ || ((termios_p->c_cflag & CSIZE)
+ && ((termios_p->c_cflag & CSIZE)
+ != (k_termios.c_cflag & CSIZE))))
+ {
+ /* It looks like the Linux kernel silently changed the
+ PARENB/CREAD/CSIZE bits in c_cflag. Report it as an
+ error. */
+ __set_errno (EINVAL);
+ retval = -1;
+ }
+ }
+
+ return retval;
}
weak_alias (__tcsetattr, tcsetattr)
libc_hidden_def (tcsetattr)

View file

@ -1,20 +0,0 @@
glibc-2.3.3-1478-g37582bc
* Thu Nov 30 2006 Jakub Jelinek <jakub@redhat.com> 2.5.90-9
- on ppc64 build __libc_start_main without unwind info,
as it breaks MD_FROB_UPDATE_CONTEXT (#217729, #217775; in the
future that could be fixable just by providing .cfi_undefined r2
in __libc_start_main instead)
diff -Nrup a/sysdeps/powerpc/powerpc64/Makefile b/sysdeps/powerpc/powerpc64/Makefile
--- a/sysdeps/powerpc/powerpc64/Makefile 2012-06-05 07:42:49.000000000 -0600
+++ b/sysdeps/powerpc/powerpc64/Makefile 2012-06-07 12:15:21.828318633 -0600
@@ -35,6 +35,8 @@ CFLAGS-rtld-memmove.os = $(no-special-re
CFLAGS-rtld-memchr.os = $(no-special-regs)
CFLAGS-rtld-strnlen.os = $(no-special-regs)
+CFLAGS-libc-start.c += -fno-asynchronous-unwind-tables
+
ifeq ($(subdir),elf)
# help gcc inline asm code from dl-machine.h
+cflags += -finline-limit=2000

View file

@ -1,12 +0,0 @@
diff -up glibc-2.30/nis/ypclnt.c.17~ glibc-2.30/nis/ypclnt.c
--- glibc-2.30/nis/ypclnt.c.17~ 2019-08-02 13:54:49.077566424 +0200
+++ glibc-2.30/nis/ypclnt.c 2019-08-02 13:55:21.850394517 +0200
@@ -590,7 +590,7 @@ yp_master (const char *indomain, const c
{
ypreq_nokey req;
ypresp_master resp;
- enum clnt_stat result;
+ int result;
if (indomain == NULL || indomain[0] == '\0'
|| inmap == NULL || inmap[0] == '\0')

View file

@ -1,37 +0,0 @@
Short description: Fix newlocale error return.
Author(s): Fedora glibc team <glibc@lists.fedoraproject.org>
Origin: PATCH
Bug-RHEL: #832516
Bug-Fedora: #827510
Bug-Upstream: #14247
Upstream status: not-submitted
This needs to go upstream right away to fix the error case for
newlocale not correctly returning an error.
2012-06-14 Jeff Law <law@redhat.com>
* locale/loadlocale.c (_nl_load_locale): Delay setting
file->decided until we have successfully loaded the file's
data.
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index e3fa187..9fd9216 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -169,7 +169,6 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
int save_err;
int alloc = ld_mapped;
- file->decided = 1;
file->data = NULL;
fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
@@ -278,6 +277,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
newdata->alloc = alloc;
file->data = newdata;
+ file->decided = 1;
}
void

View file

@ -1,12 +0,0 @@
diff -up glibc-2.33/misc/Makefile.omv~ glibc-2.33/misc/Makefile
--- glibc-2.33/misc/Makefile.omv~ 2021-05-31 23:28:41.341567881 +0200
+++ glibc-2.33/misc/Makefile 2021-05-31 23:28:51.604675253 +0200
@@ -107,7 +107,7 @@ tests-special += $(objpfx)tst-error1-mem
$(objpfx)tst-allocate_once-mem.out
endif
-CFLAGS-select.c += -fexceptions -fasynchronous-unwind-tables
+CFLAGS-select.c += -fexceptions -fasynchronous-unwind-tables -mno-stackrealign
CFLAGS-tsearch.c += $(uses-callbacks)
CFLAGS-lsearch.c += $(uses-callbacks)
CFLAGS-pselect.c += -fexceptions

View file

@ -1,3 +1,10 @@
# Use snapshots of post-release branch
# https://sourceware.org/git/?p=glibc.git;a=log;h=refs/heads/release/2.36/master
# Package from the last commit from there
# Only important patches are ported into it
# (instead of applying many commits as patches)
%define commit 4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c
%define commit_short %(echo %{commit} | head -c6)
%bcond_with crosscompilers
# The test suite should be run after updates, but is very
@ -34,7 +41,7 @@
%define oname glibc
%define major 6
%define source_dir %{oname}-%{version}
%define source_dir %{oname}-%{commit}
%define checklist %{_builddir}/%{source_dir}/Check.list
%define libc %mklibname c %{major}
%define devname %mklibname -d c
@ -146,11 +153,10 @@ Summary: The GNU libc libraries
Name: %{cross_prefix}%{oname}
Epoch: 6
Version: 2.36
Source0: http://ftp.gnu.org/gnu/glibc/%{oname}-%{version}.tar.xz
#if %(test $(echo %{version}.0 |cut -d. -f3) -lt 90 && echo 1 || echo 0)
#Source1: http://ftp.gnu.org/gnu/glibc/%{oname}-%{version}.tar.xz.sig
#endif
Release: 3
#Source0: http://ftp.gnu.org/gnu/glibc/%{oname}-%{version}.tar.xz
# use ./upd.sh to make a tarball and automatically update Release
Source0: glibc-%{commit}.tar.xz
Release: 4.git%{commit_short}.1
License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Group: System/Libraries
Url: http://www.gnu.org/software/libc/
@ -168,108 +174,31 @@ Source1001: locale_install.sh
Source1002: locale_uninstall.sh
Source1003: locales.sysconfig
# Ugly, temporary arch specific (x86_32) hack
Source1010: glibc-x86_32-workaround-for-gcc-11-bug.patch
#-----------------------------------------------------------------------
# fedora patches
Patch25: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-linux-tcsetattr.patch
Patch26: eglibc-fedora-locale-euro.patch
Patch27: https://src.fedoraproject.org/rpms/glibc/raw/rawhide/f/glibc-fedora-localedata-rh61908.patch
# We disagree with
# http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-streams-rh436349.patch
# Therefore we don't package/apply it.
Patch30: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-localedef.patch
Patch31: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-locarchive.patch
Patch32: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-manual-dircategory.patch
Patch35: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-ppc-unwind.patch
Patch36: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-aarch64-tls-fixes.patch
Patch38: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-arm-hardfloat-3.patch
Patch41: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-cs-path.patch
# We disagree with http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-disable-rwlock-elision.patch
# Patch 131 is a much nicer solution that disables rwlock elision only on CPUs that can't handle it.
Patch44: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-__libc_multiple_libcs.patch
Patch46: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-fedora-nscd.patch
Patch47: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-gcc-PR69537.patch
Patch50: http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/plain/glibc-nscd-sysconfig.patch
Patch65: https://src.fedoraproject.org/rpms/glibc/raw/rawhide/f/glibc-rh827510.patch
#-----------------------------------------------------------------------
# Clear Linux patches
Patch83: https://github.com/clearlinux-pkgs/glibc/blob/master/alternate_trim.patch
Patch84: https://github.com/clearlinux-pkgs/glibc/blob/master/madvise-bss.patch
Patch86: https://raw.githubusercontent.com/clearlinux-pkgs/glibc/master/large-page-huge-page.patch
Patch87: https://raw.githubusercontent.com/clearlinux-pkgs/glibc/master/use_madv_free.patch
Patch88: https://raw.githubusercontent.com/clearlinux-pkgs/glibc/master/malloc_tune.patch
# (tpg) CLR disabled this patch
#Patch90: https://raw.githubusercontent.com/clearlinux-pkgs/glibc/master/ldconfig-Os.patch
Patch92: https://raw.githubusercontent.com/clearlinux-pkgs/glibc/master/pause.patch
Patch101: https://raw.githubusercontent.com/clearlinux-pkgs/glibc/master/nostackshrink.patch
#
# Patches from upstream
#
# Taken from git://sourceware.org/git/glibc.git
# release branch
# git format-patch glibc-2.36
# (PN=200; for i in *patch; do echo -e "Patch$((PN)):\t$i"; PN=$((PN+1)); done)
Patch200: 0001-stdlib-Suppress-gcc-diagnostic-that-char8_t-is-a-key.patch
Patch201: 0002-wcsmbs-Add-missing-test-c8rtomb-test-mbrtoc8-depende.patch
Patch202: 0003-dlfcn-Pass-caller-pointer-to-static-dlopen-implement.patch
Patch203: 0004-Update-syscall-lists-for-Linux-5.19.patch
Patch204: 0005-elf-Replace-strcpy-call-with-memcpy-BZ-29454.patch
Patch205: 0006-Linux-Terminate-subprocess-on-late-failure-in-tst-pi.patch
Patch206: 0007-alpha-Fix-generic-brk-system-call-emulation-in-__brk.patch
Patch207: 0008-socket-Check-lengths-before-advancing-pointer-in-CMS.patch
Patch208: 0009-NEWS-Add-entry-for-bug-28846.patch
Patch209: 0010-glibcextract.py-Add-compile_c_snippet.patch
Patch210: 0011-linux-Use-compile_c_snippet-to-check-linux-pidfd.h-a.patch
Patch211: 0012-linux-Mimic-kernel-defition-for-BLOCK_SIZE.patch
Patch212: 0013-linux-Use-compile_c_snippet-to-check-linux-mount.h-a.patch
Patch213: 0014-linux-Fix-sys-mount.h-usage-with-kernel-headers.patch
Patch214: 0015-Linux-Fix-enum-fsconfig_command-detection-in-sys-mou.patch
Patch215: 0016-syslog-Fix-large-messages-BZ-29536.patch
Patch216: 0017-elf-Call-__libc_early_init-for-reused-namespaces-bug.patch
Patch217: 0018-Apply-asm-redirections-in-wchar.h-before-first-use.patch
Patch218: 0019-elf-Restore-how-vDSO-dependency-is-printed-with-LD_T.patch
Patch219: 0020-syslog-Remove-extra-whitespace-between-timestamp-and.patch
Patch220: 0021-Add-NEWS-entry-for-CVE-2022-39046.patch
Patch221: 0022-nscd-Fix-netlink-cache-invalidation-if-epoll-is-used.patch
# from IBM release branch (ibm/%{version}/master branch in git)
# [currently none]
# Clear Linux patches may be found here: https://github.com/clearlinux-pkgs/glibc/tree/main
# Keeping careful with using not widely tested and audited code in libc
#-----------------------------------------------------------------------
# OpenMandriva patches
Patch1002: glibc-2.34-headers-clang.patch
Patch1003: eglibc-mandriva-share-locale.patch
Patch1004: eglibc-mandriva-nsswitch.conf.patch
Patch1005: eglibc-mandriva-xterm-xvt.patch
Patch1007: eglibc-mandriva-nscd-no-host-cache.patch
Patch1010: eglibc-mandriva-timezone.patch
Patch1018: eglibc-mandriva-testsuite-ldbl-bits.patch
Patch1019: eglibc-mandriva-testsuite-rt-notparallel.patch
Patch1020: glibc-2.19-no-__builtin_va_arg_pack-with-clang.patch
# http://sourceware.org/bugzilla/show_bug.cgi?id=14995
# http://sourceware.org/bugzilla/attachment.cgi?id=6795
Patch1029: glibc-2.19-nscd-socket-and-pid-moved-from-varrun-to-run.patch
Patch1033: glibc-2.25-force-use-ld-bfd.patch
Patch1035: glibc-2.29-aarch64-buildfix.patch
Patch1036: glibc-2.29-strict-aliasing.patch
Patch1037: glibc-2.29-SIG_BLOCK.patch
Patch1038: glibc-2.31.9000-aarch64-compile.patch
Patch1039: https://github.com/FireBurn/glibc/commit/4483f2500825a84382c2a6a9ac60fc77954533d7.patch
Patch1040: https://github.com/FireBurn/glibc/commit/2efa9591e5e8a129e7b73ad0dad3eecbd69482ff.patch
# Workaround for ISA levels going wrong -- causes glibc to abort on
# znver1 inside VirtualBox even if the right CPU instructions are
# supported
# https://forums.gentoo.org/viewtopic-p-8568765.html?sid=563ab671df23b2a550273edc2dea30a2
# https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5dbd6a821ff753e3b41324c4fb7c58cf65eeea33
Patch1041: glibc-2.33-no-x86-isa-level.patch
Patch1042: glibc-2.33-gcc-11.1.patch
# Fix _Float32/_Float64 assumptions to make it work with
# clang setting __GNUC__ to something > 6
Patch1043: glibc-2.33-clang-_Float32-_Float64.patch
Patch1044: glibc-2.34-allow-zstd-compressed-locales.patch
Patch1050: https://803950.bugs.gentoo.org/attachment.cgi?id=757176#/nss-dont-crash-on-NULL.patch
# https://www.phoronix.com/news/Glibc-2.36-EAC-Problems
@ -1487,10 +1416,6 @@ function BuildGlibc() {
fi
rm -f test.o
if echo $arch |grep -q i.86; then
patch -p1 -b -z .1010~ <%{S:1010}
fi
# Force a separate object dir
mkdir -p build-$arch-linux
cd build-$arch-linux
@ -1545,10 +1470,6 @@ echo CC="$BuildCC" CXX="$BuildCXX" CFLAGS="$BuildFlags -Wno-error" ARFLAGS="$ARF
fi
cd -
if echo $arch |grep -q i.86; then
patch -p1 -R <%{S:1010}
fi
check_flags="-k"
# Generate test matrix

View file

@ -1,13 +0,0 @@
diff -up glibc-2.35/malloc/malloc.c.23~ glibc-2.35/malloc/malloc.c
--- glibc-2.35/malloc/malloc.c.23~ 2022-02-03 11:12:21.887241710 +0100
+++ glibc-2.35/malloc/malloc.c 2022-02-03 11:13:26.221492043 +0100
@@ -2449,6 +2449,9 @@ sysmalloc_mmap (INTERNAL_SIZE_T nb, size
madvise_thp (mm, size);
#endif
+ if (size > 8 * 1024 * 1024)
+ __madvise (mm, size , MADV_HUGEPAGE);
+
/*
The offset to the start of the mmapped region is stored in the prev_size
field of the chunk. This allows us to adjust returned start address to

View file

@ -1,10 +0,0 @@
--- glibc-2.22/elf/dl-map-segments.h.org 2015-11-23 17:13:52.948724559 -0500
+++ glibc-2.22/elf/dl-map-segments.h 2015-11-23 17:14:42.434105906 -0500
@@ -139,6 +139,7 @@
-1, 0);
if (__glibc_unlikely (mapat == MAP_FAILED))
return DL_MAP_SEGMENTS_ERROR_MAP_ZERO_FILL;
+ __madvise((caddr_t) zeropage, zeroend - zeropage, MADV_MERGEABLE);
}
}

View file

@ -1,20 +0,0 @@
--- glibc-2.24/malloc/malloc.c~ 2016-11-13 22:53:14.000000000 +0000
+++ glibc-2.24/malloc/malloc.c 2016-11-13 23:01:29.750884186 +0000
@@ -858,7 +858,7 @@
#define M_TRIM_THRESHOLD -1
#ifndef DEFAULT_TRIM_THRESHOLD
-#define DEFAULT_TRIM_THRESHOLD (128 * 1024)
+#define DEFAULT_TRIM_THRESHOLD (512 * 1024)
#endif
/*
@@ -891,7 +891,7 @@
#define M_TOP_PAD -2
#ifndef DEFAULT_TOP_PAD
-#define DEFAULT_TOP_PAD (0)
+#define DEFAULT_TOP_PAD (64 * 1024)
#endif
/*

View file

@ -1,14 +0,0 @@
when this gets called the stack is likely not there; avoid the tlb flushes
--- glibc-2.28/nptl/allocatestack.c~ 2018-08-01 05:10:47.000000000 +0000
+++ glibc-2.28/nptl/allocatestack.c 2018-09-27 16:18:09.043648892 +0000
@@ -385,6 +385,8 @@
{
uintptr_t sp = (uintptr_t) CURRENT_STACK_FRAME;
size_t pagesize_m1 = __getpagesize () - 1;
+
+ return;
#if _STACK_GROWS_DOWN && !defined(NEED_SEPARATE_REGISTER_STACK)
size_t freesize = (sp - (uintptr_t) mem) & ~pagesize_m1;
assert (freesize < size);

View file

@ -1,10 +0,0 @@
--- glibc-2.29/sysdeps/x86/atomic-machine.h~ 2019-01-31 16:45:36.000000000 +0000
+++ glibc-2.29/sysdeps/x86/atomic-machine.h 2019-01-31 22:21:32.316611237 +0000
@@ -566,6 +566,6 @@
#define atomic_read_barrier() __asm ("" ::: "memory")
#define atomic_write_barrier() __asm ("" ::: "memory")
-#define atomic_spin_nop() __asm ("pause")
+#define atomic_spin_nop() __asm ("lfence")
#endif /* atomic-machine.h */

52
upd.sh Executable file
View file

@ -0,0 +1,52 @@
#!/bin/bash
set -efu
set -o pipefail
# get current commit (version)
old_commit="$(grep '^%define commit ' glibc.spec | awk '{print $NF}')"
[ -n "$old_commit" ]
# or: rpmspec --define "_sourcedir $PWD" -q --srpm --qf '%{version}' glibc.spec
version="$(grep '^Version:' glibc.spec | awk '{print $NF}')"
[ -n "$version" ]
# get latest available commit (version)
new_commit="$(git ls-remote git://sourceware.org/git/glibc.git release/2.36/master | awk '{print $1}')"
[ -n "$new_commit" ]
if [ "$old_commit" = "$new_commit" ]; then
echo "There are no updates"
fi
tmp="$(mktemp -d)"
trap 'rm -fr "$tmp"' EXIT
# download the latest version
git clone --depth=1 https://sourceware.org/git/glibc.git -b release/"$version"/master "$tmp"/glibc-"$new_commit"
if [ "$(cd "$tmp"/glibc-"$new_commit" && git rev-parse HEAD)" != "$new_commit" ]; then
echo "Repository has probably changed in the middle, rerun this script"
exit 1
fi
# pack it
XZ_OPT="-6 --threads=0 -v" tar cJf glibc-"$new_commit".tar.xz -C "$tmp" glibc-"$new_commit"
# Bump RPM release
# 3.git%{commit_short}.1 -> 4.git%{commit_short}.1
# 3.git%{commit_short}.2 -> 4.git%{commit_short}.1
old_release="$(grep '^Release:' glibc.spec | awk '{print $NF}')"
[ -n "$old_release" ]
IFS=. read -r -a release <<< "$old_release"
# increase first number
num1=$((${release[0]}+1))
# decrease last number to 1
num2=1
new_release="${num1}.${release[1]}.${num2}"
sed -i'' -E glibc.spec \
-e "s,^%define commit .+,%define commit ${new_commit}," \
-e "s,^Release:.+,Release:\t${new_release},"
sed -i'' .abf.yml -e "/glibc-${old_release}.tar.xz/d"
# upload glibc-$new_commit.tar.xz to file-store.rosalinux.ru
abf put -n
PAGER= GIT_PAGER= git diff
# copypastable commit message
echo "upd to snapshot $(echo "$new_commit" | head -c5) of v$version"

View file

@ -1,22 +0,0 @@
--- glibc-2.24/malloc/malloc.c~ 2016-08-27 04:16:33.000000000 +0000
+++ glibc-2.24/malloc/malloc.c 2016-11-13 22:53:14.772986778 +0000
@@ -4568,7 +4568,7 @@
content. */
memset (paligned_mem, 0x89, size & ~psm1);
#endif
- __madvise (paligned_mem, size & ~psm1, MADV_DONTNEED);
+ __madvise (paligned_mem, size & ~psm1, MADV_FREE);
result = 1;
}
--- glibc-2.24/malloc/arena.c~ 2016-08-02 02:01:36.000000000 +0000
+++ glibc-2.24/malloc/arena.c 2016-11-13 22:52:52.889299846 +0000
@@ -524,7 +524,7 @@
h->mprotect_size = new_size;
}
else
- __madvise ((char *) h + new_size, diff, MADV_DONTNEED);
+ __madvise ((char *) h + new_size, diff, MADV_FREE);
/*fprintf(stderr, "shrink %p %08lx\n", h, new_size);*/
h->size = new_size;