1 diff --git a/NEWS b/NEWS
2 index 485b8ddffa..2afe250ccf 100644
5 @@ -5,6 +5,25 @@ See the end for copying conditions.
6 Please send GNU C library bug reports via <https://sourceware.org/bugzilla/>
7 using `glibc' in the "product" field.
9 +The following bugs are resolved with this release:
11 + [20019] NULL pointer dereference in libc.so.6 IFUNC due to uninitialized GOT
12 + [26224] iconv hangs when converting some invalid inputs from several IBM
13 + character sets (CVE-2020-27618)
14 + [26534] libm.so 2.32 SIGILL in pow() due to FMA4 instruction on non-FMA4
16 + [26555] string: strerrorname_np does not return the documented value
17 + [26600] Transaction ID collisions cause slow DNS lookups in getaddrinfo
18 + [26636] libc: 32-bit shmctl(IPC_INFO) crashes when shminfo struct is
19 + at the end of a memory mapping
20 + [26637] libc: semctl SEM_STAT_ANY fails to pass the buffer specified
21 + by the caller to the kernel
22 + [26639] libc: msgctl IPC_INFO and MSG_INFO return garbage
23 + [26853] aarch64: Missing unwind information in statically linked startup code
24 + [26932] libc: sh: Multiple floating point functions defined as stubs only
25 + [27130] "rep movsb" performance issue
26 + [27177] GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on doesn't work
31 @@ -185,6 +204,14 @@ Security related changes:
32 Dytrych of the Cisco Security Assessment and Penetration Team (See
35 + CVE-2020-27618: An infinite loop has been fixed in the iconv program when
36 + invoked with input containing redundant shift sequences in the IBM1364,
37 + IBM1371, IBM1388, IBM1390, or IBM1399 character sets.
39 + CVE-2021-33574: The mq_notify function has a potential use-after-free
40 + issue when using a notification type of SIGEV_THREAD and a thread
41 + attribute with a non-default affinity mask.
43 The following bugs are resolved with this release:
45 [9809] localedata: ckb_IQ: new Kurdish Sorani locale
46 diff --git a/Rules b/Rules
47 index 8b771f6095..beab969fde 100644
50 @@ -155,6 +155,7 @@ xtests: tests $(xtests-special)
52 tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
53 $(tests-container:%=$(objpfx)%.out) \
54 + $(tests-mcheck:%=$(objpfx)%-mcheck.out) \
55 $(tests-special) $(tests-printers-out)
56 xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-special)
58 @@ -165,7 +166,7 @@ ifeq ($(run-built-tests),no)
61 tests-expected = $(tests) $(tests-internal) $(tests-printers) \
63 + $(tests-container) $(tests-mcheck:%=%-mcheck)
66 $(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \
67 @@ -191,6 +192,7 @@ else
69 binaries-pie-notests =
71 +binaries-mcheck-tests = $(tests-mcheck:%=%-mcheck)
73 binaries-all-notests =
74 binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs)
75 @@ -200,6 +202,7 @@ binaries-static-tests =
78 binaries-pie-notests =
79 +binaries-mcheck-tests =
82 binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests)
83 @@ -223,6 +226,14 @@ $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
87 +ifneq "$(strip $(binaries-mcheck-tests))" ""
88 +$(addprefix $(objpfx),$(binaries-mcheck-tests)): %-mcheck: %.o \
89 + $(link-extra-libs-tests) \
90 + $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
91 + $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
95 ifneq "$(strip $(binaries-pie-tests))" ""
96 $(addprefix $(objpfx),$(binaries-pie-tests)): %: %.o \
97 $(link-extra-libs-tests) \
98 @@ -253,6 +264,12 @@ $(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
102 +# All mcheck tests will be run with MALLOC_CHECK_=3
104 +$(1)-mcheck-ENV = MALLOC_CHECK_=3
106 +$(foreach t,$(tests-mcheck),$(eval $(call mcheck-ENVS,$(t))))
108 ifneq "$(strip $(tests) $(tests-internal) $(xtests) $(test-srcs))" ""
109 # These are the implicit rules for making test outputs
110 # from the test programs and whatever input files are present.
111 diff --git a/debug/Makefile b/debug/Makefile
112 index 3a60d7af7a..0036edd187 100644
115 @@ -51,7 +51,7 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \
117 stack_chk_fail fortify_fail \
118 $(static-only-routines)
119 -static-only-routines := warning-nop stack_chk_fail_local
120 +static-only-routines := stack_chk_fail_local
122 # Don't add stack_chk_fail_local.o to libc.a since __stack_chk_fail_local
123 # is an alias of __stack_chk_fail in stack_chk_fail.o.
124 diff --git a/debug/warning-nop.c b/debug/warning-nop.c
125 deleted file mode 100644
126 index 4ab7e182b7..0000000000
127 --- a/debug/warning-nop.c
130 -/* Dummy nop functions to elicit link-time warnings.
131 - Copyright (C) 2005-2020 Free Software Foundation, Inc.
132 - This file is part of the GNU C Library.
134 - The GNU C Library is free software; you can redistribute it and/or
135 - modify it under the terms of the GNU Lesser General Public
136 - License as published by the Free Software Foundation; either
137 - version 2.1 of the License, or (at your option) any later version.
139 - In addition to the permissions in the GNU Lesser General Public
140 - License, the Free Software Foundation gives you unlimited
141 - permission to link the compiled version of this file with other
142 - programs, and to distribute those programs without any restriction
143 - coming from the use of this file. (The GNU Lesser General Public
144 - License restrictions do apply in other respects; for example, they
145 - cover modification of the file, and distribution when not linked
146 - into another program.)
148 - Note that people who make modified versions of this file are not
149 - obligated to grant this special exception for their modified
150 - versions; it is their choice whether to do so. The GNU Lesser
151 - General Public License gives permission to release a modified
152 - version without this exception; this exception also makes it
153 - possible to release a modified version which carries forward this
156 - The GNU C Library is distributed in the hope that it will be useful,
157 - but WITHOUT ANY WARRANTY; without even the implied warranty of
158 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
159 - Lesser General Public License for more details.
161 - You should have received a copy of the GNU Lesser General Public
162 - License along with the GNU C Library; if not, see
163 - <https://www.gnu.org/licenses/>. */
165 -#include <sys/cdefs.h>
168 -__attribute__ ((used))
173 -/* Don't insert any other #include's before this #undef! */
176 -#define __warndecl(name, msg) \
177 - extern void name (void) __attribute__ ((alias ("nop"))) attribute_hidden; \
178 - link_warning (name, msg)
180 -#undef __USE_FORTIFY_LEVEL
181 -#define __USE_FORTIFY_LEVEL 99
183 -/* Following here we need an #include for each public header file
184 - that uses __warndecl. */
186 -/* Define away to avoid warnings with compilers that do not have these
188 -#define __builtin___memcpy_chk(dest, src, len, bos) NULL
189 -#define __builtin___memmove_chk(dest, src, len, bos) NULL
190 -#define __builtin___mempcpy_chk(dest, src, len, bos) NULL
191 -#define __builtin___memset_chk(dest, ch, len, bos) NULL
192 -#define __builtin___stpcpy_chk(dest, src, bos) NULL
193 -#define __builtin___strcat_chk(dest, src, bos) NULL
194 -#define __builtin___strcpy_chk(dest, src, bos) NULL
195 -#define __builtin___strncat_chk(dest, src, len, bos) NULL
196 -#define __builtin___strncpy_chk(dest, src, len, bos) NULL
197 -#define __builtin_object_size(bos, level) 0
200 diff --git a/elf/Makefile b/elf/Makefile
201 index 0b78721848..3ba7f4ecfc 100644
204 @@ -1381,6 +1381,8 @@ CFLAGS-ifuncmain7pie.c += $(pie-ccflag)
205 CFLAGS-ifuncmain9pie.c += $(pie-ccflag)
206 CFLAGS-tst-ifunc-textrel.c += $(pic-ccflag)
208 +LDFLAGS-ifuncmain6pie = -Wl,-z,lazy
210 $(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so
211 $(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o
212 $(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so
213 @@ -1630,8 +1632,6 @@ $(objpfx)tst-nodelete-dlclose.out: $(objpfx)tst-nodelete-dlclose-dso.so \
215 tst-env-setuid-ENV = MALLOC_CHECK_=2 MALLOC_MMAP_THRESHOLD_=4096 \
217 -tst-env-setuid-tunables-ENV = \
218 - GLIBC_TUNABLES=glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096
220 $(objpfx)tst-debug1: $(libdl)
221 $(objpfx)tst-debug1.out: $(objpfx)tst-debug1mod1.so
222 diff --git a/elf/dl-load.c b/elf/dl-load.c
223 index e39980fb19..71867e7c1a 100644
226 @@ -855,10 +855,12 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
228 /* Process PT_GNU_PROPERTY program header PH in module L after
229 PT_LOAD segments are mapped. Only one NT_GNU_PROPERTY_TYPE_0
230 - note is handled which contains processor specific properties. */
231 + note is handled which contains processor specific properties.
232 + FD is -1 for the kernel mapped main executable otherwise it is
233 + the fd used for loading module L. */
236 -_dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph)
237 +_dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph)
239 const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
240 const ElfW(Addr) size = ph->p_memsz;
241 @@ -905,7 +907,7 @@ _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph)
244 /* Target specific property processing. */
245 - if (_dl_process_gnu_property (l, type, datasz, ptr) == 0)
246 + if (_dl_process_gnu_property (l, fd, type, datasz, ptr) == 0)
249 /* Check the next property item. */
250 @@ -1251,21 +1253,6 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
251 maplength, has_holes, loader);
252 if (__glibc_unlikely (errstring != NULL))
255 - /* Process program headers again after load segments are mapped in
256 - case processing requires accessing those segments. Scan program
257 - headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
259 - for (ph = &phdr[l->l_phnum]; ph != phdr; --ph)
260 - switch (ph[-1].p_type)
263 - _dl_process_pt_note (l, &ph[-1]);
265 - case PT_GNU_PROPERTY:
266 - _dl_process_pt_gnu_property (l, &ph[-1]);
272 @@ -1377,6 +1364,21 @@ cannot enable executable stack as shared object requires");
273 if (l->l_tls_initimage != NULL)
274 l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
276 + /* Process program headers again after load segments are mapped in
277 + case processing requires accessing those segments. Scan program
278 + headers backward so that PT_NOTE can be skipped if PT_GNU_PROPERTY
280 + for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph)
281 + switch (ph[-1].p_type)
284 + _dl_process_pt_note (l, fd, &ph[-1]);
286 + case PT_GNU_PROPERTY:
287 + _dl_process_pt_gnu_property (l, fd, &ph[-1]);
291 /* We are done mapping in the file. We no longer need the descriptor. */
292 if (__glibc_unlikely (__close_nocancel (fd) != 0))
294 diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
295 index 26e6e26612..15b29bcb90 100644
296 --- a/elf/dl-tunables.c
297 +++ b/elf/dl-tunables.c
298 @@ -177,6 +177,7 @@ parse_tunables (char *tunestr, char *valstring)
306 @@ -190,7 +191,11 @@ parse_tunables (char *tunestr, char *valstring)
307 /* If we reach the end of the string before getting a valid name-value
312 + if (__libc_enable_secure)
313 + tunestr[off] = '\0';
317 /* We did not find a valid name-value pair before encountering the
319 @@ -216,35 +221,28 @@ parse_tunables (char *tunestr, char *valstring)
321 if (tunable_is_name (cur->name, name))
323 - /* If we are in a secure context (AT_SECURE) then ignore the tunable
324 - unless it is explicitly marked as secure. Tunable values take
325 - precedence over their envvar aliases. */
326 + /* If we are in a secure context (AT_SECURE) then ignore the
327 + tunable unless it is explicitly marked as secure. Tunable
328 + values take precedence over their envvar aliases. We write
329 + the tunables that are not SXID_ERASE back to TUNESTR, thus
330 + dropping all SXID_ERASE tunables and any invalid or
331 + unrecognized tunables. */
332 if (__libc_enable_secure)
334 - if (cur->security_level == TUNABLE_SECLEVEL_SXID_ERASE)
335 + if (cur->security_level != TUNABLE_SECLEVEL_SXID_ERASE)
337 - if (p[len] == '\0')
339 - /* Last tunable in the valstring. Null-terminate and
346 - /* Remove the current tunable from the string. We do
347 - this by overwriting the string starting from NAME
348 - (which is where the current tunable begins) with
349 - the remainder of the string. We then have P point
350 - to NAME so that we continue in the correct
351 - position in the valstring. */
352 - char *q = &p[len + 1];
360 + tunestr[off++] = ':';
362 + const char *n = cur->name;
365 + tunestr[off++] = *n++;
367 + tunestr[off++] = '=';
369 + for (size_t j = 0; j < len; j++)
370 + tunestr[off++] = value[j];
373 if (cur->security_level != TUNABLE_SECLEVEL_NONE)
374 @@ -257,9 +255,7 @@ parse_tunables (char *tunestr, char *valstring)
378 - if (p[len] == '\0')
381 + if (p[len] != '\0')
385 diff --git a/elf/ifuncmain6pie.c b/elf/ifuncmain6pie.c
386 index 04faeb86ef..4a01906836 100644
387 --- a/elf/ifuncmain6pie.c
388 +++ b/elf/ifuncmain6pie.c
390 #include "ifunc-sel.h"
392 typedef int (*foo_p) (void);
393 -extern foo_p foo_ptr;
397 @@ -28,20 +27,17 @@ foo_ifunc (void)
400 extern int foo (void);
401 -extern foo_p get_foo (void);
402 +extern int call_foo (void);
403 extern foo_p get_foo_p (void);
405 -foo_p my_foo_ptr = foo;
406 +foo_p foo_ptr = foo;
416 - if ((*p) () != -30)
417 + if (call_foo () != -30)
421 @@ -52,12 +48,8 @@ main (void)
425 - if (my_foo_ptr != foo)
427 if ((*foo_ptr) () != -30)
429 - if ((*my_foo_ptr) () != -30)
434 diff --git a/elf/ifuncmod6.c b/elf/ifuncmod6.c
435 index 2e16c1d06d..2f6d0715e6 100644
436 --- a/elf/ifuncmod6.c
437 +++ b/elf/ifuncmod6.c
438 @@ -4,7 +4,7 @@ extern int foo (void);
440 typedef int (*foo_p) (void);
442 -foo_p foo_ptr = foo;
443 +extern foo_p foo_ptr;
447 @@ -12,8 +12,8 @@ get_foo_p (void)
459 diff --git a/elf/rtld.c b/elf/rtld.c
460 index 5b882163fa..14a42ed00a 100644
463 @@ -1534,10 +1534,10 @@ of this helper program; chances are you did not intend to run this program.\n\
464 switch (ph[-1].p_type)
467 - _dl_process_pt_note (main_map, &ph[-1]);
468 + _dl_process_pt_note (main_map, -1, &ph[-1]);
470 case PT_GNU_PROPERTY:
471 - _dl_process_pt_gnu_property (main_map, &ph[-1]);
472 + _dl_process_pt_gnu_property (main_map, -1, &ph[-1]);
476 diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c
477 index 971d5892b1..ca0c8c245c 100644
478 --- a/elf/tst-env-setuid-tunables.c
479 +++ b/elf/tst-env-setuid-tunables.c
484 -#define test_parent test_parent_tunables
485 -#define test_child test_child_tunables
487 -static int test_child_tunables (void);
488 -static int test_parent_tunables (void);
490 -#include "tst-env-setuid.c"
492 -#define CHILD_VALSTRING_VALUE "glibc.malloc.mmap_threshold=4096"
493 -#define PARENT_VALSTRING_VALUE \
494 - "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096"
501 +#include <sys/stat.h>
502 +#include <sys/wait.h>
504 +#include <intprops.h>
505 +#include <array_length.h>
507 +#include <support/check.h>
508 +#include <support/support.h>
509 +#include <support/test-driver.h>
510 +#include <support/capture_subprocess.h>
512 +const char *teststrings[] =
514 + "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096",
515 + "glibc.malloc.check=2:glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096",
516 + "glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096:glibc.malloc.check=2",
517 + "glibc.malloc.perturb=0x800",
518 + "glibc.malloc.perturb=0x800:glibc.malloc.mmap_threshold=4096",
519 + "glibc.malloc.perturb=0x800:not_valid.malloc.check=2:glibc.malloc.mmap_threshold=4096",
520 + "glibc.not_valid.check=2:glibc.malloc.mmap_threshold=4096",
521 + "not_valid.malloc.check=2:glibc.malloc.mmap_threshold=4096",
522 + "glibc.malloc.garbage=2:glibc.maoc.mmap_threshold=4096:glibc.malloc.check=2",
523 + "glibc.malloc.check=4:glibc.malloc.garbage=2:glibc.maoc.mmap_threshold=4096",
524 + ":glibc.malloc.garbage=2:glibc.malloc.check=1",
525 + "glibc.malloc.check=1:glibc.malloc.check=2",
526 + "not_valid.malloc.check=2",
527 + "glibc.not_valid.check=2",
530 +const char *resultstrings[] =
532 + "glibc.malloc.mmap_threshold=4096",
533 + "glibc.malloc.mmap_threshold=4096",
534 + "glibc.malloc.mmap_threshold=4096",
535 + "glibc.malloc.perturb=0x800",
536 + "glibc.malloc.perturb=0x800:glibc.malloc.mmap_threshold=4096",
537 + "glibc.malloc.perturb=0x800:glibc.malloc.mmap_threshold=4096",
538 + "glibc.malloc.mmap_threshold=4096",
539 + "glibc.malloc.mmap_threshold=4096",
549 -test_child_tunables (void)
550 +test_child (int off)
552 const char *val = getenv ("GLIBC_TUNABLES");
555 - if (val != NULL && strcmp (val, CHILD_VALSTRING_VALUE) == 0)
556 + if (val != NULL && strcmp (val, resultstrings[off]) == 0)
560 - printf ("Unexpected GLIBC_TUNABLES VALUE %s\n", val);
561 + printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val);
567 - printf ("GLIBC_TUNABLES not cleared\n");
568 + printf ("[%d] GLIBC_TUNABLES not cleared\n", off);
572 @@ -61,15 +102,48 @@ test_child_tunables (void)
576 -test_parent_tunables (void)
577 +do_test (int argc, char **argv)
579 - const char *val = getenv ("GLIBC_TUNABLES");
580 + /* Setgid child process. */
583 + if (getgid () == getegid ())
584 + /* This can happen if the file system is mounted nosuid. */
585 + FAIL_UNSUPPORTED ("SGID failed: GID and EGID match (%jd)\n",
586 + (intmax_t) getgid ());
588 - if (val != NULL && strcmp (val, PARENT_VALSTRING_VALUE) == 0)
590 + int ret = test_child (atoi (argv[1]));
593 - printf ("Unexpected GLIBC_TUNABLES VALUE %s\n", val);
598 + exit (EXIT_SUCCESS);
605 + for (int i = 0; i < array_length (teststrings); i++)
607 + char buf[INT_BUFSIZE_BOUND (int)];
609 + printf ("Spawned test for %s (%d)\n", teststrings[i], i);
610 + snprintf (buf, sizeof (buf), "%d\n", i);
611 + if (setenv ("GLIBC_TUNABLES", teststrings[i], 1) != 0)
614 + int status = support_capture_subprogram_self_sgid (buf);
616 + /* Bail out early if unsupported. */
617 + if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
618 + return EXIT_UNSUPPORTED;
626 +#define TEST_FUNCTION_ARGV do_test
627 +#include <support/test-driver.c>
628 diff --git a/elf/tst-env-setuid.c b/elf/tst-env-setuid.c
629 index 41dc79e83a..2dbccdb69e 100644
630 --- a/elf/tst-env-setuid.c
631 +++ b/elf/tst-env-setuid.c
633 #include <sys/wait.h>
636 +#include <support/check.h>
637 #include <support/support.h>
638 #include <support/test-driver.h>
639 +#include <support/capture_subprocess.h>
641 static char SETGID_CHILD[] = "setgid-child";
642 -#define CHILD_STATUS 42
644 -/* Return a GID which is not our current GID, but is present in the
645 - supplementary group list. */
649 - const int count = 64;
650 - gid_t groups[count];
651 - int ret = getgroups (count, groups);
654 - printf ("getgroups: %m\n");
657 - gid_t current = getgid ();
658 - for (int i = 0; i < ret; ++i)
660 - if (groups[i] != current)
666 -/* Spawn and execute a program and verify that it returns the CHILD_STATUS. */
668 -do_execve (char **args)
670 - pid_t kid = vfork ();
674 - printf ("vfork: %m\n");
680 - /* Child process. */
681 - execve (args[0], args, environ);
690 - if (waitpid (kid, &status, 0) < 0)
692 - printf ("waitpid: %m\n");
696 - if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
697 - return EXIT_UNSUPPORTED;
699 - if (!WIFEXITED (status) || WEXITSTATUS (status) != CHILD_STATUS)
701 - printf ("Unexpected exit status %d from child process\n",
702 - WEXITSTATUS (status));
708 -/* Copies the executable into a restricted directory, so that we can
709 - safely make it SGID with the TARGET group ID. Then runs the
712 -run_executable_sgid (gid_t target)
714 - char *dirname = xasprintf ("%s/tst-tunables-setuid.%jd",
715 - test_dir, (intmax_t) getpid ());
716 - char *execname = xasprintf ("%s/bin", dirname);
720 - if (mkdir (dirname, 0700) < 0)
722 - printf ("mkdir: %m\n");
725 - infd = open ("/proc/self/exe", O_RDONLY);
728 - printf ("open (/proc/self/exe): %m\n");
731 - outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700);
734 - printf ("open (%s): %m\n", execname);
740 - ssize_t rdcount = read (infd, buf, sizeof (buf));
743 - printf ("read: %m\n");
749 - char *end = buf + rdcount;
752 - ssize_t wrcount = write (outfd, buf, end - p);
757 - printf ("write: %m\n");
763 - if (fchown (outfd, getuid (), target) < 0)
765 - printf ("fchown (%s): %m\n", execname);
768 - if (fchmod (outfd, 02750) < 0)
770 - printf ("fchmod (%s): %m\n", execname);
773 - if (close (outfd) < 0)
775 - printf ("close (outfd): %m\n");
778 - if (close (infd) < 0)
780 - printf ("close (infd): %m\n");
784 - char *args[] = {execname, SETGID_CHILD, NULL};
786 - ret = do_execve (args);
808 @@ -256,40 +95,32 @@ do_test (int argc, char **argv)
809 if (argc == 2 && strcmp (argv[1], SETGID_CHILD) == 0)
811 if (getgid () == getegid ())
813 - /* This can happen if the file system is mounted nosuid. */
814 - fprintf (stderr, "SGID failed: GID and EGID match (%jd)\n",
815 - (intmax_t) getgid ());
816 - exit (EXIT_UNSUPPORTED);
818 + /* This can happen if the file system is mounted nosuid. */
819 + FAIL_UNSUPPORTED ("SGID failed: GID and EGID match (%jd)\n",
820 + (intmax_t) getgid ());
822 int ret = test_child ();
827 - exit (CHILD_STATUS);
828 + exit (EXIT_SUCCESS);
832 if (test_parent () != 0)
835 - /* Try running a setgid program. */
836 - gid_t target = choose_gid ();
840 - "Could not find a suitable GID for user %jd, skipping test\n",
841 - (intmax_t) getuid ());
844 + int status = support_capture_subprogram_self_sgid (SETGID_CHILD);
846 - return run_executable_sgid (target);
848 + if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
849 + return EXIT_UNSUPPORTED;
851 + if (!WIFEXITED (status))
852 + FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status);
854 - /* Something went wrong and our argv was corrupted. */
860 #define TEST_FUNCTION_ARGV do_test
861 diff --git a/iconv/Versions b/iconv/Versions
862 index 8a5f4cf780..d51af52fa3 100644
865 @@ -6,7 +6,9 @@ libc {
867 # functions shared with iconv program
868 __gconv_get_alias_db; __gconv_get_cache; __gconv_get_modules_db;
869 - __gconv_open; __gconv_create_spec;
871 + # functions used elsewhere in glibc
872 + __gconv_open; __gconv_create_spec; __gconv_destroy_spec;
874 # function used by the gconv modules
875 __gconv_transliterate;
876 diff --git a/iconv/gconv_charset.c b/iconv/gconv_charset.c
877 index 6ccd0773cc..4ba0aa99f5 100644
878 --- a/iconv/gconv_charset.c
879 +++ b/iconv/gconv_charset.c
880 @@ -216,3 +216,13 @@ out:
883 libc_hidden_def (__gconv_create_spec)
887 +__gconv_destroy_spec (struct gconv_spec *conv_spec)
889 + free (conv_spec->fromcode);
890 + free (conv_spec->tocode);
893 +libc_hidden_def (__gconv_destroy_spec)
894 diff --git a/iconv/gconv_charset.h b/iconv/gconv_charset.h
895 index b39b09aea1..e9c122cf7e 100644
896 --- a/iconv/gconv_charset.h
897 +++ b/iconv/gconv_charset.h
899 #define GCONV_IGNORE_ERRORS_SUFFIX "IGNORE"
902 -/* This function accepts the charset names of the source and destination of the
903 - conversion and populates *conv_spec with an equivalent conversion
904 - specification that may later be used by __gconv_open. The charset names
905 - might contain options in the form of suffixes that alter the conversion,
906 - e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring
907 - and truncating any suffix options in fromcode, and processing and truncating
908 - any suffix options in tocode. Supported suffix options ("TRANSLIT" or
909 - "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec
910 - to be set to true. Unrecognized suffix options are silently discarded. If
911 - the function succeeds, it returns conv_spec back to the caller. It returns
912 - NULL upon failure. */
914 -__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode,
915 - const char *tocode);
916 -libc_hidden_proto (__gconv_create_spec)
919 -/* This function frees all heap memory allocated by __gconv_create_spec. */
920 -static void __attribute__ ((unused))
921 -gconv_destroy_spec (struct gconv_spec *conv_spec)
923 - free (conv_spec->fromcode);
924 - free (conv_spec->tocode);
929 /* This function copies in-order, characters from the source 's' that are
930 either alpha-numeric or one in one of these: "_-.,:/" - into the destination
931 'wp' while dropping all other characters. In the process, it converts all
932 diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h
933 index e86938dae7..f721ce30ff 100644
934 --- a/iconv/gconv_int.h
935 +++ b/iconv/gconv_int.h
936 @@ -152,6 +152,27 @@ extern int __gconv_open (struct gconv_spec *conv_spec,
937 __gconv_t *handle, int flags);
938 libc_hidden_proto (__gconv_open)
940 +/* This function accepts the charset names of the source and destination of the
941 + conversion and populates *conv_spec with an equivalent conversion
942 + specification that may later be used by __gconv_open. The charset names
943 + might contain options in the form of suffixes that alter the conversion,
944 + e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring
945 + and truncating any suffix options in fromcode, and processing and truncating
946 + any suffix options in tocode. Supported suffix options ("TRANSLIT" or
947 + "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec
948 + to be set to true. Unrecognized suffix options are silently discarded. If
949 + the function succeeds, it returns conv_spec back to the caller. It returns
950 + NULL upon failure. */
951 +extern struct gconv_spec *
952 +__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode,
953 + const char *tocode);
954 +libc_hidden_proto (__gconv_create_spec)
956 +/* This function frees all heap memory allocated by __gconv_create_spec. */
958 +__gconv_destroy_spec (struct gconv_spec *conv_spec);
959 +libc_hidden_proto (__gconv_destroy_spec)
961 /* Free resources associated with transformation descriptor CD. */
962 extern int __gconv_close (__gconv_t cd)
964 diff --git a/iconv/iconv_open.c b/iconv/iconv_open.c
965 index dd54bc12e0..5b30055c04 100644
966 --- a/iconv/iconv_open.c
967 +++ b/iconv/iconv_open.c
968 @@ -39,7 +39,7 @@ iconv_open (const char *tocode, const char *fromcode)
970 int res = __gconv_open (&conv_spec, &cd, 0);
972 - gconv_destroy_spec (&conv_spec);
973 + __gconv_destroy_spec (&conv_spec);
975 if (__builtin_expect (res, __GCONV_OK) != __GCONV_OK)
977 diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
978 index b4334faa57..d59979759c 100644
979 --- a/iconv/iconv_prog.c
980 +++ b/iconv/iconv_prog.c
981 @@ -184,7 +184,7 @@ main (int argc, char *argv[])
982 /* Let's see whether we have these coded character sets. */
983 res = __gconv_open (&conv_spec, &cd, 0);
985 - gconv_destroy_spec (&conv_spec);
986 + __gconv_destroy_spec (&conv_spec);
988 if (res != __GCONV_OK)
990 diff --git a/iconv/tst-iconv_prog.sh b/iconv/tst-iconv_prog.sh
991 index 8298136b7f..d8db7b335c 100644
992 --- a/iconv/tst-iconv_prog.sh
993 +++ b/iconv/tst-iconv_prog.sh
994 @@ -102,12 +102,16 @@ hangarray=(
995 "\x00\x80;-c;IBM1161;UTF-8//TRANSLIT//IGNORE"
996 "\x00\xdb;-c;IBM1162;UTF-8//TRANSLIT//IGNORE"
997 "\x00\x70;-c;IBM12712;UTF-8//TRANSLIT//IGNORE"
998 -# These are known hangs that are yet to be fixed:
999 -# "\x00\x0f;-c;IBM1364;UTF-8"
1000 -# "\x00\x0f;-c;IBM1371;UTF-8"
1001 -# "\x00\x0f;-c;IBM1388;UTF-8"
1002 -# "\x00\x0f;-c;IBM1390;UTF-8"
1003 -# "\x00\x0f;-c;IBM1399;UTF-8"
1004 +"\x00\x0f;-c;IBM1364;UTF-8"
1005 +"\x0e\x0e;-c;IBM1364;UTF-8"
1006 +"\x00\x0f;-c;IBM1371;UTF-8"
1007 +"\x0e\x0e;-c;IBM1371;UTF-8"
1008 +"\x00\x0f;-c;IBM1388;UTF-8"
1009 +"\x0e\x0e;-c;IBM1388;UTF-8"
1010 +"\x00\x0f;-c;IBM1390;UTF-8"
1011 +"\x0e\x0e;-c;IBM1390;UTF-8"
1012 +"\x00\x0f;-c;IBM1399;UTF-8"
1013 +"\x0e\x0e;-c;IBM1399;UTF-8"
1014 "\x00\x53;-c;IBM16804;UTF-8//TRANSLIT//IGNORE"
1015 "\x00\x41;-c;IBM274;UTF-8//TRANSLIT//IGNORE"
1016 "\x00\x41;-c;IBM275;UTF-8//TRANSLIT//IGNORE"
1017 diff --git a/iconvdata/Makefile b/iconvdata/Makefile
1018 index 4ec2741cdc..4eef07557e 100644
1019 --- a/iconvdata/Makefile
1020 +++ b/iconvdata/Makefile
1021 @@ -73,7 +73,8 @@ modules.so := $(addsuffix .so, $(modules))
1022 ifeq (yes,$(build-shared))
1023 tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
1024 tst-iconv6 bug-iconv5 bug-iconv6 tst-iconv7 bug-iconv8 bug-iconv9 \
1025 - bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4
1026 + bug-iconv10 bug-iconv11 bug-iconv12 tst-iconv-big5-hkscs-to-2ucs4 \
1027 + bug-iconv13 bug-iconv14
1028 ifeq ($(have-thread-library),yes)
1031 @@ -321,6 +322,8 @@ $(objpfx)bug-iconv10.out: $(objpfx)gconv-modules \
1032 $(addprefix $(objpfx),$(modules.so))
1033 $(objpfx)bug-iconv12.out: $(objpfx)gconv-modules \
1034 $(addprefix $(objpfx),$(modules.so))
1035 +$(objpfx)bug-iconv14.out: $(objpfx)gconv-modules \
1036 + $(addprefix $(objpfx),$(modules.so))
1038 $(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \
1039 $(addprefix $(objpfx),$(modules.so)) \
1040 diff --git a/iconvdata/bug-iconv13.c b/iconvdata/bug-iconv13.c
1041 new file mode 100644
1042 index 0000000000..87aaff398e
1044 +++ b/iconvdata/bug-iconv13.c
1046 +/* bug 24973: Test EUC-KR module
1047 + Copyright (C) 2020 Free Software Foundation, Inc.
1048 + This file is part of the GNU C Library.
1050 + The GNU C Library is free software; you can redistribute it and/or
1051 + modify it under the terms of the GNU Lesser General Public
1052 + License as published by the Free Software Foundation; either
1053 + version 2.1 of the License, or (at your option) any later version.
1055 + The GNU C Library is distributed in the hope that it will be useful,
1056 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1057 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1058 + Lesser General Public License for more details.
1060 + You should have received a copy of the GNU Lesser General Public
1061 + License along with the GNU C Library; if not, see
1062 + <https://www.gnu.org/licenses/>. */
1067 +#include <support/check.h>
1072 + iconv_t cd = iconv_open ("UTF-8//IGNORE", "EUC-KR");
1073 + TEST_VERIFY_EXIT (cd != (iconv_t) -1);
1075 + /* 0xfe (->0x7e : row 94) and 0xc9 (->0x49 : row 41) are user-defined
1076 + areas, which are not allowed and should be skipped over due to
1077 + //IGNORE. The trailing 0xfe also is an incomplete sequence, which
1078 + should be checked first. */
1079 + char input[4] = { '\xc9', '\xa1', '\0', '\xfe' };
1080 + char *inptr = input;
1081 + size_t insize = sizeof (input);
1083 + char *outptr = output;
1084 + size_t outsize = sizeof (output);
1086 + /* This used to crash due to buffer overrun. */
1087 + TEST_VERIFY (iconv (cd, &inptr, &insize, &outptr, &outsize) == (size_t) -1);
1088 + TEST_VERIFY (errno == EINVAL);
1089 + /* The conversion should produce one character, the converted null
1091 + TEST_VERIFY (sizeof (output) - outsize == 1);
1093 + TEST_VERIFY_EXIT (iconv_close (cd) != -1);
1098 +#include <support/test-driver.c>
1099 diff --git a/iconvdata/bug-iconv14.c b/iconvdata/bug-iconv14.c
1100 new file mode 100644
1101 index 0000000000..902f140fa9
1103 +++ b/iconvdata/bug-iconv14.c
1105 +/* Assertion in ISO-2022-JP-3 due to two-character sequence (bug 27256).
1106 + Copyright (C) 2021 Free Software Foundation, Inc.
1107 + This file is part of the GNU C Library.
1109 + The GNU C Library is free software; you can redistribute it and/or
1110 + modify it under the terms of the GNU Lesser General Public
1111 + License as published by the Free Software Foundation; either
1112 + version 2.1 of the License, or (at your option) any later version.
1114 + The GNU C Library is distributed in the hope that it will be useful,
1115 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1116 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1117 + Lesser General Public License for more details.
1119 + You should have received a copy of the GNU Lesser General Public
1120 + License along with the GNU C Library; if not, see
1121 + <https://www.gnu.org/licenses/>. */
1124 +#include <string.h>
1126 +#include <support/check.h>
1128 +/* Use an escape sequence to return to the initial state. */
1130 +with_escape_sequence (void)
1132 + iconv_t c = iconv_open ("UTF-8", "ISO-2022-JP-3");
1133 + TEST_VERIFY_EXIT (c != (iconv_t) -1);
1135 + char in[] = "\e$(O+D\e(B";
1137 + size_t inleft = strlen (in);
1138 + char out[3]; /* Space for one output character. */
1143 + outleft = sizeof (out);
1144 + TEST_COMPARE (iconv (c, &inbuf, &inleft, &outbuf, &outleft), (size_t) -1);
1145 + TEST_COMPARE (errno, E2BIG);
1146 + TEST_COMPARE (inleft, 3);
1147 + TEST_COMPARE (inbuf - in, strlen (in) - 3);
1148 + TEST_COMPARE (outleft, sizeof (out) - 2);
1149 + TEST_COMPARE (outbuf - out, 2);
1150 + TEST_COMPARE (out[0] & 0xff, 0xc3);
1151 + TEST_COMPARE (out[1] & 0xff, 0xa6);
1153 + /* Return to the initial shift state, producing the pending
1156 + outleft = sizeof (out);
1157 + TEST_COMPARE (iconv (c, &inbuf, &inleft, &outbuf, &outleft), 0);
1158 + TEST_COMPARE (inleft, 0);
1159 + TEST_COMPARE (inbuf - in, strlen (in));
1160 + TEST_COMPARE (outleft, sizeof (out) - 2);
1161 + TEST_COMPARE (outbuf - out, 2);
1162 + TEST_COMPARE (out[0] & 0xff, 0xcc);
1163 + TEST_COMPARE (out[1] & 0xff, 0x80);
1165 + /* Nothing should be flushed the second time. */
1167 + outleft = sizeof (out);
1168 + TEST_COMPARE (iconv (c, NULL, 0, &outbuf, &outleft), 0);
1169 + TEST_COMPARE (outleft, sizeof (out));
1170 + TEST_COMPARE (outbuf - out, 0);
1171 + TEST_COMPARE (out[0] & 0xff, 0xcc);
1172 + TEST_COMPARE (out[1] & 0xff, 0x80);
1174 + TEST_COMPARE (iconv_close (c), 0);
1177 +/* Use an explicit flush to return to the initial state. */
1181 + iconv_t c = iconv_open ("UTF-8", "ISO-2022-JP-3");
1182 + TEST_VERIFY_EXIT (c != (iconv_t) -1);
1184 + char in[] = "\e$(O+D";
1186 + size_t inleft = strlen (in);
1187 + char out[3]; /* Space for one output character. */
1192 + outleft = sizeof (out);
1193 + TEST_COMPARE (iconv (c, &inbuf, &inleft, &outbuf, &outleft), (size_t) -1);
1194 + TEST_COMPARE (errno, E2BIG);
1195 + TEST_COMPARE (inleft, 0);
1196 + TEST_COMPARE (inbuf - in, strlen (in));
1197 + TEST_COMPARE (outleft, sizeof (out) - 2);
1198 + TEST_COMPARE (outbuf - out, 2);
1199 + TEST_COMPARE (out[0] & 0xff, 0xc3);
1200 + TEST_COMPARE (out[1] & 0xff, 0xa6);
1202 + /* Flush the pending character. */
1204 + outleft = sizeof (out);
1205 + TEST_COMPARE (iconv (c, NULL, 0, &outbuf, &outleft), 0);
1206 + TEST_COMPARE (outleft, sizeof (out) - 2);
1207 + TEST_COMPARE (outbuf - out, 2);
1208 + TEST_COMPARE (out[0] & 0xff, 0xcc);
1209 + TEST_COMPARE (out[1] & 0xff, 0x80);
1211 + /* Nothing should be flushed the second time. */
1213 + outleft = sizeof (out);
1214 + TEST_COMPARE (iconv (c, NULL, 0, &outbuf, &outleft), 0);
1215 + TEST_COMPARE (outleft, sizeof (out));
1216 + TEST_COMPARE (outbuf - out, 0);
1217 + TEST_COMPARE (out[0] & 0xff, 0xcc);
1218 + TEST_COMPARE (out[1] & 0xff, 0x80);
1220 + TEST_COMPARE (iconv_close (c), 0);
1226 + with_escape_sequence ();
1231 +#include <support/test-driver.c>
1232 diff --git a/iconvdata/euc-kr.c b/iconvdata/euc-kr.c
1233 index b0d56cf3ee..1045bae926 100644
1234 --- a/iconvdata/euc-kr.c
1235 +++ b/iconvdata/euc-kr.c
1236 @@ -80,11 +80,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
1240 - /* 0xfe(->0x7e : row 94) and 0xc9(->0x59 : row 41) are \
1241 - user-defined areas. */ \
1242 - else if (__builtin_expect (ch == 0xa0, 0) \
1243 - || __builtin_expect (ch > 0xfe, 0) \
1244 - || __builtin_expect (ch == 0xc9, 0)) \
1245 + else if (__glibc_unlikely (ch == 0xa0)) \
1247 /* This is illegal. */ \
1248 STANDARD_FROM_LOOP_ERR_HANDLER (1); \
1249 diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c
1250 index 49e7267ab4..521f0825b7 100644
1251 --- a/iconvdata/ibm1364.c
1252 +++ b/iconvdata/ibm1364.c
1253 @@ -158,24 +158,14 @@ enum
1255 if (__builtin_expect (ch, 0) == SO) \
1257 - /* Shift OUT, change to DBCS converter. */ \
1258 - if (curcs == db) \
1260 - result = __GCONV_ILLEGAL_INPUT; \
1263 + /* Shift OUT, change to DBCS converter (redundant escape okay). */ \
1268 if (__builtin_expect (ch, 0) == SI) \
1270 - /* Shift IN, change to SBCS converter. */ \
1271 - if (curcs == sb) \
1273 - result = __GCONV_ILLEGAL_INPUT; \
1276 + /* Shift IN, change to SBCS converter (redundant escape okay). */ \
1280 diff --git a/iconvdata/iso-2022-jp-3.c b/iconvdata/iso-2022-jp-3.c
1281 index 8c3b7e627e..62cbc54a11 100644
1282 --- a/iconvdata/iso-2022-jp-3.c
1283 +++ b/iconvdata/iso-2022-jp-3.c
1284 @@ -67,23 +67,34 @@ enum
1285 CURRENT_SEL_MASK = 7 << 3
1288 -/* During UCS-4 to ISO-2022-JP-3 conversion, the COUNT element of the state
1289 - also contains the last two bytes to be output, shifted by 6 bits, and a
1290 - one-bit indicator whether they must be preceded by the shift sequence,
1292 +/* During UCS-4 to ISO-2022-JP-3 conversion, the COUNT element of the
1293 + state also contains the last two bytes to be output, shifted by 6
1294 + bits, and a one-bit indicator whether they must be preceded by the
1295 + shift sequence, in bit 22. During ISO-2022-JP-3 to UCS-4
1296 + conversion, COUNT may also contain a non-zero pending wide
1297 + character, shifted by six bits. This happens for certain inputs in
1298 + JISX0213_1_2004_set and JISX0213_2_set if the second wide character
1299 + in a combining sequence cannot be written because the buffer is
1302 /* Since this is a stateful encoding we have to provide code which resets
1303 the output state to the initial state. This has to be done during the
1305 #define EMIT_SHIFT_TO_INIT \
1306 - if ((data->__statep->__count & ~7) != ASCII_set) \
1307 + if (data->__statep->__count != ASCII_set) \
1309 if (FROM_DIRECTION) \
1311 - /* It's easy, we don't have to emit anything, we just reset the \
1312 - state for the input. */ \
1313 - data->__statep->__count &= 7; \
1314 - data->__statep->__count |= ASCII_set; \
1315 + if (__glibc_likely (outbuf + 4 <= outend)) \
1317 + /* Write out the last character. */ \
1318 + *((uint32_t *) outbuf) = data->__statep->__count >> 6; \
1319 + outbuf += sizeof (uint32_t); \
1320 + data->__statep->__count = ASCII_set; \
1323 + /* We don't have enough room in the output buffer. */ \
1324 + status = __GCONV_FULL_OUTPUT; \
1328 @@ -151,7 +162,21 @@ enum
1329 #define LOOPFCT FROM_LOOP
1332 - uint32_t ch = *inptr; \
1335 + /* Output any pending character. */ \
1337 + if (__glibc_unlikely (ch != 0)) \
1339 + put32 (outptr, ch); \
1341 + /* Remove the pending character, but preserve state bits. */ \
1342 + set &= (1 << 6) - 1; \
1346 + /* Otherwise read the next input byte. */ \
1349 /* Recognize escape sequences. */ \
1350 if (__glibc_unlikely (ch == ESC)) \
1351 @@ -297,21 +322,25 @@ enum
1352 uint32_t u1 = __jisx0213_to_ucs_combining[ch - 1][0]; \
1353 uint32_t u2 = __jisx0213_to_ucs_combining[ch - 1][1]; \
1357 + put32 (outptr, u1); \
1360 /* See whether we have room for two characters. */ \
1361 - if (outptr + 8 <= outend) \
1362 + if (outptr + 4 <= outend) \
1365 - put32 (outptr, u1); \
1367 put32 (outptr, u2); \
1373 - result = __GCONV_FULL_OUTPUT; \
1377 + /* Otherwise store only the first character now, and \
1378 + put the second one into the queue. */ \
1380 + /* Tell the caller why we terminate the loop. */ \
1381 + result = __GCONV_FULL_OUTPUT; \
1386 diff --git a/iconvdata/ksc5601.h b/iconvdata/ksc5601.h
1387 index d3eb3a4ff8..f5cdc72797 100644
1388 --- a/iconvdata/ksc5601.h
1389 +++ b/iconvdata/ksc5601.h
1390 @@ -50,15 +50,15 @@ ksc5601_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
1397 /* row 94(0x7e) and row 41(0x49) are user-defined area in KS C 5601 */
1399 if (ch < offset || (ch - offset) <= 0x20 || (ch - offset) >= 0x7e
1400 || (ch - offset) == 0x49)
1401 return __UNKNOWN_10646_CHAR;
1407 if (ch2 < offset || (ch2 - offset) <= 0x20 || (ch2 - offset) >= 0x7f)
1408 return __UNKNOWN_10646_CHAR;
1409 diff --git a/intl/dcigettext.c b/intl/dcigettext.c
1410 index 2e7c662bc7..bd332e71da 100644
1411 --- a/intl/dcigettext.c
1412 +++ b/intl/dcigettext.c
1413 @@ -1120,15 +1120,18 @@ _nl_find_msg (struct loaded_l10nfile *domain_file,
1417 - struct gconv_spec conv_spec
1418 - = { .fromcode = norm_add_slashes (charset, ""),
1419 - .tocode = norm_add_slashes (outcharset, ""),
1420 - /* We always want to use transliteration. */
1424 + struct gconv_spec conv_spec;
1426 + __gconv_create_spec (&conv_spec, charset, outcharset);
1428 + /* We always want to use transliteration. */
1429 + conv_spec.translit = true;
1431 int r = __gconv_open (&conv_spec, &convd->conv,
1432 GCONV_AVOID_NOCONV);
1434 + __gconv_destroy_spec (&conv_spec);
1436 if (__builtin_expect (r != __GCONV_OK, 0))
1438 /* If the output encoding is the same there is
1439 diff --git a/intl/tst-codeset.c b/intl/tst-codeset.c
1440 index fd70432eca..e9f6e5e09f 100644
1441 --- a/intl/tst-codeset.c
1442 +++ b/intl/tst-codeset.c
1447 +#include <support/check.h>
1455 unsetenv ("LANGUAGE");
1456 unsetenv ("OUTPUT_CHARSET");
1457 setlocale (LC_ALL, "de_DE.ISO-8859-1");
1458 @@ -36,25 +34,21 @@ do_test (void)
1459 bindtextdomain ("codeset", OBJPFX "domaindir");
1461 /* Here we expect output in ISO-8859-1. */
1462 - s = gettext ("cheese");
1463 - if (strcmp (s, "K\344se"))
1465 - printf ("call 1 returned: %s\n", s);
1468 + TEST_COMPARE_STRING (gettext ("cheese"), "K\344se");
1470 + /* Here we expect output in UTF-8. */
1471 bind_textdomain_codeset ("codeset", "UTF-8");
1472 + TEST_COMPARE_STRING (gettext ("cheese"), "K\303\244se");
1474 - /* Here we expect output in UTF-8. */
1475 - s = gettext ("cheese");
1476 - if (strcmp (s, "K\303\244se"))
1478 - printf ("call 2 returned: %s\n", s);
1483 + /* `a with umlaut' is transliterated to `ae'. */
1484 + bind_textdomain_codeset ("codeset", "ASCII//TRANSLIT");
1485 + TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
1487 + /* Transliteration also works by default even if not set. */
1488 + bind_textdomain_codeset ("codeset", "ASCII");
1489 + TEST_COMPARE_STRING (gettext ("cheese"), "Kaese");
1494 -#define TEST_FUNCTION do_test ()
1495 -#include "../test-skeleton.c"
1496 +#include <support/test-driver.c>
1497 diff --git a/malloc/Makefile b/malloc/Makefile
1498 index e22cbde22d..5093e8730e 100644
1499 --- a/malloc/Makefile
1500 +++ b/malloc/Makefile
1501 @@ -62,6 +62,16 @@ endif
1502 tests += $(tests-static)
1503 test-srcs = tst-mtrace
1505 +# These tests either are run with MALLOC_CHECK_=3 by default or do not work
1506 +# with MALLOC_CHECK_=3 because they expect a specific failure.
1507 +tests-exclude-mcheck = tst-mcheck tst-malloc-usable \
1508 + tst-interpose-nothread tst-interpose-static-nothread \
1509 + tst-interpose-static-thread tst-malloc-too-large \
1510 + tst-mxfast tst-safe-linking
1512 +# Run all tests with MALLOC_CHECK_=3
1513 +tests-mcheck = $(filter-out $(tests-exclude-mcheck),$(tests))
1515 routines = malloc morecore mcheck mtrace obstack reallocarray \
1516 scratch_buffer_grow scratch_buffer_grow_preserve \
1517 scratch_buffer_set_array_size \
1518 @@ -100,6 +110,11 @@ $(objpfx)tst-malloc-thread-exit: $(shared-thread-library)
1519 $(objpfx)tst-malloc-thread-fail: $(shared-thread-library)
1520 $(objpfx)tst-malloc-fork-deadlock: $(shared-thread-library)
1521 $(objpfx)tst-malloc-stats-cancellation: $(shared-thread-library)
1522 +$(objpfx)tst-malloc-backtrace-mcheck: $(shared-thread-library)
1523 +$(objpfx)tst-malloc-thread-exit-mcheck: $(shared-thread-library)
1524 +$(objpfx)tst-malloc-thread-fail-mcheck: $(shared-thread-library)
1525 +$(objpfx)tst-malloc-fork-deadlock-mcheck: $(shared-thread-library)
1526 +$(objpfx)tst-malloc-stats-cancellation-mcheck: $(shared-thread-library)
1528 # Export the __malloc_initialize_hook variable to libc.so.
1529 LDFLAGS-tst-mallocstate = -rdynamic
1530 @@ -239,6 +254,8 @@ $(tests:%=$(objpfx)%.o): CPPFLAGS += -DTEST_NO_MALLOPT
1531 $(objpfx)tst-interpose-nothread: $(objpfx)tst-interpose-aux-nothread.o
1532 $(objpfx)tst-interpose-thread: \
1533 $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
1534 +$(objpfx)tst-interpose-thread-mcheck: \
1535 + $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
1536 $(objpfx)tst-interpose-static-nothread: $(objpfx)tst-interpose-aux-nothread.o
1537 $(objpfx)tst-interpose-static-thread: \
1538 $(objpfx)tst-interpose-aux-thread.o $(static-thread-library)
1539 @@ -256,3 +273,6 @@ $(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out
1540 $(objpfx)tst-malloc-tcache-leak: $(shared-thread-library)
1541 $(objpfx)tst-malloc_info: $(shared-thread-library)
1542 $(objpfx)tst-mallocfork2: $(shared-thread-library)
1543 +$(objpfx)tst-malloc-tcache-leak-mcheck: $(shared-thread-library)
1544 +$(objpfx)tst-malloc_info-mcheck: $(shared-thread-library)
1545 +$(objpfx)tst-mallocfork2-mcheck: $(shared-thread-library)
1546 diff --git a/manual/tunables.texi b/manual/tunables.texi
1547 index 23ef0d40e7..d72d7a5ec0 100644
1548 --- a/manual/tunables.texi
1549 +++ b/manual/tunables.texi
1550 @@ -432,7 +432,11 @@ set shared cache size in bytes for use in memory and string routines.
1552 @deftp Tunable glibc.cpu.x86_non_temporal_threshold
1553 The @code{glibc.cpu.x86_non_temporal_threshold} tunable allows the user
1554 -to set threshold in bytes for non temporal store.
1555 +to set threshold in bytes for non temporal store. Non temporal stores
1556 +give a hint to the hardware to move data directly to memory without
1557 +displacing other data from the cache. This tunable is used by some
1558 +platforms to determine when to use non temporal stores in operations
1559 +like memmove and memcpy.
1561 This tunable is specific to i386 and x86-64.
1563 diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
1564 index 19d9cc5cfe..38221d0b2a 100644
1565 --- a/misc/sys/cdefs.h
1566 +++ b/misc/sys/cdefs.h
1567 @@ -124,13 +124,10 @@
1568 #define __bos0(ptr) __builtin_object_size (ptr, 0)
1570 #if __GNUC_PREREQ (4,3)
1571 -# define __warndecl(name, msg) \
1572 - extern void name (void) __attribute__((__warning__ (msg)))
1573 # define __warnattr(msg) __attribute__((__warning__ (msg)))
1574 # define __errordecl(name, msg) \
1575 extern void name (void) __attribute__((__error__ (msg)))
1577 -# define __warndecl(name, msg) extern void name (void)
1578 # define __warnattr(msg)
1579 # define __errordecl(name, msg) extern void name (void)
1581 diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
1582 index 88c69d1e9c..381aa721ef 100644
1583 --- a/nscd/netgroupcache.c
1584 +++ b/nscd/netgroupcache.c
1585 @@ -248,7 +248,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
1587 ndomain = (ndomain ? newbuf + ndomaindiff
1590 + *tofreep = buffer = newbuf;
1593 nhost = memcpy (buffer + bufused,
1594 @@ -319,7 +319,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
1595 else if (status == NSS_STATUS_TRYAGAIN && e == ERANGE)
1598 - buffer = xrealloc (buffer, buflen);
1599 + *tofreep = buffer = xrealloc (buffer, buflen);
1601 else if (status == NSS_STATUS_RETURN
1602 || status == NSS_STATUS_NOTFOUND
1603 diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
1604 index ed1b22308e..cb3f989cba 100644
1605 --- a/posix/wordexp-test.c
1606 +++ b/posix/wordexp-test.c
1607 @@ -183,6 +183,7 @@ struct test_case_struct
1608 { 0, NULL, "$var", 0, 0, { NULL, }, IFS },
1609 { 0, NULL, "\"\\n\"", 0, 1, { "\\n", }, IFS },
1610 { 0, NULL, "", 0, 0, { NULL, }, IFS },
1611 + { 0, NULL, "${1234567890123456789012}", 0, 0, { NULL, }, IFS },
1613 /* Flags not already covered (testit() has special handling for these) */
1614 { 0, NULL, "one two", WRDE_DOOFFS, 2, { "one", "two", }, IFS },
1615 diff --git a/posix/wordexp.c b/posix/wordexp.c
1616 index e082d94895..56289503a1 100644
1617 --- a/posix/wordexp.c
1618 +++ b/posix/wordexp.c
1619 @@ -1399,7 +1399,7 @@ envsubst:
1620 /* Is it a numeric parameter? */
1621 else if (isdigit (env[0]))
1623 - int n = atoi (env);
1624 + unsigned long n = strtoul (env, NULL, 10);
1626 if (n >= __libc_argc)
1627 /* Substitute NULL. */
1628 diff --git a/resolv/Makefile b/resolv/Makefile
1629 index b61c0c3e0c..dbd8f8bf4f 100644
1630 --- a/resolv/Makefile
1631 +++ b/resolv/Makefile
1632 @@ -61,6 +61,11 @@ tests += \
1634 tst-resolv-trailing \
1636 +# This test calls __res_context_send directly, which is not exported
1638 +tests-internal += tst-resolv-txnid-collision
1639 +tests-static += tst-resolv-txnid-collision
1641 # These tests need libdl.
1642 ifeq (yes,$(build-shared))
1644 @@ -191,6 +196,8 @@ $(objpfx)tst-resolv-search: $(objpfx)libresolv.so $(shared-thread-library)
1645 $(objpfx)tst-resolv-trailing: $(objpfx)libresolv.so $(shared-thread-library)
1646 $(objpfx)tst-resolv-threads: \
1647 $(libdl) $(objpfx)libresolv.so $(shared-thread-library)
1648 +$(objpfx)tst-resolv-txnid-collision: $(objpfx)libresolv.a \
1649 + $(static-thread-library)
1650 $(objpfx)tst-resolv-canonname: \
1651 $(libdl) $(objpfx)libresolv.so $(shared-thread-library)
1652 $(objpfx)tst-resolv-trustad: $(objpfx)libresolv.so $(shared-thread-library)
1653 diff --git a/resolv/res_send.c b/resolv/res_send.c
1654 index 7e5fec6646..70e5066031 100644
1655 --- a/resolv/res_send.c
1656 +++ b/resolv/res_send.c
1657 @@ -1342,15 +1342,6 @@ send_dg(res_state statp,
1659 return close_and_return_error (statp, resplen2);
1661 - if ((recvresp1 || hp->id != anhp->id)
1662 - && (recvresp2 || hp2->id != anhp->id)) {
1664 - * response from old query, ignore it.
1665 - * XXX - potential security hazard could
1666 - * be detected here.
1671 /* Paranoia check. Due to the connected UDP socket,
1672 the kernel has already filtered invalid addresses
1673 @@ -1360,15 +1351,24 @@ send_dg(res_state statp,
1675 /* Check for the correct header layout and a matching
1677 - if ((recvresp1 || !res_queriesmatch(buf, buf + buflen,
1681 - && (recvresp2 || !res_queriesmatch(buf2, buf2 + buflen2,
1686 + int matching_query = 0; /* Default to no matching query. */
1688 + && anhp->id == hp->id
1689 + && res_queriesmatch (buf, buf + buflen,
1690 + *thisansp, *thisansp + *thisanssizp))
1691 + matching_query = 1;
1693 + && anhp->id == hp2->id
1694 + && res_queriesmatch (buf2, buf2 + buflen2,
1695 + *thisansp, *thisansp + *thisanssizp))
1696 + matching_query = 2;
1697 + if (matching_query == 0)
1698 + /* Spurious UDP packet. Drop it and continue
1701 + need_recompute = 1;
1705 if (anhp->rcode == SERVFAIL ||
1706 anhp->rcode == NOTIMP ||
1707 @@ -1383,7 +1383,7 @@ send_dg(res_state statp,
1708 /* No data from the first reply. */
1710 /* We are waiting for a possible second reply. */
1711 - if (hp->id == anhp->id)
1712 + if (matching_query == 1)
1716 @@ -1414,7 +1414,7 @@ send_dg(res_state statp,
1719 /* Mark which reply we received. */
1720 - if (recvresp1 == 0 && hp->id == anhp->id)
1721 + if (matching_query == 1)
1725 diff --git a/resolv/tst-resolv-txnid-collision.c b/resolv/tst-resolv-txnid-collision.c
1726 new file mode 100644
1727 index 0000000000..189b76f126
1729 +++ b/resolv/tst-resolv-txnid-collision.c
1731 +/* Test parallel queries with transaction ID collisions.
1732 + Copyright (C) 2020 Free Software Foundation, Inc.
1733 + This file is part of the GNU C Library.
1735 + The GNU C Library is free software; you can redistribute it and/or
1736 + modify it under the terms of the GNU Lesser General Public
1737 + License as published by the Free Software Foundation; either
1738 + version 2.1 of the License, or (at your option) any later version.
1740 + The GNU C Library is distributed in the hope that it will be useful,
1741 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1742 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1743 + Lesser General Public License for more details.
1745 + You should have received a copy of the GNU Lesser General Public
1746 + License along with the GNU C Library; if not, see
1747 + <https://www.gnu.org/licenses/>. */
1749 +#include <arpa/nameser.h>
1750 +#include <array_length.h>
1751 +#include <resolv-internal.h>
1752 +#include <resolv_context.h>
1753 +#include <stdbool.h>
1755 +#include <string.h>
1756 +#include <support/check.h>
1757 +#include <support/check_nss.h>
1758 +#include <support/resolv_test.h>
1759 +#include <support/support.h>
1760 +#include <support/test-driver.h>
1762 +/* Result of parsing a DNS question name.
1764 + A question name has the form reorder-N-M-rcode-C.example.net, where
1765 + N and M are either 0 and 1, corresponding to the reorder member,
1766 + and C is a number that will be stored in the rcode field.
1768 + Also see parse_qname below. */
1769 +struct parsed_qname
1771 + /* The DNS response code requested from the first server. The
1772 + second server always responds with RCODE zero. */
1775 + /* Indicates whether to perform reordering in the responses from the
1776 + respective server. */
1780 +/* Fills *PARSED based on QNAME. */
1782 +parse_qname (struct parsed_qname *parsed, const char *qname)
1788 + if (sscanf (qname, "reorder-%d-%d.rcode-%d.%ms",
1789 + &reorder0, &reorder1, &rcode, &suffix) == 4)
1791 + if (reorder0 != 0)
1792 + TEST_COMPARE (reorder0, 1);
1793 + if (reorder1 != 0)
1794 + TEST_COMPARE (reorder1, 1);
1795 + TEST_VERIFY (rcode >= 0 && rcode <= 15);
1796 + TEST_COMPARE_STRING (suffix, "example.net");
1799 + parsed->rcode = rcode;
1800 + parsed->reorder[0] = reorder0;
1801 + parsed->reorder[1] = reorder1;
1804 + FAIL_EXIT1 ("unexpected query: %s", qname);
1807 +/* Used to construct a response. The first server responds with an
1808 + error, the second server succeeds. */
1810 +build_response (const struct resolv_response_context *ctx,
1811 + struct resolv_response_builder *b,
1812 + const char *qname, uint16_t qclass, uint16_t qtype)
1814 + struct parsed_qname parsed;
1815 + parse_qname (&parsed, qname);
1817 + switch (ctx->server_index)
1821 + struct resolv_response_flags flags = { 0 };
1822 + if (parsed.rcode == 0)
1823 + /* Simulate a delegation in case a NODATA (RCODE zero)
1824 + response is requested. */
1825 + flags.clear_ra = true;
1827 + flags.rcode = parsed.rcode;
1829 + resolv_response_init (b, flags);
1830 + resolv_response_add_question (b, qname, qclass, qtype);
1836 + struct resolv_response_flags flags = { 0, };
1837 + resolv_response_init (b, flags);
1838 + resolv_response_add_question (b, qname, qclass, qtype);
1840 + resolv_response_section (b, ns_s_an);
1841 + resolv_response_open_record (b, qname, qclass, qtype, 0);
1844 + char ipv4[4] = { 192, 0, 2, 1 };
1845 + resolv_response_add_data (b, &ipv4, sizeof (ipv4));
1850 + = { 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
1851 + resolv_response_add_data (b, &ipv6, sizeof (ipv6));
1853 + resolv_response_close_record (b);
1859 +/* Used to reorder responses. */
1860 +struct resolv_response_context *previous_query;
1862 +/* Used to keep track of the queries received. */
1863 +static int previous_server_index = -1;
1864 +static uint16_t previous_qtype;
1866 +/* For each server, buffer the first query and then send both answers
1867 + to the second query, reordered if requested. */
1869 +response (const struct resolv_response_context *ctx,
1870 + struct resolv_response_builder *b,
1871 + const char *qname, uint16_t qclass, uint16_t qtype)
1873 + TEST_VERIFY (qtype == T_A || qtype == T_AAAA);
1874 + if (ctx->server_index != 0)
1875 + TEST_COMPARE (ctx->server_index, 1);
1877 + struct parsed_qname parsed;
1878 + parse_qname (&parsed, qname);
1880 + if (previous_query == NULL)
1882 + /* No buffered query. Record this query and do not send a
1884 + TEST_COMPARE (previous_qtype, 0);
1885 + previous_query = resolv_response_context_duplicate (ctx);
1886 + previous_qtype = qtype;
1887 + resolv_response_drop (b);
1888 + previous_server_index = ctx->server_index;
1891 + printf ("info: buffering first query for: %s\n", qname);
1895 + TEST_VERIFY (previous_query != 0);
1896 + TEST_COMPARE (ctx->server_index, previous_server_index);
1897 + TEST_VERIFY (previous_qtype != qtype); /* Not a duplicate. */
1899 + /* If reordering, send a response for this query explicitly, and
1900 + then skip the implicit send. */
1901 + if (parsed.reorder[ctx->server_index])
1904 + printf ("info: sending reordered second response for: %s\n",
1906 + build_response (ctx, b, qname, qclass, qtype);
1907 + resolv_response_send_udp (ctx, b);
1908 + resolv_response_drop (b);
1911 + /* Build a response for the previous query and send it, thus
1912 + reordering the two responses. */
1915 + printf ("info: sending first response for: %s\n", qname);
1916 + struct resolv_response_builder *btmp
1917 + = resolv_response_builder_allocate (previous_query->query_buffer,
1918 + previous_query->query_length);
1919 + build_response (ctx, btmp, qname, qclass, previous_qtype);
1920 + resolv_response_send_udp (ctx, btmp);
1921 + resolv_response_builder_free (btmp);
1924 + /* If not reordering, send the reply as usual. */
1925 + if (!parsed.reorder[ctx->server_index])
1928 + printf ("info: sending non-reordered second response for: %s\n",
1930 + build_response (ctx, b, qname, qclass, qtype);
1933 + /* Unbuffer the response and prepare for the next query. */
1934 + resolv_response_context_free (previous_query);
1935 + previous_query = NULL;
1936 + previous_qtype = 0;
1937 + previous_server_index = -1;
1941 +/* Runs a query for QNAME and checks for the expected reply. See
1942 + struct parsed_qname for the expected format for QNAME. */
1944 +test_qname (const char *qname, int rcode)
1946 + struct resolv_context *ctx = __resolv_context_get ();
1947 + TEST_VERIFY_EXIT (ctx != NULL);
1949 + unsigned char q1[512];
1950 + int q1len = res_mkquery (QUERY, qname, C_IN, T_A, NULL, 0, NULL,
1952 + TEST_VERIFY_EXIT (q1len > 12);
1954 + unsigned char q2[512];
1955 + int q2len = res_mkquery (QUERY, qname, C_IN, T_AAAA, NULL, 0, NULL,
1957 + TEST_VERIFY_EXIT (q2len > 12);
1959 + /* Produce a transaction ID collision. */
1960 + memcpy (q2, q1, 2);
1962 + unsigned char ans1[512];
1963 + unsigned char *ans1p = ans1;
1964 + unsigned char *ans2p = NULL;
1967 + int ans2p_malloced = 0;
1969 + /* Perform a parallel A/AAAA query. */
1970 + int resplen1 = __res_context_send (ctx, q1, q1len, q2, q2len,
1971 + ans1, sizeof (ans1), &ans1p,
1973 + &resplen2, &ans2p_malloced);
1975 + TEST_VERIFY (resplen1 > 12);
1976 + TEST_VERIFY (resplen2 > 12);
1977 + if (resplen1 <= 12 || resplen2 <= 12)
1980 + if (rcode == 1 || rcode == 3)
1982 + /* Format Error and Name Error responses does not trigger
1983 + switching to the next server. */
1984 + TEST_COMPARE (ans1p[3] & 0x0f, rcode);
1985 + TEST_COMPARE (ans2p[3] & 0x0f, rcode);
1989 + /* The response should be successful. */
1990 + TEST_COMPARE (ans1p[3] & 0x0f, 0);
1991 + TEST_COMPARE (ans2p[3] & 0x0f, 0);
1993 + /* Due to bug 19691, the answer may not be in the slot matching the
1994 + query. Assume that the AAAA response is the longer one. */
1995 + unsigned char *a_answer;
1996 + int a_answer_length;
1997 + unsigned char *aaaa_answer;
1998 + int aaaa_answer_length;
1999 + if (resplen2 > resplen1)
2002 + a_answer_length = resplen1;
2003 + aaaa_answer = ans2p;
2004 + aaaa_answer_length = resplen2;
2009 + a_answer_length = resplen2;
2010 + aaaa_answer = ans1p;
2011 + aaaa_answer_length = resplen1;
2015 + char *expected = xasprintf ("name: %s\n"
2016 + "address: 192.0.2.1\n",
2018 + check_dns_packet (qname, a_answer, a_answer_length, expected);
2022 + char *expected = xasprintf ("name: %s\n"
2023 + "address: 2001:db8::1\n",
2025 + check_dns_packet (qname, aaaa_answer, aaaa_answer_length, expected);
2029 + if (ans2p_malloced)
2032 + __resolv_context_put (ctx);
2038 + struct resolv_test *aux = resolv_test_start
2039 + ((struct resolv_redirect_config)
2041 + .response_callback = response,
2043 + /* The response callback use global state (the previous_*
2044 + variables), and query processing must therefore be
2046 + .single_thread_udp = true,
2049 + for (int rcode = 0; rcode <= 5; ++rcode)
2050 + for (int do_reorder_0 = 0; do_reorder_0 < 2; ++do_reorder_0)
2051 + for (int do_reorder_1 = 0; do_reorder_1 < 2; ++do_reorder_1)
2053 + char *qname = xasprintf ("reorder-%d-%d.rcode-%d.example.net",
2054 + do_reorder_0, do_reorder_1, rcode);
2055 + test_qname (qname, rcode);
2059 + resolv_test_end (aux);
2064 +#include <support/test-driver.c>
2065 diff --git a/stdio-common/Makefile b/stdio-common/Makefile
2066 index 8475fd1f09..eff0c98d82 100644
2067 --- a/stdio-common/Makefile
2068 +++ b/stdio-common/Makefile
2069 @@ -69,7 +69,8 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
2070 tst-printf-bz25691 \
2071 tst-vfprintf-width-prec-alloc \
2072 tst-printf-fp-free \
2073 - tst-printf-fp-leak
2074 + tst-printf-fp-leak \
2078 test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
2079 diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
2080 index d15f13a22a..2ecf121674 100644
2081 --- a/stdio-common/errlist.c
2082 +++ b/stdio-common/errlist.c
2084 #include <libintl.h>
2085 #include <array_length.h>
2088 +# define ERR_MAP(n) n
2091 const char *const _sys_errlist_internal[] =
2093 -#define _S(n, str) [n] = str,
2094 +#define _S(n, str) [ERR_MAP(n)] = str,
2095 #include <errlist.h>
2098 @@ -41,20 +45,21 @@ static const union sys_errname_t
2100 #define MSGSTRFIELD1(line) str##line
2101 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
2102 -#define _S(n, str) char MSGSTRFIELD(__LINE__)[sizeof(str)];
2103 +#define _S(n, str) char MSGSTRFIELD(__LINE__)[sizeof(#n)];
2104 #include <errlist.h>
2108 } _sys_errname = { {
2109 -#define _S(n, s) s,
2110 +#define _S(n, s) #n,
2111 #include <errlist.h>
2115 static const unsigned short _sys_errnameidx[] =
2117 -#define _S(n, s) [n] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)),
2119 + [ERR_MAP(n)] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)),
2120 #include <errlist.h>
2123 diff --git a/stdio-common/test-strerr.c b/stdio-common/test-strerr.c
2124 index fded208118..d77b81d507 100644
2125 --- a/stdio-common/test-strerr.c
2126 +++ b/stdio-common/test-strerr.c
2127 @@ -18,46 +18,672 @@
2131 -#include <array_length.h>
2133 #include <support/support.h>
2134 #include <support/check.h>
2136 -#define N_(name) name
2138 -static const char *const errlist[] =
2140 -/* This file is auto-generated from errlist.def. */
2141 -#include <errlist.h>
2144 -#define MSGSTR_T errname_t
2145 -#define MSGSTR errname
2146 -#define MSGIDX errnameidx
2147 -#include <errlist-name.h>
2154 - TEST_VERIFY (strerrordesc_np (-1) == NULL);
2155 - TEST_VERIFY (strerrordesc_np (array_length (errlist)) == NULL);
2156 - for (size_t i = 0; i < array_length (errlist); i++)
2158 - if (errlist[i] == NULL)
2160 - TEST_COMPARE_STRING (strerrordesc_np (i), errlist[i]);
2162 + TEST_COMPARE_STRING (strerrordesc_np (0), "Success");
2163 + TEST_COMPARE_STRING (strerrorname_np (0), "0");
2165 - TEST_VERIFY (strerrorname_np (-1) == NULL);
2166 - TEST_VERIFY (strerrorname_np (array_length (errlist)) == NULL);
2167 - for (size_t i = 0; i < array_length (errlist); i++)
2169 - if (errlist[i] == NULL)
2171 - TEST_COMPARE_STRING (strerrorname_np (i), errname.str + errnameidx[i]);
2174 + TEST_COMPARE_STRING (strerrordesc_np (EPERM), "Operation not permitted");
2175 + TEST_COMPARE_STRING (strerrorname_np (EPERM), "EPERM");
2178 + TEST_COMPARE_STRING (strerrordesc_np (ENOENT),
2179 + "No such file or directory");
2180 + TEST_COMPARE_STRING (strerrorname_np (ENOENT), "ENOENT");
2183 + TEST_COMPARE_STRING (strerrordesc_np (ESRCH), "No such process");
2184 + TEST_COMPARE_STRING (strerrorname_np (ESRCH), "ESRCH");
2187 + TEST_COMPARE_STRING (strerrordesc_np (EINTR), "Interrupted system call");
2188 + TEST_COMPARE_STRING (strerrorname_np (EINTR), "EINTR");
2191 + TEST_COMPARE_STRING (strerrordesc_np (EIO), "Input/output error");
2192 + TEST_COMPARE_STRING (strerrorname_np (EIO), "EIO");
2195 + TEST_COMPARE_STRING (strerrordesc_np (ENXIO), "No such device or address");
2196 + TEST_COMPARE_STRING (strerrorname_np (ENXIO), "ENXIO");
2199 + TEST_COMPARE_STRING (strerrordesc_np (E2BIG), "Argument list too long");
2200 + TEST_COMPARE_STRING (strerrorname_np (E2BIG), "E2BIG");
2203 + TEST_COMPARE_STRING (strerrordesc_np (ENOEXEC), "Exec format error");
2204 + TEST_COMPARE_STRING (strerrorname_np (ENOEXEC), "ENOEXEC");
2207 + TEST_COMPARE_STRING (strerrordesc_np (EBADF), "Bad file descriptor");
2208 + TEST_COMPARE_STRING (strerrorname_np (EBADF), "EBADF");
2211 + TEST_COMPARE_STRING (strerrordesc_np (ECHILD), "No child processes");
2212 + TEST_COMPARE_STRING (strerrorname_np (ECHILD), "ECHILD");
2215 + TEST_COMPARE_STRING (strerrordesc_np (EDEADLK),
2216 + "Resource deadlock avoided");
2217 + TEST_COMPARE_STRING (strerrorname_np (EDEADLK), "EDEADLK");
2220 + TEST_COMPARE_STRING (strerrordesc_np (ENOMEM), "Cannot allocate memory");
2221 + TEST_COMPARE_STRING (strerrorname_np (ENOMEM), "ENOMEM");
2224 + TEST_COMPARE_STRING (strerrordesc_np (EACCES), "Permission denied");
2225 + TEST_COMPARE_STRING (strerrorname_np (EACCES), "EACCES");
2228 + TEST_COMPARE_STRING (strerrordesc_np (EFAULT), "Bad address");
2229 + TEST_COMPARE_STRING (strerrorname_np (EFAULT), "EFAULT");
2232 + TEST_COMPARE_STRING (strerrordesc_np (ENOTBLK), "Block device required");
2233 + TEST_COMPARE_STRING (strerrorname_np (ENOTBLK), "ENOTBLK");
2236 + TEST_COMPARE_STRING (strerrordesc_np (EBUSY), "Device or resource busy");
2237 + TEST_COMPARE_STRING (strerrorname_np (EBUSY), "EBUSY");
2240 + TEST_COMPARE_STRING (strerrordesc_np (EEXIST), "File exists");
2241 + TEST_COMPARE_STRING (strerrorname_np (EEXIST), "EEXIST");
2244 + TEST_COMPARE_STRING (strerrordesc_np (EXDEV), "Invalid cross-device link");
2245 + TEST_COMPARE_STRING (strerrorname_np (EXDEV), "EXDEV");
2248 + TEST_COMPARE_STRING (strerrordesc_np (ENODEV), "No such device");
2249 + TEST_COMPARE_STRING (strerrorname_np (ENODEV), "ENODEV");
2252 + TEST_COMPARE_STRING (strerrordesc_np (ENOTDIR), "Not a directory");
2253 + TEST_COMPARE_STRING (strerrorname_np (ENOTDIR), "ENOTDIR");
2256 + TEST_COMPARE_STRING (strerrordesc_np (EISDIR), "Is a directory");
2257 + TEST_COMPARE_STRING (strerrorname_np (EISDIR), "EISDIR");
2260 + TEST_COMPARE_STRING (strerrordesc_np (EINVAL), "Invalid argument");
2261 + TEST_COMPARE_STRING (strerrorname_np (EINVAL), "EINVAL");
2264 + TEST_COMPARE_STRING (strerrordesc_np (EMFILE), "Too many open files");
2265 + TEST_COMPARE_STRING (strerrorname_np (EMFILE), "EMFILE");
2268 + TEST_COMPARE_STRING (strerrordesc_np (ENFILE),
2269 + "Too many open files in system");
2270 + TEST_COMPARE_STRING (strerrorname_np (ENFILE), "ENFILE");
2273 + TEST_COMPARE_STRING (strerrordesc_np (ENOTTY),
2274 + "Inappropriate ioctl for device");
2275 + TEST_COMPARE_STRING (strerrorname_np (ENOTTY), "ENOTTY");
2278 + TEST_COMPARE_STRING (strerrordesc_np (ETXTBSY), "Text file busy");
2279 + TEST_COMPARE_STRING (strerrorname_np (ETXTBSY), "ETXTBSY");
2282 + TEST_COMPARE_STRING (strerrordesc_np (EFBIG), "File too large");
2283 + TEST_COMPARE_STRING (strerrorname_np (EFBIG), "EFBIG");
2286 + TEST_COMPARE_STRING (strerrordesc_np (ENOSPC), "No space left on device");
2287 + TEST_COMPARE_STRING (strerrorname_np (ENOSPC), "ENOSPC");
2290 + TEST_COMPARE_STRING (strerrordesc_np (ESPIPE), "Illegal seek");
2291 + TEST_COMPARE_STRING (strerrorname_np (ESPIPE), "ESPIPE");
2294 + TEST_COMPARE_STRING (strerrordesc_np (EROFS), "Read-only file system");
2295 + TEST_COMPARE_STRING (strerrorname_np (EROFS), "EROFS");
2298 + TEST_COMPARE_STRING (strerrordesc_np (EMLINK), "Too many links");
2299 + TEST_COMPARE_STRING (strerrorname_np (EMLINK), "EMLINK");
2302 + TEST_COMPARE_STRING (strerrordesc_np (EPIPE), "Broken pipe");
2303 + TEST_COMPARE_STRING (strerrorname_np (EPIPE), "EPIPE");
2306 + TEST_COMPARE_STRING (strerrordesc_np (EDOM),
2307 + "Numerical argument out of domain");
2308 + TEST_COMPARE_STRING (strerrorname_np (EDOM), "EDOM");
2311 + TEST_COMPARE_STRING (strerrordesc_np (ERANGE),
2312 + "Numerical result out of range");
2313 + TEST_COMPARE_STRING (strerrorname_np (ERANGE), "ERANGE");
2316 + TEST_COMPARE_STRING (strerrordesc_np (EAGAIN),
2317 + "Resource temporarily unavailable");
2318 + TEST_COMPARE_STRING (strerrorname_np (EAGAIN), "EAGAIN");
2321 + TEST_COMPARE_STRING (strerrordesc_np (EINPROGRESS),
2322 + "Operation now in progress");
2323 + TEST_COMPARE_STRING (strerrorname_np (EINPROGRESS), "EINPROGRESS");
2326 + TEST_COMPARE_STRING (strerrordesc_np (EALREADY),
2327 + "Operation already in progress");
2328 + TEST_COMPARE_STRING (strerrorname_np (EALREADY), "EALREADY");
2331 + TEST_COMPARE_STRING (strerrordesc_np (ENOTSOCK),
2332 + "Socket operation on non-socket");
2333 + TEST_COMPARE_STRING (strerrorname_np (ENOTSOCK), "ENOTSOCK");
2336 + TEST_COMPARE_STRING (strerrordesc_np (EMSGSIZE), "Message too long");
2337 + TEST_COMPARE_STRING (strerrorname_np (EMSGSIZE), "EMSGSIZE");
2340 + TEST_COMPARE_STRING (strerrordesc_np (EPROTOTYPE),
2341 + "Protocol wrong type for socket");
2342 + TEST_COMPARE_STRING (strerrorname_np (EPROTOTYPE), "EPROTOTYPE");
2345 + TEST_COMPARE_STRING (strerrordesc_np (ENOPROTOOPT),
2346 + "Protocol not available");
2347 + TEST_COMPARE_STRING (strerrorname_np (ENOPROTOOPT), "ENOPROTOOPT");
2349 +#ifdef EPROTONOSUPPORT
2350 + TEST_COMPARE_STRING (strerrordesc_np (EPROTONOSUPPORT),
2351 + "Protocol not supported");
2352 + TEST_COMPARE_STRING (strerrorname_np (EPROTONOSUPPORT), "EPROTONOSUPPORT");
2354 +#ifdef ESOCKTNOSUPPORT
2355 + TEST_COMPARE_STRING (strerrordesc_np (ESOCKTNOSUPPORT),
2356 + "Socket type not supported");
2357 + TEST_COMPARE_STRING (strerrorname_np (ESOCKTNOSUPPORT), "ESOCKTNOSUPPORT");
2360 + TEST_COMPARE_STRING (strerrordesc_np (EOPNOTSUPP),
2361 + "Operation not supported");
2362 + TEST_COMPARE_STRING (strerrorname_np (EOPNOTSUPP), "EOPNOTSUPP");
2364 +#ifdef EPFNOSUPPORT
2365 + TEST_COMPARE_STRING (strerrordesc_np (EPFNOSUPPORT),
2366 + "Protocol family not supported");
2367 + TEST_COMPARE_STRING (strerrorname_np (EPFNOSUPPORT), "EPFNOSUPPORT");
2369 +#ifdef EAFNOSUPPORT
2370 + TEST_COMPARE_STRING (strerrordesc_np (EAFNOSUPPORT),
2371 + "Address family not supported by protocol");
2372 + TEST_COMPARE_STRING (strerrorname_np (EAFNOSUPPORT), "EAFNOSUPPORT");
2375 + TEST_COMPARE_STRING (strerrordesc_np (EADDRINUSE),
2376 + "Address already in use");
2377 + TEST_COMPARE_STRING (strerrorname_np (EADDRINUSE), "EADDRINUSE");
2379 +#ifdef EADDRNOTAVAIL
2380 + TEST_COMPARE_STRING (strerrordesc_np (EADDRNOTAVAIL),
2381 + "Cannot assign requested address");
2382 + TEST_COMPARE_STRING (strerrorname_np (EADDRNOTAVAIL), "EADDRNOTAVAIL");
2385 + TEST_COMPARE_STRING (strerrordesc_np (ENETDOWN), "Network is down");
2386 + TEST_COMPARE_STRING (strerrorname_np (ENETDOWN), "ENETDOWN");
2389 + TEST_COMPARE_STRING (strerrordesc_np (ENETUNREACH),
2390 + "Network is unreachable");
2391 + TEST_COMPARE_STRING (strerrorname_np (ENETUNREACH), "ENETUNREACH");
2394 + TEST_COMPARE_STRING (strerrordesc_np (ENETRESET),
2395 + "Network dropped connection on reset");
2396 + TEST_COMPARE_STRING (strerrorname_np (ENETRESET), "ENETRESET");
2398 +#ifdef ECONNABORTED
2399 + TEST_COMPARE_STRING (strerrordesc_np (ECONNABORTED),
2400 + "Software caused connection abort");
2401 + TEST_COMPARE_STRING (strerrorname_np (ECONNABORTED), "ECONNABORTED");
2404 + TEST_COMPARE_STRING (strerrordesc_np (ECONNRESET),
2405 + "Connection reset by peer");
2406 + TEST_COMPARE_STRING (strerrorname_np (ECONNRESET), "ECONNRESET");
2409 + TEST_COMPARE_STRING (strerrordesc_np (ENOBUFS),
2410 + "No buffer space available");
2411 + TEST_COMPARE_STRING (strerrorname_np (ENOBUFS), "ENOBUFS");
2414 + TEST_COMPARE_STRING (strerrordesc_np (EISCONN),
2415 + "Transport endpoint is already connected");
2416 + TEST_COMPARE_STRING (strerrorname_np (EISCONN), "EISCONN");
2419 + TEST_COMPARE_STRING (strerrordesc_np (ENOTCONN),
2420 + "Transport endpoint is not connected");
2421 + TEST_COMPARE_STRING (strerrorname_np (ENOTCONN), "ENOTCONN");
2423 +#ifdef EDESTADDRREQ
2424 + TEST_COMPARE_STRING (strerrordesc_np (EDESTADDRREQ),
2425 + "Destination address required");
2426 + TEST_COMPARE_STRING (strerrorname_np (EDESTADDRREQ), "EDESTADDRREQ");
2429 + TEST_COMPARE_STRING (strerrordesc_np (ESHUTDOWN),
2430 + "Cannot send after transport endpoint shutdown");
2431 + TEST_COMPARE_STRING (strerrorname_np (ESHUTDOWN), "ESHUTDOWN");
2433 +#ifdef ETOOMANYREFS
2434 + TEST_COMPARE_STRING (strerrordesc_np (ETOOMANYREFS),
2435 + "Too many references: cannot splice");
2436 + TEST_COMPARE_STRING (strerrorname_np (ETOOMANYREFS), "ETOOMANYREFS");
2439 + TEST_COMPARE_STRING (strerrordesc_np (ETIMEDOUT), "Connection timed out");
2440 + TEST_COMPARE_STRING (strerrorname_np (ETIMEDOUT), "ETIMEDOUT");
2442 +#ifdef ECONNREFUSED
2443 + TEST_COMPARE_STRING (strerrordesc_np (ECONNREFUSED), "Connection refused");
2444 + TEST_COMPARE_STRING (strerrorname_np (ECONNREFUSED), "ECONNREFUSED");
2447 + TEST_COMPARE_STRING (strerrordesc_np (ELOOP),
2448 + "Too many levels of symbolic links");
2449 + TEST_COMPARE_STRING (strerrorname_np (ELOOP), "ELOOP");
2451 +#ifdef ENAMETOOLONG
2452 + TEST_COMPARE_STRING (strerrordesc_np (ENAMETOOLONG), "File name too long");
2453 + TEST_COMPARE_STRING (strerrorname_np (ENAMETOOLONG), "ENAMETOOLONG");
2456 + TEST_COMPARE_STRING (strerrordesc_np (EHOSTDOWN), "Host is down");
2457 + TEST_COMPARE_STRING (strerrorname_np (EHOSTDOWN), "EHOSTDOWN");
2459 +#ifdef EHOSTUNREACH
2460 + TEST_COMPARE_STRING (strerrordesc_np (EHOSTUNREACH), "No route to host");
2461 + TEST_COMPARE_STRING (strerrorname_np (EHOSTUNREACH), "EHOSTUNREACH");
2464 + TEST_COMPARE_STRING (strerrordesc_np (ENOTEMPTY), "Directory not empty");
2465 + TEST_COMPARE_STRING (strerrorname_np (ENOTEMPTY), "ENOTEMPTY");
2468 + TEST_COMPARE_STRING (strerrordesc_np (EUSERS), "Too many users");
2469 + TEST_COMPARE_STRING (strerrorname_np (EUSERS), "EUSERS");
2472 + TEST_COMPARE_STRING (strerrordesc_np (EDQUOT), "Disk quota exceeded");
2473 + TEST_COMPARE_STRING (strerrorname_np (EDQUOT), "EDQUOT");
2476 + TEST_COMPARE_STRING (strerrordesc_np (ESTALE), "Stale file handle");
2477 + TEST_COMPARE_STRING (strerrorname_np (ESTALE), "ESTALE");
2480 + TEST_COMPARE_STRING (strerrordesc_np (EREMOTE), "Object is remote");
2481 + TEST_COMPARE_STRING (strerrorname_np (EREMOTE), "EREMOTE");
2484 + TEST_COMPARE_STRING (strerrordesc_np (ENOLCK), "No locks available");
2485 + TEST_COMPARE_STRING (strerrorname_np (ENOLCK), "ENOLCK");
2488 + TEST_COMPARE_STRING (strerrordesc_np (ENOSYS), "Function not implemented");
2489 + TEST_COMPARE_STRING (strerrorname_np (ENOSYS), "ENOSYS");
2492 + TEST_COMPARE_STRING (strerrordesc_np (EILSEQ),
2493 + "Invalid or incomplete multibyte or wide character");
2494 + TEST_COMPARE_STRING (strerrorname_np (EILSEQ), "EILSEQ");
2497 + TEST_COMPARE_STRING (strerrordesc_np (EBADMSG), "Bad message");
2498 + TEST_COMPARE_STRING (strerrorname_np (EBADMSG), "EBADMSG");
2501 + TEST_COMPARE_STRING (strerrordesc_np (EIDRM), "Identifier removed");
2502 + TEST_COMPARE_STRING (strerrorname_np (EIDRM), "EIDRM");
2505 + TEST_COMPARE_STRING (strerrordesc_np (EMULTIHOP), "Multihop attempted");
2506 + TEST_COMPARE_STRING (strerrorname_np (EMULTIHOP), "EMULTIHOP");
2509 + TEST_COMPARE_STRING (strerrordesc_np (ENODATA), "No data available");
2510 + TEST_COMPARE_STRING (strerrorname_np (ENODATA), "ENODATA");
2513 + TEST_COMPARE_STRING (strerrordesc_np (ENOLINK), "Link has been severed");
2514 + TEST_COMPARE_STRING (strerrorname_np (ENOLINK), "ENOLINK");
2517 + TEST_COMPARE_STRING (strerrordesc_np (ENOMSG),
2518 + "No message of desired type");
2519 + TEST_COMPARE_STRING (strerrorname_np (ENOMSG), "ENOMSG");
2522 + TEST_COMPARE_STRING (strerrordesc_np (ENOSR), "Out of streams resources");
2523 + TEST_COMPARE_STRING (strerrorname_np (ENOSR), "ENOSR");
2526 + TEST_COMPARE_STRING (strerrordesc_np (ENOSTR), "Device not a stream");
2527 + TEST_COMPARE_STRING (strerrorname_np (ENOSTR), "ENOSTR");
2530 + TEST_COMPARE_STRING (strerrordesc_np (EOVERFLOW),
2531 + "Value too large for defined data type");
2532 + TEST_COMPARE_STRING (strerrorname_np (EOVERFLOW), "EOVERFLOW");
2535 + TEST_COMPARE_STRING (strerrordesc_np (EPROTO), "Protocol error");
2536 + TEST_COMPARE_STRING (strerrorname_np (EPROTO), "EPROTO");
2539 + TEST_COMPARE_STRING (strerrordesc_np (ETIME), "Timer expired");
2540 + TEST_COMPARE_STRING (strerrorname_np (ETIME), "ETIME");
2543 + TEST_COMPARE_STRING (strerrordesc_np (ECANCELED), "Operation canceled");
2544 + TEST_COMPARE_STRING (strerrorname_np (ECANCELED), "ECANCELED");
2547 + TEST_COMPARE_STRING (strerrordesc_np (EOWNERDEAD), "Owner died");
2548 + TEST_COMPARE_STRING (strerrorname_np (EOWNERDEAD), "EOWNERDEAD");
2550 +#ifdef ENOTRECOVERABLE
2551 + TEST_COMPARE_STRING (strerrordesc_np (ENOTRECOVERABLE),
2552 + "State not recoverable");
2553 + TEST_COMPARE_STRING (strerrorname_np (ENOTRECOVERABLE), "ENOTRECOVERABLE");
2556 + TEST_COMPARE_STRING (strerrordesc_np (ERESTART),
2557 + "Interrupted system call should be restarted");
2558 + TEST_COMPARE_STRING (strerrorname_np (ERESTART), "ERESTART");
2561 + TEST_COMPARE_STRING (strerrordesc_np (ECHRNG),
2562 + "Channel number out of range");
2563 + TEST_COMPARE_STRING (strerrorname_np (ECHRNG), "ECHRNG");
2566 + TEST_COMPARE_STRING (strerrordesc_np (EL2NSYNC),
2567 + "Level 2 not synchronized");
2568 + TEST_COMPARE_STRING (strerrorname_np (EL2NSYNC), "EL2NSYNC");
2571 + TEST_COMPARE_STRING (strerrordesc_np (EL3HLT), "Level 3 halted");
2572 + TEST_COMPARE_STRING (strerrorname_np (EL3HLT), "EL3HLT");
2575 + TEST_COMPARE_STRING (strerrordesc_np (EL3RST), "Level 3 reset");
2576 + TEST_COMPARE_STRING (strerrorname_np (EL3RST), "EL3RST");
2579 + TEST_COMPARE_STRING (strerrordesc_np (ELNRNG), "Link number out of range");
2580 + TEST_COMPARE_STRING (strerrorname_np (ELNRNG), "ELNRNG");
2583 + TEST_COMPARE_STRING (strerrordesc_np (EUNATCH),
2584 + "Protocol driver not attached");
2585 + TEST_COMPARE_STRING (strerrorname_np (EUNATCH), "EUNATCH");
2588 + TEST_COMPARE_STRING (strerrordesc_np (ENOCSI),
2589 + "No CSI structure available");
2590 + TEST_COMPARE_STRING (strerrorname_np (ENOCSI), "ENOCSI");
2593 + TEST_COMPARE_STRING (strerrordesc_np (EL2HLT), "Level 2 halted");
2594 + TEST_COMPARE_STRING (strerrorname_np (EL2HLT), "EL2HLT");
2597 + TEST_COMPARE_STRING (strerrordesc_np (EBADE), "Invalid exchange");
2598 + TEST_COMPARE_STRING (strerrorname_np (EBADE), "EBADE");
2601 + TEST_COMPARE_STRING (strerrordesc_np (EBADR),
2602 + "Invalid request descriptor");
2603 + TEST_COMPARE_STRING (strerrorname_np (EBADR), "EBADR");
2606 + TEST_COMPARE_STRING (strerrordesc_np (EXFULL), "Exchange full");
2607 + TEST_COMPARE_STRING (strerrorname_np (EXFULL), "EXFULL");
2610 + TEST_COMPARE_STRING (strerrordesc_np (ENOANO), "No anode");
2611 + TEST_COMPARE_STRING (strerrorname_np (ENOANO), "ENOANO");
2614 + TEST_COMPARE_STRING (strerrordesc_np (EBADRQC), "Invalid request code");
2615 + TEST_COMPARE_STRING (strerrorname_np (EBADRQC), "EBADRQC");
2618 + TEST_COMPARE_STRING (strerrordesc_np (EBADSLT), "Invalid slot");
2619 + TEST_COMPARE_STRING (strerrorname_np (EBADSLT), "EBADSLT");
2622 + TEST_COMPARE_STRING (strerrordesc_np (EBFONT), "Bad font file format");
2623 + TEST_COMPARE_STRING (strerrorname_np (EBFONT), "EBFONT");
2626 + TEST_COMPARE_STRING (strerrordesc_np (ENONET),
2627 + "Machine is not on the network");
2628 + TEST_COMPARE_STRING (strerrorname_np (ENONET), "ENONET");
2631 + TEST_COMPARE_STRING (strerrordesc_np (ENOPKG), "Package not installed");
2632 + TEST_COMPARE_STRING (strerrorname_np (ENOPKG), "ENOPKG");
2635 + TEST_COMPARE_STRING (strerrordesc_np (EADV), "Advertise error");
2636 + TEST_COMPARE_STRING (strerrorname_np (EADV), "EADV");
2639 + TEST_COMPARE_STRING (strerrordesc_np (ESRMNT), "Srmount error");
2640 + TEST_COMPARE_STRING (strerrorname_np (ESRMNT), "ESRMNT");
2643 + TEST_COMPARE_STRING (strerrordesc_np (ECOMM),
2644 + "Communication error on send");
2645 + TEST_COMPARE_STRING (strerrorname_np (ECOMM), "ECOMM");
2648 + TEST_COMPARE_STRING (strerrordesc_np (EDOTDOT), "RFS specific error");
2649 + TEST_COMPARE_STRING (strerrorname_np (EDOTDOT), "EDOTDOT");
2652 + TEST_COMPARE_STRING (strerrordesc_np (ENOTUNIQ),
2653 + "Name not unique on network");
2654 + TEST_COMPARE_STRING (strerrorname_np (ENOTUNIQ), "ENOTUNIQ");
2657 + TEST_COMPARE_STRING (strerrordesc_np (EBADFD),
2658 + "File descriptor in bad state");
2659 + TEST_COMPARE_STRING (strerrorname_np (EBADFD), "EBADFD");
2662 + TEST_COMPARE_STRING (strerrordesc_np (EREMCHG), "Remote address changed");
2663 + TEST_COMPARE_STRING (strerrorname_np (EREMCHG), "EREMCHG");
2666 + TEST_COMPARE_STRING (strerrordesc_np (ELIBACC),
2667 + "Can not access a needed shared library");
2668 + TEST_COMPARE_STRING (strerrorname_np (ELIBACC), "ELIBACC");
2671 + TEST_COMPARE_STRING (strerrordesc_np (ELIBBAD),
2672 + "Accessing a corrupted shared library");
2673 + TEST_COMPARE_STRING (strerrorname_np (ELIBBAD), "ELIBBAD");
2676 + TEST_COMPARE_STRING (strerrordesc_np (ELIBSCN),
2677 + ".lib section in a.out corrupted");
2678 + TEST_COMPARE_STRING (strerrorname_np (ELIBSCN), "ELIBSCN");
2681 + TEST_COMPARE_STRING (strerrordesc_np (ELIBMAX),
2682 + "Attempting to link in too many shared libraries");
2683 + TEST_COMPARE_STRING (strerrorname_np (ELIBMAX), "ELIBMAX");
2686 + TEST_COMPARE_STRING (strerrordesc_np (ELIBEXEC),
2687 + "Cannot exec a shared library directly");
2688 + TEST_COMPARE_STRING (strerrorname_np (ELIBEXEC), "ELIBEXEC");
2691 + TEST_COMPARE_STRING (strerrordesc_np (ESTRPIPE), "Streams pipe error");
2692 + TEST_COMPARE_STRING (strerrorname_np (ESTRPIPE), "ESTRPIPE");
2695 + TEST_COMPARE_STRING (strerrordesc_np (EUCLEAN),
2696 + "Structure needs cleaning");
2697 + TEST_COMPARE_STRING (strerrorname_np (EUCLEAN), "EUCLEAN");
2700 + TEST_COMPARE_STRING (strerrordesc_np (ENOTNAM),
2701 + "Not a XENIX named type file");
2702 + TEST_COMPARE_STRING (strerrorname_np (ENOTNAM), "ENOTNAM");
2705 + TEST_COMPARE_STRING (strerrordesc_np (ENAVAIL),
2706 + "No XENIX semaphores available");
2707 + TEST_COMPARE_STRING (strerrorname_np (ENAVAIL), "ENAVAIL");
2710 + TEST_COMPARE_STRING (strerrordesc_np (EISNAM), "Is a named type file");
2711 + TEST_COMPARE_STRING (strerrorname_np (EISNAM), "EISNAM");
2714 + TEST_COMPARE_STRING (strerrordesc_np (EREMOTEIO), "Remote I/O error");
2715 + TEST_COMPARE_STRING (strerrorname_np (EREMOTEIO), "EREMOTEIO");
2718 + TEST_COMPARE_STRING (strerrordesc_np (ENOMEDIUM), "No medium found");
2719 + TEST_COMPARE_STRING (strerrorname_np (ENOMEDIUM), "ENOMEDIUM");
2722 + TEST_COMPARE_STRING (strerrordesc_np (EMEDIUMTYPE), "Wrong medium type");
2723 + TEST_COMPARE_STRING (strerrorname_np (EMEDIUMTYPE), "EMEDIUMTYPE");
2726 + TEST_COMPARE_STRING (strerrordesc_np (ENOKEY),
2727 + "Required key not available");
2728 + TEST_COMPARE_STRING (strerrorname_np (ENOKEY), "ENOKEY");
2731 + TEST_COMPARE_STRING (strerrordesc_np (EKEYEXPIRED), "Key has expired");
2732 + TEST_COMPARE_STRING (strerrorname_np (EKEYEXPIRED), "EKEYEXPIRED");
2735 + TEST_COMPARE_STRING (strerrordesc_np (EKEYREVOKED),
2736 + "Key has been revoked");
2737 + TEST_COMPARE_STRING (strerrorname_np (EKEYREVOKED), "EKEYREVOKED");
2739 +#ifdef EKEYREJECTED
2740 + TEST_COMPARE_STRING (strerrordesc_np (EKEYREJECTED),
2741 + "Key was rejected by service");
2742 + TEST_COMPARE_STRING (strerrorname_np (EKEYREJECTED), "EKEYREJECTED");
2745 + TEST_COMPARE_STRING (strerrordesc_np (ERFKILL),
2746 + "Operation not possible due to RF-kill");
2747 + TEST_COMPARE_STRING (strerrorname_np (ERFKILL), "ERFKILL");
2750 + TEST_COMPARE_STRING (strerrordesc_np (EHWPOISON),
2751 + "Memory page has hardware error");
2752 + TEST_COMPARE_STRING (strerrorname_np (EHWPOISON), "EHWPOISON");
2755 + TEST_COMPARE_STRING (strerrordesc_np (EBADRPC), "RPC struct is bad");
2756 + TEST_COMPARE_STRING (strerrorname_np (EBADRPC), "EBADRPC");
2759 + TEST_COMPARE_STRING (strerrordesc_np (EFTYPE),
2760 + "Inappropriate file type or format");
2761 + TEST_COMPARE_STRING (strerrorname_np (EFTYPE), "EFTYPE");
2763 +#ifdef EPROCUNAVAIL
2764 + TEST_COMPARE_STRING (strerrordesc_np (EPROCUNAVAIL),
2765 + "RPC bad procedure for program");
2766 + TEST_COMPARE_STRING (strerrorname_np (EPROCUNAVAIL), "EPROCUNAVAIL");
2769 + TEST_COMPARE_STRING (strerrordesc_np (EAUTH), "Authentication error");
2770 + TEST_COMPARE_STRING (strerrorname_np (EAUTH), "EAUTH");
2773 + TEST_COMPARE_STRING (strerrordesc_np (EDIED), "Translator died");
2774 + TEST_COMPARE_STRING (strerrorname_np (EDIED), "EDIED");
2776 +#ifdef ERPCMISMATCH
2777 + TEST_COMPARE_STRING (strerrordesc_np (ERPCMISMATCH), "RPC version wrong");
2778 + TEST_COMPARE_STRING (strerrorname_np (ERPCMISMATCH), "ERPCMISMATCH");
2781 + TEST_COMPARE_STRING (strerrordesc_np (EGREGIOUS),
2782 + "You really blew it this time");
2783 + TEST_COMPARE_STRING (strerrorname_np (EGREGIOUS), "EGREGIOUS");
2786 + TEST_COMPARE_STRING (strerrordesc_np (EPROCLIM), "Too many processes");
2787 + TEST_COMPARE_STRING (strerrorname_np (EPROCLIM), "EPROCLIM");
2790 + TEST_COMPARE_STRING (strerrordesc_np (EGRATUITOUS), "Gratuitous error");
2791 + TEST_COMPARE_STRING (strerrorname_np (EGRATUITOUS), "EGRATUITOUS");
2793 +#if defined (ENOTSUP) && ENOTSUP != EOPNOTSUPP
2794 + TEST_COMPARE_STRING (strerrordesc_np (ENOTSUP), "Not supported");
2795 + TEST_COMPARE_STRING (strerrorname_np (ENOTSUP), "ENOTSUP");
2797 +#ifdef EPROGMISMATCH
2798 + TEST_COMPARE_STRING (strerrordesc_np (EPROGMISMATCH),
2799 + "RPC program version wrong");
2800 + TEST_COMPARE_STRING (strerrorname_np (EPROGMISMATCH), "EPROGMISMATCH");
2803 + TEST_COMPARE_STRING (strerrordesc_np (EBACKGROUND),
2804 + "Inappropriate operation for background process");
2805 + TEST_COMPARE_STRING (strerrorname_np (EBACKGROUND), "EBACKGROUND");
2808 + TEST_COMPARE_STRING (strerrordesc_np (EIEIO), "Computer bought the farm");
2809 + TEST_COMPARE_STRING (strerrorname_np (EIEIO), "EIEIO");
2811 +#if defined (EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
2812 + TEST_COMPARE_STRING (strerrordesc_np (EWOULDBLOCK),
2813 + "Operation would block");
2814 + TEST_COMPARE_STRING (strerrorname_np (EWOULDBLOCK), "EWOULDBLOCK");
2817 + TEST_COMPARE_STRING (strerrordesc_np (ENEEDAUTH), "Need authenticator");
2818 + TEST_COMPARE_STRING (strerrorname_np (ENEEDAUTH), "ENEEDAUTH");
2821 + TEST_COMPARE_STRING (strerrordesc_np (ED), "?");
2822 + TEST_COMPARE_STRING (strerrorname_np (ED), "ED");
2824 +#ifdef EPROGUNAVAIL
2825 + TEST_COMPARE_STRING (strerrordesc_np (EPROGUNAVAIL),
2826 + "RPC program not available");
2827 + TEST_COMPARE_STRING (strerrorname_np (EPROGUNAVAIL), "EPROGUNAVAIL");
2832 diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
2833 index 95b46dcbeb..3a323547f9 100644
2834 --- a/stdio-common/vfscanf-internal.c
2835 +++ b/stdio-common/vfscanf-internal.c
2836 @@ -277,7 +277,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2840 - const CHAR_T *f = format;
2841 + const UCHAR_T *f = (const UCHAR_T *) format;
2842 UCHAR_T fc; /* Current character of the format. */
2843 WINT_T done = 0; /* Assignments done. */
2844 size_t read_in = 0; /* Chars read in. */
2845 @@ -415,10 +415,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2848 #ifndef COMPILE_WSCANF
2849 - if (!isascii ((unsigned char) *f))
2850 + if (!isascii (*f))
2852 /* Non-ASCII, may be a multibyte. */
2853 - int len = __mbrlen (f, strlen (f), &state);
2854 + int len = __mbrlen ((const char *) f, strlen ((const char *) f),
2859 @@ -426,7 +427,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2861 if (__glibc_unlikely (c == EOF))
2863 - else if (c != (unsigned char) *f++)
2864 + else if (c != *f++)
2866 ungetc_not_eof (c, s);
2868 @@ -484,9 +485,9 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2869 char_buffer_rewind (&charbuf);
2871 /* Check for a positional parameter specification. */
2872 - if (ISDIGIT ((UCHAR_T) *f))
2875 - argpos = read_int ((const UCHAR_T **) &f);
2876 + argpos = read_int (&f);
2880 @@ -521,8 +522,8 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2882 /* Find the maximum field width. */
2884 - if (ISDIGIT ((UCHAR_T) *f))
2885 - width = read_int ((const UCHAR_T **) &f);
2887 + width = read_int (&f);
2891 @@ -2522,12 +2523,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
2894 while ((fc = *f++) != '\0' && fc != ']')
2895 - if (fc == '-' && *f != '\0' && *f != ']'
2896 - && (unsigned char) f[-2] <= (unsigned char) *f)
2897 + if (fc == '-' && *f != '\0' && *f != ']' && f[-2] <= *f)
2899 /* Add all characters from the one before the '-'
2900 up to (but not including) the next format char. */
2901 - for (fc = (unsigned char) f[-2]; fc < (unsigned char) *f; ++fc)
2902 + for (fc = f[-2]; fc < *f; ++fc)
2903 ((char *)charbuf.scratch.data)[fc] = 1;
2906 diff --git a/stdlib/tst-secure-getenv.c b/stdlib/tst-secure-getenv.c
2907 index 3cfe9a05c3..d4b1139c5e 100644
2908 --- a/stdlib/tst-secure-getenv.c
2909 +++ b/stdlib/tst-secure-getenv.c
2910 @@ -30,167 +30,12 @@
2911 #include <sys/wait.h>
2914 +#include <support/check.h>
2915 #include <support/support.h>
2916 +#include <support/capture_subprocess.h>
2917 #include <support/test-driver.h>
2919 static char MAGIC_ARGUMENT[] = "run-actual-test";
2920 -#define MAGIC_STATUS 19
2922 -/* Return a GID which is not our current GID, but is present in the
2923 - supplementary group list. */
2927 - int count = getgroups (0, NULL);
2930 - printf ("getgroups: %m\n");
2934 - groups = xcalloc (count, sizeof (*groups));
2935 - int ret = getgroups (count, groups);
2938 - printf ("getgroups: %m\n");
2941 - gid_t current = getgid ();
2942 - gid_t not_current = 0;
2943 - for (int i = 0; i < ret; ++i)
2945 - if (groups[i] != current)
2947 - not_current = groups[i];
2952 - return not_current;
2956 -/* Copies the executable into a restricted directory, so that we can
2957 - safely make it SGID with the TARGET group ID. Then runs the
2960 -run_executable_sgid (gid_t target)
2962 - char *dirname = xasprintf ("%s/secure-getenv.%jd",
2963 - test_dir, (intmax_t) getpid ());
2964 - char *execname = xasprintf ("%s/bin", dirname);
2968 - if (mkdir (dirname, 0700) < 0)
2970 - printf ("mkdir: %m\n");
2973 - infd = open ("/proc/self/exe", O_RDONLY);
2976 - printf ("open (/proc/self/exe): %m\n");
2979 - outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700);
2982 - printf ("open (%s): %m\n", execname);
2988 - ssize_t rdcount = read (infd, buf, sizeof (buf));
2991 - printf ("read: %m\n");
2997 - char *end = buf + rdcount;
3000 - ssize_t wrcount = write (outfd, buf, end - p);
3005 - printf ("write: %m\n");
3011 - if (fchown (outfd, getuid (), target) < 0)
3013 - printf ("fchown (%s): %m\n", execname);
3016 - if (fchmod (outfd, 02750) < 0)
3018 - printf ("fchmod (%s): %m\n", execname);
3021 - if (close (outfd) < 0)
3023 - printf ("close (outfd): %m\n");
3026 - if (close (infd) < 0)
3028 - printf ("close (infd): %m\n");
3032 - int kid = fork ();
3035 - printf ("fork: %m\n");
3040 - /* Child process. */
3041 - char *args[] = { execname, MAGIC_ARGUMENT, NULL };
3042 - execve (execname, args, environ);
3043 - printf ("execve (%s): %m\n", execname);
3047 - if (waitpid (kid, &status, 0) < 0)
3049 - printf ("waitpid: %m\n");
3052 - if (!WIFEXITED (status) || WEXITSTATUS (status) != MAGIC_STATUS)
3054 - printf ("Unexpected exit status %d from child process\n",
3067 - unlink (execname);
3080 @@ -212,15 +57,15 @@ do_test (void)
3084 - gid_t target = choose_gid ();
3088 - "Could not find a suitable GID for user %jd, skipping test\n",
3089 - (intmax_t) getuid ());
3092 - return run_executable_sgid (target);
3093 + int status = support_capture_subprogram_self_sgid (MAGIC_ARGUMENT);
3095 + if (WEXITSTATUS (status) == EXIT_UNSUPPORTED)
3096 + return EXIT_UNSUPPORTED;
3098 + if (!WIFEXITED (status))
3099 + FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status);
3105 @@ -229,23 +74,15 @@ alternative_main (int argc, char **argv)
3106 if (argc == 2 && strcmp (argv[1], MAGIC_ARGUMENT) == 0)
3108 if (getgid () == getegid ())
3110 - /* This can happen if the file system is mounted nosuid. */
3111 - fprintf (stderr, "SGID failed: GID and EGID match (%jd)\n",
3112 - (intmax_t) getgid ());
3113 - exit (MAGIC_STATUS);
3115 + /* This can happen if the file system is mounted nosuid. */
3116 + FAIL_UNSUPPORTED ("SGID failed: GID and EGID match (%jd)\n",
3117 + (intmax_t) getgid ());
3118 if (getenv ("PATH") == NULL)
3120 - printf ("PATH variable not present\n");
3123 + FAIL_EXIT (3, "PATH variable not present\n");
3124 if (secure_getenv ("PATH") != NULL)
3126 - printf ("PATH variable not filtered out\n");
3129 - exit (MAGIC_STATUS);
3130 + FAIL_EXIT (4, "PATH variable not filtered out\n");
3132 + exit (EXIT_SUCCESS);
3136 diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
3137 index 309d0f39b2..c8d3051af8 100644
3138 --- a/string/bits/string_fortified.h
3139 +++ b/string/bits/string_fortified.h
3141 # error "Never use <bits/string_fortified.h> directly; include <string.h> instead."
3144 -#if !__GNUC_PREREQ (5,0)
3145 -__warndecl (__warn_memset_zero_len,
3146 - "memset used with constant zero length parameter; this could be due to transposed parameters");
3149 __fortify_function void *
3150 __NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
3152 @@ -58,16 +53,6 @@ __NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
3153 __fortify_function void *
3154 __NTH (memset (void *__dest, int __ch, size_t __len))
3156 - /* GCC-5.0 and newer implements these checks in the compiler, so we don't
3157 - need them here. */
3158 -#if !__GNUC_PREREQ (5,0)
3159 - if (__builtin_constant_p (__len) && __len == 0
3160 - && (!__builtin_constant_p (__ch) || __ch != 0))
3162 - __warn_memset_zero_len ();
3166 return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
3169 diff --git a/support/Makefile b/support/Makefile
3170 index 93faafddf9..4154863511 100644
3171 --- a/support/Makefile
3172 +++ b/support/Makefile
3173 @@ -35,6 +35,8 @@ libsupport-routines = \
3177 + resolv_response_context_duplicate \
3178 + resolv_response_context_free \
3180 set_fortify_handler \
3182 diff --git a/support/capture_subprocess.h b/support/capture_subprocess.h
3183 index 9808750f80..421f657678 100644
3184 --- a/support/capture_subprocess.h
3185 +++ b/support/capture_subprocess.h
3186 @@ -41,6 +41,12 @@ struct support_capture_subprocess support_capture_subprocess
3187 struct support_capture_subprocess support_capture_subprogram
3188 (const char *file, char *const argv[]);
3190 +/* Copy the running program into a setgid binary and run it with CHILD_ID
3191 + argument. If execution is successful, return the exit status of the child
3192 + program, otherwise return a non-zero failure exit code. */
3193 +int support_capture_subprogram_self_sgid
3196 /* Deallocate the subprocess data captured by
3197 support_capture_subprocess. */
3198 void support_capture_subprocess_free (struct support_capture_subprocess *);
3199 diff --git a/support/resolv_response_context_duplicate.c b/support/resolv_response_context_duplicate.c
3200 new file mode 100644
3201 index 0000000000..f9c5c3462a
3203 +++ b/support/resolv_response_context_duplicate.c
3205 +/* Duplicate a response context used in DNS resolver tests.
3206 + Copyright (C) 2020 Free Software Foundation, Inc.
3207 + This file is part of the GNU C Library.
3209 + The GNU C Library is free software; you can redistribute it and/or
3210 + modify it under the terms of the GNU Lesser General Public
3211 + License as published by the Free Software Foundation; either
3212 + version 2.1 of the License, or (at your option) any later version.
3214 + The GNU C Library is distributed in the hope that it will be useful,
3215 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3216 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3217 + Lesser General Public License for more details.
3219 + You should have received a copy of the GNU Lesser General Public
3220 + License along with the GNU C Library; if not, see
3221 + <https://www.gnu.org/licenses/>. */
3223 +#include <string.h>
3224 +#include <support/resolv_test.h>
3225 +#include <support/support.h>
3227 +struct resolv_response_context *
3228 +resolv_response_context_duplicate (const struct resolv_response_context *ctx)
3230 + struct resolv_response_context *result = xmalloc (sizeof (*result));
3231 + memcpy (result, ctx, sizeof (*result));
3232 + if (result->client_address != NULL)
3234 + result->client_address = xmalloc (result->client_address_length);
3235 + memcpy (result->client_address, ctx->client_address,
3236 + result->client_address_length);
3238 + result->query_buffer = xmalloc (result->query_length);
3239 + memcpy (result->query_buffer, ctx->query_buffer, result->query_length);
3242 diff --git a/support/resolv_response_context_free.c b/support/resolv_response_context_free.c
3243 new file mode 100644
3244 index 0000000000..b88c05ffd4
3246 +++ b/support/resolv_response_context_free.c
3248 +/* Free a response context used in DNS resolver tests.
3249 + Copyright (C) 2020 Free Software Foundation, Inc.
3250 + This file is part of the GNU C Library.
3252 + The GNU C Library is free software; you can redistribute it and/or
3253 + modify it under the terms of the GNU Lesser General Public
3254 + License as published by the Free Software Foundation; either
3255 + version 2.1 of the License, or (at your option) any later version.
3257 + The GNU C Library is distributed in the hope that it will be useful,
3258 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3259 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3260 + Lesser General Public License for more details.
3262 + You should have received a copy of the GNU Lesser General Public
3263 + License along with the GNU C Library; if not, see
3264 + <https://www.gnu.org/licenses/>. */
3266 +#include <stdlib.h>
3267 +#include <support/resolv_test.h>
3270 +resolv_response_context_free (struct resolv_response_context *ctx)
3272 + free (ctx->query_buffer);
3273 + free (ctx->client_address);
3276 diff --git a/support/resolv_test.c b/support/resolv_test.c
3277 index 53b7fc41ab..9878a040a3 100644
3278 --- a/support/resolv_test.c
3279 +++ b/support/resolv_test.c
3280 @@ -181,7 +181,9 @@ resolv_response_init (struct resolv_response_builder *b,
3281 b->buffer[2] |= b->query_buffer[2] & 0x01; /* Copy the RD bit. */
3283 b->buffer[2] |= 0x02;
3284 - b->buffer[3] = 0x80 | flags.rcode; /* Always set RA. */
3285 + b->buffer[3] = flags.rcode;
3286 + if (!flags.clear_ra)
3287 + b->buffer[3] |= 0x80;
3289 b->buffer[3] |= 0x20;
3291 @@ -434,9 +436,9 @@ resolv_response_buffer (const struct resolv_response_builder *b)
3295 -static struct resolv_response_builder *
3296 -response_builder_allocate
3297 - (const unsigned char *query_buffer, size_t query_length)
3298 +struct resolv_response_builder *
3299 +resolv_response_builder_allocate (const unsigned char *query_buffer,
3300 + size_t query_length)
3302 struct resolv_response_builder *b = xmalloc (sizeof (*b));
3303 memset (b, 0, offsetof (struct resolv_response_builder, buffer));
3304 @@ -445,8 +447,8 @@ response_builder_allocate
3309 -response_builder_free (struct resolv_response_builder *b)
3311 +resolv_response_builder_free (struct resolv_response_builder *b)
3313 tdestroy (b->compression_offsets, free);
3315 @@ -661,13 +663,17 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
3317 struct resolv_response_context ctx =
3320 + .client_address = &peer,
3321 + .client_address_length = peerlen,
3322 .query_buffer = query,
3323 .query_length = length,
3324 .server_index = server_index,
3328 - struct resolv_response_builder *b = response_builder_allocate (query, length);
3329 + struct resolv_response_builder *b
3330 + = resolv_response_builder_allocate (query, length);
3331 obj->config.response_callback
3332 (&ctx, b, qinfo.qname, qinfo.qclass, qinfo.qtype);
3334 @@ -684,7 +690,7 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
3335 if (b->offset >= 12)
3336 printf ("info: UDP server %d: sending response:"
3337 " %zu bytes, RCODE %d (for %s/%u/%u)\n",
3338 - server_index, b->offset, b->buffer[3] & 0x0f,
3339 + ctx.server_index, b->offset, b->buffer[3] & 0x0f,
3340 qinfo.qname, qinfo.qclass, qinfo.qtype);
3342 printf ("info: UDP server %d: sending response: %zu bytes"
3343 @@ -694,23 +700,31 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index)
3344 if (b->truncate_bytes > 0)
3345 printf ("info: truncated by %u bytes\n", b->truncate_bytes);
3347 - size_t to_send = b->offset;
3348 - if (to_send < b->truncate_bytes)
3351 - to_send -= b->truncate_bytes;
3353 - /* Ignore most errors here because the other end may have closed
3355 - if (sendto (obj->servers[server_index].socket_udp,
3356 - b->buffer, to_send, 0,
3357 - (struct sockaddr *) &peer, peerlen) < 0)
3358 - TEST_VERIFY_EXIT (errno != EBADF);
3359 + resolv_response_send_udp (&ctx, b);
3361 - response_builder_free (b);
3362 + resolv_response_builder_free (b);
3367 +resolv_response_send_udp (const struct resolv_response_context *ctx,
3368 + struct resolv_response_builder *b)
3370 + TEST_VERIFY_EXIT (!ctx->tcp);
3371 + size_t to_send = b->offset;
3372 + if (to_send < b->truncate_bytes)
3375 + to_send -= b->truncate_bytes;
3377 + /* Ignore most errors here because the other end may have closed
3379 + if (sendto (ctx->test->servers[ctx->server_index].socket_udp,
3380 + b->buffer, to_send, 0,
3381 + ctx->client_address, ctx->client_address_length) < 0)
3382 + TEST_VERIFY_EXIT (errno != EBADF);
3385 /* UDP thread_callback function. Variant for one thread per
3388 @@ -897,14 +911,15 @@ server_thread_tcp_client (void *arg)
3390 struct resolv_response_context ctx =
3392 + .test = closure->obj,
3393 .query_buffer = query_buffer,
3394 .query_length = query_length,
3395 .server_index = closure->server_index,
3399 - struct resolv_response_builder *b = response_builder_allocate
3400 - (query_buffer, query_length);
3401 + struct resolv_response_builder *b
3402 + = resolv_response_builder_allocate (query_buffer, query_length);
3403 closure->obj->config.response_callback
3404 (&ctx, b, qinfo.qname, qinfo.qclass, qinfo.qtype);
3406 @@ -936,7 +951,7 @@ server_thread_tcp_client (void *arg)
3407 writev_fully (closure->client_socket, buffers, 2);
3409 bool close_flag = b->close;
3410 - response_builder_free (b);
3411 + resolv_response_builder_free (b);
3412 free (query_buffer);
3415 diff --git a/support/resolv_test.h b/support/resolv_test.h
3416 index 67819469a0..31a5c1c3e7 100644
3417 --- a/support/resolv_test.h
3418 +++ b/support/resolv_test.h
3419 @@ -35,25 +35,36 @@ struct resolv_edns_info
3420 uint16_t payload_size;
3423 +/* This opaque struct collects information about the resolver testing
3424 + currently in progress. */
3425 +struct resolv_test;
3427 /* This struct provides context information when the response callback
3428 specified in struct resolv_redirect_config is invoked. */
3429 struct resolv_response_context
3431 - const unsigned char *query_buffer;
3432 + struct resolv_test *test;
3433 + void *client_address;
3434 + size_t client_address_length;
3435 + unsigned char *query_buffer;
3436 size_t query_length;
3439 struct resolv_edns_info edns;
3442 +/* Produces a deep copy of the context. */
3443 +struct resolv_response_context *
3444 + resolv_response_context_duplicate (const struct resolv_response_context *);
3446 +/* Frees the copy. For the context passed to the response function,
3447 + this happens implicitly. */
3448 +void resolv_response_context_free (struct resolv_response_context *);
3450 /* This opaque struct is used to construct responses from within the
3451 response callback function. */
3452 struct resolv_response_builder;
3454 -/* This opaque struct collects information about the resolver testing
3455 - currently in progress. */
3456 -struct resolv_test;
3460 /* Maximum number of test servers supported by the framework. */
3461 @@ -137,6 +148,10 @@ struct resolv_response_flags
3462 /* If true, the AD (authenticated data) flag will be set. */
3465 + /* If true, do not set the RA (recursion available) flag in the
3469 /* Initial section count values. Can be used to artificially
3470 increase the counts, for malformed packet testing.*/
3471 unsigned short qdcount;
3472 @@ -188,6 +203,22 @@ void resolv_response_close (struct resolv_response_builder *);
3473 /* The size of the response packet built so far. */
3474 size_t resolv_response_length (const struct resolv_response_builder *);
3476 +/* Allocates a response builder tied to a specific query packet,
3477 + starting at QUERY_BUFFER, containing QUERY_LENGTH bytes. */
3478 +struct resolv_response_builder *
3479 + resolv_response_builder_allocate (const unsigned char *query_buffer,
3480 + size_t query_length);
3482 +/* Deallocates a response buffer. */
3483 +void resolv_response_builder_free (struct resolv_response_builder *);
3485 +/* Sends a UDP response using a specific context. This can be used to
3486 + reorder or duplicate responses, along with
3487 + resolv_response_context_duplicate and
3488 + response_builder_allocate. */
3489 +void resolv_response_send_udp (const struct resolv_response_context *,
3490 + struct resolv_response_builder *);
3494 #endif /* SUPPORT_RESOLV_TEST_H */
3495 diff --git a/support/subprocess.h b/support/subprocess.h
3496 index 8b442fd5c0..34ffd02e8e 100644
3497 --- a/support/subprocess.h
3498 +++ b/support/subprocess.h
3499 @@ -38,6 +38,11 @@ struct support_subprocess support_subprocess
3500 struct support_subprocess support_subprogram
3501 (const char *file, char *const argv[]);
3503 +/* Invoke program FILE with ARGV arguments by using posix_spawn and wait for it
3504 + to complete. Return program exit status. */
3505 +int support_subprogram_wait
3506 + (const char *file, char *const argv[]);
3508 /* Wait for the subprocess indicated by PROC::PID. Return the status
3509 indicate by waitpid call. */
3510 int support_process_wait (struct support_subprocess *proc);
3511 diff --git a/support/support_capture_subprocess.c b/support/support_capture_subprocess.c
3512 index eeed676e3d..28a37df67f 100644
3513 --- a/support/support_capture_subprocess.c
3514 +++ b/support/support_capture_subprocess.c
3516 #include <support/capture_subprocess.h>
3521 #include <support/check.h>
3522 #include <support/xunistd.h>
3523 #include <support/xsocket.h>
3524 #include <support/xspawn.h>
3525 +#include <support/support.h>
3526 +#include <support/test-driver.h>
3529 transfer (const char *what, struct pollfd *pfd, struct xmemstream *stream)
3530 @@ -36,7 +39,7 @@ transfer (const char *what, struct pollfd *pfd, struct xmemstream *stream)
3533 support_record_failure ();
3534 - printf ("error: reading from subprocess %s: %m", what);
3535 + printf ("error: reading from subprocess %s: %m\n", what);
3539 @@ -102,6 +105,129 @@ support_capture_subprogram (const char *file, char *const argv[])
3543 +/* Copies the executable into a restricted directory, so that we can
3544 + safely make it SGID with the TARGET group ID. Then runs the
3547 +copy_and_spawn_sgid (char *child_id, gid_t gid)
3549 + char *dirname = xasprintf ("%s/tst-tunables-setuid.%jd",
3550 + test_dir, (intmax_t) getpid ());
3551 + char *execname = xasprintf ("%s/bin", dirname);
3554 + int ret = 1, status = 1;
3556 + TEST_VERIFY (mkdir (dirname, 0700) == 0);
3557 + if (support_record_failure_is_failed ())
3560 + infd = open ("/proc/self/exe", O_RDONLY);
3562 + FAIL_UNSUPPORTED ("unsupported: Cannot read binary from procfs\n");
3564 + outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700);
3565 + TEST_VERIFY (outfd >= 0);
3566 + if (support_record_failure_is_failed ())
3572 + ssize_t rdcount = read (infd, buf, sizeof (buf));
3573 + TEST_VERIFY (rdcount >= 0);
3574 + if (support_record_failure_is_failed ())
3579 + char *end = buf + rdcount;
3582 + ssize_t wrcount = write (outfd, buf, end - p);
3585 + TEST_VERIFY (wrcount > 0);
3586 + if (support_record_failure_is_failed ())
3591 + TEST_VERIFY (fchown (outfd, getuid (), gid) == 0);
3592 + if (support_record_failure_is_failed ())
3594 + TEST_VERIFY (fchmod (outfd, 02750) == 0);
3595 + if (support_record_failure_is_failed ())
3597 + TEST_VERIFY (close (outfd) == 0);
3598 + if (support_record_failure_is_failed ())
3600 + TEST_VERIFY (close (infd) == 0);
3601 + if (support_record_failure_is_failed ())
3604 + /* We have the binary, now spawn the subprocess. Avoid using
3605 + support_subprogram because we only want the program exit status, not the
3609 + char * const args[] = {execname, child_id, NULL};
3611 + status = support_subprogram_wait (args[0], args);
3618 + if (execname != NULL)
3620 + unlink (execname);
3623 + if (dirname != NULL)
3630 + FAIL_EXIT1("Failed to make sgid executable for test\n");
3636 +support_capture_subprogram_self_sgid (char *child_id)
3639 + const int count = 64;
3640 + gid_t groups[count];
3642 + /* Get a GID which is not our current GID, but is present in the
3643 + supplementary group list. */
3644 + int ret = getgroups (count, groups);
3646 + FAIL_UNSUPPORTED("Could not get group list for user %jd\n",
3647 + (intmax_t) getuid ());
3649 + gid_t current = getgid ();
3650 + for (int i = 0; i < ret; ++i)
3652 + if (groups[i] != current)
3654 + target = groups[i];
3660 + FAIL_UNSUPPORTED("Could not find a suitable GID for user %jd\n",
3661 + (intmax_t) getuid ());
3663 + return copy_and_spawn_sgid (child_id, target);
3667 support_capture_subprocess_free (struct support_capture_subprocess *p)
3669 diff --git a/support/support_subprocess.c b/support/support_subprocess.c
3670 index 36e3a77af2..4a25828111 100644
3671 --- a/support/support_subprocess.c
3672 +++ b/support/support_subprocess.c
3674 #include <support/subprocess.h>
3676 static struct support_subprocess
3677 -support_suprocess_init (void)
3678 +support_subprocess_init (void)
3680 struct support_subprocess result;
3682 @@ -48,7 +48,7 @@ support_suprocess_init (void)
3683 struct support_subprocess
3684 support_subprocess (void (*callback) (void *), void *closure)
3686 - struct support_subprocess result = support_suprocess_init ();
3687 + struct support_subprocess result = support_subprocess_init ();
3689 result.pid = xfork ();
3690 if (result.pid == 0)
3691 @@ -71,7 +71,7 @@ support_subprocess (void (*callback) (void *), void *closure)
3692 struct support_subprocess
3693 support_subprogram (const char *file, char *const argv[])
3695 - struct support_subprocess result = support_suprocess_init ();
3696 + struct support_subprocess result = support_subprocess_init ();
3698 posix_spawn_file_actions_t fa;
3699 /* posix_spawn_file_actions_init does not fail. */
3700 @@ -84,7 +84,7 @@ support_subprogram (const char *file, char *const argv[])
3701 xposix_spawn_file_actions_addclose (&fa, result.stdout_pipe[1]);
3702 xposix_spawn_file_actions_addclose (&fa, result.stderr_pipe[1]);
3704 - result.pid = xposix_spawn (file, &fa, NULL, argv, NULL);
3705 + result.pid = xposix_spawn (file, &fa, NULL, argv, environ);
3707 xclose (result.stdout_pipe[1]);
3708 xclose (result.stderr_pipe[1]);
3709 @@ -92,6 +92,19 @@ support_subprogram (const char *file, char *const argv[])
3714 +support_subprogram_wait (const char *file, char *const argv[])
3716 + posix_spawn_file_actions_t fa;
3718 + posix_spawn_file_actions_init (&fa);
3719 + struct support_subprocess res = support_subprocess_init ();
3721 + res.pid = xposix_spawn (file, &fa, NULL, argv, environ);
3723 + return support_process_wait (&res);
3727 support_process_wait (struct support_subprocess *proc)
3729 diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c
3730 index 196e462520..cf7624aaa2 100644
3731 --- a/sysdeps/aarch64/dl-bti.c
3732 +++ b/sysdeps/aarch64/dl-bti.c
3735 #include <libintl.h>
3736 #include <ldsodefs.h>
3737 +#include <sys/mman.h>
3740 -enable_bti (struct link_map *map, const char *program)
3741 +/* See elf/dl-load.h. */
3743 +# define MAP_COPY (MAP_PRIVATE | MAP_DENYWRITE)
3746 +/* Enable BTI protection for MAP. */
3749 +_dl_bti_protect (struct link_map *map, int fd)
3751 + const size_t pagesz = GLRO(dl_pagesize);
3752 const ElfW(Phdr) *phdr;
3755 for (phdr = map->l_phdr; phdr < &map->l_phdr[map->l_phnum]; ++phdr)
3756 if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X))
3758 - void *start = (void *) (phdr->p_vaddr + map->l_addr);
3759 - size_t len = phdr->p_memsz;
3760 + size_t vstart = ALIGN_DOWN (phdr->p_vaddr, pagesz);
3761 + size_t vend = ALIGN_UP (phdr->p_vaddr + phdr->p_filesz, pagesz);
3762 + off_t off = ALIGN_DOWN (phdr->p_offset, pagesz);
3763 + void *start = (void *) (vstart + map->l_addr);
3764 + size_t len = vend - vstart;
3766 - prot = PROT_EXEC | PROT_BTI;
3767 + unsigned prot = PROT_EXEC | PROT_BTI;
3768 if (phdr->p_flags & PF_R)
3770 if (phdr->p_flags & PF_W)
3773 - if (__mprotect (start, len, prot) < 0)
3776 - _dl_fatal_printf ("%s: mprotect failed to turn on BTI\n",
3779 - _dl_signal_error (errno, map->l_name, "dlopen",
3780 - N_("mprotect failed to turn on BTI"));
3783 + /* Ignore failures for kernel mapped binaries. */
3784 + __mprotect (start, len, prot);
3786 + map->l_mach.bti_fail = __mmap (start, len, prot,
3787 + MAP_FIXED|MAP_COPY|MAP_FILE,
3788 + fd, off) == MAP_FAILED;
3793 -/* Enable BTI for L if required. */
3796 +bti_failed (struct link_map *l, const char *program)
3799 + _dl_fatal_printf ("%s: %s: failed to turn on BTI protection\n",
3800 + program, l->l_name);
3802 + /* Note: the errno value is not available any more. */
3803 + _dl_signal_error (0, l->l_name, "dlopen",
3804 + N_("failed to turn on BTI protection"));
3808 +/* Enable BTI for L and its dependencies. */
3811 _dl_bti_check (struct link_map *l, const char *program)
3813 - if (GLRO(dl_aarch64_cpu_features).bti && l->l_mach.bti)
3814 - enable_bti (l, program);
3815 + if (!GLRO(dl_aarch64_cpu_features).bti)
3818 + if (l->l_mach.bti_fail)
3819 + bti_failed (l, program);
3821 + unsigned int i = l->l_searchlist.r_nlist;
3824 + struct link_map *dep = l->l_initfini[i];
3825 + if (dep->l_mach.bti_fail)
3826 + bti_failed (dep, program);
3829 diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
3830 index 70b9ed3925..fde7cfd9e2 100644
3831 --- a/sysdeps/aarch64/dl-machine.h
3832 +++ b/sysdeps/aarch64/dl-machine.h
3833 @@ -395,13 +395,6 @@ elf_machine_lazy_rel (struct link_map *map,
3834 /* Check for unexpected PLT reloc type. */
3835 if (__builtin_expect (r_type == AARCH64_R(JUMP_SLOT), 1))
3837 - if (map->l_mach.plt == 0)
3840 - *reloc_addr += l_addr;
3844 if (__glibc_unlikely (map->l_info[DT_AARCH64 (VARIANT_PCS)] != NULL))
3846 /* Check the symbol table for variant PCS symbols. */
3847 @@ -425,7 +418,10 @@ elf_machine_lazy_rel (struct link_map *map,
3851 - *reloc_addr = map->l_mach.plt;
3852 + if (map->l_mach.plt == 0)
3853 + *reloc_addr += l_addr;
3855 + *reloc_addr = map->l_mach.plt;
3857 else if (__builtin_expect (r_type == AARCH64_R(TLSDESC), 1))
3859 diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h
3860 index b0785bda83..e926e54984 100644
3861 --- a/sysdeps/aarch64/dl-prop.h
3862 +++ b/sysdeps/aarch64/dl-prop.h
3867 +extern void _dl_bti_protect (struct link_map *, int) attribute_hidden;
3869 extern void _dl_bti_check (struct link_map *, const char *)
3872 @@ -35,14 +37,18 @@ _dl_open_check (struct link_map *m)
3875 static inline void __attribute__ ((always_inline))
3876 -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
3877 +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
3882 -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
3884 +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
3885 + uint32_t datasz, void *data)
3887 + if (!GLRO(dl_aarch64_cpu_features).bti)
3888 + /* Skip note processing. */
3891 if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
3893 /* Stop if the property note is ill-formed. */
3894 @@ -51,7 +57,7 @@ _dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
3896 unsigned int feature_1 = *(unsigned int *) data;
3897 if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
3898 - l->l_mach.bti = true;
3899 + _dl_bti_protect (l, fd);
3901 /* Stop if we processed the property note. */
3903 diff --git a/sysdeps/aarch64/linkmap.h b/sysdeps/aarch64/linkmap.h
3904 index 847a03ace2..b3f7663b07 100644
3905 --- a/sysdeps/aarch64/linkmap.h
3906 +++ b/sysdeps/aarch64/linkmap.h
3907 @@ -22,5 +22,5 @@ struct link_map_machine
3909 ElfW(Addr) plt; /* Address of .plt */
3910 void *tlsdesc_table; /* Address of TLS descriptor hash table. */
3911 - bool bti; /* Branch Target Identification is enabled. */
3912 + bool bti_fail; /* Failed to enable Branch Target Identification. */
3914 diff --git a/sysdeps/aarch64/multiarch/memcpy.c b/sysdeps/aarch64/multiarch/memcpy.c
3915 index 7cf5f033e8..799d60c98c 100644
3916 --- a/sysdeps/aarch64/multiarch/memcpy.c
3917 +++ b/sysdeps/aarch64/multiarch/memcpy.c
3918 @@ -41,7 +41,8 @@ libc_ifunc (__libc_memcpy,
3920 : (IS_THUNDERX2 (midr) || IS_THUNDERX2PA (midr)
3921 ? __memcpy_thunderx2
3922 - : (IS_NEOVERSE_N1 (midr)
3923 + : (IS_NEOVERSE_N1 (midr) || IS_NEOVERSE_N2 (midr)
3924 + || IS_NEOVERSE_V1 (midr)
3926 : __memcpy_generic)))));
3928 diff --git a/sysdeps/aarch64/multiarch/memcpy_advsimd.S b/sysdeps/aarch64/multiarch/memcpy_advsimd.S
3929 index d4ba747777..48bb6d7ca4 100644
3930 --- a/sysdeps/aarch64/multiarch/memcpy_advsimd.S
3931 +++ b/sysdeps/aarch64/multiarch/memcpy_advsimd.S
3932 @@ -223,12 +223,13 @@ L(copy_long_backwards):
3933 b.ls L(copy64_from_start)
3935 L(loop64_backwards):
3936 - stp A_q, B_q, [dstend, -32]
3937 + str B_q, [dstend, -16]
3938 + str A_q, [dstend, -32]
3939 ldp A_q, B_q, [srcend, -96]
3940 - stp C_q, D_q, [dstend, -64]
3941 + str D_q, [dstend, -48]
3942 + str C_q, [dstend, -64]!
3943 ldp C_q, D_q, [srcend, -128]
3944 sub srcend, srcend, 64
3945 - sub dstend, dstend, 64
3946 subs count, count, 64
3947 b.hi L(loop64_backwards)
3949 diff --git a/sysdeps/aarch64/multiarch/memmove.c b/sysdeps/aarch64/multiarch/memmove.c
3950 index ad10aa8ac6..46a4cb3a54 100644
3951 --- a/sysdeps/aarch64/multiarch/memmove.c
3952 +++ b/sysdeps/aarch64/multiarch/memmove.c
3953 @@ -41,7 +41,8 @@ libc_ifunc (__libc_memmove,
3955 : (IS_THUNDERX2 (midr) || IS_THUNDERX2PA (midr)
3956 ? __memmove_thunderx2
3957 - : (IS_NEOVERSE_N1 (midr)
3958 + : (IS_NEOVERSE_N1 (midr) || IS_NEOVERSE_N2 (midr)
3959 + || IS_NEOVERSE_V1 (midr)
3961 : __memmove_generic)))));
3963 diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
3964 index 75393e1c18..1998ea95d4 100644
3965 --- a/sysdeps/aarch64/start.S
3966 +++ b/sysdeps/aarch64/start.S
3972 - .type _start,#function
3976 /* Create an initial frame with 0 LR and FP */
3977 + cfi_undefined (x30)
3981 @@ -101,8 +99,10 @@ _start:
3982 because crt1.o and rcrt1.o share code and the later must avoid the
3983 use of GOT relocations before __libc_start_main is called. */
3990 /* Define a symbol for the first piece of initialized data. */
3992 diff --git a/sysdeps/generic/dl-prop.h b/sysdeps/generic/dl-prop.h
3993 index f1cf576fe3..df27ff8e6a 100644
3994 --- a/sysdeps/generic/dl-prop.h
3995 +++ b/sysdeps/generic/dl-prop.h
3996 @@ -37,15 +37,15 @@ _dl_open_check (struct link_map *m)
3999 static inline void __attribute__ ((always_inline))
4000 -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
4001 +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
4005 /* Called for each property in the NT_GNU_PROPERTY_TYPE_0 note of L,
4006 processing of the properties continues until this returns 0. */
4007 static inline int __attribute__ ((always_inline))
4008 -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
4010 +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
4011 + uint32_t datasz, void *data)
4015 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
4016 index ba114ab4b1..62ac40d81b 100644
4017 --- a/sysdeps/generic/ldsodefs.h
4018 +++ b/sysdeps/generic/ldsodefs.h
4019 @@ -919,8 +919,9 @@ extern void _dl_rtld_di_serinfo (struct link_map *loader,
4020 Dl_serinfo *si, bool counting);
4022 /* Process PT_GNU_PROPERTY program header PH in module L after
4023 - PT_LOAD segments are mapped. */
4024 -void _dl_process_pt_gnu_property (struct link_map *l, const ElfW(Phdr) *ph);
4025 + PT_LOAD segments are mapped from file FD. */
4026 +void _dl_process_pt_gnu_property (struct link_map *l, int fd,
4027 + const ElfW(Phdr) *ph);
4030 /* Search loaded objects' symbol tables for a definition of the symbol
4031 diff --git a/sysdeps/generic/unwind.h b/sysdeps/generic/unwind.h
4032 index b667a5b652..c229603af3 100644
4033 --- a/sysdeps/generic/unwind.h
4034 +++ b/sysdeps/generic/unwind.h
4035 @@ -75,15 +75,21 @@ typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
4037 struct _Unwind_Exception
4039 - _Unwind_Exception_Class exception_class;
4040 - _Unwind_Exception_Cleanup_Fn exception_cleanup;
4041 - _Unwind_Word private_1;
4042 - _Unwind_Word private_2;
4044 - /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
4045 - Taking that literally does not make much sense generically. Instead we
4046 - provide the maximum alignment required by any type for the machine. */
4047 -} __attribute__((__aligned__));
4052 + _Unwind_Exception_Class exception_class;
4053 + _Unwind_Exception_Cleanup_Fn exception_cleanup;
4054 + _Unwind_Word private_1;
4055 + _Unwind_Word private_2;
4058 + /* The IA-64 ABI says that this structure must be double-word aligned. */
4059 + _Unwind_Word unwind_exception_align[2]
4060 + __attribute__ ((__aligned__ (2 * sizeof (_Unwind_Word))));
4065 /* The ACTIONS argument to the personality routine is a bitwise OR of one
4066 diff --git a/sysdeps/gnu/errlist.h b/sysdeps/gnu/errlist.h
4067 index 5d11ed723d..6329e5f393 100644
4068 --- a/sysdeps/gnu/errlist.h
4069 +++ b/sysdeps/gnu/errlist.h
4072 -#define ERR_MAP(value) value
4074 -_S(ERR_MAP(0), N_("Success"))
4075 +_S(0, N_("Success"))
4078 TRANS Only the owner of the file (or other resource)
4079 TRANS or processes with special privileges can perform the operation. */
4080 -_S(ERR_MAP(EPERM), N_("Operation not permitted"))
4081 +_S(EPERM, N_("Operation not permitted"))
4085 TRANS This is a ``file doesn't exist'' error
4086 TRANS for ordinary files that are referenced in contexts where they are
4087 TRANS expected to already exist. */
4088 -_S(ERR_MAP(ENOENT), N_("No such file or directory"))
4089 +_S(ENOENT, N_("No such file or directory"))
4093 TRANS No process matches the specified process ID. */
4094 -_S(ERR_MAP(ESRCH), N_("No such process"))
4095 +_S(ESRCH, N_("No such process"))
4099 @@ -29,12 +26,12 @@ TRANS
4100 TRANS You can choose to have functions resume after a signal that is handled,
4101 TRANS rather than failing with @code{EINTR}; see @ref{Interrupted
4102 TRANS Primitives}. */
4103 -_S(ERR_MAP(EINTR), N_("Interrupted system call"))
4104 +_S(EINTR, N_("Interrupted system call"))
4108 TRANS Usually used for physical read or write errors. */
4109 -_S(ERR_MAP(EIO), N_("Input/output error"))
4110 +_S(EIO, N_("Input/output error"))
4114 @@ -43,7 +40,7 @@ TRANS represented by a file you specified, and it couldn't find the device.
4115 TRANS This can mean that the device file was installed incorrectly, or that
4116 TRANS the physical device is missing or not correctly attached to the
4118 -_S(ERR_MAP(ENXIO), N_("No such device or address"))
4119 +_S(ENXIO, N_("No such device or address"))
4123 @@ -51,27 +48,27 @@ TRANS Used when the arguments passed to a new program
4124 TRANS being executed with one of the @code{exec} functions (@pxref{Executing a
4125 TRANS File}) occupy too much memory space. This condition never arises on
4126 TRANS @gnuhurdsystems{}. */
4127 -_S(ERR_MAP(E2BIG), N_("Argument list too long"))
4128 +_S(E2BIG, N_("Argument list too long"))
4132 TRANS Invalid executable file format. This condition is detected by the
4133 TRANS @code{exec} functions; see @ref{Executing a File}. */
4134 -_S(ERR_MAP(ENOEXEC), N_("Exec format error"))
4135 +_S(ENOEXEC, N_("Exec format error"))
4139 TRANS For example, I/O on a descriptor that has been
4140 TRANS closed or reading from a descriptor open only for writing (or vice
4142 -_S(ERR_MAP(EBADF), N_("Bad file descriptor"))
4143 +_S(EBADF, N_("Bad file descriptor"))
4147 TRANS This error happens on operations that are
4148 TRANS supposed to manipulate child processes, when there aren't any processes
4149 TRANS to manipulate. */
4150 -_S(ERR_MAP(ECHILD), N_("No child processes"))
4151 +_S(ECHILD, N_("No child processes"))
4155 @@ -79,74 +76,74 @@ TRANS Allocating a system resource would have resulted in a
4156 TRANS deadlock situation. The system does not guarantee that it will notice
4157 TRANS all such situations. This error means you got lucky and the system
4158 TRANS noticed; it might just hang. @xref{File Locks}, for an example. */
4159 -_S(ERR_MAP(EDEADLK), N_("Resource deadlock avoided"))
4160 +_S(EDEADLK, N_("Resource deadlock avoided"))
4164 TRANS The system cannot allocate more virtual memory
4165 TRANS because its capacity is full. */
4166 -_S(ERR_MAP(ENOMEM), N_("Cannot allocate memory"))
4167 +_S(ENOMEM, N_("Cannot allocate memory"))
4171 TRANS The file permissions do not allow the attempted operation. */
4172 -_S(ERR_MAP(EACCES), N_("Permission denied"))
4173 +_S(EACCES, N_("Permission denied"))
4177 TRANS An invalid pointer was detected.
4178 TRANS On @gnuhurdsystems{}, this error never happens; you get a signal instead. */
4179 -_S(ERR_MAP(EFAULT), N_("Bad address"))
4180 +_S(EFAULT, N_("Bad address"))
4184 TRANS A file that isn't a block special file was given in a situation that
4185 TRANS requires one. For example, trying to mount an ordinary file as a file
4186 TRANS system in Unix gives this error. */
4187 -_S(ERR_MAP(ENOTBLK), N_("Block device required"))
4188 +_S(ENOTBLK, N_("Block device required"))
4192 TRANS A system resource that can't be shared is already in use.
4193 TRANS For example, if you try to delete a file that is the root of a currently
4194 TRANS mounted filesystem, you get this error. */
4195 -_S(ERR_MAP(EBUSY), N_("Device or resource busy"))
4196 +_S(EBUSY, N_("Device or resource busy"))
4200 TRANS An existing file was specified in a context where it only
4201 TRANS makes sense to specify a new file. */
4202 -_S(ERR_MAP(EEXIST), N_("File exists"))
4203 +_S(EEXIST, N_("File exists"))
4207 TRANS An attempt to make an improper link across file systems was detected.
4208 TRANS This happens not only when you use @code{link} (@pxref{Hard Links}) but
4209 TRANS also when you rename a file with @code{rename} (@pxref{Renaming Files}). */
4210 -_S(ERR_MAP(EXDEV), N_("Invalid cross-device link"))
4211 +_S(EXDEV, N_("Invalid cross-device link"))
4215 TRANS The wrong type of device was given to a function that expects a
4216 TRANS particular sort of device. */
4217 -_S(ERR_MAP(ENODEV), N_("No such device"))
4218 +_S(ENODEV, N_("No such device"))
4222 TRANS A file that isn't a directory was specified when a directory is required. */
4223 -_S(ERR_MAP(ENOTDIR), N_("Not a directory"))
4224 +_S(ENOTDIR, N_("Not a directory"))
4228 TRANS You cannot open a directory for writing,
4229 TRANS or create or remove hard links to it. */
4230 -_S(ERR_MAP(EISDIR), N_("Is a directory"))
4231 +_S(EISDIR, N_("Is a directory"))
4235 TRANS This is used to indicate various kinds of problems
4236 TRANS with passing the wrong argument to a library function. */
4237 -_S(ERR_MAP(EINVAL), N_("Invalid argument"))
4238 +_S(EINVAL, N_("Invalid argument"))
4242 @@ -157,20 +154,20 @@ TRANS In BSD and GNU, the number of open files is controlled by a resource
4243 TRANS limit that can usually be increased. If you get this error, you might
4244 TRANS want to increase the @code{RLIMIT_NOFILE} limit or make it unlimited;
4245 TRANS @pxref{Limits on Resources}. */
4246 -_S(ERR_MAP(EMFILE), N_("Too many open files"))
4247 +_S(EMFILE, N_("Too many open files"))
4251 TRANS There are too many distinct file openings in the entire system. Note
4252 TRANS that any number of linked channels count as just one file opening; see
4253 TRANS @ref{Linked Channels}. This error never occurs on @gnuhurdsystems{}. */
4254 -_S(ERR_MAP(ENFILE), N_("Too many open files in system"))
4255 +_S(ENFILE, N_("Too many open files in system"))
4259 TRANS Inappropriate I/O control operation, such as trying to set terminal
4260 TRANS modes on an ordinary file. */
4261 -_S(ERR_MAP(ENOTTY), N_("Inappropriate ioctl for device"))
4262 +_S(ENOTTY, N_("Inappropriate ioctl for device"))
4266 @@ -179,35 +176,35 @@ TRANS write to a file that is currently being executed. Often using a
4267 TRANS debugger to run a program is considered having it open for writing and
4268 TRANS will cause this error. (The name stands for ``text file busy''.) This
4269 TRANS is not an error on @gnuhurdsystems{}; the text is copied as necessary. */
4270 -_S(ERR_MAP(ETXTBSY), N_("Text file busy"))
4271 +_S(ETXTBSY, N_("Text file busy"))
4275 TRANS The size of a file would be larger than allowed by the system. */
4276 -_S(ERR_MAP(EFBIG), N_("File too large"))
4277 +_S(EFBIG, N_("File too large"))
4281 TRANS Write operation on a file failed because the
4282 TRANS disk is full. */
4283 -_S(ERR_MAP(ENOSPC), N_("No space left on device"))
4284 +_S(ENOSPC, N_("No space left on device"))
4288 TRANS Invalid seek operation (such as on a pipe). */
4289 -_S(ERR_MAP(ESPIPE), N_("Illegal seek"))
4290 +_S(ESPIPE, N_("Illegal seek"))
4294 TRANS An attempt was made to modify something on a read-only file system. */
4295 -_S(ERR_MAP(EROFS), N_("Read-only file system"))
4296 +_S(EROFS, N_("Read-only file system"))
4300 TRANS The link count of a single file would become too large.
4301 TRANS @code{rename} can cause this error if the file being renamed already has
4302 TRANS as many links as it can take (@pxref{Renaming Files}). */
4303 -_S(ERR_MAP(EMLINK), N_("Too many links"))
4304 +_S(EMLINK, N_("Too many links"))
4308 @@ -216,19 +213,19 @@ TRANS Every library function that returns this error code also generates a
4309 TRANS @code{SIGPIPE} signal; this signal terminates the program if not handled
4310 TRANS or blocked. Thus, your program will never actually see @code{EPIPE}
4311 TRANS unless it has handled or blocked @code{SIGPIPE}. */
4312 -_S(ERR_MAP(EPIPE), N_("Broken pipe"))
4313 +_S(EPIPE, N_("Broken pipe"))
4317 TRANS Used by mathematical functions when an argument value does
4318 TRANS not fall into the domain over which the function is defined. */
4319 -_S(ERR_MAP(EDOM), N_("Numerical argument out of domain"))
4320 +_S(EDOM, N_("Numerical argument out of domain"))
4324 TRANS Used by mathematical functions when the result value is
4325 TRANS not representable because of overflow or underflow. */
4326 -_S(ERR_MAP(ERANGE), N_("Numerical result out of range"))
4327 +_S(ERANGE, N_("Numerical result out of range"))
4331 @@ -261,7 +258,7 @@ TRANS Such shortages are usually fairly serious and affect the whole system,
4332 TRANS so usually an interactive program should report the error to the user
4333 TRANS and return to its command loop.
4334 TRANS @end itemize */
4335 -_S(ERR_MAP(EAGAIN), N_("Resource temporarily unavailable"))
4336 +_S(EAGAIN, N_("Resource temporarily unavailable"))
4340 @@ -273,47 +270,47 @@ TRANS the operation has begun and will take some time. Attempts to manipulate
4341 TRANS the object before the call completes return @code{EALREADY}. You can
4342 TRANS use the @code{select} function to find out when the pending operation
4343 TRANS has completed; @pxref{Waiting for I/O}. */
4344 -_S(ERR_MAP(EINPROGRESS), N_("Operation now in progress"))
4345 +_S(EINPROGRESS, N_("Operation now in progress"))
4349 TRANS An operation is already in progress on an object that has non-blocking
4350 TRANS mode selected. */
4351 -_S(ERR_MAP(EALREADY), N_("Operation already in progress"))
4352 +_S(EALREADY, N_("Operation already in progress"))
4356 TRANS A file that isn't a socket was specified when a socket is required. */
4357 -_S(ERR_MAP(ENOTSOCK), N_("Socket operation on non-socket"))
4358 +_S(ENOTSOCK, N_("Socket operation on non-socket"))
4362 TRANS The size of a message sent on a socket was larger than the supported
4363 TRANS maximum size. */
4364 -_S(ERR_MAP(EMSGSIZE), N_("Message too long"))
4365 +_S(EMSGSIZE, N_("Message too long"))
4369 TRANS The socket type does not support the requested communications protocol. */
4370 -_S(ERR_MAP(EPROTOTYPE), N_("Protocol wrong type for socket"))
4371 +_S(EPROTOTYPE, N_("Protocol wrong type for socket"))
4375 TRANS You specified a socket option that doesn't make sense for the
4376 TRANS particular protocol being used by the socket. @xref{Socket Options}. */
4377 -_S(ERR_MAP(ENOPROTOOPT), N_("Protocol not available"))
4378 +_S(ENOPROTOOPT, N_("Protocol not available"))
4380 #ifdef EPROTONOSUPPORT
4382 TRANS The socket domain does not support the requested communications protocol
4383 TRANS (perhaps because the requested protocol is completely invalid).
4384 TRANS @xref{Creating a Socket}. */
4385 -_S(ERR_MAP(EPROTONOSUPPORT), N_("Protocol not supported"))
4386 +_S(EPROTONOSUPPORT, N_("Protocol not supported"))
4388 #ifdef ESOCKTNOSUPPORT
4390 TRANS The socket type is not supported. */
4391 -_S(ERR_MAP(ESOCKTNOSUPPORT), N_("Socket type not supported"))
4392 +_S(ESOCKTNOSUPPORT, N_("Socket type not supported"))
4396 @@ -323,71 +320,71 @@ TRANS implemented for all communications protocols. On @gnuhurdsystems{}, this
4397 TRANS error can happen for many calls when the object does not support the
4398 TRANS particular operation; it is a generic indication that the server knows
4399 TRANS nothing to do for that call. */
4400 -_S(ERR_MAP(EOPNOTSUPP), N_("Operation not supported"))
4401 +_S(EOPNOTSUPP, N_("Operation not supported"))
4405 TRANS The socket communications protocol family you requested is not supported. */
4406 -_S(ERR_MAP(EPFNOSUPPORT), N_("Protocol family not supported"))
4407 +_S(EPFNOSUPPORT, N_("Protocol family not supported"))
4411 TRANS The address family specified for a socket is not supported; it is
4412 TRANS inconsistent with the protocol being used on the socket. @xref{Sockets}. */
4413 -_S(ERR_MAP(EAFNOSUPPORT), N_("Address family not supported by protocol"))
4414 +_S(EAFNOSUPPORT, N_("Address family not supported by protocol"))
4418 TRANS The requested socket address is already in use. @xref{Socket Addresses}. */
4419 -_S(ERR_MAP(EADDRINUSE), N_("Address already in use"))
4420 +_S(EADDRINUSE, N_("Address already in use"))
4422 #ifdef EADDRNOTAVAIL
4424 TRANS The requested socket address is not available; for example, you tried
4425 TRANS to give a socket a name that doesn't match the local host name.
4426 TRANS @xref{Socket Addresses}. */
4427 -_S(ERR_MAP(EADDRNOTAVAIL), N_("Cannot assign requested address"))
4428 +_S(EADDRNOTAVAIL, N_("Cannot assign requested address"))
4432 TRANS A socket operation failed because the network was down. */
4433 -_S(ERR_MAP(ENETDOWN), N_("Network is down"))
4434 +_S(ENETDOWN, N_("Network is down"))
4438 TRANS A socket operation failed because the subnet containing the remote host
4439 TRANS was unreachable. */
4440 -_S(ERR_MAP(ENETUNREACH), N_("Network is unreachable"))
4441 +_S(ENETUNREACH, N_("Network is unreachable"))
4445 TRANS A network connection was reset because the remote host crashed. */
4446 -_S(ERR_MAP(ENETRESET), N_("Network dropped connection on reset"))
4447 +_S(ENETRESET, N_("Network dropped connection on reset"))
4451 TRANS A network connection was aborted locally. */
4452 -_S(ERR_MAP(ECONNABORTED), N_("Software caused connection abort"))
4453 +_S(ECONNABORTED, N_("Software caused connection abort"))
4457 TRANS A network connection was closed for reasons outside the control of the
4458 TRANS local host, such as by the remote machine rebooting or an unrecoverable
4459 TRANS protocol violation. */
4460 -_S(ERR_MAP(ECONNRESET), N_("Connection reset by peer"))
4461 +_S(ECONNRESET, N_("Connection reset by peer"))
4465 TRANS The kernel's buffers for I/O operations are all in use. In GNU, this
4466 TRANS error is always synonymous with @code{ENOMEM}; you may get one or the
4467 TRANS other from network operations. */
4468 -_S(ERR_MAP(ENOBUFS), N_("No buffer space available"))
4469 +_S(ENOBUFS, N_("No buffer space available"))
4473 TRANS You tried to connect a socket that is already connected.
4474 TRANS @xref{Connecting}. */
4475 -_S(ERR_MAP(EISCONN), N_("Transport endpoint is already connected"))
4476 +_S(EISCONN, N_("Transport endpoint is already connected"))
4480 @@ -395,74 +392,74 @@ TRANS The socket is not connected to anything. You get this error when you
4481 TRANS try to transmit data over a socket, without first specifying a
4482 TRANS destination for the data. For a connectionless socket (for datagram
4483 TRANS protocols, such as UDP), you get @code{EDESTADDRREQ} instead. */
4484 -_S(ERR_MAP(ENOTCONN), N_("Transport endpoint is not connected"))
4485 +_S(ENOTCONN, N_("Transport endpoint is not connected"))
4489 TRANS No default destination address was set for the socket. You get this
4490 TRANS error when you try to transmit data over a connectionless socket,
4491 TRANS without first specifying a destination for the data with @code{connect}. */
4492 -_S(ERR_MAP(EDESTADDRREQ), N_("Destination address required"))
4493 +_S(EDESTADDRREQ, N_("Destination address required"))
4497 TRANS The socket has already been shut down. */
4498 -_S(ERR_MAP(ESHUTDOWN), N_("Cannot send after transport endpoint shutdown"))
4499 +_S(ESHUTDOWN, N_("Cannot send after transport endpoint shutdown"))
4502 -_S(ERR_MAP(ETOOMANYREFS), N_("Too many references: cannot splice"))
4503 +_S(ETOOMANYREFS, N_("Too many references: cannot splice"))
4507 TRANS A socket operation with a specified timeout received no response during
4508 TRANS the timeout period. */
4509 -_S(ERR_MAP(ETIMEDOUT), N_("Connection timed out"))
4510 +_S(ETIMEDOUT, N_("Connection timed out"))
4514 TRANS A remote host refused to allow the network connection (typically because
4515 TRANS it is not running the requested service). */
4516 -_S(ERR_MAP(ECONNREFUSED), N_("Connection refused"))
4517 +_S(ECONNREFUSED, N_("Connection refused"))
4521 TRANS Too many levels of symbolic links were encountered in looking up a file name.
4522 TRANS This often indicates a cycle of symbolic links. */
4523 -_S(ERR_MAP(ELOOP), N_("Too many levels of symbolic links"))
4524 +_S(ELOOP, N_("Too many levels of symbolic links"))
4528 TRANS Filename too long (longer than @code{PATH_MAX}; @pxref{Limits for
4529 TRANS Files}) or host name too long (in @code{gethostname} or
4530 TRANS @code{sethostname}; @pxref{Host Identification}). */
4531 -_S(ERR_MAP(ENAMETOOLONG), N_("File name too long"))
4532 +_S(ENAMETOOLONG, N_("File name too long"))
4536 TRANS The remote host for a requested network connection is down. */
4537 -_S(ERR_MAP(EHOSTDOWN), N_("Host is down"))
4538 +_S(EHOSTDOWN, N_("Host is down"))
4541 TRANS The remote host for a requested network connection is not reachable. */
4543 -_S(ERR_MAP(EHOSTUNREACH), N_("No route to host"))
4544 +_S(EHOSTUNREACH, N_("No route to host"))
4548 TRANS Directory not empty, where an empty directory was expected. Typically,
4549 TRANS this error occurs when you are trying to delete a directory. */
4550 -_S(ERR_MAP(ENOTEMPTY), N_("Directory not empty"))
4551 +_S(ENOTEMPTY, N_("Directory not empty"))
4555 TRANS The file quota system is confused because there are too many users.
4556 TRANS @c This can probably happen in a GNU system when using NFS. */
4557 -_S(ERR_MAP(EUSERS), N_("Too many users"))
4558 +_S(EUSERS, N_("Too many users"))
4562 TRANS The user's disk quota was exceeded. */
4563 -_S(ERR_MAP(EDQUOT), N_("Disk quota exceeded"))
4564 +_S(EDQUOT, N_("Disk quota exceeded"))
4568 @@ -471,7 +468,7 @@ TRANS file system which is due to file system rearrangements on the server host
4569 TRANS for NFS file systems or corruption in other file systems.
4570 TRANS Repairing this condition usually requires unmounting, possibly repairing
4571 TRANS and remounting the file system. */
4572 -_S(ERR_MAP(ESTALE), N_("Stale file handle"))
4573 +_S(ESTALE, N_("Stale file handle"))
4577 @@ -479,7 +476,7 @@ TRANS An attempt was made to NFS-mount a remote file system with a file name tha
4578 TRANS already specifies an NFS-mounted file.
4579 TRANS (This is an error on some operating systems, but we expect it to work
4580 TRANS properly on @gnuhurdsystems{}, making this error code impossible.) */
4581 -_S(ERR_MAP(EREMOTE), N_("Object is remote"))
4582 +_S(EREMOTE, N_("Object is remote"))
4586 @@ -487,7 +484,7 @@ TRANS This is used by the file locking facilities; see
4587 TRANS @ref{File Locks}. This error is never generated by @gnuhurdsystems{}, but
4588 TRANS it can result from an operation to an NFS server running another
4589 TRANS operating system. */
4590 -_S(ERR_MAP(ENOLCK), N_("No locks available"))
4591 +_S(ENOLCK, N_("No locks available"))
4595 @@ -496,46 +493,46 @@ TRANS not implemented at all, either in the C library itself or in the
4596 TRANS operating system. When you get this error, you can be sure that this
4597 TRANS particular function will always fail with @code{ENOSYS} unless you
4598 TRANS install a new version of the C library or the operating system. */
4599 -_S(ERR_MAP(ENOSYS), N_("Function not implemented"))
4600 +_S(ENOSYS, N_("Function not implemented"))
4604 TRANS While decoding a multibyte character the function came along an invalid
4605 TRANS or an incomplete sequence of bytes or the given wide character is invalid. */
4606 -_S(ERR_MAP(EILSEQ), N_("Invalid or incomplete multibyte or wide character"))
4607 +_S(EILSEQ, N_("Invalid or incomplete multibyte or wide character"))
4610 -_S(ERR_MAP(EBADMSG), N_("Bad message"))
4611 +_S(EBADMSG, N_("Bad message"))
4614 -_S(ERR_MAP(EIDRM), N_("Identifier removed"))
4615 +_S(EIDRM, N_("Identifier removed"))
4618 -_S(ERR_MAP(EMULTIHOP), N_("Multihop attempted"))
4619 +_S(EMULTIHOP, N_("Multihop attempted"))
4622 -_S(ERR_MAP(ENODATA), N_("No data available"))
4623 +_S(ENODATA, N_("No data available"))
4626 -_S(ERR_MAP(ENOLINK), N_("Link has been severed"))
4627 +_S(ENOLINK, N_("Link has been severed"))
4630 -_S(ERR_MAP(ENOMSG), N_("No message of desired type"))
4631 +_S(ENOMSG, N_("No message of desired type"))
4634 -_S(ERR_MAP(ENOSR), N_("Out of streams resources"))
4635 +_S(ENOSR, N_("Out of streams resources"))
4638 -_S(ERR_MAP(ENOSTR), N_("Device not a stream"))
4639 +_S(ENOSTR, N_("Device not a stream"))
4642 -_S(ERR_MAP(EOVERFLOW), N_("Value too large for defined data type"))
4643 +_S(EOVERFLOW, N_("Value too large for defined data type"))
4646 -_S(ERR_MAP(EPROTO), N_("Protocol error"))
4647 +_S(EPROTO, N_("Protocol error"))
4650 -_S(ERR_MAP(ETIME), N_("Timer expired"))
4651 +_S(ETIME, N_("Timer expired"))
4655 @@ -543,148 +540,148 @@ TRANS An asynchronous operation was canceled before it
4656 TRANS completed. @xref{Asynchronous I/O}. When you call @code{aio_cancel},
4657 TRANS the normal result is for the operations affected to complete with this
4658 TRANS error; @pxref{Cancel AIO Operations}. */
4659 -_S(ERR_MAP(ECANCELED), N_("Operation canceled"))
4660 +_S(ECANCELED, N_("Operation canceled"))
4663 -_S(ERR_MAP(EOWNERDEAD), N_("Owner died"))
4664 +_S(EOWNERDEAD, N_("Owner died"))
4666 #ifdef ENOTRECOVERABLE
4667 -_S(ERR_MAP(ENOTRECOVERABLE), N_("State not recoverable"))
4668 +_S(ENOTRECOVERABLE, N_("State not recoverable"))
4671 -_S(ERR_MAP(ERESTART), N_("Interrupted system call should be restarted"))
4672 +_S(ERESTART, N_("Interrupted system call should be restarted"))
4675 -_S(ERR_MAP(ECHRNG), N_("Channel number out of range"))
4676 +_S(ECHRNG, N_("Channel number out of range"))
4679 -_S(ERR_MAP(EL2NSYNC), N_("Level 2 not synchronized"))
4680 +_S(EL2NSYNC, N_("Level 2 not synchronized"))
4683 -_S(ERR_MAP(EL3HLT), N_("Level 3 halted"))
4684 +_S(EL3HLT, N_("Level 3 halted"))
4687 -_S(ERR_MAP(EL3RST), N_("Level 3 reset"))
4688 +_S(EL3RST, N_("Level 3 reset"))
4691 -_S(ERR_MAP(ELNRNG), N_("Link number out of range"))
4692 +_S(ELNRNG, N_("Link number out of range"))
4695 -_S(ERR_MAP(EUNATCH), N_("Protocol driver not attached"))
4696 +_S(EUNATCH, N_("Protocol driver not attached"))
4699 -_S(ERR_MAP(ENOCSI), N_("No CSI structure available"))
4700 +_S(ENOCSI, N_("No CSI structure available"))
4703 -_S(ERR_MAP(EL2HLT), N_("Level 2 halted"))
4704 +_S(EL2HLT, N_("Level 2 halted"))
4707 -_S(ERR_MAP(EBADE), N_("Invalid exchange"))
4708 +_S(EBADE, N_("Invalid exchange"))
4711 -_S(ERR_MAP(EBADR), N_("Invalid request descriptor"))
4712 +_S(EBADR, N_("Invalid request descriptor"))
4715 -_S(ERR_MAP(EXFULL), N_("Exchange full"))
4716 +_S(EXFULL, N_("Exchange full"))
4719 -_S(ERR_MAP(ENOANO), N_("No anode"))
4720 +_S(ENOANO, N_("No anode"))
4723 -_S(ERR_MAP(EBADRQC), N_("Invalid request code"))
4724 +_S(EBADRQC, N_("Invalid request code"))
4727 -_S(ERR_MAP(EBADSLT), N_("Invalid slot"))
4728 +_S(EBADSLT, N_("Invalid slot"))
4731 -_S(ERR_MAP(EBFONT), N_("Bad font file format"))
4732 +_S(EBFONT, N_("Bad font file format"))
4735 -_S(ERR_MAP(ENONET), N_("Machine is not on the network"))
4736 +_S(ENONET, N_("Machine is not on the network"))
4739 -_S(ERR_MAP(ENOPKG), N_("Package not installed"))
4740 +_S(ENOPKG, N_("Package not installed"))
4743 -_S(ERR_MAP(EADV), N_("Advertise error"))
4744 +_S(EADV, N_("Advertise error"))
4747 -_S(ERR_MAP(ESRMNT), N_("Srmount error"))
4748 +_S(ESRMNT, N_("Srmount error"))
4751 -_S(ERR_MAP(ECOMM), N_("Communication error on send"))
4752 +_S(ECOMM, N_("Communication error on send"))
4755 -_S(ERR_MAP(EDOTDOT), N_("RFS specific error"))
4756 +_S(EDOTDOT, N_("RFS specific error"))
4759 -_S(ERR_MAP(ENOTUNIQ), N_("Name not unique on network"))
4760 +_S(ENOTUNIQ, N_("Name not unique on network"))
4763 -_S(ERR_MAP(EBADFD), N_("File descriptor in bad state"))
4764 +_S(EBADFD, N_("File descriptor in bad state"))
4767 -_S(ERR_MAP(EREMCHG), N_("Remote address changed"))
4768 +_S(EREMCHG, N_("Remote address changed"))
4771 -_S(ERR_MAP(ELIBACC), N_("Can not access a needed shared library"))
4772 +_S(ELIBACC, N_("Can not access a needed shared library"))
4775 -_S(ERR_MAP(ELIBBAD), N_("Accessing a corrupted shared library"))
4776 +_S(ELIBBAD, N_("Accessing a corrupted shared library"))
4779 -_S(ERR_MAP(ELIBSCN), N_(".lib section in a.out corrupted"))
4780 +_S(ELIBSCN, N_(".lib section in a.out corrupted"))
4783 -_S(ERR_MAP(ELIBMAX), N_("Attempting to link in too many shared libraries"))
4784 +_S(ELIBMAX, N_("Attempting to link in too many shared libraries"))
4787 -_S(ERR_MAP(ELIBEXEC), N_("Cannot exec a shared library directly"))
4788 +_S(ELIBEXEC, N_("Cannot exec a shared library directly"))
4791 -_S(ERR_MAP(ESTRPIPE), N_("Streams pipe error"))
4792 +_S(ESTRPIPE, N_("Streams pipe error"))
4795 -_S(ERR_MAP(EUCLEAN), N_("Structure needs cleaning"))
4796 +_S(EUCLEAN, N_("Structure needs cleaning"))
4799 -_S(ERR_MAP(ENOTNAM), N_("Not a XENIX named type file"))
4800 +_S(ENOTNAM, N_("Not a XENIX named type file"))
4803 -_S(ERR_MAP(ENAVAIL), N_("No XENIX semaphores available"))
4804 +_S(ENAVAIL, N_("No XENIX semaphores available"))
4807 -_S(ERR_MAP(EISNAM), N_("Is a named type file"))
4808 +_S(EISNAM, N_("Is a named type file"))
4811 -_S(ERR_MAP(EREMOTEIO), N_("Remote I/O error"))
4812 +_S(EREMOTEIO, N_("Remote I/O error"))
4815 -_S(ERR_MAP(ENOMEDIUM), N_("No medium found"))
4816 +_S(ENOMEDIUM, N_("No medium found"))
4819 -_S(ERR_MAP(EMEDIUMTYPE), N_("Wrong medium type"))
4820 +_S(EMEDIUMTYPE, N_("Wrong medium type"))
4823 -_S(ERR_MAP(ENOKEY), N_("Required key not available"))
4824 +_S(ENOKEY, N_("Required key not available"))
4827 -_S(ERR_MAP(EKEYEXPIRED), N_("Key has expired"))
4828 +_S(EKEYEXPIRED, N_("Key has expired"))
4831 -_S(ERR_MAP(EKEYREVOKED), N_("Key has been revoked"))
4832 +_S(EKEYREVOKED, N_("Key has been revoked"))
4835 -_S(ERR_MAP(EKEYREJECTED), N_("Key was rejected by service"))
4836 +_S(EKEYREJECTED, N_("Key was rejected by service"))
4839 -_S(ERR_MAP(ERFKILL), N_("Operation not possible due to RF-kill"))
4840 +_S(ERFKILL, N_("Operation not possible due to RF-kill"))
4843 -_S(ERR_MAP(EHWPOISON), N_("Memory page has hardware error"))
4844 +_S(EHWPOISON, N_("Memory page has hardware error"))
4847 -_S(ERR_MAP(EBADRPC), N_("RPC struct is bad"))
4848 +_S(EBADRPC, N_("RPC struct is bad"))
4852 @@ -693,40 +690,40 @@ TRANS operation, or a data file had the wrong format.
4854 TRANS On some systems @code{chmod} returns this error if you try to set the
4855 TRANS sticky bit on a non-directory file; @pxref{Setting Permissions}. */
4856 -_S(ERR_MAP(EFTYPE), N_("Inappropriate file type or format"))
4857 +_S(EFTYPE, N_("Inappropriate file type or format"))
4860 -_S(ERR_MAP(EPROCUNAVAIL), N_("RPC bad procedure for program"))
4861 +_S(EPROCUNAVAIL, N_("RPC bad procedure for program"))
4864 -_S(ERR_MAP(EAUTH), N_("Authentication error"))
4865 +_S(EAUTH, N_("Authentication error"))
4869 TRANS On @gnuhurdsystems{}, opening a file returns this error when the file is
4870 TRANS translated by a program and the translator program dies while starting
4871 TRANS up, before it has connected to the file. */
4872 -_S(ERR_MAP(EDIED), N_("Translator died"))
4873 +_S(EDIED, N_("Translator died"))
4876 -_S(ERR_MAP(ERPCMISMATCH), N_("RPC version wrong"))
4877 +_S(ERPCMISMATCH, N_("RPC version wrong"))
4881 TRANS You did @strong{what}? */
4882 -_S(ERR_MAP(EGREGIOUS), N_("You really blew it this time"))
4883 +_S(EGREGIOUS, N_("You really blew it this time"))
4887 TRANS This means that the per-user limit on new process would be exceeded by
4888 TRANS an attempted @code{fork}. @xref{Limits on Resources}, for details on
4889 TRANS the @code{RLIMIT_NPROC} limit. */
4890 -_S(ERR_MAP(EPROCLIM), N_("Too many processes"))
4891 +_S(EPROCLIM, N_("Too many processes"))
4895 TRANS This error code has no purpose. */
4896 -_S(ERR_MAP(EGRATUITOUS), N_("Gratuitous error"))
4897 +_S(EGRATUITOUS, N_("Gratuitous error"))
4899 #if defined (ENOTSUP) && ENOTSUP != EOPNOTSUPP
4901 @@ -742,10 +739,10 @@ TRANS values.
4903 TRANS If the entire function is not available at all in the implementation,
4904 TRANS it returns @code{ENOSYS} instead. */
4905 -_S(ERR_MAP(ENOTSUP), N_("Not supported"))
4906 +_S(ENOTSUP, N_("Not supported"))
4908 #ifdef EPROGMISMATCH
4909 -_S(ERR_MAP(EPROGMISMATCH), N_("RPC program version wrong"))
4910 +_S(EPROGMISMATCH, N_("RPC program version wrong"))
4914 @@ -755,7 +752,7 @@ TRANS foreground process group of the terminal. Users do not usually see this
4915 TRANS error because functions such as @code{read} and @code{write} translate
4916 TRANS it into a @code{SIGTTIN} or @code{SIGTTOU} signal. @xref{Job Control},
4917 TRANS for information on process groups and these signals. */
4918 -_S(ERR_MAP(EBACKGROUND), N_("Inappropriate operation for background process"))
4919 +_S(EBACKGROUND, N_("Inappropriate operation for background process"))
4923 @@ -773,7 +770,7 @@ TRANS @c "bought the farm" means "died". -jtobey
4925 TRANS @c Translators, please do not translate this litteraly, translate it into
4926 TRANS @c an idiomatic funny way of saying that the computer died. */
4927 -_S(ERR_MAP(EIEIO), N_("Computer bought the farm"))
4928 +_S(EIEIO, N_("Computer bought the farm"))
4930 #if defined (EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
4932 @@ -782,18 +779,18 @@ TRANS The values are always the same, on every operating system.
4934 TRANS C libraries in many older Unix systems have @code{EWOULDBLOCK} as a
4935 TRANS separate error code. */
4936 -_S(ERR_MAP(EWOULDBLOCK), N_("Operation would block"))
4937 +_S(EWOULDBLOCK, N_("Operation would block"))
4940 -_S(ERR_MAP(ENEEDAUTH), N_("Need authenticator"))
4941 +_S(ENEEDAUTH, N_("Need authenticator"))
4945 TRANS The experienced user will know what is wrong.
4946 TRANS @c This error code is a joke. Its perror text is part of the joke.
4947 TRANS @c Don't change it. */
4948 -_S(ERR_MAP(ED), N_("?"))
4952 -_S(ERR_MAP(EPROGUNAVAIL), N_("RPC program not available"))
4953 +_S(EPROGUNAVAIL, N_("RPC program not available"))
4955 diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
4956 index 0f08079e48..672d8f27ce 100644
4957 --- a/sysdeps/i386/dl-machine.h
4958 +++ b/sysdeps/i386/dl-machine.h
4959 @@ -338,16 +338,22 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
4961 # ifndef RTLD_BOOTSTRAP
4963 - && sym_map->l_type != lt_executable
4964 && !sym_map->l_relocated)
4967 = (const char *) D_PTR (map, l_info[DT_STRTAB]);
4968 - _dl_error_printf ("\
4969 + if (sym_map->l_type == lt_executable)
4970 + _dl_fatal_printf ("\
4971 +%s: IFUNC symbol '%s' referenced in '%s' is defined in the executable \
4972 +and creates an unsatisfiable circular dependency.\n",
4973 + RTLD_PROGNAME, strtab + refsym->st_name,
4976 + _dl_error_printf ("\
4977 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
4978 - RTLD_PROGNAME, map->l_name,
4980 - strtab + refsym->st_name);
4981 + RTLD_PROGNAME, map->l_name,
4983 + strtab + refsym->st_name);
4986 value = ((Elf32_Addr (*) (void)) value) ();
4987 diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c
4988 index 8a53a1088f..362a2b713c 100644
4989 --- a/sysdeps/powerpc/powerpc64/backtrace.c
4990 +++ b/sysdeps/powerpc/powerpc64/backtrace.c
4991 @@ -54,11 +54,22 @@ struct signal_frame_64 {
4992 /* We don't care about the rest, since the IP value is at 'uc' field. */
4995 +/* Test if the address match to the inside the trampoline code.
4996 + Up to and including kernel 5.8, returning from an interrupt or syscall to a
4997 + signal handler starts execution directly at the handler's entry point, with
4998 + LR set to address of the sigreturn trampoline (the vDSO symbol).
4999 + Newer kernels will branch to signal handler from the trampoline instead, so
5000 + checking the stacktrace against the vDSO entrypoint does not work in such
5002 + The vDSO branches with a 'bctrl' instruction, so checking either the
5003 + vDSO address itself and the next instruction should cover all kernel
5006 is_sigtramp_address (void *nip)
5008 #ifdef HAVE_SIGTRAMP_RT64
5009 - if (nip == GLRO (dl_vdso_sigtramp_rt64))
5010 + if (nip == GLRO (dl_vdso_sigtramp_rt64) ||
5011 + nip == GLRO (dl_vdso_sigtramp_rt64) + 4)
5015 diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure
5016 index fa46e9e351..e7f576338d 100644
5017 --- a/sysdeps/s390/configure
5018 +++ b/sysdeps/s390/configure
5019 @@ -123,7 +123,9 @@ void testinsn (char *buf)
5020 __asm__ (".machine \"arch13\" \n\t"
5021 ".machinemode \"zarch_nohighgprs\" \n\t"
5023 - "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
5024 + "mvcrl 0(%0),32(%0) \n\t"
5025 + "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
5026 + : : "a" (buf) : "memory", "r0");
5029 if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
5030 @@ -271,7 +273,9 @@ else
5031 void testinsn (char *buf)
5033 __asm__ ("lghi %%r0,16 \n\t"
5034 - "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
5035 + "mvcrl 0(%0),32(%0) \n\t"
5036 + "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
5037 + : : "a" (buf) : "memory", "r0");
5040 if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
5041 diff --git a/sysdeps/s390/configure.ac b/sysdeps/s390/configure.ac
5042 index 3ed5a8ef87..5c3479e8cf 100644
5043 --- a/sysdeps/s390/configure.ac
5044 +++ b/sysdeps/s390/configure.ac
5045 @@ -88,7 +88,9 @@ void testinsn (char *buf)
5046 __asm__ (".machine \"arch13\" \n\t"
5047 ".machinemode \"zarch_nohighgprs\" \n\t"
5049 - "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
5050 + "mvcrl 0(%0),32(%0) \n\t"
5051 + "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
5052 + : : "a" (buf) : "memory", "r0");
5055 dnl test, if assembler supports S390 arch13 instructions
5056 @@ -195,7 +197,9 @@ cat > conftest.c <<\EOF
5057 void testinsn (char *buf)
5059 __asm__ ("lghi %%r0,16 \n\t"
5060 - "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
5061 + "mvcrl 0(%0),32(%0) \n\t"
5062 + "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
5063 + : : "a" (buf) : "memory", "r0");
5066 dnl test, if assembler supports S390 arch13 zarch instructions as default
5067 diff --git a/sysdeps/s390/memmove.c b/sysdeps/s390/memmove.c
5068 index 5fc85e129f..ee59b5de14 100644
5069 --- a/sysdeps/s390/memmove.c
5070 +++ b/sysdeps/s390/memmove.c
5071 @@ -43,7 +43,7 @@ extern __typeof (__redirect_memmove) MEMMOVE_ARCH13 attribute_hidden;
5072 s390_libc_ifunc_expr (__redirect_memmove, memmove,
5074 s390_libc_ifunc_expr_stfle_init ();
5075 - (HAVE_MEMMOVE_ARCH13
5076 + (HAVE_MEMMOVE_ARCH13 && (hwcap & HWCAP_S390_VXRS_EXT2)
5077 && S390_IS_ARCH13_MIE3 (stfle_bits))
5079 : (HAVE_MEMMOVE_Z13 && (hwcap & HWCAP_S390_VX))
5080 diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
5081 index e6195c6e26..17c0cc3952 100644
5082 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c
5083 +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
5084 @@ -171,7 +171,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
5085 IFUNC_IMPL (i, name, memmove,
5086 # if HAVE_MEMMOVE_ARCH13
5087 IFUNC_IMPL_ADD (array, i, memmove,
5088 - S390_IS_ARCH13_MIE3 (stfle_bits),
5089 + ((dl_hwcap & HWCAP_S390_VXRS_EXT2)
5090 + && S390_IS_ARCH13_MIE3 (stfle_bits)),
5093 # if HAVE_MEMMOVE_Z13
5094 diff --git a/sysdeps/sh/be/sh4/fpu/Implies b/sysdeps/sh/be/sh4/fpu/Implies
5095 new file mode 100644
5096 index 0000000000..71b28ee1a4
5098 +++ b/sysdeps/sh/be/sh4/fpu/Implies
5101 diff --git a/sysdeps/sh/le/sh4/fpu/Implies b/sysdeps/sh/le/sh4/fpu/Implies
5102 new file mode 100644
5103 index 0000000000..71b28ee1a4
5105 +++ b/sysdeps/sh/le/sh4/fpu/Implies
5108 diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
5109 index 9b2a253032..34748ffcd1 100644
5110 --- a/sysdeps/unix/sysv/linux/Makefile
5111 +++ b/sysdeps/unix/sysv/linux/Makefile
5112 @@ -100,7 +100,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
5113 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
5114 test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \
5115 tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
5117 + tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux
5118 tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
5120 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
5121 diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
5122 index fc688450ee..00a4d0c8e7 100644
5123 --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
5124 +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.h
5126 && MIDR_PARTNUM(midr) == 0x000)
5127 #define IS_NEOVERSE_N1(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \
5128 && MIDR_PARTNUM(midr) == 0xd0c)
5129 +#define IS_NEOVERSE_N2(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \
5130 + && MIDR_PARTNUM(midr) == 0xd49)
5131 +#define IS_NEOVERSE_V1(midr) (MIDR_IMPLEMENTOR(midr) == 'A' \
5132 + && MIDR_PARTNUM(midr) == 0xd40)
5134 #define IS_EMAG(midr) (MIDR_IMPLEMENTOR(midr) == 'P' \
5135 && MIDR_PARTNUM(midr) == 0x000)
5136 diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
5137 index 61bbb03b64..b5a903c3a2 100644
5138 --- a/sysdeps/unix/sysv/linux/mq_notify.c
5139 +++ b/sysdeps/unix/sysv/linux/mq_notify.c
5140 @@ -133,8 +133,11 @@ helper_thread (void *arg)
5141 (void) __pthread_barrier_wait (¬ify_barrier);
5143 else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED)
5144 - /* The only state we keep is the copy of the thread attributes. */
5147 + /* The only state we keep is the copy of the thread attributes. */
5148 + pthread_attr_destroy (data.attr);
5154 @@ -255,8 +258,14 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification)
5155 if (data.attr == NULL)
5158 - memcpy (data.attr, notification->sigev_notify_attributes,
5159 - sizeof (pthread_attr_t));
5160 + int ret = __pthread_attr_copy (data.attr,
5161 + notification->sigev_notify_attributes);
5165 + __set_errno (ret);
5170 /* Construct the new request. */
5171 @@ -269,8 +278,11 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification)
5172 int retval = INLINE_SYSCALL (mq_notify, 2, mqdes, &se);
5174 /* If it failed, free the allocated memory. */
5175 - if (__glibc_unlikely (retval != 0))
5177 + if (retval != 0 && data.attr != NULL)
5179 + pthread_attr_destroy (data.attr);
5185 diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c
5186 index 0776472d5e..a1f24ab242 100644
5187 --- a/sysdeps/unix/sysv/linux/msgctl.c
5188 +++ b/sysdeps/unix/sysv/linux/msgctl.c
5189 @@ -90,8 +90,15 @@ __msgctl64 (int msqid, int cmd, struct __msqid64_ds *buf)
5190 struct kernel_msqid64_ds ksemid, *arg = NULL;
5193 - msqid64_to_kmsqid64 (buf, &ksemid);
5195 + /* This is a Linux extension where kernel returns a 'struct msginfo'
5197 + if (cmd == IPC_INFO || cmd == MSG_INFO)
5198 + arg = (struct kernel_msqid64_ds *) buf;
5201 + msqid64_to_kmsqid64 (buf, &ksemid);
5205 # ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
5207 @@ -169,8 +176,15 @@ __msgctl (int msqid, int cmd, struct msqid_ds *buf)
5208 struct __msqid64_ds msqid64, *buf64 = NULL;
5211 - msqid_to_msqid64 (&msqid64, buf);
5213 + /* This is a Linux extension where kernel returns a 'struct msginfo'
5215 + if (cmd == IPC_INFO || cmd == MSG_INFO)
5216 + buf64 = (struct __msqid64_ds *) buf;
5219 + msqid_to_msqid64 (&msqid64, buf);
5224 int ret = __msgctl64 (msqid, cmd, buf64);
5225 diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
5226 index f131a26fc7..1cdabde8f2 100644
5227 --- a/sysdeps/unix/sysv/linux/semctl.c
5228 +++ b/sysdeps/unix/sysv/linux/semctl.c
5229 @@ -102,6 +102,7 @@ semun64_to_ksemun64 (int cmd, union semun64 semun64,
5230 r.array = semun64.array;
5233 + case SEM_STAT_ANY:
5237 @@ -150,6 +151,7 @@ __semctl64 (int semid, int semnum, int cmd, ...)
5238 case IPC_STAT: /* arg.buf */
5241 + case SEM_STAT_ANY:
5242 case IPC_INFO: /* arg.__buf */
5245 @@ -238,6 +240,7 @@ semun_to_semun64 (int cmd, union semun semun, struct __semid64_ds *semid64)
5246 r.array = semun.array;
5249 + case SEM_STAT_ANY:
5253 @@ -267,6 +270,7 @@ __semctl (int semid, int semnum, int cmd, ...)
5254 case IPC_STAT: /* arg.buf */
5257 + case SEM_STAT_ANY:
5258 case IPC_INFO: /* arg.__buf */
5261 @@ -321,6 +325,7 @@ __semctl_mode16 (int semid, int semnum, int cmd, ...)
5262 case IPC_STAT: /* arg.buf */
5265 + case SEM_STAT_ANY:
5266 case IPC_INFO: /* arg.__buf */
5269 @@ -354,6 +359,7 @@ __old_semctl (int semid, int semnum, int cmd, ...)
5270 case IPC_STAT: /* arg.buf */
5273 + case SEM_STAT_ANY:
5274 case IPC_INFO: /* arg.__buf */
5277 diff --git a/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies b/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies
5278 new file mode 100644
5279 index 0000000000..7eeaf15a5a
5281 +++ b/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies
5283 +unix/sysv/linux/sh/sh4/fpu
5284 diff --git a/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies b/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies
5285 new file mode 100644
5286 index 0000000000..7eeaf15a5a
5288 +++ b/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies
5290 +unix/sysv/linux/sh/sh4/fpu
5291 diff --git a/sysdeps/unix/sysv/linux/shmctl.c b/sysdeps/unix/sysv/linux/shmctl.c
5292 index 76d88441f1..1d19a798b1 100644
5293 --- a/sysdeps/unix/sysv/linux/shmctl.c
5294 +++ b/sysdeps/unix/sysv/linux/shmctl.c
5295 @@ -90,8 +90,15 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf)
5296 struct kernel_shmid64_ds kshmid, *arg = NULL;
5299 - shmid64_to_kshmid64 (buf, &kshmid);
5301 + /* This is a Linux extension where kernel expects either a
5302 + 'struct shminfo' (IPC_INFO) or 'struct shm_info' (SHM_INFO). */
5303 + if (cmd == IPC_INFO || cmd == SHM_INFO)
5304 + arg = (struct kernel_shmid64_ds *) buf;
5307 + shmid64_to_kshmid64 (buf, &kshmid);
5311 # ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
5313 @@ -107,7 +114,6 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf)
5321 @@ -168,8 +174,15 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf)
5322 struct __shmid64_ds shmid64, *buf64 = NULL;
5325 - shmid_to_shmid64 (&shmid64, buf);
5327 + /* This is a Linux extension where kernel expects either a
5328 + 'struct shminfo' (IPC_INFO) or 'struct shm_info' (SHM_INFO). */
5329 + if (cmd == IPC_INFO || cmd == SHM_INFO)
5330 + buf64 = (struct __shmid64_ds *) buf;
5333 + shmid_to_shmid64 (&shmid64, buf);
5338 int ret = __shmctl64 (shmid, cmd, buf64);
5339 @@ -178,7 +191,6 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf)
5347 diff --git a/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c b/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c
5348 new file mode 100644
5349 index 0000000000..630f4f792c
5351 +++ b/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c
5353 +/* Basic tests for Linux SYSV message queue extensions.
5354 + Copyright (C) 2020 Free Software Foundation, Inc.
5355 + This file is part of the GNU C Library.
5357 + The GNU C Library is free software; you can redistribute it and/or
5358 + modify it under the terms of the GNU Lesser General Public
5359 + License as published by the Free Software Foundation; either
5360 + version 2.1 of the License, or (at your option) any later version.
5362 + The GNU C Library is distributed in the hope that it will be useful,
5363 + but WITHOUT ANY WARRANTY; without even the implied warranty of
5364 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5365 + Lesser General Public License for more details.
5367 + You should have received a copy of the GNU Lesser General Public
5368 + License along with the GNU C Library; if not, see
5369 + <https://www.gnu.org/licenses/>. */
5371 +#include <sys/ipc.h>
5372 +#include <sys/msg.h>
5374 +#include <stdlib.h>
5375 +#include <stdbool.h>
5378 +#include <support/check.h>
5379 +#include <support/temp_file.h>
5381 +#define MSGQ_MODE 0644
5383 +/* These are for the temporary file we generate. */
5390 + /* Enforce message queue removal in case of early test failure.
5391 + Ignore error since the msg may already have being removed. */
5392 + msgctl (msqid, IPC_RMID, NULL);
5396 +do_prepare (int argc, char *argv[])
5398 + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvmsg.", &name) != -1);
5401 +#define PREPARE do_prepare
5403 +struct test_msginfo
5410 +/* It tries to obtain some system-wide SysV messsage queue information from
5411 + /proc to check against IPC_INFO/MSG_INFO. The /proc only returns the
5412 + tunables value of MSGMAX, MSGMNB, and MSGMNI.
5414 + The kernel also returns constant value for MSGSSZ, MSGSEG and also MSGMAP,
5415 + MSGPOOL, and MSGTQL (for IPC_INFO). The issue to check them is they might
5416 + change over kernel releases. */
5419 +read_proc_file (const char *file)
5421 + FILE *f = fopen (file, "r");
5423 + FAIL_UNSUPPORTED ("/proc is not mounted or %s is not available", file);
5426 + int r = fscanf (f, "%d", & v);
5427 + TEST_VERIFY_EXIT (r == 1);
5434 +/* Check if the message queue with IDX (index into the kernel's internal
5435 + array) matches the one with KEY. The CMD is either MSG_STAT or
5439 +check_msginfo (int idx, key_t key, int cmd)
5441 + struct msqid_ds msginfo;
5442 + int mid = msgctl (idx, cmd, &msginfo);
5443 + /* Ignore unused array slot returned by the kernel or information from
5444 + unknown message queue. */
5445 + if ((mid == -1 && errno == EINVAL) || mid != msqid)
5449 + FAIL_EXIT1 ("msgctl with %s failed: %m",
5450 + cmd == MSG_STAT ? "MSG_STAT" : "MSG_STAT_ANY");
5452 + TEST_COMPARE (msginfo.msg_perm.__key, key);
5453 + TEST_COMPARE (msginfo.msg_perm.mode, MSGQ_MODE);
5454 + TEST_COMPARE (msginfo.msg_qnum, 0);
5462 + atexit (remove_msq);
5464 + key_t key = ftok (name, 'G');
5466 + FAIL_EXIT1 ("ftok failed: %m");
5468 + msqid = msgget (key, MSGQ_MODE | IPC_CREAT);
5470 + FAIL_EXIT1 ("msgget failed: %m");
5472 + struct test_msginfo tipcinfo;
5473 + tipcinfo.msgmax = read_proc_file ("/proc/sys/kernel/msgmax");
5474 + tipcinfo.msgmnb = read_proc_file ("/proc/sys/kernel/msgmnb");
5475 + tipcinfo.msgmni = read_proc_file ("/proc/sys/kernel/msgmni");
5480 + struct msginfo ipcinfo;
5481 + msqidx = msgctl (msqid, IPC_INFO, (struct msqid_ds *) &ipcinfo);
5483 + FAIL_EXIT1 ("msgctl with IPC_INFO failed: %m");
5485 + TEST_COMPARE (ipcinfo.msgmax, tipcinfo.msgmax);
5486 + TEST_COMPARE (ipcinfo.msgmnb, tipcinfo.msgmnb);
5487 + TEST_COMPARE (ipcinfo.msgmni, tipcinfo.msgmni);
5490 + /* Same as before but with MSG_INFO. */
5492 + struct msginfo ipcinfo;
5493 + msqidx = msgctl (msqid, MSG_INFO, (struct msqid_ds *) &ipcinfo);
5495 + FAIL_EXIT1 ("msgctl with IPC_INFO failed: %m");
5497 + TEST_COMPARE (ipcinfo.msgmax, tipcinfo.msgmax);
5498 + TEST_COMPARE (ipcinfo.msgmnb, tipcinfo.msgmnb);
5499 + TEST_COMPARE (ipcinfo.msgmni, tipcinfo.msgmni);
5502 + /* We check if the created message queue shows in global list. */
5503 + bool found = false;
5504 + for (int i = 0; i <= msqidx; i++)
5506 + /* We can't tell apart if MSG_STAT_ANY is not supported (kernel older
5507 + than 4.17) or if the index used is invalid. So it just check if the
5508 + value returned from a valid call matches the created message
5510 + check_msginfo (i, key, MSG_STAT_ANY);
5512 + if (check_msginfo (i, key, MSG_STAT))
5520 + FAIL_EXIT1 ("msgctl with MSG_STAT/MSG_STAT_ANY could not find the "
5521 + "created message queue");
5523 + if (msgctl (msqid, IPC_RMID, NULL) == -1)
5524 + FAIL_EXIT1 ("msgctl failed");
5529 +#include <support/test-driver.c>
5530 diff --git a/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
5531 new file mode 100644
5532 index 0000000000..45f19e2d37
5534 +++ b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c
5536 +/* Basic tests for Linux SYSV semaphore extensions.
5537 + Copyright (C) 2020 Free Software Foundation, Inc.
5538 + This file is part of the GNU C Library.
5540 + The GNU C Library is free software; you can redistribute it and/or
5541 + modify it under the terms of the GNU Lesser General Public
5542 + License as published by the Free Software Foundation; either
5543 + version 2.1 of the License, or (at your option) any later version.
5545 + The GNU C Library is distributed in the hope that it will be useful,
5546 + but WITHOUT ANY WARRANTY; without even the implied warranty of
5547 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5548 + Lesser General Public License for more details.
5550 + You should have received a copy of the GNU Lesser General Public
5551 + License along with the GNU C Library; if not, see
5552 + <https://www.gnu.org/licenses/>. */
5554 +#include <sys/ipc.h>
5555 +#include <sys/sem.h>
5557 +#include <stdlib.h>
5558 +#include <stdbool.h>
5561 +#include <support/check.h>
5562 +#include <support/temp_file.h>
5564 +/* These are for the temporary file we generate. */
5571 + /* Enforce message queue removal in case of early test failure.
5572 + Ignore error since the sem may already have being removed. */
5573 + semctl (semid, 0, IPC_RMID, 0);
5577 +do_prepare (int argc, char *argv[])
5579 + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvsem.", &name) != -1);
5582 +#define PREPARE do_prepare
5584 +#define SEM_MODE 0644
5589 + struct semid_ds *buf;
5590 + unsigned short *array;
5591 + struct seminfo *__buf;
5594 +struct test_seminfo
5602 +/* It tries to obtain some system-wide SysV semaphore information from /proc
5603 + to check against IPC_INFO/SEM_INFO. The /proc only returns the tunables
5604 + value of SEMMSL, SEMMNS, SEMOPM, and SEMMNI.
5606 + The kernel also returns constant value for SEMVMX, SEMMNU, SEMMAP, SEMUME,
5607 + and also SEMUSZ and SEMAEM (for IPC_INFO). The issue to check them is they
5608 + might change over kernel releases. */
5611 +read_sem_stat (struct test_seminfo *tseminfo)
5613 + FILE *f = fopen ("/proc/sys/kernel/sem", "r");
5615 + FAIL_UNSUPPORTED ("/proc is not mounted or /proc/sys/kernel/sem is not "
5618 + int r = fscanf (f, "%d %d %d %d",
5619 + &tseminfo->semmsl, &tseminfo->semmns, &tseminfo->semopm,
5620 + &tseminfo->semmni);
5621 + TEST_VERIFY_EXIT (r == 4);
5627 +/* Check if the semaphore with IDX (index into the kernel's internal array)
5628 + matches the one with KEY. The CMD is either SEM_STAT or SEM_STAT_ANY. */
5631 +check_seminfo (int idx, key_t key, int cmd)
5633 + struct semid_ds seminfo;
5634 + int sid = semctl (idx, 0, cmd, (union semun) { .buf = &seminfo });
5635 + /* Ignore unused array slot returned by the kernel or information from
5636 + unknown semaphores. */
5637 + if ((sid == -1 && errno == EINVAL) || sid != semid)
5641 + FAIL_EXIT1 ("semctl with SEM_STAT failed (errno=%d)", errno);
5643 + TEST_COMPARE (seminfo.sem_perm.__key, key);
5644 + TEST_COMPARE (seminfo.sem_perm.mode, SEM_MODE);
5645 + TEST_COMPARE (seminfo.sem_nsems, 1);
5653 + atexit (remove_sem);
5655 + key_t key = ftok (name, 'G');
5657 + FAIL_EXIT1 ("ftok failed: %m");
5659 + semid = semget (key, 1, IPC_CREAT | IPC_EXCL | SEM_MODE);
5661 + FAIL_EXIT1 ("semget failed: %m");
5663 + struct test_seminfo tipcinfo;
5664 + read_sem_stat (&tipcinfo);
5669 + struct seminfo ipcinfo;
5670 + semidx = semctl (semid, 0, IPC_INFO, (union semun) { .__buf = &ipcinfo });
5672 + FAIL_EXIT1 ("semctl with IPC_INFO failed: %m");
5674 + TEST_COMPARE (ipcinfo.semmsl, tipcinfo.semmsl);
5675 + TEST_COMPARE (ipcinfo.semmns, tipcinfo.semmns);
5676 + TEST_COMPARE (ipcinfo.semopm, tipcinfo.semopm);
5677 + TEST_COMPARE (ipcinfo.semmni, tipcinfo.semmni);
5680 + /* Same as before but with SEM_INFO. */
5682 + struct seminfo ipcinfo;
5683 + semidx = semctl (semid, 0, SEM_INFO, (union semun) { .__buf = &ipcinfo });
5685 + FAIL_EXIT1 ("semctl with IPC_INFO failed: %m");
5687 + TEST_COMPARE (ipcinfo.semmsl, tipcinfo.semmsl);
5688 + TEST_COMPARE (ipcinfo.semmns, tipcinfo.semmns);
5689 + TEST_COMPARE (ipcinfo.semopm, tipcinfo.semopm);
5690 + TEST_COMPARE (ipcinfo.semmni, tipcinfo.semmni);
5693 + /* We check if the created semaphore shows in the system-wide status. */
5694 + bool found = false;
5695 + for (int i = 0; i <= semidx; i++)
5697 + /* We can't tell apart if SEM_STAT_ANY is not supported (kernel older
5698 + than 4.17) or if the index used is invalid. So it just check if
5699 + value returned from a valid call matches the created semaphore. */
5700 + check_seminfo (i, key, SEM_STAT_ANY);
5702 + if (check_seminfo (i, key, SEM_STAT))
5710 + FAIL_EXIT1 ("semctl with SEM_STAT/SEM_STAT_ANY could not find the "
5711 + "created semaphore");
5713 + if (semctl (semid, 0, IPC_RMID, 0) == -1)
5714 + FAIL_EXIT1 ("semctl failed: %m");
5719 +#include <support/test-driver.c>
5720 diff --git a/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
5721 new file mode 100644
5722 index 0000000000..7128ae2e14
5724 +++ b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
5726 +/* Basic tests for Linux SYSV shared memory extensions.
5727 + Copyright (C) 2020 Free Software Foundation, Inc.
5728 + This file is part of the GNU C Library.
5730 + The GNU C Library is free software; you can redistribute it and/or
5731 + modify it under the terms of the GNU Lesser General Public
5732 + License as published by the Free Software Foundation; either
5733 + version 2.1 of the License, or (at your option) any later version.
5735 + The GNU C Library is distributed in the hope that it will be useful,
5736 + but WITHOUT ANY WARRANTY; without even the implied warranty of
5737 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5738 + Lesser General Public License for more details.
5740 + You should have received a copy of the GNU Lesser General Public
5741 + License along with the GNU C Library; if not, see
5742 + <https://www.gnu.org/licenses/>. */
5744 +#include <sys/ipc.h>
5745 +#include <sys/shm.h>
5747 +#include <stdlib.h>
5748 +#include <stdbool.h>
5750 +#include <unistd.h>
5751 +#include <inttypes.h>
5752 +#include <limits.h>
5754 +#include <support/check.h>
5755 +#include <support/temp_file.h>
5757 +#define SHM_MODE 0644
5759 +/* These are for the temporary file we generate. */
5762 +static long int pgsz;
5767 + /* Enforce message queue removal in case of early test failure.
5768 + Ignore error since the shm may already have being removed. */
5769 + shmctl (shmid, IPC_RMID, NULL);
5773 +do_prepare (int argc, char *argv[])
5775 + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvshm.", &name) != -1);
5778 +#define PREPARE do_prepare
5780 +struct test_shminfo
5782 + unsigned long int shmall;
5783 + unsigned long int shmmax;
5784 + unsigned long int shmmni;
5787 +/* It tries to obtain some system-wide SysV shared memory information from
5788 + /proc to check against IPC_INFO/SHM_INFO. The /proc only returns the
5789 + tunables value of SHMALL, SHMMAX, and SHMMNI. */
5792 +read_proc_file (const char *file)
5794 + FILE *f = fopen (file, "r");
5796 + FAIL_UNSUPPORTED ("/proc is not mounted or %s is not available", file);
5798 + /* Handle 32-bit binaries running on 64-bit kernels. */
5800 + int r = fscanf (f, "%" SCNu64, &v);
5801 + TEST_VERIFY_EXIT (r == 1);
5808 +/* Check if the message queue with IDX (index into the kernel's internal
5809 + array) matches the one with KEY. The CMD is either SHM_STAT or
5813 +check_shminfo (int idx, key_t key, int cmd)
5815 + struct shmid_ds shminfo;
5816 + int sid = shmctl (idx, cmd, &shminfo);
5817 + /* Ignore unused array slot returned by the kernel or information from
5818 + unknown message queue. */
5819 + if ((sid == -1 && errno == EINVAL) || sid != shmid)
5823 + FAIL_EXIT1 ("shmctl with %s failed: %m",
5824 + cmd == SHM_STAT ? "SHM_STAT" : "SHM_STAT_ANY");
5826 + TEST_COMPARE (shminfo.shm_perm.__key, key);
5827 + TEST_COMPARE (shminfo.shm_perm.mode, SHM_MODE);
5828 + TEST_COMPARE (shminfo.shm_segsz, pgsz);
5836 + atexit (remove_shm);
5838 + pgsz = sysconf (_SC_PAGESIZE);
5840 + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE) failed: %m");
5842 + key_t key = ftok (name, 'G');
5844 + FAIL_EXIT1 ("ftok failed: %m");
5846 + shmid = shmget (key, pgsz, IPC_CREAT | IPC_EXCL | SHM_MODE);
5848 + FAIL_EXIT1 ("shmget failed: %m");
5850 + struct test_shminfo tipcinfo;
5852 + uint64_t v = read_proc_file ("/proc/sys/kernel/shmmax");
5853 +#if LONG_MAX == INT_MAX
5854 + /* Kernel explicit clamp the value for shmmax on compat symbol (32-bit
5855 + binaries running on 64-bit kernels). */
5859 + tipcinfo.shmmax = v;
5861 + tipcinfo.shmall = read_proc_file ("/proc/sys/kernel/shmall");
5862 + tipcinfo.shmmni = read_proc_file ("/proc/sys/kernel/shmmni");
5866 + /* Note: SHM_INFO does not return a shminfo, but rather a 'struct shm_info'.
5867 + It is tricky to verify its values since the syscall returns system wide
5868 + resources consumed by shared memory. The shmctl implementation handles
5869 + SHM_INFO as IPC_INFO, so the IPC_INFO test should validate SHM_INFO as
5873 + struct shminfo ipcinfo;
5874 + shmidx = shmctl (shmid, IPC_INFO, (struct shmid_ds *) &ipcinfo);
5876 + FAIL_EXIT1 ("shmctl with IPC_INFO failed: %m");
5878 + TEST_COMPARE (ipcinfo.shmall, tipcinfo.shmall);
5879 + TEST_COMPARE (ipcinfo.shmmax, tipcinfo.shmmax);
5880 + TEST_COMPARE (ipcinfo.shmmni, tipcinfo.shmmni);
5883 + /* We check if the created shared memory shows in the global list. */
5884 + bool found = false;
5885 + for (int i = 0; i <= shmidx; i++)
5887 + /* We can't tell apart if SHM_STAT_ANY is not supported (kernel older
5888 + than 4.17) or if the index used is invalid. So it just check if
5889 + value returned from a valid call matches the created message
5891 + check_shminfo (i, key, SHM_STAT_ANY);
5893 + if (check_shminfo (i, key, SHM_STAT))
5901 + FAIL_EXIT1 ("shmctl with SHM_STAT/SHM_STAT_ANY could not find the "
5902 + "created shared memory");
5904 + if (shmctl (shmid, IPC_RMID, NULL) == -1)
5905 + FAIL_EXIT1 ("shmctl failed");
5910 +#include <support/test-driver.c>
5911 diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
5912 index a6736aef25..9736a13e7b 100644
5913 --- a/sysdeps/x86/Makefile
5914 +++ b/sysdeps/x86/Makefile
5915 @@ -12,6 +12,12 @@ endif
5916 ifeq ($(subdir),setjmp)
5917 gen-as-const-headers += jmp_buf-ssp.sym
5918 sysdep_routines += __longjmp_cancel
5919 +ifneq ($(enable-cet),no)
5920 +ifneq ($(have-tunables),no)
5921 +tests += tst-setjmp-cet
5922 +tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on
5927 ifeq ($(subdir),string)
5928 diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c
5929 index 217c21c34f..3fb4a028d8 100644
5930 --- a/sysdeps/x86/cacheinfo.c
5931 +++ b/sysdeps/x86/cacheinfo.c
5932 @@ -808,7 +808,7 @@ init_cacheinfo (void)
5933 threads = 1 << ((ecx >> 12) & 0x0f);
5937 + if (threads == 0 || cpu_features->basic.family >= 0x17)
5939 /* If APIC ID width is not available, use logical
5941 @@ -823,8 +823,22 @@ init_cacheinfo (void)
5945 - /* Account for exclusive L2 and L3 caches. */
5947 + /* Get shared cache per ccx for Zen architectures. */
5948 + if (cpu_features->basic.family >= 0x17)
5952 + /* Get number of threads share the L3 cache in CCX. */
5953 + __cpuid_count (0x8000001D, 0x3, eax, ebx, ecx, edx);
5955 + unsigned int threads_per_ccx = ((eax >> 14) & 0xfff) + 1;
5956 + shared *= threads_per_ccx;
5960 + /* Account for exclusive L2 and L3 caches. */
5966 @@ -854,14 +868,20 @@ init_cacheinfo (void)
5967 __x86_shared_cache_size = shared;
5970 - /* The large memcpy micro benchmark in glibc shows that 6 times of
5971 - shared cache size is the approximate value above which non-temporal
5972 - store becomes faster on a 8-core processor. This is the 3/4 of the
5973 - total shared cache size. */
5974 + /* The default setting for the non_temporal threshold is 3/4 of one
5975 + thread's share of the chip's cache. For most Intel and AMD processors
5976 + with an initial release date between 2017 and 2020, a thread's typical
5977 + share of the cache is from 500 KBytes to 2 MBytes. Using the 3/4
5978 + threshold leaves 125 KBytes to 500 KBytes of the thread's data
5979 + in cache after a maximum temporal copy, which will maintain
5980 + in cache a reasonable portion of the thread's stack and other
5981 + active data. If the threshold is set higher than one thread's
5982 + share of the cache, it has a substantial risk of negatively
5983 + impacting the performance of other threads running on the chip. */
5984 __x86_shared_non_temporal_threshold
5985 = (cpu_features->non_temporal_threshold != 0
5986 ? cpu_features->non_temporal_threshold
5987 - : __x86_shared_cache_size * threads * 3 / 4);
5988 + : __x86_shared_cache_size * 3 / 4);
5990 /* NB: The REP MOVSB threshold must be greater than VEC_SIZE * 8. */
5991 unsigned int minimum_rep_movsb_threshold;
5992 diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c
5993 index 03572f7af6..3cc54a8d53 100644
5994 --- a/sysdeps/x86/dl-cet.c
5995 +++ b/sysdeps/x86/dl-cet.c
5996 @@ -47,7 +47,10 @@ dl_cet_check (struct link_map *m, const char *program)
5997 /* No legacy object check if both IBT and SHSTK are always on. */
5998 if (enable_ibt_type == cet_always_on
5999 && enable_shstk_type == cet_always_on)
6002 + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1));
6006 /* Check if IBT is enabled by kernel. */
6008 diff --git a/sysdeps/x86/dl-prop.h b/sysdeps/x86/dl-prop.h
6009 index 89911e19e2..4eb3b85a7b 100644
6010 --- a/sysdeps/x86/dl-prop.h
6011 +++ b/sysdeps/x86/dl-prop.h
6012 @@ -145,15 +145,15 @@ _dl_process_cet_property_note (struct link_map *l,
6015 static inline void __attribute__ ((unused))
6016 -_dl_process_pt_note (struct link_map *l, const ElfW(Phdr) *ph)
6017 +_dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
6019 const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
6020 _dl_process_cet_property_note (l, note, ph->p_memsz, ph->p_align);
6023 static inline int __attribute__ ((always_inline))
6024 -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz,
6026 +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
6027 + uint32_t datasz, void *data)
6031 diff --git a/sysdeps/x86/tst-setjmp-cet.c b/sysdeps/x86/tst-setjmp-cet.c
6032 new file mode 100644
6033 index 0000000000..42c795d2a8
6035 +++ b/sysdeps/x86/tst-setjmp-cet.c
6037 +#include <setjmp/tst-setjmp.c>
6038 diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure
6041 index 84f82c2406..fc1840e23f
6042 --- a/sysdeps/x86_64/configure
6043 +++ b/sysdeps/x86_64/configure
6044 @@ -107,39 +107,6 @@ if test x"$build_mathvec" = xnotset; then
6048 -if test "$static_pie" = yes; then
6049 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker static PIE support" >&5
6050 -$as_echo_n "checking for linker static PIE support... " >&6; }
6051 -if ${libc_cv_ld_static_pie+:} false; then :
6052 - $as_echo_n "(cached) " >&6
6054 - cat > conftest.s <<\EOF
6059 - leaq foo(%rip), %rax
6061 - libc_cv_pie_option="-Wl,-pie"
6062 - if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp $libc_cv_pie_option -o conftest conftest.s 1>&5'
6063 - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
6064 - (eval $ac_try) 2>&5
6066 - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
6067 - test $ac_status = 0; }; }; then
6068 - libc_cv_ld_static_pie=yes
6070 - libc_cv_ld_static_pie=no
6074 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ld_static_pie" >&5
6075 -$as_echo "$libc_cv_ld_static_pie" >&6; }
6076 - if test "$libc_cv_ld_static_pie" != yes; then
6077 - as_fn_error $? "linker support for static PIE needed" "$LINENO" 5
6081 $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
6084 diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
6085 index cdaba0c075..611a7d9ba3 100644
6086 --- a/sysdeps/x86_64/configure.ac
6087 +++ b/sysdeps/x86_64/configure.ac
6088 @@ -53,31 +53,6 @@ if test x"$build_mathvec" = xnotset; then
6092 -dnl Check if linker supports static PIE with the fix for
6094 -dnl https://sourceware.org/bugzilla/show_bug.cgi?id=21782
6096 -if test "$static_pie" = yes; then
6097 - AC_CACHE_CHECK(for linker static PIE support, libc_cv_ld_static_pie, [dnl
6098 -cat > conftest.s <<\EOF
6103 - leaq foo(%rip), %rax
6105 - libc_cv_pie_option="-Wl,-pie"
6106 - if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp $libc_cv_pie_option -o conftest conftest.s 1>&AS_MESSAGE_LOG_FD); then
6107 - libc_cv_ld_static_pie=yes
6109 - libc_cv_ld_static_pie=no
6112 - if test "$libc_cv_ld_static_pie" != yes; then
6113 - AC_MSG_ERROR([linker support for static PIE needed])
6117 dnl It is always possible to access static and hidden symbols in an
6118 dnl position independent way.
6119 AC_DEFINE(PI_STATIC_AND_HIDDEN)
6120 diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
6121 index ca73d8fef9..363a749cb2 100644
6122 --- a/sysdeps/x86_64/dl-machine.h
6123 +++ b/sysdeps/x86_64/dl-machine.h
6124 @@ -315,16 +315,22 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
6126 # ifndef RTLD_BOOTSTRAP
6128 - && sym_map->l_type != lt_executable
6129 && !sym_map->l_relocated)
6132 = (const char *) D_PTR (map, l_info[DT_STRTAB]);
6133 - _dl_error_printf ("\
6134 + if (sym_map->l_type == lt_executable)
6135 + _dl_fatal_printf ("\
6136 +%s: IFUNC symbol '%s' referenced in '%s' is defined in the executable \
6137 +and creates an unsatisfiable circular dependency.\n",
6138 + RTLD_PROGNAME, strtab + refsym->st_name,
6141 + _dl_error_printf ("\
6142 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
6143 - RTLD_PROGNAME, map->l_name,
6145 - strtab + refsym->st_name);
6146 + RTLD_PROGNAME, map->l_name,
6148 + strtab + refsym->st_name);
6151 value = ((ElfW(Addr) (*) (void)) value) ();
6152 diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
6153 index 7659758972..e5fd5ac9cb 100644
6154 --- a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
6155 +++ b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
6156 @@ -32,7 +32,7 @@ IFUNC_SELECTOR (void)
6157 && CPU_FEATURE_USABLE_P (cpu_features, AVX2))
6158 return OPTIMIZE (fma);
6160 - if (CPU_FEATURE_USABLE_P (cpu_features, FMA))
6161 + if (CPU_FEATURE_USABLE_P (cpu_features, FMA4))
6162 return OPTIMIZE (fma4);
6164 return OPTIMIZE (sse2);
6165 diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
6166 index bd5dc1a3f3..092f364bb6 100644
6167 --- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
6168 +++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
6173 +/* Avoid short distance rep movsb only with non-SSE vector. */
6174 +#ifndef AVOID_SHORT_DISTANCE_REP_MOVSB
6175 +# define AVOID_SHORT_DISTANCE_REP_MOVSB (VEC_SIZE > 16)
6177 +# define AVOID_SHORT_DISTANCE_REP_MOVSB 0
6181 # define PREFETCH(addr) prefetcht0 addr
6183 @@ -243,7 +250,21 @@ L(movsb):
6185 /* Avoid slow backward REP MOVSB. */
6186 jb L(more_8x_vec_backward)
6187 +# if AVOID_SHORT_DISTANCE_REP_MOVSB
6193 +# if AVOID_SHORT_DISTANCE_REP_MOVSB
6197 +/* Avoid "rep movsb" if RCX, the distance between source and destination,
6198 + is N*4GB + [1..63] with N >= 0. */
6200 + jbe L(more_2x_vec) /* Avoid "rep movsb" if ECX <= 63. */
6202 mov %RDX_LP, %RCX_LP
6205 diff --git a/sysvipc/test-sysvsem.c b/sysvipc/test-sysvsem.c
6206 index 01dbff343a..b7284e0b48 100644
6207 --- a/sysvipc/test-sysvsem.c
6208 +++ b/sysvipc/test-sysvsem.c
6213 +#include <stdbool.h>
6214 #include <sys/types.h>
6215 #include <sys/ipc.h>
6216 #include <sys/sem.h>
6217 diff --git a/version.h b/version.h
6218 index 83cd196798..e6ca7a8857 100644
6222 /* This file just defines the current version number of libc. */
6224 -#define RELEASE "release"
6225 +#define RELEASE "stable"
6226 #define VERSION "2.32"
6227 diff --git a/sysdeps/unix/sysv/linux/x86_64/64/configure b/sysdeps/unix/sysv/linux/x86_64/64/configure
6228 index 9d298faba7..cef1ec842c 100644
6229 --- a/sysdeps/unix/sysv/linux/x86_64/64/configure
6230 +++ b/sysdeps/unix/sysv/linux/x86_64/64/configure
6232 test -n "$libc_cv_slibdir" ||
6235 - libc_cv_slibdir='/lib64'
6236 - libc_cv_rtlddir='/lib64'
6237 + libc_cv_slibdir='/lib'
6238 + libc_cv_rtlddir='/lib'
6239 if test "$libdir" = '${exec_prefix}/lib'; then
6240 - libdir='${exec_prefix}/lib64';
6241 + libdir='${exec_prefix}/lib';
6242 # Locale data can be shared between 32-bit and 64-bit libraries.
6243 libc_cv_complocaledir='${exec_prefix}/lib/locale'
6245 diff --git a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
6246 index 062c04689d..7783757726 100644
6247 --- a/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
6248 +++ b/sysdeps/unix/sysv/linux/x86_64/ldconfig.h
6250 #include <sysdeps/generic/ldconfig.h>
6252 #define SYSDEP_KNOWN_INTERPRETER_NAMES \
6253 - { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
6254 + { "/lib32/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
6255 { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
6256 - { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
6257 + { "/lib/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },
6258 #define SYSDEP_KNOWN_LIBRARY_NAMES \
6259 { "libc.so.6", FLAG_ELF_LIBC6 }, \
6260 { "libm.so.6", FLAG_ELF_LIBC6 },