commit 0c800492e99286c0f8ddd0ea6e8461f202588723 Author: Juergen Daubert <jue@jue.li> Date: Sun Aug 28 10:53:30 2022 +0200 glibc: update to 2.36 diff --git a/glibc/.footprint b/glibc/.footprint index 90b6f0ea..5e2b8500 100644 --- a/glibc/.footprint +++ b/glibc/.footprint @@ -231,6 +231,7 @@ drwxr-xr-x root/root usr/include/bits/ -rw-r--r-- root/root usr/include/bits/mman-map-flags-generic.h -rw-r--r-- root/root usr/include/bits/mman-shared.h -rw-r--r-- root/root usr/include/bits/mman.h +-rw-r--r-- root/root usr/include/bits/mman_ext.h -rw-r--r-- root/root usr/include/bits/monetary-ldbl.h -rw-r--r-- root/root usr/include/bits/mqueue.h -rw-r--r-- root/root usr/include/bits/mqueue2.h @@ -294,6 +295,7 @@ drwxr-xr-x root/root usr/include/bits/platform/ -rw-r--r-- root/root usr/include/bits/stdint-uintn.h -rw-r--r-- root/root usr/include/bits/stdio-ldbl.h -rw-r--r-- root/root usr/include/bits/stdio.h +-rw-r--r-- root/root usr/include/bits/stdio2-decl.h -rw-r--r-- root/root usr/include/bits/stdio2.h -rw-r--r-- root/root usr/include/bits/stdio_lim.h -rw-r--r-- root/root usr/include/bits/stdlib-bsearch.h @@ -341,6 +343,7 @@ drwxr-xr-x root/root usr/include/bits/types/ -rw-r--r-- root/root usr/include/bits/types/clockid_t.h -rw-r--r-- root/root usr/include/bits/types/cookie_io_functions_t.h -rw-r--r-- root/root usr/include/bits/types/error_t.h +-rw-r--r-- root/root usr/include/bits/types/idtype_t.h -rw-r--r-- root/root usr/include/bits/types/locale_t.h -rw-r--r-- root/root usr/include/bits/types/mbstate_t.h -rw-r--r-- root/root usr/include/bits/types/res_state.h @@ -1458,6 +1461,7 @@ drwxr-xr-x root/root usr/include/sys/ -rw-r--r-- root/root usr/include/sys/pci.h -rw-r--r-- root/root usr/include/sys/perm.h -rw-r--r-- root/root usr/include/sys/personality.h +-rw-r--r-- root/root usr/include/sys/pidfd.h drwxr-xr-x root/root usr/include/sys/platform/ -rw-r--r-- root/root usr/include/sys/platform/x86.h -rw-r--r-- root/root usr/include/sys/poll.h @@ -1827,7 +1831,7 @@ lrwxrwxrwx root/root usr/lib/libc_malloc_debug.so -> ../../lib/libc_malloc_debug lrwxrwxrwx root/root usr/lib/libcrypt.so -> ../../lib/libcrypt.so.1 -rw-r--r-- root/root usr/lib/libdl.a -rw-r--r-- root/root usr/lib/libg.a --rw-r--r-- root/root usr/lib/libm-2.35.a +-rw-r--r-- root/root usr/lib/libm-2.36.a -rw-r--r-- root/root usr/lib/libm.a -rw-r--r-- root/root usr/lib/libm.so -rw-r--r-- root/root usr/lib/libmcheck.a @@ -2364,6 +2368,7 @@ drwxr-xr-x root/root usr/share/i18n/locales/ -rw-r--r-- root/root usr/share/i18n/locales/pt_PT@euro -rw-r--r-- root/root usr/share/i18n/locales/quz_PE -rw-r--r-- root/root usr/share/i18n/locales/raj_IN +-rw-r--r-- root/root usr/share/i18n/locales/rif_MA -rw-r--r-- root/root usr/share/i18n/locales/ro_RO -rw-r--r-- root/root usr/share/i18n/locales/ru_RU -rw-r--r-- root/root usr/share/i18n/locales/ru_UA @@ -2399,6 +2404,7 @@ drwxr-xr-x root/root usr/share/i18n/locales/ -rw-r--r-- root/root usr/share/i18n/locales/sv_SE -rw-r--r-- root/root usr/share/i18n/locales/sw_KE -rw-r--r-- root/root usr/share/i18n/locales/sw_TZ +-rw-r--r-- root/root usr/share/i18n/locales/syr -rw-r--r-- root/root usr/share/i18n/locales/szl_PL -rw-r--r-- root/root usr/share/i18n/locales/ta_IN -rw-r--r-- root/root usr/share/i18n/locales/ta_LK diff --git a/glibc/.signature b/glibc/.signature index 66354522..7ffbe06e 100644 --- a/glibc/.signature +++ b/glibc/.signature @@ -1,10 +1,10 @@ untrusted comment: verify with /etc/ports/core.pub -RWRJc1FUaeVeqjYRriUla91KhlDq9gPFCu5L0MnCcjEoJZ+xVqsbB8PQbgiidYaruz05fx7exAjsC/id8PcPgtESarBOlRQfTQ4= -SHA256 (Pkgfile) = ae7490c52d39fdcb8c04f44abf21f9d9996d2bbe3bba833a3b5c67803866e632 -SHA256 (.footprint) = 45fa1520934f3952bbdffbe7303ec2f3cf97c17e98c7dd23a14e076e95edf466 -SHA256 (glibc-2.35.tar.xz) = 5123732f6b67ccd319305efd399971d58592122bcc2a6518a1bd2510dd0cf52e -SHA256 (linux-5.15.21.tar.xz) = 294eeb6cd7dc9b144c3c3c8b8c7b3fca9c6b072b6ed9bf9d6c922f9deb70fbd1 -SHA256 (glibc-2.35-1.patch) = f9041b36bd2194753d43da1053320d58d75acc76cfdcc2bd13e502b247d90b4e +RWRJc1FUaeVeqkxOnwc5iLM9nx9NtANOUXrU0QXTmG0NVy87nmVgZTkXM6+Dje7epyFVHtzkAcADD84bKf8MEfJh2M/5L8xC5AE= +SHA256 (Pkgfile) = 79237a932d21c7b4ef43e8a56d9cd489939c3216b4ec0d32448acdc3443ab11d +SHA256 (.footprint) = d6c55451befafd731c0b3de1b5eff63c4dcafae7ad4ae9ac0baaeb5a055ab80b +SHA256 (glibc-2.36.tar.xz) = 1c959fea240906226062cb4b1e7ebce71a9f0e3c0836c09e7e3423d434fcfe75 +SHA256 (linux-5.15.55.tar.xz) = 1ef6bd508b6c3af3bef2d5b337e4477254dba284c79e329aa38f9763ae3bfdcc +SHA256 (glibc-2.36-1.patch) = 6245087ab20402836cbd32b52ba944d31aeafc961ba597bcec0fa3727db79eee SHA256 (hosts) = 5c02b256c105f1d4a12fb738d71c1bab9eb126533074d7a0c8a14b92670c9431 SHA256 (resolv.conf) = 72ccb58768a72a771ec37142bc361a18478a07ec9de6e925a20760794389bf51 SHA256 (nsswitch.conf) = 859b8984e5e90aff3cce8f9779996ae4033b280d2122840e9411e2f44a1c2e61 diff --git a/glibc/Pkgfile b/glibc/Pkgfile index 23fb8966..4101e393 100644 --- a/glibc/Pkgfile +++ b/glibc/Pkgfile @@ -3,9 +3,9 @@ # Maintainer: CRUX System Team, core-ports at crux dot nu name=glibc -version=2.35 -release=2 -_kernel_version=5.15.21 +version=2.36 +release=1 +_kernel_version=5.15.55 source=(https://ftp.gnu.org/gnu/glibc/glibc-$version.tar.xz https://www.kernel.org/pub/linux/kernel/v5.x/linux-$_kernel_version.tar.xz diff --git a/glibc/glibc-2.35-1.patch b/glibc/glibc-2.35-1.patch deleted file mode 100644 index ce52a6e0..00000000 --- a/glibc/glibc-2.35-1.patch +++ /dev/null @@ -1,230 +0,0 @@ -diff --git a/NEWS b/NEWS -index faa7ec1871..6b8db4e947 100644 ---- a/NEWS -+++ b/NEWS -@@ -4,6 +4,17 @@ 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.35.1 -+ -+The following bugs are resolved with this release: -+ -+ [28850] linux: __get_nprocs_sched reads uninitialized memory from the stack -+ [28853] libc: tst-spawn6 changes current foreground process group -+ (breaks test isolation) -+ [28860] build: --enable-kernel=5.1.0 build fails because of missing -+ __convert_scm_timestamps -+ - - Version 2.35 - -diff --git a/configure b/configure -index 00dc638388..8e5bee775a 100755 ---- a/configure -+++ b/configure -@@ -730,7 +730,6 @@ infodir - docdir - oldincludedir - includedir --runstatedir - localstatedir - sharedstatedir - sysconfdir -@@ -845,7 +844,6 @@ datadir='${datarootdir}' - sysconfdir='${prefix}/etc' - sharedstatedir='${prefix}/com' - localstatedir='${prefix}/var' --runstatedir='${localstatedir}/run' - includedir='${prefix}/include' - oldincludedir='/usr/include' - docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -@@ -1098,15 +1096,6 @@ do - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - -- -runstatedir | --runstatedir | --runstatedi | --runstated \ -- | --runstate | --runstat | --runsta | --runst | --runs \ -- | --run | --ru | --r) -- ac_prev=runstatedir ;; -- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ -- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ -- | --run=* | --ru=* | --r=*) -- runstatedir=$ac_optarg ;; -- - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -@@ -1244,7 +1233,7 @@ fi - for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ -- libdir localedir mandir runstatedir -+ libdir localedir mandir - do - eval ac_val=\$$ac_var - # Remove trailing slashes. -@@ -1397,7 +1386,6 @@ Fine tuning of the installation directories: - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] -- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] -diff --git a/posix/tst-spawn6.c b/posix/tst-spawn6.c -index 911e90a461..044abd8535 100644 ---- a/posix/tst-spawn6.c -+++ b/posix/tst-spawn6.c -@@ -29,7 +29,14 @@ - #include <support/check.h> - #include <support/xunistd.h> - #include <sys/wait.h> -+#include <sys/ioctl.h> - #include <stdlib.h> -+#include <termios.h> -+ -+#ifndef PATH_MAX -+# define PATH_MAX 1024 -+#endif -+static char ptmxpath[PATH_MAX]; - - static int - handle_restart (const char *argv1, const char *argv2) -@@ -115,7 +122,7 @@ run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr, - } - - static int --do_test (int argc, char *argv[]) -+run_test (int argc, char *argv[]) - { - /* We must have either: - - four parameters left if called initially: -@@ -127,16 +134,7 @@ do_test (int argc, char *argv[]) - + --setgrpr optional - */ - -- if (restart) -- return handle_restart (argv[1], argv[2]); -- -- int tcfd = open64 (_PATH_TTY, O_RDONLY, 0600); -- if (tcfd == -1) -- { -- if (errno == ENXIO) -- FAIL_UNSUPPORTED ("terminal not available, skipping test"); -- FAIL_EXIT1 ("open64 (\"%s\", 0x%x, 0600): %m", _PATH_TTY, O_RDONLY); -- } -+ int tcfd = xopen (ptmxpath, O_RDONLY, 0600); - - /* Check setting the controlling terminal without changing the group. */ - { -@@ -198,5 +196,47 @@ do_test (int argc, char *argv[]) - return 0; - } - -+static int -+do_test (int argc, char *argv[]) -+{ -+ if (restart) -+ return handle_restart (argv[1], argv[2]); -+ -+ pid_t pid = xfork (); -+ if (pid == 0) -+ { -+ /* Create a pseudo-terminal to avoid interfering with the one using by -+ test itself, creates a new session (so there is no controlling -+ terminal), and set the pseudo-terminal as the controlling one. */ -+ int ptmx = posix_openpt (0); -+ if (ptmx == -1) -+ { -+ if (errno == ENXIO) -+ FAIL_UNSUPPORTED ("terminal not available, skipping test"); -+ FAIL_EXIT1 ("posix_openpt (0): %m"); -+ } -+ TEST_VERIFY_EXIT (grantpt (ptmx) == 0); -+ TEST_VERIFY_EXIT (unlockpt (ptmx) == 0); -+ -+ TEST_VERIFY_EXIT (setsid () != -1); -+ TEST_VERIFY_EXIT (ioctl (ptmx, TIOCSCTTY, NULL) == 0); -+ while (dup2 (ptmx, STDIN_FILENO) == -1 && errno == EBUSY) -+ ; -+ while (dup2 (ptmx, STDOUT_FILENO) == -1 && errno == EBUSY) -+ ; -+ while (dup2 (ptmx, STDERR_FILENO) == -1 && errno == EBUSY) -+ ; -+ TEST_VERIFY_EXIT (ptsname_r (ptmx, ptmxpath, sizeof ptmxpath) == 0); -+ xclose (ptmx); -+ -+ run_test (argc, argv); -+ _exit (0); -+ } -+ int status; -+ xwaitpid (pid, &status, 0); -+ TEST_VERIFY (WIFEXITED (status)); -+ exit (0); -+} -+ - #define TEST_FUNCTION_ARGV do_test - #include <support/test-driver.c> -diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c -index 82171bf325..dfc8c2beff 100644 ---- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c -+++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c -@@ -16,9 +16,9 @@ - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - --#include <kernel-features.h> -+#include <bits/timesize.h> - --#ifndef __ASSUME_TIME64_SYSCALLS -+#if __TIMESIZE != 64 - # include <stdint.h> - # include <string.h> - # include <sys/socket.h> -diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c -index 4798cc337e..c98c8ce3d4 100644 ---- a/sysdeps/unix/sysv/linux/getsysstats.c -+++ b/sysdeps/unix/sysv/linux/getsysstats.c -@@ -44,7 +44,7 @@ __get_nprocs_sched (void) - int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size, - cpu_bits); - if (r > 0) -- return CPU_COUNT_S (cpu_bits_size, (cpu_set_t*) cpu_bits); -+ return CPU_COUNT_S (r, (cpu_set_t*) cpu_bits); - else if (r == -EINVAL) - /* The input buffer is still not enough to store the number of cpus. This - is an arbitrary values assuming such systems should be rare and there -diff -pruN glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/64/configure glibc-2.32/sysdeps/unix/sysv/linux/x86_64/64/configure ---- glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/64/configure 2021-09-18 21:02:32.741186019 +1000 -+++ glibc-2.32/sysdeps/unix/sysv/linux/x86_64/64/configure 2021-09-18 21:03:05.314302356 +1000 -@@ -4,10 +4,10 @@ - test -n "$libc_cv_slibdir" || - case "$prefix" in - /usr | /usr/) -- libc_cv_slibdir='/lib64' -- libc_cv_rtlddir='/lib64' -+ libc_cv_slibdir='/lib' -+ libc_cv_rtlddir='/lib' - if test "$libdir" = '${exec_prefix}/lib'; then -- libdir='${exec_prefix}/lib64'; -+ libdir='${exec_prefix}/lib'; - # Locale data can be shared between 32-bit and 64-bit libraries. - libc_cv_complocaledir='${exec_prefix}/lib/locale' - fi -diff -pruN glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/ldconfig.h glibc-2.32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h ---- glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2021-09-18 21:02:32.742186053 +1000 -+++ glibc-2.32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2021-09-18 21:03:05.314302356 +1000 -@@ -18,9 +18,9 @@ - #include <sysdeps/generic/ldconfig.h> - - #define SYSDEP_KNOWN_INTERPRETER_NAMES \ -- { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \ -+ { "/lib32/ld-linux.so.2", FLAG_ELF_LIBC6 }, \ - { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \ -- { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 }, -+ { "/lib/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 }, - #define SYSDEP_KNOWN_LIBRARY_NAMES \ - { "libc.so.6", FLAG_ELF_LIBC6 }, \ - { "libm.so.6", FLAG_ELF_LIBC6 }, diff --git a/glibc/glibc-2.36-1.patch b/glibc/glibc-2.36-1.patch new file mode 100644 index 00000000..36bf0075 --- /dev/null +++ b/glibc/glibc-2.36-1.patch @@ -0,0 +1,985 @@ +diff --git a/NEWS b/NEWS +index f61e521fc8..ae30900bbc 100644 +--- a/NEWS ++++ b/NEWS +@@ -4,6 +4,16 @@ 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: ++ ++ [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 ++ + + Version 2.36 + +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/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 * +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); + } + +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) +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/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/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; + } +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) +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/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h +index f965986ba8..19841d0738 100644 +--- a/sysdeps/unix/sysv/linux/sys/mount.h ++++ b/sysdeps/unix/sysv/linux/sys/mount.h +@@ -27,77 +27,113 @@ + #include <stddef.h> + #include <sys/ioctl.h> + +-#define BLOCK_SIZE 1024 ++#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) + + + /* These are the fs-independent mount-flags: up to 16 flags are + 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. */ + + +@@ -137,9 +188,6 @@ enum + }; + + +-/* fsopen flags. */ +-#define FSOPEN_CLOEXEC 0x00000001 +- + /* fsmount flags. */ + #define FSMOUNT_CLOEXEC 0x00000001 + +@@ -157,6 +205,7 @@ enum + #define MOUNT_ATTR_NOSYMFOLLOW 0x00200000 /* Do not follow symlinks. */ + + ++#ifndef MOUNT_ATTR_SIZE_VER0 + /* For mount_setattr. */ + struct mount_attr + { +@@ -165,6 +214,7 @@ struct mount_attr + uint64_t propagation; + uint64_t userns_fd; + }; ++#endif + + #define MOUNT_ATTR_SIZE_VER0 32 /* sizeof first published struct */ + +@@ -185,26 +235,31 @@ 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 ++ ++/* fsopen flags. */ ++#define FSOPEN_CLOEXEC 0x00000001 + + /* open_tree flags. */ + #define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */ +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 +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() +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 +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' +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); +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) +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 +diff -pruN glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/64/configure glibc-2.32/sysdeps/unix/sysv/linux/x86_64/64/configure +--- glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/64/configure 2021-09-18 21:02:32.741186019 +1000 ++++ glibc-2.32/sysdeps/unix/sysv/linux/x86_64/64/configure 2021-09-18 21:03:05.314302356 +1000 +@@ -4,10 +4,10 @@ + test -n "$libc_cv_slibdir" || + case "$prefix" in + /usr | /usr/) +- libc_cv_slibdir='/lib64' +- libc_cv_rtlddir='/lib64' ++ libc_cv_slibdir='/lib' ++ libc_cv_rtlddir='/lib' + if test "$libdir" = '${exec_prefix}/lib'; then +- libdir='${exec_prefix}/lib64'; ++ libdir='${exec_prefix}/lib'; + # Locale data can be shared between 32-bit and 64-bit libraries. + libc_cv_complocaledir='${exec_prefix}/lib/locale' + fi +diff -pruN glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/ldconfig.h glibc-2.32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h +--- glibc-2.32.orig/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2021-09-18 21:02:32.742186053 +1000 ++++ glibc-2.32/sysdeps/unix/sysv/linux/x86_64/ldconfig.h 2021-09-18 21:03:05.314302356 +1000 +@@ -18,9 +18,9 @@ + #include <sysdeps/generic/ldconfig.h> + + #define SYSDEP_KNOWN_INTERPRETER_NAMES \ +- { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \ ++ { "/lib32/ld-linux.so.2", FLAG_ELF_LIBC6 }, \ + { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \ +- { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 }, ++ { "/lib/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 }, + #define SYSDEP_KNOWN_LIBRARY_NAMES \ + { "libc.so.6", FLAG_ELF_LIBC6 }, \ + { "libm.so.6", FLAG_ELF_LIBC6 },