Commit | Line | Data |
---|---|---|
5685e009 | 1 | diff --git a/NEWS b/NEWS |
ad3e853a | 2 | index 485b8ddffa..2afe250ccf 100644 |
5685e009 VM |
3 | --- a/NEWS |
4 | +++ b/NEWS | |
2d5de23a | 5 | @@ -5,6 +5,25 @@ See the end for copying conditions. |
5685e009 VM |
6 | Please send GNU C library bug reports via <https://sourceware.org/bugzilla/> |
7 | using `glibc' in the "product" field. | |
8 | \f | |
9 | +The following bugs are resolved with this release: | |
10 | + | |
2d5de23a VM |
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) | |
5685e009 VM |
14 | + [26534] libm.so 2.32 SIGILL in pow() due to FMA4 instruction on non-FMA4 |
15 | + system | |
16 | + [26555] string: strerrorname_np does not return the documented value | |
2d5de23a | 17 | + [26600] Transaction ID collisions cause slow DNS lookups in getaddrinfo |
5685e009 VM |
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 | |
2d5de23a VM |
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 | |
5685e009 VM |
27 | + |
28 | Version 2.32 | |
29 | ||
30 | Major new features: | |
ad3e853a | 31 | @@ -185,6 +204,14 @@ Security related changes: |
2d5de23a VM |
32 | Dytrych of the Cisco Security Assessment and Penetration Team (See |
33 | TALOS-2020-1019). | |
34 | ||
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. | |
ad3e853a VM |
38 | + |
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. | |
2d5de23a VM |
42 | + |
43 | The following bugs are resolved with this release: | |
44 | ||
45 | [9809] localedata: ckb_IQ: new Kurdish Sorani locale | |
46 | diff --git a/Rules b/Rules | |
47 | index 8b771f6095..beab969fde 100644 | |
48 | --- a/Rules | |
49 | +++ b/Rules | |
50 | @@ -155,6 +155,7 @@ xtests: tests $(xtests-special) | |
51 | else | |
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) | |
57 | endif | |
58 | @@ -165,7 +166,7 @@ ifeq ($(run-built-tests),no) | |
59 | tests-expected = | |
60 | else | |
61 | tests-expected = $(tests) $(tests-internal) $(tests-printers) \ | |
62 | - $(tests-container) | |
63 | + $(tests-container) $(tests-mcheck:%=%-mcheck) | |
64 | endif | |
65 | tests: | |
66 | $(..)scripts/merge-test-results.sh -s $(objpfx) $(subdir) \ | |
67 | @@ -191,6 +192,7 @@ else | |
68 | binaries-pie-tests = | |
69 | binaries-pie-notests = | |
70 | endif | |
71 | +binaries-mcheck-tests = $(tests-mcheck:%=%-mcheck) | |
72 | else | |
73 | binaries-all-notests = | |
74 | binaries-all-tests = $(tests) $(tests-internal) $(xtests) $(test-srcs) | |
75 | @@ -200,6 +202,7 @@ binaries-static-tests = | |
76 | binaries-static = | |
77 | binaries-pie-tests = | |
78 | binaries-pie-notests = | |
79 | +binaries-mcheck-tests = | |
80 | endif | |
81 | ||
82 | binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests) | |
83 | @@ -223,6 +226,14 @@ $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \ | |
84 | $(+link-tests) | |
85 | endif | |
86 | ||
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) | |
92 | + $(+link-tests) | |
93 | +endif | |
94 | + | |
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 \ | |
99 | $(+link-static-tests) | |
100 | endif | |
101 | ||
102 | +# All mcheck tests will be run with MALLOC_CHECK_=3 | |
103 | +define mcheck-ENVS | |
104 | +$(1)-mcheck-ENV = MALLOC_CHECK_=3 | |
105 | +endef | |
106 | +$(foreach t,$(tests-mcheck),$(eval $(call mcheck-ENVS,$(t)))) | |
107 | + | |
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 | |
113 | --- a/debug/Makefile | |
114 | +++ b/debug/Makefile | |
115 | @@ -51,7 +51,7 @@ routines = backtrace backtracesyms backtracesymsfd noophooks \ | |
116 | explicit_bzero_chk \ | |
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 | |
121 | ||
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 | |
128 | +++ /dev/null | |
129 | @@ -1,70 +0,0 @@ | |
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. | |
133 | - | |
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. | |
138 | - | |
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.) | |
147 | - | |
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 | |
154 | - exception. | |
155 | - | |
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. | |
160 | - | |
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/>. */ | |
164 | - | |
165 | -#include <sys/cdefs.h> | |
166 | - | |
167 | -static void | |
168 | -__attribute__ ((used)) | |
169 | -nop (void) | |
170 | -{ | |
171 | -} | |
172 | - | |
173 | -/* Don't insert any other #include's before this #undef! */ | |
174 | - | |
175 | -#undef __warndecl | |
176 | -#define __warndecl(name, msg) \ | |
177 | - extern void name (void) __attribute__ ((alias ("nop"))) attribute_hidden; \ | |
178 | - link_warning (name, msg) | |
179 | - | |
180 | -#undef __USE_FORTIFY_LEVEL | |
181 | -#define __USE_FORTIFY_LEVEL 99 | |
182 | - | |
183 | -/* Following here we need an #include for each public header file | |
184 | - that uses __warndecl. */ | |
185 | - | |
186 | -/* Define away to avoid warnings with compilers that do not have these | |
187 | - builtins. */ | |
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 | |
198 | - | |
199 | -#include <string.h> | |
200 | diff --git a/elf/Makefile b/elf/Makefile | |
ad3e853a | 201 | index 0b78721848..3ba7f4ecfc 100644 |
2d5de23a VM |
202 | --- a/elf/Makefile |
203 | +++ b/elf/Makefile | |
204 | @@ -1381,6 +1381,8 @@ CFLAGS-ifuncmain7pie.c += $(pie-ccflag) | |
205 | CFLAGS-ifuncmain9pie.c += $(pie-ccflag) | |
206 | CFLAGS-tst-ifunc-textrel.c += $(pic-ccflag) | |
207 | ||
208 | +LDFLAGS-ifuncmain6pie = -Wl,-z,lazy | |
209 | + | |
210 | $(objpfx)ifuncmain1pie: $(objpfx)ifuncmod1.so | |
211 | $(objpfx)ifuncmain1staticpie: $(objpfx)ifuncdep1pic.o | |
212 | $(objpfx)ifuncmain1vispie: $(objpfx)ifuncmod1.so | |
ad3e853a VM |
213 | @@ -1630,8 +1632,6 @@ $(objpfx)tst-nodelete-dlclose.out: $(objpfx)tst-nodelete-dlclose-dso.so \ |
214 | ||
215 | tst-env-setuid-ENV = MALLOC_CHECK_=2 MALLOC_MMAP_THRESHOLD_=4096 \ | |
216 | LD_HWCAP_MASK=0x1 | |
217 | -tst-env-setuid-tunables-ENV = \ | |
218 | - GLIBC_TUNABLES=glibc.malloc.check=2:glibc.malloc.mmap_threshold=4096 | |
219 | ||
220 | $(objpfx)tst-debug1: $(libdl) | |
221 | $(objpfx)tst-debug1.out: $(objpfx)tst-debug1mod1.so | |
2d5de23a VM |
222 | diff --git a/elf/dl-load.c b/elf/dl-load.c |
223 | index e39980fb19..71867e7c1a 100644 | |
224 | --- a/elf/dl-load.c | |
225 | +++ b/elf/dl-load.c | |
226 | @@ -855,10 +855,12 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l, | |
227 | ||
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. */ | |
234 | ||
235 | void | |
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) | |
238 | { | |
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) | |
242 | last_type = type; | |
243 | ||
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) | |
247 | return; | |
248 | ||
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)) | |
253 | goto call_lose; | |
254 | - | |
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 | |
258 | - exits. */ | |
259 | - for (ph = &phdr[l->l_phnum]; ph != phdr; --ph) | |
260 | - switch (ph[-1].p_type) | |
261 | - { | |
262 | - case PT_NOTE: | |
263 | - _dl_process_pt_note (l, &ph[-1]); | |
264 | - break; | |
265 | - case PT_GNU_PROPERTY: | |
266 | - _dl_process_pt_gnu_property (l, &ph[-1]); | |
267 | - break; | |
268 | - } | |
269 | } | |
270 | ||
271 | if (l->l_ld == 0) | |
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; | |
275 | ||
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 | |
279 | + exits. */ | |
280 | + for (ph = &l->l_phdr[l->l_phnum]; ph != l->l_phdr; --ph) | |
281 | + switch (ph[-1].p_type) | |
282 | + { | |
283 | + case PT_NOTE: | |
284 | + _dl_process_pt_note (l, fd, &ph[-1]); | |
285 | + break; | |
286 | + case PT_GNU_PROPERTY: | |
287 | + _dl_process_pt_gnu_property (l, fd, &ph[-1]); | |
288 | + break; | |
289 | + } | |
290 | + | |
291 | /* We are done mapping in the file. We no longer need the descriptor. */ | |
292 | if (__glibc_unlikely (__close_nocancel (fd) != 0)) | |
293 | { | |
ad3e853a VM |
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) | |
299 | return; | |
300 | ||
301 | char *p = tunestr; | |
302 | + size_t off = 0; | |
303 | ||
304 | while (true) | |
305 | { | |
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 | |
308 | pair, bail out. */ | |
309 | if (p[len] == '\0') | |
310 | - return; | |
311 | + { | |
312 | + if (__libc_enable_secure) | |
313 | + tunestr[off] = '\0'; | |
314 | + return; | |
315 | + } | |
316 | ||
317 | /* We did not find a valid name-value pair before encountering the | |
318 | colon. */ | |
319 | @@ -216,35 +221,28 @@ parse_tunables (char *tunestr, char *valstring) | |
320 | ||
321 | if (tunable_is_name (cur->name, name)) | |
322 | { | |
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) | |
333 | { | |
334 | - if (cur->security_level == TUNABLE_SECLEVEL_SXID_ERASE) | |
335 | + if (cur->security_level != TUNABLE_SECLEVEL_SXID_ERASE) | |
336 | { | |
337 | - if (p[len] == '\0') | |
338 | - { | |
339 | - /* Last tunable in the valstring. Null-terminate and | |
340 | - return. */ | |
341 | - *name = '\0'; | |
342 | - return; | |
343 | - } | |
344 | - else | |
345 | - { | |
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]; | |
353 | - p = name; | |
354 | - while (*q != '\0') | |
355 | - *name++ = *q++; | |
356 | - name[0] = '\0'; | |
357 | - len = 0; | |
358 | - } | |
359 | + if (off > 0) | |
360 | + tunestr[off++] = ':'; | |
361 | + | |
362 | + const char *n = cur->name; | |
363 | + | |
364 | + while (*n != '\0') | |
365 | + tunestr[off++] = *n++; | |
366 | + | |
367 | + tunestr[off++] = '='; | |
368 | + | |
369 | + for (size_t j = 0; j < len; j++) | |
370 | + tunestr[off++] = value[j]; | |
371 | } | |
372 | ||
373 | if (cur->security_level != TUNABLE_SECLEVEL_NONE) | |
374 | @@ -257,9 +255,7 @@ parse_tunables (char *tunestr, char *valstring) | |
375 | } | |
376 | } | |
377 | ||
378 | - if (p[len] == '\0') | |
379 | - return; | |
380 | - else | |
381 | + if (p[len] != '\0') | |
382 | p += len + 1; | |
383 | } | |
384 | } | |
2d5de23a VM |
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 | |
389 | @@ -9,7 +9,6 @@ | |
390 | #include "ifunc-sel.h" | |
391 | ||
392 | typedef int (*foo_p) (void); | |
393 | -extern foo_p foo_ptr; | |
394 | ||
395 | static int | |
396 | one (void) | |
397 | @@ -28,20 +27,17 @@ foo_ifunc (void) | |
398 | } | |
399 | ||
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); | |
404 | ||
405 | -foo_p my_foo_ptr = foo; | |
406 | +foo_p foo_ptr = foo; | |
407 | ||
408 | int | |
409 | main (void) | |
410 | { | |
411 | foo_p p; | |
412 | ||
413 | - p = get_foo (); | |
414 | - if (p != foo) | |
415 | - abort (); | |
416 | - if ((*p) () != -30) | |
417 | + if (call_foo () != -30) | |
418 | abort (); | |
419 | ||
420 | p = get_foo_p (); | |
421 | @@ -52,12 +48,8 @@ main (void) | |
422 | ||
423 | if (foo_ptr != foo) | |
424 | abort (); | |
425 | - if (my_foo_ptr != foo) | |
426 | - abort (); | |
427 | if ((*foo_ptr) () != -30) | |
428 | abort (); | |
429 | - if ((*my_foo_ptr) () != -30) | |
430 | - abort (); | |
431 | if (foo () != -30) | |
432 | abort (); | |
433 | ||
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); | |
439 | ||
440 | typedef int (*foo_p) (void); | |
441 | ||
442 | -foo_p foo_ptr = foo; | |
443 | +extern foo_p foo_ptr; | |
444 | ||
445 | foo_p | |
446 | get_foo_p (void) | |
447 | @@ -12,8 +12,8 @@ get_foo_p (void) | |
448 | return foo_ptr; | |
449 | } | |
450 | ||
451 | -foo_p | |
452 | -get_foo (void) | |
453 | +int | |
454 | +call_foo (void) | |
455 | { | |
456 | - return foo; | |
457 | + return foo (); | |
458 | } | |
459 | diff --git a/elf/rtld.c b/elf/rtld.c | |
460 | index 5b882163fa..14a42ed00a 100644 | |
461 | --- a/elf/rtld.c | |
462 | +++ b/elf/rtld.c | |
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) | |
465 | { | |
466 | case PT_NOTE: | |
467 | - _dl_process_pt_note (main_map, &ph[-1]); | |
468 | + _dl_process_pt_note (main_map, -1, &ph[-1]); | |
469 | break; | |
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]); | |
473 | break; | |
474 | } | |
475 | ||
ad3e853a VM |
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 | |
480 | @@ -25,35 +25,76 @@ | |
481 | #include "config.h" | |
482 | #undef _LIBC | |
483 | ||
484 | -#define test_parent test_parent_tunables | |
485 | -#define test_child test_child_tunables | |
486 | - | |
487 | -static int test_child_tunables (void); | |
488 | -static int test_parent_tunables (void); | |
489 | - | |
490 | -#include "tst-env-setuid.c" | |
491 | - | |
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" | |
495 | +#include <errno.h> | |
496 | +#include <fcntl.h> | |
497 | +#include <stdlib.h> | |
498 | +#include <stdint.h> | |
499 | +#include <stdio.h> | |
500 | +#include <string.h> | |
501 | +#include <sys/stat.h> | |
502 | +#include <sys/wait.h> | |
503 | +#include <unistd.h> | |
504 | +#include <intprops.h> | |
505 | +#include <array_length.h> | |
506 | + | |
507 | +#include <support/check.h> | |
508 | +#include <support/support.h> | |
509 | +#include <support/test-driver.h> | |
510 | +#include <support/capture_subprocess.h> | |
511 | + | |
512 | +const char *teststrings[] = | |
513 | +{ | |
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", | |
528 | +}; | |
529 | + | |
530 | +const char *resultstrings[] = | |
531 | +{ | |
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", | |
540 | + "", | |
541 | + "", | |
542 | + "", | |
543 | + "", | |
544 | + "", | |
545 | + "", | |
546 | +}; | |
547 | ||
548 | static int | |
549 | -test_child_tunables (void) | |
550 | +test_child (int off) | |
551 | { | |
552 | const char *val = getenv ("GLIBC_TUNABLES"); | |
553 | ||
554 | #if HAVE_TUNABLES | |
555 | - if (val != NULL && strcmp (val, CHILD_VALSTRING_VALUE) == 0) | |
556 | + if (val != NULL && strcmp (val, resultstrings[off]) == 0) | |
557 | return 0; | |
558 | ||
559 | if (val != NULL) | |
560 | - printf ("Unexpected GLIBC_TUNABLES VALUE %s\n", val); | |
561 | + printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val); | |
562 | ||
563 | return 1; | |
564 | #else | |
565 | if (val != NULL) | |
566 | { | |
567 | - printf ("GLIBC_TUNABLES not cleared\n"); | |
568 | + printf ("[%d] GLIBC_TUNABLES not cleared\n", off); | |
569 | return 1; | |
570 | } | |
571 | return 0; | |
572 | @@ -61,15 +102,48 @@ test_child_tunables (void) | |
573 | } | |
574 | ||
575 | static int | |
576 | -test_parent_tunables (void) | |
577 | +do_test (int argc, char **argv) | |
578 | { | |
579 | - const char *val = getenv ("GLIBC_TUNABLES"); | |
580 | + /* Setgid child process. */ | |
581 | + if (argc == 2) | |
582 | + { | |
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 ()); | |
587 | ||
588 | - if (val != NULL && strcmp (val, PARENT_VALSTRING_VALUE) == 0) | |
589 | - return 0; | |
590 | + int ret = test_child (atoi (argv[1])); | |
591 | ||
592 | - if (val != NULL) | |
593 | - printf ("Unexpected GLIBC_TUNABLES VALUE %s\n", val); | |
594 | + if (ret != 0) | |
595 | + exit (1); | |
596 | ||
597 | - return 1; | |
598 | + exit (EXIT_SUCCESS); | |
599 | + } | |
600 | + else | |
601 | + { | |
602 | + int ret = 0; | |
603 | + | |
604 | + /* Spawn tests. */ | |
605 | + for (int i = 0; i < array_length (teststrings); i++) | |
606 | + { | |
607 | + char buf[INT_BUFSIZE_BOUND (int)]; | |
608 | + | |
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) | |
612 | + exit (1); | |
613 | + | |
614 | + int status = support_capture_subprogram_self_sgid (buf); | |
615 | + | |
616 | + /* Bail out early if unsupported. */ | |
617 | + if (WEXITSTATUS (status) == EXIT_UNSUPPORTED) | |
618 | + return EXIT_UNSUPPORTED; | |
619 | + | |
620 | + ret |= status; | |
621 | + } | |
622 | + return ret; | |
623 | + } | |
624 | } | |
625 | + | |
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 | |
632 | @@ -29,173 +29,12 @@ | |
633 | #include <sys/wait.h> | |
634 | #include <unistd.h> | |
635 | ||
636 | +#include <support/check.h> | |
637 | #include <support/support.h> | |
638 | #include <support/test-driver.h> | |
639 | +#include <support/capture_subprocess.h> | |
640 | ||
641 | static char SETGID_CHILD[] = "setgid-child"; | |
642 | -#define CHILD_STATUS 42 | |
643 | - | |
644 | -/* Return a GID which is not our current GID, but is present in the | |
645 | - supplementary group list. */ | |
646 | -static gid_t | |
647 | -choose_gid (void) | |
648 | -{ | |
649 | - const int count = 64; | |
650 | - gid_t groups[count]; | |
651 | - int ret = getgroups (count, groups); | |
652 | - if (ret < 0) | |
653 | - { | |
654 | - printf ("getgroups: %m\n"); | |
655 | - exit (1); | |
656 | - } | |
657 | - gid_t current = getgid (); | |
658 | - for (int i = 0; i < ret; ++i) | |
659 | - { | |
660 | - if (groups[i] != current) | |
661 | - return groups[i]; | |
662 | - } | |
663 | - return 0; | |
664 | -} | |
665 | - | |
666 | -/* Spawn and execute a program and verify that it returns the CHILD_STATUS. */ | |
667 | -static pid_t | |
668 | -do_execve (char **args) | |
669 | -{ | |
670 | - pid_t kid = vfork (); | |
671 | - | |
672 | - if (kid < 0) | |
673 | - { | |
674 | - printf ("vfork: %m\n"); | |
675 | - return -1; | |
676 | - } | |
677 | - | |
678 | - if (kid == 0) | |
679 | - { | |
680 | - /* Child process. */ | |
681 | - execve (args[0], args, environ); | |
682 | - _exit (-errno); | |
683 | - } | |
684 | - | |
685 | - if (kid < 0) | |
686 | - return 1; | |
687 | - | |
688 | - int status; | |
689 | - | |
690 | - if (waitpid (kid, &status, 0) < 0) | |
691 | - { | |
692 | - printf ("waitpid: %m\n"); | |
693 | - return 1; | |
694 | - } | |
695 | - | |
696 | - if (WEXITSTATUS (status) == EXIT_UNSUPPORTED) | |
697 | - return EXIT_UNSUPPORTED; | |
698 | - | |
699 | - if (!WIFEXITED (status) || WEXITSTATUS (status) != CHILD_STATUS) | |
700 | - { | |
701 | - printf ("Unexpected exit status %d from child process\n", | |
702 | - WEXITSTATUS (status)); | |
703 | - return 1; | |
704 | - } | |
705 | - return 0; | |
706 | -} | |
707 | - | |
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 | |
710 | - executable. */ | |
711 | -static int | |
712 | -run_executable_sgid (gid_t target) | |
713 | -{ | |
714 | - char *dirname = xasprintf ("%s/tst-tunables-setuid.%jd", | |
715 | - test_dir, (intmax_t) getpid ()); | |
716 | - char *execname = xasprintf ("%s/bin", dirname); | |
717 | - int infd = -1; | |
718 | - int outfd = -1; | |
719 | - int ret = 0; | |
720 | - if (mkdir (dirname, 0700) < 0) | |
721 | - { | |
722 | - printf ("mkdir: %m\n"); | |
723 | - goto err; | |
724 | - } | |
725 | - infd = open ("/proc/self/exe", O_RDONLY); | |
726 | - if (infd < 0) | |
727 | - { | |
728 | - printf ("open (/proc/self/exe): %m\n"); | |
729 | - goto err; | |
730 | - } | |
731 | - outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700); | |
732 | - if (outfd < 0) | |
733 | - { | |
734 | - printf ("open (%s): %m\n", execname); | |
735 | - goto err; | |
736 | - } | |
737 | - char buf[4096]; | |
738 | - for (;;) | |
739 | - { | |
740 | - ssize_t rdcount = read (infd, buf, sizeof (buf)); | |
741 | - if (rdcount < 0) | |
742 | - { | |
743 | - printf ("read: %m\n"); | |
744 | - goto err; | |
745 | - } | |
746 | - if (rdcount == 0) | |
747 | - break; | |
748 | - char *p = buf; | |
749 | - char *end = buf + rdcount; | |
750 | - while (p != end) | |
751 | - { | |
752 | - ssize_t wrcount = write (outfd, buf, end - p); | |
753 | - if (wrcount == 0) | |
754 | - errno = ENOSPC; | |
755 | - if (wrcount <= 0) | |
756 | - { | |
757 | - printf ("write: %m\n"); | |
758 | - goto err; | |
759 | - } | |
760 | - p += wrcount; | |
761 | - } | |
762 | - } | |
763 | - if (fchown (outfd, getuid (), target) < 0) | |
764 | - { | |
765 | - printf ("fchown (%s): %m\n", execname); | |
766 | - goto err; | |
767 | - } | |
768 | - if (fchmod (outfd, 02750) < 0) | |
769 | - { | |
770 | - printf ("fchmod (%s): %m\n", execname); | |
771 | - goto err; | |
772 | - } | |
773 | - if (close (outfd) < 0) | |
774 | - { | |
775 | - printf ("close (outfd): %m\n"); | |
776 | - goto err; | |
777 | - } | |
778 | - if (close (infd) < 0) | |
779 | - { | |
780 | - printf ("close (infd): %m\n"); | |
781 | - goto err; | |
782 | - } | |
783 | - | |
784 | - char *args[] = {execname, SETGID_CHILD, NULL}; | |
785 | - | |
786 | - ret = do_execve (args); | |
787 | - | |
788 | -err: | |
789 | - if (outfd >= 0) | |
790 | - close (outfd); | |
791 | - if (infd >= 0) | |
792 | - close (infd); | |
793 | - if (execname) | |
794 | - { | |
795 | - unlink (execname); | |
796 | - free (execname); | |
797 | - } | |
798 | - if (dirname) | |
799 | - { | |
800 | - rmdir (dirname); | |
801 | - free (dirname); | |
802 | - } | |
803 | - return ret; | |
804 | -} | |
805 | ||
806 | #ifndef test_child | |
807 | static int | |
808 | @@ -256,40 +95,32 @@ do_test (int argc, char **argv) | |
809 | if (argc == 2 && strcmp (argv[1], SETGID_CHILD) == 0) | |
810 | { | |
811 | if (getgid () == getegid ()) | |
812 | - { | |
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); | |
817 | - } | |
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 ()); | |
821 | ||
822 | int ret = test_child (); | |
823 | ||
824 | if (ret != 0) | |
825 | exit (1); | |
826 | ||
827 | - exit (CHILD_STATUS); | |
828 | + exit (EXIT_SUCCESS); | |
829 | } | |
830 | else | |
831 | { | |
832 | if (test_parent () != 0) | |
833 | exit (1); | |
834 | ||
835 | - /* Try running a setgid program. */ | |
836 | - gid_t target = choose_gid (); | |
837 | - if (target == 0) | |
838 | - { | |
839 | - fprintf (stderr, | |
840 | - "Could not find a suitable GID for user %jd, skipping test\n", | |
841 | - (intmax_t) getuid ()); | |
842 | - exit (0); | |
843 | - } | |
844 | + int status = support_capture_subprogram_self_sgid (SETGID_CHILD); | |
845 | ||
846 | - return run_executable_sgid (target); | |
847 | - } | |
848 | + if (WEXITSTATUS (status) == EXIT_UNSUPPORTED) | |
849 | + return EXIT_UNSUPPORTED; | |
850 | + | |
851 | + if (!WIFEXITED (status)) | |
852 | + FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status); | |
853 | ||
854 | - /* Something went wrong and our argv was corrupted. */ | |
855 | - _exit (1); | |
856 | + return 0; | |
857 | + } | |
858 | } | |
859 | ||
860 | #define TEST_FUNCTION_ARGV do_test | |
5685e009 VM |
861 | diff --git a/iconv/Versions b/iconv/Versions |
862 | index 8a5f4cf780..d51af52fa3 100644 | |
863 | --- a/iconv/Versions | |
864 | +++ b/iconv/Versions | |
865 | @@ -6,7 +6,9 @@ libc { | |
866 | GLIBC_PRIVATE { | |
867 | # functions shared with iconv program | |
868 | __gconv_get_alias_db; __gconv_get_cache; __gconv_get_modules_db; | |
869 | - __gconv_open; __gconv_create_spec; | |
870 | + | |
871 | + # functions used elsewhere in glibc | |
872 | + __gconv_open; __gconv_create_spec; __gconv_destroy_spec; | |
873 | ||
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: | |
881 | return ret; | |
882 | } | |
883 | libc_hidden_def (__gconv_create_spec) | |
884 | + | |
885 | + | |
886 | +void | |
887 | +__gconv_destroy_spec (struct gconv_spec *conv_spec) | |
888 | +{ | |
889 | + free (conv_spec->fromcode); | |
890 | + free (conv_spec->tocode); | |
891 | + return; | |
892 | +} | |
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 | |
898 | @@ -48,33 +48,6 @@ | |
899 | #define GCONV_IGNORE_ERRORS_SUFFIX "IGNORE" | |
900 | ||
901 | ||
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. */ | |
913 | -struct gconv_spec * | |
914 | -__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode, | |
915 | - const char *tocode); | |
916 | -libc_hidden_proto (__gconv_create_spec) | |
917 | - | |
918 | - | |
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) | |
922 | -{ | |
923 | - free (conv_spec->fromcode); | |
924 | - free (conv_spec->tocode); | |
925 | - return; | |
926 | -} | |
927 | - | |
928 | - | |
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) | |
939 | ||
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) | |
955 | + | |
956 | +/* This function frees all heap memory allocated by __gconv_create_spec. */ | |
957 | +extern void | |
958 | +__gconv_destroy_spec (struct gconv_spec *conv_spec); | |
959 | +libc_hidden_proto (__gconv_destroy_spec) | |
960 | + | |
961 | /* Free resources associated with transformation descriptor CD. */ | |
962 | extern int __gconv_close (__gconv_t cd) | |
963 | attribute_hidden; | |
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) | |
969 | ||
970 | int res = __gconv_open (&conv_spec, &cd, 0); | |
971 | ||
972 | - gconv_destroy_spec (&conv_spec); | |
973 | + __gconv_destroy_spec (&conv_spec); | |
974 | ||
975 | if (__builtin_expect (res, __GCONV_OK) != __GCONV_OK) | |
976 | { | |
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); | |
984 | ||
985 | - gconv_destroy_spec (&conv_spec); | |
986 | + __gconv_destroy_spec (&conv_spec); | |
987 | ||
988 | if (res != __GCONV_OK) | |
989 | { | |
2d5de23a VM |
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) | |
1029 | tests += bug-iconv3 | |
1030 | endif | |
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)) | |
1037 | ||
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 | |
1043 | --- /dev/null | |
1044 | +++ b/iconvdata/bug-iconv13.c | |
1045 | @@ -0,0 +1,53 @@ | |
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. | |
1049 | + | |
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. | |
1054 | + | |
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. | |
1059 | + | |
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/>. */ | |
1063 | + | |
1064 | +#include <errno.h> | |
1065 | +#include <iconv.h> | |
1066 | +#include <stdio.h> | |
1067 | +#include <support/check.h> | |
1068 | + | |
1069 | +static int | |
1070 | +do_test (void) | |
1071 | +{ | |
1072 | + iconv_t cd = iconv_open ("UTF-8//IGNORE", "EUC-KR"); | |
1073 | + TEST_VERIFY_EXIT (cd != (iconv_t) -1); | |
1074 | + | |
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); | |
1082 | + char output[4]; | |
1083 | + char *outptr = output; | |
1084 | + size_t outsize = sizeof (output); | |
1085 | + | |
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 | |
1090 | + character. */ | |
1091 | + TEST_VERIFY (sizeof (output) - outsize == 1); | |
1092 | + | |
1093 | + TEST_VERIFY_EXIT (iconv_close (cd) != -1); | |
1094 | + | |
1095 | + return 0; | |
1096 | +} | |
1097 | + | |
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 | |
1102 | --- /dev/null | |
1103 | +++ b/iconvdata/bug-iconv14.c | |
1104 | @@ -0,0 +1,127 @@ | |
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. | |
1108 | + | |
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. | |
1113 | + | |
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. | |
1118 | + | |
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/>. */ | |
1122 | + | |
1123 | +#include <iconv.h> | |
1124 | +#include <string.h> | |
1125 | +#include <errno.h> | |
1126 | +#include <support/check.h> | |
1127 | + | |
1128 | +/* Use an escape sequence to return to the initial state. */ | |
1129 | +static void | |
1130 | +with_escape_sequence (void) | |
1131 | +{ | |
1132 | + iconv_t c = iconv_open ("UTF-8", "ISO-2022-JP-3"); | |
1133 | + TEST_VERIFY_EXIT (c != (iconv_t) -1); | |
1134 | + | |
1135 | + char in[] = "\e$(O+D\e(B"; | |
1136 | + char *inbuf = in; | |
1137 | + size_t inleft = strlen (in); | |
1138 | + char out[3]; /* Space for one output character. */ | |
1139 | + char *outbuf; | |
1140 | + size_t outleft; | |
1141 | + | |
1142 | + outbuf = out; | |
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); | |
1152 | + | |
1153 | + /* Return to the initial shift state, producing the pending | |
1154 | + character. */ | |
1155 | + outbuf = out; | |
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); | |
1164 | + | |
1165 | + /* Nothing should be flushed the second time. */ | |
1166 | + outbuf = out; | |
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); | |
1173 | + | |
1174 | + TEST_COMPARE (iconv_close (c), 0); | |
1175 | +} | |
1176 | + | |
1177 | +/* Use an explicit flush to return to the initial state. */ | |
1178 | +static void | |
1179 | +with_flush (void) | |
1180 | +{ | |
1181 | + iconv_t c = iconv_open ("UTF-8", "ISO-2022-JP-3"); | |
1182 | + TEST_VERIFY_EXIT (c != (iconv_t) -1); | |
1183 | + | |
1184 | + char in[] = "\e$(O+D"; | |
1185 | + char *inbuf = in; | |
1186 | + size_t inleft = strlen (in); | |
1187 | + char out[3]; /* Space for one output character. */ | |
1188 | + char *outbuf; | |
1189 | + size_t outleft; | |
1190 | + | |
1191 | + outbuf = out; | |
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); | |
1201 | + | |
1202 | + /* Flush the pending character. */ | |
1203 | + outbuf = out; | |
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); | |
1210 | + | |
1211 | + /* Nothing should be flushed the second time. */ | |
1212 | + outbuf = out; | |
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); | |
1219 | + | |
1220 | + TEST_COMPARE (iconv_close (c), 0); | |
1221 | +} | |
1222 | + | |
1223 | +static int | |
1224 | +do_test (void) | |
1225 | +{ | |
1226 | + with_escape_sequence (); | |
1227 | + with_flush (); | |
1228 | + return 0; | |
1229 | +} | |
1230 | + | |
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) | |
1237 | \ | |
1238 | if (ch <= 0x9f) \ | |
1239 | ++inptr; \ | |
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)) \ | |
1246 | { \ | |
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 | |
1254 | \ | |
1255 | if (__builtin_expect (ch, 0) == SO) \ | |
1256 | { \ | |
1257 | - /* Shift OUT, change to DBCS converter. */ \ | |
1258 | - if (curcs == db) \ | |
1259 | - { \ | |
1260 | - result = __GCONV_ILLEGAL_INPUT; \ | |
1261 | - break; \ | |
1262 | - } \ | |
1263 | + /* Shift OUT, change to DBCS converter (redundant escape okay). */ \ | |
1264 | curcs = db; \ | |
1265 | ++inptr; \ | |
1266 | continue; \ | |
1267 | } \ | |
1268 | if (__builtin_expect (ch, 0) == SI) \ | |
1269 | { \ | |
1270 | - /* Shift IN, change to SBCS converter. */ \ | |
1271 | - if (curcs == sb) \ | |
1272 | - { \ | |
1273 | - result = __GCONV_ILLEGAL_INPUT; \ | |
1274 | - break; \ | |
1275 | - } \ | |
1276 | + /* Shift IN, change to SBCS converter (redundant escape okay). */ \ | |
1277 | curcs = sb; \ | |
1278 | ++inptr; \ | |
1279 | continue; \ | |
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 | |
1286 | }; | |
1287 | ||
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, | |
1291 | - in bit 22. */ | |
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 | |
1300 | + full. */ | |
1301 | ||
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 | |
1304 | flushing. */ | |
1305 | #define EMIT_SHIFT_TO_INIT \ | |
1306 | - if ((data->__statep->__count & ~7) != ASCII_set) \ | |
1307 | + if (data->__statep->__count != ASCII_set) \ | |
1308 | { \ | |
1309 | if (FROM_DIRECTION) \ | |
1310 | { \ | |
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)) \ | |
1316 | + { \ | |
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; \ | |
1321 | + } \ | |
1322 | + else \ | |
1323 | + /* We don't have enough room in the output buffer. */ \ | |
1324 | + status = __GCONV_FULL_OUTPUT; \ | |
1325 | } \ | |
1326 | else \ | |
1327 | { \ | |
1328 | @@ -151,7 +162,21 @@ enum | |
1329 | #define LOOPFCT FROM_LOOP | |
1330 | #define BODY \ | |
1331 | { \ | |
1332 | - uint32_t ch = *inptr; \ | |
1333 | + uint32_t ch; \ | |
1334 | + \ | |
1335 | + /* Output any pending character. */ \ | |
1336 | + ch = set >> 6; \ | |
1337 | + if (__glibc_unlikely (ch != 0)) \ | |
1338 | + { \ | |
1339 | + put32 (outptr, ch); \ | |
1340 | + outptr += 4; \ | |
1341 | + /* Remove the pending character, but preserve state bits. */ \ | |
1342 | + set &= (1 << 6) - 1; \ | |
1343 | + continue; \ | |
1344 | + } \ | |
1345 | + \ | |
1346 | + /* Otherwise read the next input byte. */ \ | |
1347 | + ch = *inptr; \ | |
1348 | \ | |
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]; \ | |
1354 | \ | |
1355 | + inptr += 2; \ | |
1356 | + \ | |
1357 | + put32 (outptr, u1); \ | |
1358 | + outptr += 4; \ | |
1359 | + \ | |
1360 | /* See whether we have room for two characters. */ \ | |
1361 | - if (outptr + 8 <= outend) \ | |
1362 | + if (outptr + 4 <= outend) \ | |
1363 | { \ | |
1364 | - inptr += 2; \ | |
1365 | - put32 (outptr, u1); \ | |
1366 | - outptr += 4; \ | |
1367 | put32 (outptr, u2); \ | |
1368 | outptr += 4; \ | |
1369 | continue; \ | |
1370 | } \ | |
1371 | - else \ | |
1372 | - { \ | |
1373 | - result = __GCONV_FULL_OUTPUT; \ | |
1374 | - break; \ | |
1375 | - } \ | |
1376 | + \ | |
1377 | + /* Otherwise store only the first character now, and \ | |
1378 | + put the second one into the queue. */ \ | |
1379 | + set |= u2 << 6; \ | |
1380 | + /* Tell the caller why we terminate the loop. */ \ | |
1381 | + result = __GCONV_FULL_OUTPUT; \ | |
1382 | + break; \ | |
1383 | } \ | |
1384 | \ | |
1385 | inptr += 2; \ | |
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) | |
1391 | unsigned char ch2; | |
1392 | int idx; | |
1393 | ||
1394 | + if (avail < 2) | |
1395 | + return 0; | |
1396 | + | |
1397 | /* row 94(0x7e) and row 41(0x49) are user-defined area in KS C 5601 */ | |
1398 | ||
1399 | if (ch < offset || (ch - offset) <= 0x20 || (ch - offset) >= 0x7e | |
1400 | || (ch - offset) == 0x49) | |
1401 | return __UNKNOWN_10646_CHAR; | |
1402 | ||
1403 | - if (avail < 2) | |
1404 | - return 0; | |
1405 | - | |
1406 | ch2 = (*s)[1]; | |
1407 | if (ch2 < offset || (ch2 - offset) <= 0x20 || (ch2 - offset) >= 0x7f) | |
1408 | return __UNKNOWN_10646_CHAR; | |
5685e009 VM |
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, | |
1414 | ||
1415 | # ifdef _LIBC | |
1416 | ||
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. */ | |
1421 | - .translit = true, | |
1422 | - .ignore = false | |
1423 | - }; | |
1424 | + struct gconv_spec conv_spec; | |
1425 | + | |
1426 | + __gconv_create_spec (&conv_spec, charset, outcharset); | |
1427 | + | |
1428 | + /* We always want to use transliteration. */ | |
1429 | + conv_spec.translit = true; | |
1430 | + | |
1431 | int r = __gconv_open (&conv_spec, &convd->conv, | |
1432 | GCONV_AVOID_NOCONV); | |
1433 | + | |
1434 | + __gconv_destroy_spec (&conv_spec); | |
1435 | + | |
1436 | if (__builtin_expect (r != __GCONV_OK, 0)) | |
1437 | { | |
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 | |
1443 | @@ -22,13 +22,11 @@ | |
1444 | #include <stdio.h> | |
1445 | #include <stdlib.h> | |
1446 | #include <string.h> | |
1447 | +#include <support/check.h> | |
1448 | ||
1449 | static int | |
1450 | do_test (void) | |
1451 | { | |
1452 | - char *s; | |
1453 | - int result = 0; | |
1454 | - | |
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"); | |
1460 | ||
1461 | /* Here we expect output in ISO-8859-1. */ | |
1462 | - s = gettext ("cheese"); | |
1463 | - if (strcmp (s, "K\344se")) | |
1464 | - { | |
1465 | - printf ("call 1 returned: %s\n", s); | |
1466 | - result = 1; | |
1467 | - } | |
1468 | + TEST_COMPARE_STRING (gettext ("cheese"), "K\344se"); | |
1469 | ||
1470 | + /* Here we expect output in UTF-8. */ | |
1471 | bind_textdomain_codeset ("codeset", "UTF-8"); | |
1472 | + TEST_COMPARE_STRING (gettext ("cheese"), "K\303\244se"); | |
1473 | ||
1474 | - /* Here we expect output in UTF-8. */ | |
1475 | - s = gettext ("cheese"); | |
1476 | - if (strcmp (s, "K\303\244se")) | |
1477 | - { | |
1478 | - printf ("call 2 returned: %s\n", s); | |
1479 | - result = 1; | |
1480 | - } | |
1481 | - | |
1482 | - return result; | |
1483 | + /* `a with umlaut' is transliterated to `ae'. */ | |
1484 | + bind_textdomain_codeset ("codeset", "ASCII//TRANSLIT"); | |
1485 | + TEST_COMPARE_STRING (gettext ("cheese"), "Kaese"); | |
1486 | + | |
1487 | + /* Transliteration also works by default even if not set. */ | |
1488 | + bind_textdomain_codeset ("codeset", "ASCII"); | |
1489 | + TEST_COMPARE_STRING (gettext ("cheese"), "Kaese"); | |
1490 | + | |
1491 | + return 0; | |
1492 | } | |
1493 | ||
1494 | -#define TEST_FUNCTION do_test () | |
1495 | -#include "../test-skeleton.c" | |
1496 | +#include <support/test-driver.c> | |
2d5de23a VM |
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 | |
1504 | ||
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 | |
1511 | + | |
1512 | +# Run all tests with MALLOC_CHECK_=3 | |
1513 | +tests-mcheck = $(filter-out $(tests-exclude-mcheck),$(tests)) | |
1514 | + | |
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) | |
1527 | ||
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. | |
1551 | ||
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. | |
1560 | ||
1561 | This tunable is specific to i386 and x86-64. | |
1562 | @end deftp | |
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) | |
1569 | ||
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))) | |
1576 | #else | |
1577 | -# define __warndecl(name, msg) extern void name (void) | |
1578 | # define __warnattr(msg) | |
1579 | # define __errordecl(name, msg) extern void name (void) | |
1580 | #endif | |
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, | |
1586 | : NULL); | |
1587 | ndomain = (ndomain ? newbuf + ndomaindiff | |
1588 | : NULL); | |
1589 | - buffer = newbuf; | |
1590 | + *tofreep = buffer = newbuf; | |
1591 | } | |
1592 | ||
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) | |
1596 | { | |
1597 | buflen *= 2; | |
1598 | - buffer = xrealloc (buffer, buflen); | |
1599 | + *tofreep = buffer = xrealloc (buffer, buflen); | |
1600 | } | |
1601 | else if (status == NSS_STATUS_RETURN | |
1602 | || status == NSS_STATUS_NOTFOUND | |
ad3e853a VM |
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 }, | |
1612 | ||
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])) | |
1622 | { | |
1623 | - int n = atoi (env); | |
1624 | + unsigned long n = strtoul (env, NULL, 10); | |
1625 | ||
1626 | if (n >= __libc_argc) | |
1627 | /* Substitute NULL. */ | |
2d5de23a VM |
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 += \ | |
1633 | tst-resolv-search \ | |
1634 | tst-resolv-trailing \ | |
1635 | ||
1636 | +# This test calls __res_context_send directly, which is not exported | |
1637 | +# from libresolv. | |
1638 | +tests-internal += tst-resolv-txnid-collision | |
1639 | +tests-static += tst-resolv-txnid-collision | |
1640 | + | |
1641 | # These tests need libdl. | |
1642 | ifeq (yes,$(build-shared)) | |
1643 | tests += \ | |
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, | |
1658 | *terrno = EMSGSIZE; | |
1659 | return close_and_return_error (statp, resplen2); | |
1660 | } | |
1661 | - if ((recvresp1 || hp->id != anhp->id) | |
1662 | - && (recvresp2 || hp2->id != anhp->id)) { | |
1663 | - /* | |
1664 | - * response from old query, ignore it. | |
1665 | - * XXX - potential security hazard could | |
1666 | - * be detected here. | |
1667 | - */ | |
1668 | - goto wait; | |
1669 | - } | |
1670 | ||
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, | |
1674 | ||
1675 | /* Check for the correct header layout and a matching | |
1676 | question. */ | |
1677 | - if ((recvresp1 || !res_queriesmatch(buf, buf + buflen, | |
1678 | - *thisansp, | |
1679 | - *thisansp | |
1680 | - + *thisanssizp)) | |
1681 | - && (recvresp2 || !res_queriesmatch(buf2, buf2 + buflen2, | |
1682 | - *thisansp, | |
1683 | - *thisansp | |
1684 | - + *thisanssizp))) | |
1685 | - goto wait; | |
1686 | + int matching_query = 0; /* Default to no matching query. */ | |
1687 | + if (!recvresp1 | |
1688 | + && anhp->id == hp->id | |
1689 | + && res_queriesmatch (buf, buf + buflen, | |
1690 | + *thisansp, *thisansp + *thisanssizp)) | |
1691 | + matching_query = 1; | |
1692 | + if (!recvresp2 | |
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 | |
1699 | + waiting. */ | |
1700 | + { | |
1701 | + need_recompute = 1; | |
1702 | + goto wait; | |
1703 | + } | |
1704 | ||
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. */ | |
1709 | resplen = 0; | |
1710 | /* We are waiting for a possible second reply. */ | |
1711 | - if (hp->id == anhp->id) | |
1712 | + if (matching_query == 1) | |
1713 | recvresp1 = 1; | |
1714 | else | |
1715 | recvresp2 = 1; | |
1716 | @@ -1414,7 +1414,7 @@ send_dg(res_state statp, | |
1717 | return (1); | |
1718 | } | |
1719 | /* Mark which reply we received. */ | |
1720 | - if (recvresp1 == 0 && hp->id == anhp->id) | |
1721 | + if (matching_query == 1) | |
1722 | recvresp1 = 1; | |
1723 | else | |
1724 | recvresp2 = 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 | |
1728 | --- /dev/null | |
1729 | +++ b/resolv/tst-resolv-txnid-collision.c | |
1730 | @@ -0,0 +1,334 @@ | |
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. | |
1734 | + | |
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. | |
1739 | + | |
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. | |
1744 | + | |
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/>. */ | |
1748 | + | |
1749 | +#include <arpa/nameser.h> | |
1750 | +#include <array_length.h> | |
1751 | +#include <resolv-internal.h> | |
1752 | +#include <resolv_context.h> | |
1753 | +#include <stdbool.h> | |
1754 | +#include <stdio.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> | |
1761 | + | |
1762 | +/* Result of parsing a DNS question name. | |
1763 | + | |
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. | |
1767 | + | |
1768 | + Also see parse_qname below. */ | |
1769 | +struct parsed_qname | |
1770 | +{ | |
1771 | + /* The DNS response code requested from the first server. The | |
1772 | + second server always responds with RCODE zero. */ | |
1773 | + int rcode; | |
1774 | + | |
1775 | + /* Indicates whether to perform reordering in the responses from the | |
1776 | + respective server. */ | |
1777 | + bool reorder[2]; | |
1778 | +}; | |
1779 | + | |
1780 | +/* Fills *PARSED based on QNAME. */ | |
1781 | +static void | |
1782 | +parse_qname (struct parsed_qname *parsed, const char *qname) | |
1783 | +{ | |
1784 | + int reorder0; | |
1785 | + int reorder1; | |
1786 | + int rcode; | |
1787 | + char *suffix; | |
1788 | + if (sscanf (qname, "reorder-%d-%d.rcode-%d.%ms", | |
1789 | + &reorder0, &reorder1, &rcode, &suffix) == 4) | |
1790 | + { | |
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"); | |
1797 | + free (suffix); | |
1798 | + | |
1799 | + parsed->rcode = rcode; | |
1800 | + parsed->reorder[0] = reorder0; | |
1801 | + parsed->reorder[1] = reorder1; | |
1802 | + } | |
1803 | + else | |
1804 | + FAIL_EXIT1 ("unexpected query: %s", qname); | |
1805 | +} | |
1806 | + | |
1807 | +/* Used to construct a response. The first server responds with an | |
1808 | + error, the second server succeeds. */ | |
1809 | +static void | |
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) | |
1813 | +{ | |
1814 | + struct parsed_qname parsed; | |
1815 | + parse_qname (&parsed, qname); | |
1816 | + | |
1817 | + switch (ctx->server_index) | |
1818 | + { | |
1819 | + case 0: | |
1820 | + { | |
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; | |
1826 | + else | |
1827 | + flags.rcode = parsed.rcode; | |
1828 | + | |
1829 | + resolv_response_init (b, flags); | |
1830 | + resolv_response_add_question (b, qname, qclass, qtype); | |
1831 | + } | |
1832 | + break; | |
1833 | + | |
1834 | + case 1: | |
1835 | + { | |
1836 | + struct resolv_response_flags flags = { 0, }; | |
1837 | + resolv_response_init (b, flags); | |
1838 | + resolv_response_add_question (b, qname, qclass, qtype); | |
1839 | + | |
1840 | + resolv_response_section (b, ns_s_an); | |
1841 | + resolv_response_open_record (b, qname, qclass, qtype, 0); | |
1842 | + if (qtype == T_A) | |
1843 | + { | |
1844 | + char ipv4[4] = { 192, 0, 2, 1 }; | |
1845 | + resolv_response_add_data (b, &ipv4, sizeof (ipv4)); | |
1846 | + } | |
1847 | + else | |
1848 | + { | |
1849 | + char ipv6[16] | |
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)); | |
1852 | + } | |
1853 | + resolv_response_close_record (b); | |
1854 | + } | |
1855 | + break; | |
1856 | + } | |
1857 | +} | |
1858 | + | |
1859 | +/* Used to reorder responses. */ | |
1860 | +struct resolv_response_context *previous_query; | |
1861 | + | |
1862 | +/* Used to keep track of the queries received. */ | |
1863 | +static int previous_server_index = -1; | |
1864 | +static uint16_t previous_qtype; | |
1865 | + | |
1866 | +/* For each server, buffer the first query and then send both answers | |
1867 | + to the second query, reordered if requested. */ | |
1868 | +static void | |
1869 | +response (const struct resolv_response_context *ctx, | |
1870 | + struct resolv_response_builder *b, | |
1871 | + const char *qname, uint16_t qclass, uint16_t qtype) | |
1872 | +{ | |
1873 | + TEST_VERIFY (qtype == T_A || qtype == T_AAAA); | |
1874 | + if (ctx->server_index != 0) | |
1875 | + TEST_COMPARE (ctx->server_index, 1); | |
1876 | + | |
1877 | + struct parsed_qname parsed; | |
1878 | + parse_qname (&parsed, qname); | |
1879 | + | |
1880 | + if (previous_query == NULL) | |
1881 | + { | |
1882 | + /* No buffered query. Record this query and do not send a | |
1883 | + response. */ | |
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; | |
1889 | + | |
1890 | + if (test_verbose) | |
1891 | + printf ("info: buffering first query for: %s\n", qname); | |
1892 | + } | |
1893 | + else | |
1894 | + { | |
1895 | + TEST_VERIFY (previous_query != 0); | |
1896 | + TEST_COMPARE (ctx->server_index, previous_server_index); | |
1897 | + TEST_VERIFY (previous_qtype != qtype); /* Not a duplicate. */ | |
1898 | + | |
1899 | + /* If reordering, send a response for this query explicitly, and | |
1900 | + then skip the implicit send. */ | |
1901 | + if (parsed.reorder[ctx->server_index]) | |
1902 | + { | |
1903 | + if (test_verbose) | |
1904 | + printf ("info: sending reordered second response for: %s\n", | |
1905 | + qname); | |
1906 | + build_response (ctx, b, qname, qclass, qtype); | |
1907 | + resolv_response_send_udp (ctx, b); | |
1908 | + resolv_response_drop (b); | |
1909 | + } | |
1910 | + | |
1911 | + /* Build a response for the previous query and send it, thus | |
1912 | + reordering the two responses. */ | |
1913 | + { | |
1914 | + if (test_verbose) | |
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); | |
1922 | + } | |
1923 | + | |
1924 | + /* If not reordering, send the reply as usual. */ | |
1925 | + if (!parsed.reorder[ctx->server_index]) | |
1926 | + { | |
1927 | + if (test_verbose) | |
1928 | + printf ("info: sending non-reordered second response for: %s\n", | |
1929 | + qname); | |
1930 | + build_response (ctx, b, qname, qclass, qtype); | |
1931 | + } | |
1932 | + | |
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; | |
1938 | + } | |
1939 | +} | |
1940 | + | |
1941 | +/* Runs a query for QNAME and checks for the expected reply. See | |
1942 | + struct parsed_qname for the expected format for QNAME. */ | |
1943 | +static void | |
1944 | +test_qname (const char *qname, int rcode) | |
1945 | +{ | |
1946 | + struct resolv_context *ctx = __resolv_context_get (); | |
1947 | + TEST_VERIFY_EXIT (ctx != NULL); | |
1948 | + | |
1949 | + unsigned char q1[512]; | |
1950 | + int q1len = res_mkquery (QUERY, qname, C_IN, T_A, NULL, 0, NULL, | |
1951 | + q1, sizeof (q1)); | |
1952 | + TEST_VERIFY_EXIT (q1len > 12); | |
1953 | + | |
1954 | + unsigned char q2[512]; | |
1955 | + int q2len = res_mkquery (QUERY, qname, C_IN, T_AAAA, NULL, 0, NULL, | |
1956 | + q2, sizeof (q2)); | |
1957 | + TEST_VERIFY_EXIT (q2len > 12); | |
1958 | + | |
1959 | + /* Produce a transaction ID collision. */ | |
1960 | + memcpy (q2, q1, 2); | |
1961 | + | |
1962 | + unsigned char ans1[512]; | |
1963 | + unsigned char *ans1p = ans1; | |
1964 | + unsigned char *ans2p = NULL; | |
1965 | + int nans2p = 0; | |
1966 | + int resplen2 = 0; | |
1967 | + int ans2p_malloced = 0; | |
1968 | + | |
1969 | + /* Perform a parallel A/AAAA query. */ | |
1970 | + int resplen1 = __res_context_send (ctx, q1, q1len, q2, q2len, | |
1971 | + ans1, sizeof (ans1), &ans1p, | |
1972 | + &ans2p, &nans2p, | |
1973 | + &resplen2, &ans2p_malloced); | |
1974 | + | |
1975 | + TEST_VERIFY (resplen1 > 12); | |
1976 | + TEST_VERIFY (resplen2 > 12); | |
1977 | + if (resplen1 <= 12 || resplen2 <= 12) | |
1978 | + return; | |
1979 | + | |
1980 | + if (rcode == 1 || rcode == 3) | |
1981 | + { | |
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); | |
1986 | + return; | |
1987 | + } | |
1988 | + | |
1989 | + /* The response should be successful. */ | |
1990 | + TEST_COMPARE (ans1p[3] & 0x0f, 0); | |
1991 | + TEST_COMPARE (ans2p[3] & 0x0f, 0); | |
1992 | + | |
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) | |
2000 | + { | |
2001 | + a_answer = ans1p; | |
2002 | + a_answer_length = resplen1; | |
2003 | + aaaa_answer = ans2p; | |
2004 | + aaaa_answer_length = resplen2; | |
2005 | + } | |
2006 | + else | |
2007 | + { | |
2008 | + a_answer = ans2p; | |
2009 | + a_answer_length = resplen2; | |
2010 | + aaaa_answer = ans1p; | |
2011 | + aaaa_answer_length = resplen1; | |
2012 | + } | |
2013 | + | |
2014 | + { | |
2015 | + char *expected = xasprintf ("name: %s\n" | |
2016 | + "address: 192.0.2.1\n", | |
2017 | + qname); | |
2018 | + check_dns_packet (qname, a_answer, a_answer_length, expected); | |
2019 | + free (expected); | |
2020 | + } | |
2021 | + { | |
2022 | + char *expected = xasprintf ("name: %s\n" | |
2023 | + "address: 2001:db8::1\n", | |
2024 | + qname); | |
2025 | + check_dns_packet (qname, aaaa_answer, aaaa_answer_length, expected); | |
2026 | + free (expected); | |
2027 | + } | |
2028 | + | |
2029 | + if (ans2p_malloced) | |
2030 | + free (ans2p); | |
2031 | + | |
2032 | + __resolv_context_put (ctx); | |
2033 | +} | |
2034 | + | |
2035 | +static int | |
2036 | +do_test (void) | |
2037 | +{ | |
2038 | + struct resolv_test *aux = resolv_test_start | |
2039 | + ((struct resolv_redirect_config) | |
2040 | + { | |
2041 | + .response_callback = response, | |
2042 | + | |
2043 | + /* The response callback use global state (the previous_* | |
2044 | + variables), and query processing must therefore be | |
2045 | + serialized. */ | |
2046 | + .single_thread_udp = true, | |
2047 | + }); | |
2048 | + | |
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) | |
2052 | + { | |
2053 | + char *qname = xasprintf ("reorder-%d-%d.rcode-%d.example.net", | |
2054 | + do_reorder_0, do_reorder_1, rcode); | |
2055 | + test_qname (qname, rcode); | |
2056 | + free (qname); | |
2057 | + } | |
2058 | + | |
2059 | + resolv_test_end (aux); | |
2060 | + | |
2061 | + return 0; | |
2062 | +} | |
2063 | + | |
2064 | +#include <support/test-driver.c> | |
5685e009 VM |
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 \ | |
2075 | + test-strerr | |
2076 | ||
2077 | ||
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 | |
2083 | @@ -20,9 +20,13 @@ | |
2084 | #include <libintl.h> | |
2085 | #include <array_length.h> | |
2086 | ||
2087 | +#ifndef ERR_MAP | |
2088 | +# define ERR_MAP(n) n | |
2089 | +#endif | |
2090 | + | |
2091 | const char *const _sys_errlist_internal[] = | |
2092 | { | |
2093 | -#define _S(n, str) [n] = str, | |
2094 | +#define _S(n, str) [ERR_MAP(n)] = str, | |
2095 | #include <errlist.h> | |
2096 | #undef _S | |
2097 | }; | |
2098 | @@ -41,20 +45,21 @@ static const union sys_errname_t | |
2099 | { | |
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> | |
2105 | #undef _S | |
2106 | }; | |
2107 | char str[0]; | |
2108 | } _sys_errname = { { | |
2109 | -#define _S(n, s) s, | |
2110 | +#define _S(n, s) #n, | |
2111 | #include <errlist.h> | |
2112 | #undef _S | |
2113 | } }; | |
2114 | ||
2115 | static const unsigned short _sys_errnameidx[] = | |
2116 | { | |
2117 | -#define _S(n, s) [n] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)), | |
2118 | +#define _S(n, s) \ | |
2119 | + [ERR_MAP(n)] = offsetof(union sys_errname_t, MSGSTRFIELD(__LINE__)), | |
2120 | #include <errlist.h> | |
2121 | #undef _S | |
2122 | }; | |
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 @@ | |
2128 | ||
2129 | #include <string.h> | |
2130 | #include <errno.h> | |
2131 | -#include <array_length.h> | |
2132 | ||
2133 | #include <support/support.h> | |
2134 | #include <support/check.h> | |
2135 | ||
2136 | -#define N_(name) name | |
2137 | - | |
2138 | -static const char *const errlist[] = | |
2139 | - { | |
2140 | -/* This file is auto-generated from errlist.def. */ | |
2141 | -#include <errlist.h> | |
2142 | - }; | |
2143 | - | |
2144 | -#define MSGSTR_T errname_t | |
2145 | -#define MSGSTR errname | |
2146 | -#define MSGIDX errnameidx | |
2147 | -#include <errlist-name.h> | |
2148 | -#undef MSGSTR | |
2149 | -#undef MSGIDX | |
2150 | - | |
2151 | static int | |
2152 | do_test (void) | |
2153 | { | |
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++) | |
2157 | - { | |
2158 | - if (errlist[i] == NULL) | |
2159 | - continue; | |
2160 | - TEST_COMPARE_STRING (strerrordesc_np (i), errlist[i]); | |
2161 | - } | |
2162 | + TEST_COMPARE_STRING (strerrordesc_np (0), "Success"); | |
2163 | + TEST_COMPARE_STRING (strerrorname_np (0), "0"); | |
2164 | ||
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++) | |
2168 | - { | |
2169 | - if (errlist[i] == NULL) | |
2170 | - continue; | |
2171 | - TEST_COMPARE_STRING (strerrorname_np (i), errname.str + errnameidx[i]); | |
2172 | - } | |
2173 | +#ifdef EPERM | |
2174 | + TEST_COMPARE_STRING (strerrordesc_np (EPERM), "Operation not permitted"); | |
2175 | + TEST_COMPARE_STRING (strerrorname_np (EPERM), "EPERM"); | |
2176 | +#endif | |
2177 | +#ifdef ENOENT | |
2178 | + TEST_COMPARE_STRING (strerrordesc_np (ENOENT), | |
2179 | + "No such file or directory"); | |
2180 | + TEST_COMPARE_STRING (strerrorname_np (ENOENT), "ENOENT"); | |
2181 | +#endif | |
2182 | +#ifdef ESRCH | |
2183 | + TEST_COMPARE_STRING (strerrordesc_np (ESRCH), "No such process"); | |
2184 | + TEST_COMPARE_STRING (strerrorname_np (ESRCH), "ESRCH"); | |
2185 | +#endif | |
2186 | +#ifdef EINTR | |
2187 | + TEST_COMPARE_STRING (strerrordesc_np (EINTR), "Interrupted system call"); | |
2188 | + TEST_COMPARE_STRING (strerrorname_np (EINTR), "EINTR"); | |
2189 | +#endif | |
2190 | +#ifdef EIO | |
2191 | + TEST_COMPARE_STRING (strerrordesc_np (EIO), "Input/output error"); | |
2192 | + TEST_COMPARE_STRING (strerrorname_np (EIO), "EIO"); | |
2193 | +#endif | |
2194 | +#ifdef ENXIO | |
2195 | + TEST_COMPARE_STRING (strerrordesc_np (ENXIO), "No such device or address"); | |
2196 | + TEST_COMPARE_STRING (strerrorname_np (ENXIO), "ENXIO"); | |
2197 | +#endif | |
2198 | +#ifdef E2BIG | |
2199 | + TEST_COMPARE_STRING (strerrordesc_np (E2BIG), "Argument list too long"); | |
2200 | + TEST_COMPARE_STRING (strerrorname_np (E2BIG), "E2BIG"); | |
2201 | +#endif | |
2202 | +#ifdef ENOEXEC | |
2203 | + TEST_COMPARE_STRING (strerrordesc_np (ENOEXEC), "Exec format error"); | |
2204 | + TEST_COMPARE_STRING (strerrorname_np (ENOEXEC), "ENOEXEC"); | |
2205 | +#endif | |
2206 | +#ifdef EBADF | |
2207 | + TEST_COMPARE_STRING (strerrordesc_np (EBADF), "Bad file descriptor"); | |
2208 | + TEST_COMPARE_STRING (strerrorname_np (EBADF), "EBADF"); | |
2209 | +#endif | |
2210 | +#ifdef ECHILD | |
2211 | + TEST_COMPARE_STRING (strerrordesc_np (ECHILD), "No child processes"); | |
2212 | + TEST_COMPARE_STRING (strerrorname_np (ECHILD), "ECHILD"); | |
2213 | +#endif | |
2214 | +#ifdef EDEADLK | |
2215 | + TEST_COMPARE_STRING (strerrordesc_np (EDEADLK), | |
2216 | + "Resource deadlock avoided"); | |
2217 | + TEST_COMPARE_STRING (strerrorname_np (EDEADLK), "EDEADLK"); | |
2218 | +#endif | |
2219 | +#ifdef ENOMEM | |
2220 | + TEST_COMPARE_STRING (strerrordesc_np (ENOMEM), "Cannot allocate memory"); | |
2221 | + TEST_COMPARE_STRING (strerrorname_np (ENOMEM), "ENOMEM"); | |
2222 | +#endif | |
2223 | +#ifdef EACCES | |
2224 | + TEST_COMPARE_STRING (strerrordesc_np (EACCES), "Permission denied"); | |
2225 | + TEST_COMPARE_STRING (strerrorname_np (EACCES), "EACCES"); | |
2226 | +#endif | |
2227 | +#ifdef EFAULT | |
2228 | + TEST_COMPARE_STRING (strerrordesc_np (EFAULT), "Bad address"); | |
2229 | + TEST_COMPARE_STRING (strerrorname_np (EFAULT), "EFAULT"); | |
2230 | +#endif | |
2231 | +#ifdef ENOTBLK | |
2232 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTBLK), "Block device required"); | |
2233 | + TEST_COMPARE_STRING (strerrorname_np (ENOTBLK), "ENOTBLK"); | |
2234 | +#endif | |
2235 | +#ifdef EBUSY | |
2236 | + TEST_COMPARE_STRING (strerrordesc_np (EBUSY), "Device or resource busy"); | |
2237 | + TEST_COMPARE_STRING (strerrorname_np (EBUSY), "EBUSY"); | |
2238 | +#endif | |
2239 | +#ifdef EEXIST | |
2240 | + TEST_COMPARE_STRING (strerrordesc_np (EEXIST), "File exists"); | |
2241 | + TEST_COMPARE_STRING (strerrorname_np (EEXIST), "EEXIST"); | |
2242 | +#endif | |
2243 | +#ifdef EXDEV | |
2244 | + TEST_COMPARE_STRING (strerrordesc_np (EXDEV), "Invalid cross-device link"); | |
2245 | + TEST_COMPARE_STRING (strerrorname_np (EXDEV), "EXDEV"); | |
2246 | +#endif | |
2247 | +#ifdef ENODEV | |
2248 | + TEST_COMPARE_STRING (strerrordesc_np (ENODEV), "No such device"); | |
2249 | + TEST_COMPARE_STRING (strerrorname_np (ENODEV), "ENODEV"); | |
2250 | +#endif | |
2251 | +#ifdef ENOTDIR | |
2252 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTDIR), "Not a directory"); | |
2253 | + TEST_COMPARE_STRING (strerrorname_np (ENOTDIR), "ENOTDIR"); | |
2254 | +#endif | |
2255 | +#ifdef EISDIR | |
2256 | + TEST_COMPARE_STRING (strerrordesc_np (EISDIR), "Is a directory"); | |
2257 | + TEST_COMPARE_STRING (strerrorname_np (EISDIR), "EISDIR"); | |
2258 | +#endif | |
2259 | +#ifdef EINVAL | |
2260 | + TEST_COMPARE_STRING (strerrordesc_np (EINVAL), "Invalid argument"); | |
2261 | + TEST_COMPARE_STRING (strerrorname_np (EINVAL), "EINVAL"); | |
2262 | +#endif | |
2263 | +#ifdef EMFILE | |
2264 | + TEST_COMPARE_STRING (strerrordesc_np (EMFILE), "Too many open files"); | |
2265 | + TEST_COMPARE_STRING (strerrorname_np (EMFILE), "EMFILE"); | |
2266 | +#endif | |
2267 | +#ifdef ENFILE | |
2268 | + TEST_COMPARE_STRING (strerrordesc_np (ENFILE), | |
2269 | + "Too many open files in system"); | |
2270 | + TEST_COMPARE_STRING (strerrorname_np (ENFILE), "ENFILE"); | |
2271 | +#endif | |
2272 | +#ifdef ENOTTY | |
2273 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTTY), | |
2274 | + "Inappropriate ioctl for device"); | |
2275 | + TEST_COMPARE_STRING (strerrorname_np (ENOTTY), "ENOTTY"); | |
2276 | +#endif | |
2277 | +#ifdef ETXTBSY | |
2278 | + TEST_COMPARE_STRING (strerrordesc_np (ETXTBSY), "Text file busy"); | |
2279 | + TEST_COMPARE_STRING (strerrorname_np (ETXTBSY), "ETXTBSY"); | |
2280 | +#endif | |
2281 | +#ifdef EFBIG | |
2282 | + TEST_COMPARE_STRING (strerrordesc_np (EFBIG), "File too large"); | |
2283 | + TEST_COMPARE_STRING (strerrorname_np (EFBIG), "EFBIG"); | |
2284 | +#endif | |
2285 | +#ifdef ENOSPC | |
2286 | + TEST_COMPARE_STRING (strerrordesc_np (ENOSPC), "No space left on device"); | |
2287 | + TEST_COMPARE_STRING (strerrorname_np (ENOSPC), "ENOSPC"); | |
2288 | +#endif | |
2289 | +#ifdef ESPIPE | |
2290 | + TEST_COMPARE_STRING (strerrordesc_np (ESPIPE), "Illegal seek"); | |
2291 | + TEST_COMPARE_STRING (strerrorname_np (ESPIPE), "ESPIPE"); | |
2292 | +#endif | |
2293 | +#ifdef EROFS | |
2294 | + TEST_COMPARE_STRING (strerrordesc_np (EROFS), "Read-only file system"); | |
2295 | + TEST_COMPARE_STRING (strerrorname_np (EROFS), "EROFS"); | |
2296 | +#endif | |
2297 | +#ifdef EMLINK | |
2298 | + TEST_COMPARE_STRING (strerrordesc_np (EMLINK), "Too many links"); | |
2299 | + TEST_COMPARE_STRING (strerrorname_np (EMLINK), "EMLINK"); | |
2300 | +#endif | |
2301 | +#ifdef EPIPE | |
2302 | + TEST_COMPARE_STRING (strerrordesc_np (EPIPE), "Broken pipe"); | |
2303 | + TEST_COMPARE_STRING (strerrorname_np (EPIPE), "EPIPE"); | |
2304 | +#endif | |
2305 | +#ifdef EDOM | |
2306 | + TEST_COMPARE_STRING (strerrordesc_np (EDOM), | |
2307 | + "Numerical argument out of domain"); | |
2308 | + TEST_COMPARE_STRING (strerrorname_np (EDOM), "EDOM"); | |
2309 | +#endif | |
2310 | +#ifdef ERANGE | |
2311 | + TEST_COMPARE_STRING (strerrordesc_np (ERANGE), | |
2312 | + "Numerical result out of range"); | |
2313 | + TEST_COMPARE_STRING (strerrorname_np (ERANGE), "ERANGE"); | |
2314 | +#endif | |
2315 | +#ifdef EAGAIN | |
2316 | + TEST_COMPARE_STRING (strerrordesc_np (EAGAIN), | |
2317 | + "Resource temporarily unavailable"); | |
2318 | + TEST_COMPARE_STRING (strerrorname_np (EAGAIN), "EAGAIN"); | |
2319 | +#endif | |
2320 | +#ifdef EINPROGRESS | |
2321 | + TEST_COMPARE_STRING (strerrordesc_np (EINPROGRESS), | |
2322 | + "Operation now in progress"); | |
2323 | + TEST_COMPARE_STRING (strerrorname_np (EINPROGRESS), "EINPROGRESS"); | |
2324 | +#endif | |
2325 | +#ifdef EALREADY | |
2326 | + TEST_COMPARE_STRING (strerrordesc_np (EALREADY), | |
2327 | + "Operation already in progress"); | |
2328 | + TEST_COMPARE_STRING (strerrorname_np (EALREADY), "EALREADY"); | |
2329 | +#endif | |
2330 | +#ifdef ENOTSOCK | |
2331 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTSOCK), | |
2332 | + "Socket operation on non-socket"); | |
2333 | + TEST_COMPARE_STRING (strerrorname_np (ENOTSOCK), "ENOTSOCK"); | |
2334 | +#endif | |
2335 | +#ifdef EMSGSIZE | |
2336 | + TEST_COMPARE_STRING (strerrordesc_np (EMSGSIZE), "Message too long"); | |
2337 | + TEST_COMPARE_STRING (strerrorname_np (EMSGSIZE), "EMSGSIZE"); | |
2338 | +#endif | |
2339 | +#ifdef EPROTOTYPE | |
2340 | + TEST_COMPARE_STRING (strerrordesc_np (EPROTOTYPE), | |
2341 | + "Protocol wrong type for socket"); | |
2342 | + TEST_COMPARE_STRING (strerrorname_np (EPROTOTYPE), "EPROTOTYPE"); | |
2343 | +#endif | |
2344 | +#ifdef ENOPROTOOPT | |
2345 | + TEST_COMPARE_STRING (strerrordesc_np (ENOPROTOOPT), | |
2346 | + "Protocol not available"); | |
2347 | + TEST_COMPARE_STRING (strerrorname_np (ENOPROTOOPT), "ENOPROTOOPT"); | |
2348 | +#endif | |
2349 | +#ifdef EPROTONOSUPPORT | |
2350 | + TEST_COMPARE_STRING (strerrordesc_np (EPROTONOSUPPORT), | |
2351 | + "Protocol not supported"); | |
2352 | + TEST_COMPARE_STRING (strerrorname_np (EPROTONOSUPPORT), "EPROTONOSUPPORT"); | |
2353 | +#endif | |
2354 | +#ifdef ESOCKTNOSUPPORT | |
2355 | + TEST_COMPARE_STRING (strerrordesc_np (ESOCKTNOSUPPORT), | |
2356 | + "Socket type not supported"); | |
2357 | + TEST_COMPARE_STRING (strerrorname_np (ESOCKTNOSUPPORT), "ESOCKTNOSUPPORT"); | |
2358 | +#endif | |
2359 | +#ifdef EOPNOTSUPP | |
2360 | + TEST_COMPARE_STRING (strerrordesc_np (EOPNOTSUPP), | |
2361 | + "Operation not supported"); | |
2362 | + TEST_COMPARE_STRING (strerrorname_np (EOPNOTSUPP), "EOPNOTSUPP"); | |
2363 | +#endif | |
2364 | +#ifdef EPFNOSUPPORT | |
2365 | + TEST_COMPARE_STRING (strerrordesc_np (EPFNOSUPPORT), | |
2366 | + "Protocol family not supported"); | |
2367 | + TEST_COMPARE_STRING (strerrorname_np (EPFNOSUPPORT), "EPFNOSUPPORT"); | |
2368 | +#endif | |
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"); | |
2373 | +#endif | |
2374 | +#ifdef EADDRINUSE | |
2375 | + TEST_COMPARE_STRING (strerrordesc_np (EADDRINUSE), | |
2376 | + "Address already in use"); | |
2377 | + TEST_COMPARE_STRING (strerrorname_np (EADDRINUSE), "EADDRINUSE"); | |
2378 | +#endif | |
2379 | +#ifdef EADDRNOTAVAIL | |
2380 | + TEST_COMPARE_STRING (strerrordesc_np (EADDRNOTAVAIL), | |
2381 | + "Cannot assign requested address"); | |
2382 | + TEST_COMPARE_STRING (strerrorname_np (EADDRNOTAVAIL), "EADDRNOTAVAIL"); | |
2383 | +#endif | |
2384 | +#ifdef ENETDOWN | |
2385 | + TEST_COMPARE_STRING (strerrordesc_np (ENETDOWN), "Network is down"); | |
2386 | + TEST_COMPARE_STRING (strerrorname_np (ENETDOWN), "ENETDOWN"); | |
2387 | +#endif | |
2388 | +#ifdef ENETUNREACH | |
2389 | + TEST_COMPARE_STRING (strerrordesc_np (ENETUNREACH), | |
2390 | + "Network is unreachable"); | |
2391 | + TEST_COMPARE_STRING (strerrorname_np (ENETUNREACH), "ENETUNREACH"); | |
2392 | +#endif | |
2393 | +#ifdef ENETRESET | |
2394 | + TEST_COMPARE_STRING (strerrordesc_np (ENETRESET), | |
2395 | + "Network dropped connection on reset"); | |
2396 | + TEST_COMPARE_STRING (strerrorname_np (ENETRESET), "ENETRESET"); | |
2397 | +#endif | |
2398 | +#ifdef ECONNABORTED | |
2399 | + TEST_COMPARE_STRING (strerrordesc_np (ECONNABORTED), | |
2400 | + "Software caused connection abort"); | |
2401 | + TEST_COMPARE_STRING (strerrorname_np (ECONNABORTED), "ECONNABORTED"); | |
2402 | +#endif | |
2403 | +#ifdef ECONNRESET | |
2404 | + TEST_COMPARE_STRING (strerrordesc_np (ECONNRESET), | |
2405 | + "Connection reset by peer"); | |
2406 | + TEST_COMPARE_STRING (strerrorname_np (ECONNRESET), "ECONNRESET"); | |
2407 | +#endif | |
2408 | +#ifdef ENOBUFS | |
2409 | + TEST_COMPARE_STRING (strerrordesc_np (ENOBUFS), | |
2410 | + "No buffer space available"); | |
2411 | + TEST_COMPARE_STRING (strerrorname_np (ENOBUFS), "ENOBUFS"); | |
2412 | +#endif | |
2413 | +#ifdef EISCONN | |
2414 | + TEST_COMPARE_STRING (strerrordesc_np (EISCONN), | |
2415 | + "Transport endpoint is already connected"); | |
2416 | + TEST_COMPARE_STRING (strerrorname_np (EISCONN), "EISCONN"); | |
2417 | +#endif | |
2418 | +#ifdef ENOTCONN | |
2419 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTCONN), | |
2420 | + "Transport endpoint is not connected"); | |
2421 | + TEST_COMPARE_STRING (strerrorname_np (ENOTCONN), "ENOTCONN"); | |
2422 | +#endif | |
2423 | +#ifdef EDESTADDRREQ | |
2424 | + TEST_COMPARE_STRING (strerrordesc_np (EDESTADDRREQ), | |
2425 | + "Destination address required"); | |
2426 | + TEST_COMPARE_STRING (strerrorname_np (EDESTADDRREQ), "EDESTADDRREQ"); | |
2427 | +#endif | |
2428 | +#ifdef ESHUTDOWN | |
2429 | + TEST_COMPARE_STRING (strerrordesc_np (ESHUTDOWN), | |
2430 | + "Cannot send after transport endpoint shutdown"); | |
2431 | + TEST_COMPARE_STRING (strerrorname_np (ESHUTDOWN), "ESHUTDOWN"); | |
2432 | +#endif | |
2433 | +#ifdef ETOOMANYREFS | |
2434 | + TEST_COMPARE_STRING (strerrordesc_np (ETOOMANYREFS), | |
2435 | + "Too many references: cannot splice"); | |
2436 | + TEST_COMPARE_STRING (strerrorname_np (ETOOMANYREFS), "ETOOMANYREFS"); | |
2437 | +#endif | |
2438 | +#ifdef ETIMEDOUT | |
2439 | + TEST_COMPARE_STRING (strerrordesc_np (ETIMEDOUT), "Connection timed out"); | |
2440 | + TEST_COMPARE_STRING (strerrorname_np (ETIMEDOUT), "ETIMEDOUT"); | |
2441 | +#endif | |
2442 | +#ifdef ECONNREFUSED | |
2443 | + TEST_COMPARE_STRING (strerrordesc_np (ECONNREFUSED), "Connection refused"); | |
2444 | + TEST_COMPARE_STRING (strerrorname_np (ECONNREFUSED), "ECONNREFUSED"); | |
2445 | +#endif | |
2446 | +#ifdef ELOOP | |
2447 | + TEST_COMPARE_STRING (strerrordesc_np (ELOOP), | |
2448 | + "Too many levels of symbolic links"); | |
2449 | + TEST_COMPARE_STRING (strerrorname_np (ELOOP), "ELOOP"); | |
2450 | +#endif | |
2451 | +#ifdef ENAMETOOLONG | |
2452 | + TEST_COMPARE_STRING (strerrordesc_np (ENAMETOOLONG), "File name too long"); | |
2453 | + TEST_COMPARE_STRING (strerrorname_np (ENAMETOOLONG), "ENAMETOOLONG"); | |
2454 | +#endif | |
2455 | +#ifdef EHOSTDOWN | |
2456 | + TEST_COMPARE_STRING (strerrordesc_np (EHOSTDOWN), "Host is down"); | |
2457 | + TEST_COMPARE_STRING (strerrorname_np (EHOSTDOWN), "EHOSTDOWN"); | |
2458 | +#endif | |
2459 | +#ifdef EHOSTUNREACH | |
2460 | + TEST_COMPARE_STRING (strerrordesc_np (EHOSTUNREACH), "No route to host"); | |
2461 | + TEST_COMPARE_STRING (strerrorname_np (EHOSTUNREACH), "EHOSTUNREACH"); | |
2462 | +#endif | |
2463 | +#ifdef ENOTEMPTY | |
2464 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTEMPTY), "Directory not empty"); | |
2465 | + TEST_COMPARE_STRING (strerrorname_np (ENOTEMPTY), "ENOTEMPTY"); | |
2466 | +#endif | |
2467 | +#ifdef EUSERS | |
2468 | + TEST_COMPARE_STRING (strerrordesc_np (EUSERS), "Too many users"); | |
2469 | + TEST_COMPARE_STRING (strerrorname_np (EUSERS), "EUSERS"); | |
2470 | +#endif | |
2471 | +#ifdef EDQUOT | |
2472 | + TEST_COMPARE_STRING (strerrordesc_np (EDQUOT), "Disk quota exceeded"); | |
2473 | + TEST_COMPARE_STRING (strerrorname_np (EDQUOT), "EDQUOT"); | |
2474 | +#endif | |
2475 | +#ifdef ESTALE | |
2476 | + TEST_COMPARE_STRING (strerrordesc_np (ESTALE), "Stale file handle"); | |
2477 | + TEST_COMPARE_STRING (strerrorname_np (ESTALE), "ESTALE"); | |
2478 | +#endif | |
2479 | +#ifdef EREMOTE | |
2480 | + TEST_COMPARE_STRING (strerrordesc_np (EREMOTE), "Object is remote"); | |
2481 | + TEST_COMPARE_STRING (strerrorname_np (EREMOTE), "EREMOTE"); | |
2482 | +#endif | |
2483 | +#ifdef ENOLCK | |
2484 | + TEST_COMPARE_STRING (strerrordesc_np (ENOLCK), "No locks available"); | |
2485 | + TEST_COMPARE_STRING (strerrorname_np (ENOLCK), "ENOLCK"); | |
2486 | +#endif | |
2487 | +#ifdef ENOSYS | |
2488 | + TEST_COMPARE_STRING (strerrordesc_np (ENOSYS), "Function not implemented"); | |
2489 | + TEST_COMPARE_STRING (strerrorname_np (ENOSYS), "ENOSYS"); | |
2490 | +#endif | |
2491 | +#ifdef EILSEQ | |
2492 | + TEST_COMPARE_STRING (strerrordesc_np (EILSEQ), | |
2493 | + "Invalid or incomplete multibyte or wide character"); | |
2494 | + TEST_COMPARE_STRING (strerrorname_np (EILSEQ), "EILSEQ"); | |
2495 | +#endif | |
2496 | +#ifdef EBADMSG | |
2497 | + TEST_COMPARE_STRING (strerrordesc_np (EBADMSG), "Bad message"); | |
2498 | + TEST_COMPARE_STRING (strerrorname_np (EBADMSG), "EBADMSG"); | |
2499 | +#endif | |
2500 | +#ifdef EIDRM | |
2501 | + TEST_COMPARE_STRING (strerrordesc_np (EIDRM), "Identifier removed"); | |
2502 | + TEST_COMPARE_STRING (strerrorname_np (EIDRM), "EIDRM"); | |
2503 | +#endif | |
2504 | +#ifdef EMULTIHOP | |
2505 | + TEST_COMPARE_STRING (strerrordesc_np (EMULTIHOP), "Multihop attempted"); | |
2506 | + TEST_COMPARE_STRING (strerrorname_np (EMULTIHOP), "EMULTIHOP"); | |
2507 | +#endif | |
2508 | +#ifdef ENODATA | |
2509 | + TEST_COMPARE_STRING (strerrordesc_np (ENODATA), "No data available"); | |
2510 | + TEST_COMPARE_STRING (strerrorname_np (ENODATA), "ENODATA"); | |
2511 | +#endif | |
2512 | +#ifdef ENOLINK | |
2513 | + TEST_COMPARE_STRING (strerrordesc_np (ENOLINK), "Link has been severed"); | |
2514 | + TEST_COMPARE_STRING (strerrorname_np (ENOLINK), "ENOLINK"); | |
2515 | +#endif | |
2516 | +#ifdef ENOMSG | |
2517 | + TEST_COMPARE_STRING (strerrordesc_np (ENOMSG), | |
2518 | + "No message of desired type"); | |
2519 | + TEST_COMPARE_STRING (strerrorname_np (ENOMSG), "ENOMSG"); | |
2520 | +#endif | |
2521 | +#ifdef ENOSR | |
2522 | + TEST_COMPARE_STRING (strerrordesc_np (ENOSR), "Out of streams resources"); | |
2523 | + TEST_COMPARE_STRING (strerrorname_np (ENOSR), "ENOSR"); | |
2524 | +#endif | |
2525 | +#ifdef ENOSTR | |
2526 | + TEST_COMPARE_STRING (strerrordesc_np (ENOSTR), "Device not a stream"); | |
2527 | + TEST_COMPARE_STRING (strerrorname_np (ENOSTR), "ENOSTR"); | |
2528 | +#endif | |
2529 | +#ifdef EOVERFLOW | |
2530 | + TEST_COMPARE_STRING (strerrordesc_np (EOVERFLOW), | |
2531 | + "Value too large for defined data type"); | |
2532 | + TEST_COMPARE_STRING (strerrorname_np (EOVERFLOW), "EOVERFLOW"); | |
2533 | +#endif | |
2534 | +#ifdef EPROTO | |
2535 | + TEST_COMPARE_STRING (strerrordesc_np (EPROTO), "Protocol error"); | |
2536 | + TEST_COMPARE_STRING (strerrorname_np (EPROTO), "EPROTO"); | |
2537 | +#endif | |
2538 | +#ifdef ETIME | |
2539 | + TEST_COMPARE_STRING (strerrordesc_np (ETIME), "Timer expired"); | |
2540 | + TEST_COMPARE_STRING (strerrorname_np (ETIME), "ETIME"); | |
2541 | +#endif | |
2542 | +#ifdef ECANCELED | |
2543 | + TEST_COMPARE_STRING (strerrordesc_np (ECANCELED), "Operation canceled"); | |
2544 | + TEST_COMPARE_STRING (strerrorname_np (ECANCELED), "ECANCELED"); | |
2545 | +#endif | |
2546 | +#ifdef EOWNERDEAD | |
2547 | + TEST_COMPARE_STRING (strerrordesc_np (EOWNERDEAD), "Owner died"); | |
2548 | + TEST_COMPARE_STRING (strerrorname_np (EOWNERDEAD), "EOWNERDEAD"); | |
2549 | +#endif | |
2550 | +#ifdef ENOTRECOVERABLE | |
2551 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTRECOVERABLE), | |
2552 | + "State not recoverable"); | |
2553 | + TEST_COMPARE_STRING (strerrorname_np (ENOTRECOVERABLE), "ENOTRECOVERABLE"); | |
2554 | +#endif | |
2555 | +#ifdef ERESTART | |
2556 | + TEST_COMPARE_STRING (strerrordesc_np (ERESTART), | |
2557 | + "Interrupted system call should be restarted"); | |
2558 | + TEST_COMPARE_STRING (strerrorname_np (ERESTART), "ERESTART"); | |
2559 | +#endif | |
2560 | +#ifdef ECHRNG | |
2561 | + TEST_COMPARE_STRING (strerrordesc_np (ECHRNG), | |
2562 | + "Channel number out of range"); | |
2563 | + TEST_COMPARE_STRING (strerrorname_np (ECHRNG), "ECHRNG"); | |
2564 | +#endif | |
2565 | +#ifdef EL2NSYNC | |
2566 | + TEST_COMPARE_STRING (strerrordesc_np (EL2NSYNC), | |
2567 | + "Level 2 not synchronized"); | |
2568 | + TEST_COMPARE_STRING (strerrorname_np (EL2NSYNC), "EL2NSYNC"); | |
2569 | +#endif | |
2570 | +#ifdef EL3HLT | |
2571 | + TEST_COMPARE_STRING (strerrordesc_np (EL3HLT), "Level 3 halted"); | |
2572 | + TEST_COMPARE_STRING (strerrorname_np (EL3HLT), "EL3HLT"); | |
2573 | +#endif | |
2574 | +#ifdef EL3RST | |
2575 | + TEST_COMPARE_STRING (strerrordesc_np (EL3RST), "Level 3 reset"); | |
2576 | + TEST_COMPARE_STRING (strerrorname_np (EL3RST), "EL3RST"); | |
2577 | +#endif | |
2578 | +#ifdef ELNRNG | |
2579 | + TEST_COMPARE_STRING (strerrordesc_np (ELNRNG), "Link number out of range"); | |
2580 | + TEST_COMPARE_STRING (strerrorname_np (ELNRNG), "ELNRNG"); | |
2581 | +#endif | |
2582 | +#ifdef EUNATCH | |
2583 | + TEST_COMPARE_STRING (strerrordesc_np (EUNATCH), | |
2584 | + "Protocol driver not attached"); | |
2585 | + TEST_COMPARE_STRING (strerrorname_np (EUNATCH), "EUNATCH"); | |
2586 | +#endif | |
2587 | +#ifdef ENOCSI | |
2588 | + TEST_COMPARE_STRING (strerrordesc_np (ENOCSI), | |
2589 | + "No CSI structure available"); | |
2590 | + TEST_COMPARE_STRING (strerrorname_np (ENOCSI), "ENOCSI"); | |
2591 | +#endif | |
2592 | +#ifdef EL2HLT | |
2593 | + TEST_COMPARE_STRING (strerrordesc_np (EL2HLT), "Level 2 halted"); | |
2594 | + TEST_COMPARE_STRING (strerrorname_np (EL2HLT), "EL2HLT"); | |
2595 | +#endif | |
2596 | +#ifdef EBADE | |
2597 | + TEST_COMPARE_STRING (strerrordesc_np (EBADE), "Invalid exchange"); | |
2598 | + TEST_COMPARE_STRING (strerrorname_np (EBADE), "EBADE"); | |
2599 | +#endif | |
2600 | +#ifdef EBADR | |
2601 | + TEST_COMPARE_STRING (strerrordesc_np (EBADR), | |
2602 | + "Invalid request descriptor"); | |
2603 | + TEST_COMPARE_STRING (strerrorname_np (EBADR), "EBADR"); | |
2604 | +#endif | |
2605 | +#ifdef EXFULL | |
2606 | + TEST_COMPARE_STRING (strerrordesc_np (EXFULL), "Exchange full"); | |
2607 | + TEST_COMPARE_STRING (strerrorname_np (EXFULL), "EXFULL"); | |
2608 | +#endif | |
2609 | +#ifdef ENOANO | |
2610 | + TEST_COMPARE_STRING (strerrordesc_np (ENOANO), "No anode"); | |
2611 | + TEST_COMPARE_STRING (strerrorname_np (ENOANO), "ENOANO"); | |
2612 | +#endif | |
2613 | +#ifdef EBADRQC | |
2614 | + TEST_COMPARE_STRING (strerrordesc_np (EBADRQC), "Invalid request code"); | |
2615 | + TEST_COMPARE_STRING (strerrorname_np (EBADRQC), "EBADRQC"); | |
2616 | +#endif | |
2617 | +#ifdef EBADSLT | |
2618 | + TEST_COMPARE_STRING (strerrordesc_np (EBADSLT), "Invalid slot"); | |
2619 | + TEST_COMPARE_STRING (strerrorname_np (EBADSLT), "EBADSLT"); | |
2620 | +#endif | |
2621 | +#ifdef EBFONT | |
2622 | + TEST_COMPARE_STRING (strerrordesc_np (EBFONT), "Bad font file format"); | |
2623 | + TEST_COMPARE_STRING (strerrorname_np (EBFONT), "EBFONT"); | |
2624 | +#endif | |
2625 | +#ifdef ENONET | |
2626 | + TEST_COMPARE_STRING (strerrordesc_np (ENONET), | |
2627 | + "Machine is not on the network"); | |
2628 | + TEST_COMPARE_STRING (strerrorname_np (ENONET), "ENONET"); | |
2629 | +#endif | |
2630 | +#ifdef ENOPKG | |
2631 | + TEST_COMPARE_STRING (strerrordesc_np (ENOPKG), "Package not installed"); | |
2632 | + TEST_COMPARE_STRING (strerrorname_np (ENOPKG), "ENOPKG"); | |
2633 | +#endif | |
2634 | +#ifdef EADV | |
2635 | + TEST_COMPARE_STRING (strerrordesc_np (EADV), "Advertise error"); | |
2636 | + TEST_COMPARE_STRING (strerrorname_np (EADV), "EADV"); | |
2637 | +#endif | |
2638 | +#ifdef ESRMNT | |
2639 | + TEST_COMPARE_STRING (strerrordesc_np (ESRMNT), "Srmount error"); | |
2640 | + TEST_COMPARE_STRING (strerrorname_np (ESRMNT), "ESRMNT"); | |
2641 | +#endif | |
2642 | +#ifdef ECOMM | |
2643 | + TEST_COMPARE_STRING (strerrordesc_np (ECOMM), | |
2644 | + "Communication error on send"); | |
2645 | + TEST_COMPARE_STRING (strerrorname_np (ECOMM), "ECOMM"); | |
2646 | +#endif | |
2647 | +#ifdef EDOTDOT | |
2648 | + TEST_COMPARE_STRING (strerrordesc_np (EDOTDOT), "RFS specific error"); | |
2649 | + TEST_COMPARE_STRING (strerrorname_np (EDOTDOT), "EDOTDOT"); | |
2650 | +#endif | |
2651 | +#ifdef ENOTUNIQ | |
2652 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTUNIQ), | |
2653 | + "Name not unique on network"); | |
2654 | + TEST_COMPARE_STRING (strerrorname_np (ENOTUNIQ), "ENOTUNIQ"); | |
2655 | +#endif | |
2656 | +#ifdef EBADFD | |
2657 | + TEST_COMPARE_STRING (strerrordesc_np (EBADFD), | |
2658 | + "File descriptor in bad state"); | |
2659 | + TEST_COMPARE_STRING (strerrorname_np (EBADFD), "EBADFD"); | |
2660 | +#endif | |
2661 | +#ifdef EREMCHG | |
2662 | + TEST_COMPARE_STRING (strerrordesc_np (EREMCHG), "Remote address changed"); | |
2663 | + TEST_COMPARE_STRING (strerrorname_np (EREMCHG), "EREMCHG"); | |
2664 | +#endif | |
2665 | +#ifdef ELIBACC | |
2666 | + TEST_COMPARE_STRING (strerrordesc_np (ELIBACC), | |
2667 | + "Can not access a needed shared library"); | |
2668 | + TEST_COMPARE_STRING (strerrorname_np (ELIBACC), "ELIBACC"); | |
2669 | +#endif | |
2670 | +#ifdef ELIBBAD | |
2671 | + TEST_COMPARE_STRING (strerrordesc_np (ELIBBAD), | |
2672 | + "Accessing a corrupted shared library"); | |
2673 | + TEST_COMPARE_STRING (strerrorname_np (ELIBBAD), "ELIBBAD"); | |
2674 | +#endif | |
2675 | +#ifdef ELIBSCN | |
2676 | + TEST_COMPARE_STRING (strerrordesc_np (ELIBSCN), | |
2677 | + ".lib section in a.out corrupted"); | |
2678 | + TEST_COMPARE_STRING (strerrorname_np (ELIBSCN), "ELIBSCN"); | |
2679 | +#endif | |
2680 | +#ifdef ELIBMAX | |
2681 | + TEST_COMPARE_STRING (strerrordesc_np (ELIBMAX), | |
2682 | + "Attempting to link in too many shared libraries"); | |
2683 | + TEST_COMPARE_STRING (strerrorname_np (ELIBMAX), "ELIBMAX"); | |
2684 | +#endif | |
2685 | +#ifdef ELIBEXEC | |
2686 | + TEST_COMPARE_STRING (strerrordesc_np (ELIBEXEC), | |
2687 | + "Cannot exec a shared library directly"); | |
2688 | + TEST_COMPARE_STRING (strerrorname_np (ELIBEXEC), "ELIBEXEC"); | |
2689 | +#endif | |
2690 | +#ifdef ESTRPIPE | |
2691 | + TEST_COMPARE_STRING (strerrordesc_np (ESTRPIPE), "Streams pipe error"); | |
2692 | + TEST_COMPARE_STRING (strerrorname_np (ESTRPIPE), "ESTRPIPE"); | |
2693 | +#endif | |
2694 | +#ifdef EUCLEAN | |
2695 | + TEST_COMPARE_STRING (strerrordesc_np (EUCLEAN), | |
2696 | + "Structure needs cleaning"); | |
2697 | + TEST_COMPARE_STRING (strerrorname_np (EUCLEAN), "EUCLEAN"); | |
2698 | +#endif | |
2699 | +#ifdef ENOTNAM | |
2700 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTNAM), | |
2701 | + "Not a XENIX named type file"); | |
2702 | + TEST_COMPARE_STRING (strerrorname_np (ENOTNAM), "ENOTNAM"); | |
2703 | +#endif | |
2704 | +#ifdef ENAVAIL | |
2705 | + TEST_COMPARE_STRING (strerrordesc_np (ENAVAIL), | |
2706 | + "No XENIX semaphores available"); | |
2707 | + TEST_COMPARE_STRING (strerrorname_np (ENAVAIL), "ENAVAIL"); | |
2708 | +#endif | |
2709 | +#ifdef EISNAM | |
2710 | + TEST_COMPARE_STRING (strerrordesc_np (EISNAM), "Is a named type file"); | |
2711 | + TEST_COMPARE_STRING (strerrorname_np (EISNAM), "EISNAM"); | |
2712 | +#endif | |
2713 | +#ifdef EREMOTEIO | |
2714 | + TEST_COMPARE_STRING (strerrordesc_np (EREMOTEIO), "Remote I/O error"); | |
2715 | + TEST_COMPARE_STRING (strerrorname_np (EREMOTEIO), "EREMOTEIO"); | |
2716 | +#endif | |
2717 | +#ifdef ENOMEDIUM | |
2718 | + TEST_COMPARE_STRING (strerrordesc_np (ENOMEDIUM), "No medium found"); | |
2719 | + TEST_COMPARE_STRING (strerrorname_np (ENOMEDIUM), "ENOMEDIUM"); | |
2720 | +#endif | |
2721 | +#ifdef EMEDIUMTYPE | |
2722 | + TEST_COMPARE_STRING (strerrordesc_np (EMEDIUMTYPE), "Wrong medium type"); | |
2723 | + TEST_COMPARE_STRING (strerrorname_np (EMEDIUMTYPE), "EMEDIUMTYPE"); | |
2724 | +#endif | |
2725 | +#ifdef ENOKEY | |
2726 | + TEST_COMPARE_STRING (strerrordesc_np (ENOKEY), | |
2727 | + "Required key not available"); | |
2728 | + TEST_COMPARE_STRING (strerrorname_np (ENOKEY), "ENOKEY"); | |
2729 | +#endif | |
2730 | +#ifdef EKEYEXPIRED | |
2731 | + TEST_COMPARE_STRING (strerrordesc_np (EKEYEXPIRED), "Key has expired"); | |
2732 | + TEST_COMPARE_STRING (strerrorname_np (EKEYEXPIRED), "EKEYEXPIRED"); | |
2733 | +#endif | |
2734 | +#ifdef EKEYREVOKED | |
2735 | + TEST_COMPARE_STRING (strerrordesc_np (EKEYREVOKED), | |
2736 | + "Key has been revoked"); | |
2737 | + TEST_COMPARE_STRING (strerrorname_np (EKEYREVOKED), "EKEYREVOKED"); | |
2738 | +#endif | |
2739 | +#ifdef EKEYREJECTED | |
2740 | + TEST_COMPARE_STRING (strerrordesc_np (EKEYREJECTED), | |
2741 | + "Key was rejected by service"); | |
2742 | + TEST_COMPARE_STRING (strerrorname_np (EKEYREJECTED), "EKEYREJECTED"); | |
2743 | +#endif | |
2744 | +#ifdef ERFKILL | |
2745 | + TEST_COMPARE_STRING (strerrordesc_np (ERFKILL), | |
2746 | + "Operation not possible due to RF-kill"); | |
2747 | + TEST_COMPARE_STRING (strerrorname_np (ERFKILL), "ERFKILL"); | |
2748 | +#endif | |
2749 | +#ifdef EHWPOISON | |
2750 | + TEST_COMPARE_STRING (strerrordesc_np (EHWPOISON), | |
2751 | + "Memory page has hardware error"); | |
2752 | + TEST_COMPARE_STRING (strerrorname_np (EHWPOISON), "EHWPOISON"); | |
2753 | +#endif | |
2754 | +#ifdef EBADRPC | |
2755 | + TEST_COMPARE_STRING (strerrordesc_np (EBADRPC), "RPC struct is bad"); | |
2756 | + TEST_COMPARE_STRING (strerrorname_np (EBADRPC), "EBADRPC"); | |
2757 | +#endif | |
2758 | +#ifdef EFTYPE | |
2759 | + TEST_COMPARE_STRING (strerrordesc_np (EFTYPE), | |
2760 | + "Inappropriate file type or format"); | |
2761 | + TEST_COMPARE_STRING (strerrorname_np (EFTYPE), "EFTYPE"); | |
2762 | +#endif | |
2763 | +#ifdef EPROCUNAVAIL | |
2764 | + TEST_COMPARE_STRING (strerrordesc_np (EPROCUNAVAIL), | |
2765 | + "RPC bad procedure for program"); | |
2766 | + TEST_COMPARE_STRING (strerrorname_np (EPROCUNAVAIL), "EPROCUNAVAIL"); | |
2767 | +#endif | |
2768 | +#ifdef EAUTH | |
2769 | + TEST_COMPARE_STRING (strerrordesc_np (EAUTH), "Authentication error"); | |
2770 | + TEST_COMPARE_STRING (strerrorname_np (EAUTH), "EAUTH"); | |
2771 | +#endif | |
2772 | +#ifdef EDIED | |
2773 | + TEST_COMPARE_STRING (strerrordesc_np (EDIED), "Translator died"); | |
2774 | + TEST_COMPARE_STRING (strerrorname_np (EDIED), "EDIED"); | |
2775 | +#endif | |
2776 | +#ifdef ERPCMISMATCH | |
2777 | + TEST_COMPARE_STRING (strerrordesc_np (ERPCMISMATCH), "RPC version wrong"); | |
2778 | + TEST_COMPARE_STRING (strerrorname_np (ERPCMISMATCH), "ERPCMISMATCH"); | |
2779 | +#endif | |
2780 | +#ifdef EGREGIOUS | |
2781 | + TEST_COMPARE_STRING (strerrordesc_np (EGREGIOUS), | |
2782 | + "You really blew it this time"); | |
2783 | + TEST_COMPARE_STRING (strerrorname_np (EGREGIOUS), "EGREGIOUS"); | |
2784 | +#endif | |
2785 | +#ifdef EPROCLIM | |
2786 | + TEST_COMPARE_STRING (strerrordesc_np (EPROCLIM), "Too many processes"); | |
2787 | + TEST_COMPARE_STRING (strerrorname_np (EPROCLIM), "EPROCLIM"); | |
2788 | +#endif | |
2789 | +#ifdef EGRATUITOUS | |
2790 | + TEST_COMPARE_STRING (strerrordesc_np (EGRATUITOUS), "Gratuitous error"); | |
2791 | + TEST_COMPARE_STRING (strerrorname_np (EGRATUITOUS), "EGRATUITOUS"); | |
2792 | +#endif | |
2793 | +#if defined (ENOTSUP) && ENOTSUP != EOPNOTSUPP | |
2794 | + TEST_COMPARE_STRING (strerrordesc_np (ENOTSUP), "Not supported"); | |
2795 | + TEST_COMPARE_STRING (strerrorname_np (ENOTSUP), "ENOTSUP"); | |
2796 | +#endif | |
2797 | +#ifdef EPROGMISMATCH | |
2798 | + TEST_COMPARE_STRING (strerrordesc_np (EPROGMISMATCH), | |
2799 | + "RPC program version wrong"); | |
2800 | + TEST_COMPARE_STRING (strerrorname_np (EPROGMISMATCH), "EPROGMISMATCH"); | |
2801 | +#endif | |
2802 | +#ifdef EBACKGROUND | |
2803 | + TEST_COMPARE_STRING (strerrordesc_np (EBACKGROUND), | |
2804 | + "Inappropriate operation for background process"); | |
2805 | + TEST_COMPARE_STRING (strerrorname_np (EBACKGROUND), "EBACKGROUND"); | |
2806 | +#endif | |
2807 | +#ifdef EIEIO | |
2808 | + TEST_COMPARE_STRING (strerrordesc_np (EIEIO), "Computer bought the farm"); | |
2809 | + TEST_COMPARE_STRING (strerrorname_np (EIEIO), "EIEIO"); | |
2810 | +#endif | |
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"); | |
2815 | +#endif | |
2816 | +#ifdef ENEEDAUTH | |
2817 | + TEST_COMPARE_STRING (strerrordesc_np (ENEEDAUTH), "Need authenticator"); | |
2818 | + TEST_COMPARE_STRING (strerrorname_np (ENEEDAUTH), "ENEEDAUTH"); | |
2819 | +#endif | |
2820 | +#ifdef ED | |
2821 | + TEST_COMPARE_STRING (strerrordesc_np (ED), "?"); | |
2822 | + TEST_COMPARE_STRING (strerrorname_np (ED), "ED"); | |
2823 | +#endif | |
2824 | +#ifdef EPROGUNAVAIL | |
2825 | + TEST_COMPARE_STRING (strerrordesc_np (EPROGUNAVAIL), | |
2826 | + "RPC program not available"); | |
2827 | + TEST_COMPARE_STRING (strerrorname_np (EPROGUNAVAIL), "EPROGUNAVAIL"); | |
2828 | +#endif | |
2829 | ||
2d5de23a VM |
2830 | return 0; |
2831 | } | |
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, | |
2837 | #endif | |
2838 | { | |
2839 | va_list arg; | |
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, | |
2846 | #endif | |
2847 | ||
2848 | #ifndef COMPILE_WSCANF | |
2849 | - if (!isascii ((unsigned char) *f)) | |
2850 | + if (!isascii (*f)) | |
2851 | { | |
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), | |
2855 | + &state); | |
2856 | if (len > 0) | |
2857 | { | |
2858 | do | |
2859 | @@ -426,7 +427,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, | |
2860 | c = inchar (); | |
2861 | if (__glibc_unlikely (c == EOF)) | |
2862 | input_error (); | |
2863 | - else if (c != (unsigned char) *f++) | |
2864 | + else if (c != *f++) | |
2865 | { | |
2866 | ungetc_not_eof (c, s); | |
2867 | conv_error (); | |
2868 | @@ -484,9 +485,9 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, | |
2869 | char_buffer_rewind (&charbuf); | |
2870 | ||
2871 | /* Check for a positional parameter specification. */ | |
2872 | - if (ISDIGIT ((UCHAR_T) *f)) | |
2873 | + if (ISDIGIT (*f)) | |
2874 | { | |
2875 | - argpos = read_int ((const UCHAR_T **) &f); | |
2876 | + argpos = read_int (&f); | |
2877 | if (*f == L_('$')) | |
2878 | ++f; | |
2879 | else | |
2880 | @@ -521,8 +522,8 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, | |
2881 | ||
2882 | /* Find the maximum field width. */ | |
2883 | width = 0; | |
2884 | - if (ISDIGIT ((UCHAR_T) *f)) | |
2885 | - width = read_int ((const UCHAR_T **) &f); | |
2886 | + if (ISDIGIT (*f)) | |
2887 | + width = read_int (&f); | |
2888 | got_width: | |
2889 | if (width == 0) | |
2890 | width = -1; | |
2891 | @@ -2522,12 +2523,11 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, | |
2892 | } | |
2893 | ||
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) | |
2898 | { | |
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; | |
2904 | } | |
2905 | else | |
ad3e853a VM |
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> | |
2912 | #include <unistd.h> | |
2913 | ||
2914 | +#include <support/check.h> | |
2915 | #include <support/support.h> | |
2916 | +#include <support/capture_subprocess.h> | |
2917 | #include <support/test-driver.h> | |
2918 | ||
2919 | static char MAGIC_ARGUMENT[] = "run-actual-test"; | |
2920 | -#define MAGIC_STATUS 19 | |
2921 | - | |
2922 | -/* Return a GID which is not our current GID, but is present in the | |
2923 | - supplementary group list. */ | |
2924 | -static gid_t | |
2925 | -choose_gid (void) | |
2926 | -{ | |
2927 | - int count = getgroups (0, NULL); | |
2928 | - if (count < 0) | |
2929 | - { | |
2930 | - printf ("getgroups: %m\n"); | |
2931 | - exit (1); | |
2932 | - } | |
2933 | - gid_t *groups; | |
2934 | - groups = xcalloc (count, sizeof (*groups)); | |
2935 | - int ret = getgroups (count, groups); | |
2936 | - if (ret < 0) | |
2937 | - { | |
2938 | - printf ("getgroups: %m\n"); | |
2939 | - exit (1); | |
2940 | - } | |
2941 | - gid_t current = getgid (); | |
2942 | - gid_t not_current = 0; | |
2943 | - for (int i = 0; i < ret; ++i) | |
2944 | - { | |
2945 | - if (groups[i] != current) | |
2946 | - { | |
2947 | - not_current = groups[i]; | |
2948 | - break; | |
2949 | - } | |
2950 | - } | |
2951 | - free (groups); | |
2952 | - return not_current; | |
2953 | -} | |
2954 | - | |
2955 | - | |
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 | |
2958 | - executable. */ | |
2959 | -static int | |
2960 | -run_executable_sgid (gid_t target) | |
2961 | -{ | |
2962 | - char *dirname = xasprintf ("%s/secure-getenv.%jd", | |
2963 | - test_dir, (intmax_t) getpid ()); | |
2964 | - char *execname = xasprintf ("%s/bin", dirname); | |
2965 | - int infd = -1; | |
2966 | - int outfd = -1; | |
2967 | - int ret = -1; | |
2968 | - if (mkdir (dirname, 0700) < 0) | |
2969 | - { | |
2970 | - printf ("mkdir: %m\n"); | |
2971 | - goto err; | |
2972 | - } | |
2973 | - infd = open ("/proc/self/exe", O_RDONLY); | |
2974 | - if (infd < 0) | |
2975 | - { | |
2976 | - printf ("open (/proc/self/exe): %m\n"); | |
2977 | - goto err; | |
2978 | - } | |
2979 | - outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700); | |
2980 | - if (outfd < 0) | |
2981 | - { | |
2982 | - printf ("open (%s): %m\n", execname); | |
2983 | - goto err; | |
2984 | - } | |
2985 | - char buf[4096]; | |
2986 | - for (;;) | |
2987 | - { | |
2988 | - ssize_t rdcount = read (infd, buf, sizeof (buf)); | |
2989 | - if (rdcount < 0) | |
2990 | - { | |
2991 | - printf ("read: %m\n"); | |
2992 | - goto err; | |
2993 | - } | |
2994 | - if (rdcount == 0) | |
2995 | - break; | |
2996 | - char *p = buf; | |
2997 | - char *end = buf + rdcount; | |
2998 | - while (p != end) | |
2999 | - { | |
3000 | - ssize_t wrcount = write (outfd, buf, end - p); | |
3001 | - if (wrcount == 0) | |
3002 | - errno = ENOSPC; | |
3003 | - if (wrcount <= 0) | |
3004 | - { | |
3005 | - printf ("write: %m\n"); | |
3006 | - goto err; | |
3007 | - } | |
3008 | - p += wrcount; | |
3009 | - } | |
3010 | - } | |
3011 | - if (fchown (outfd, getuid (), target) < 0) | |
3012 | - { | |
3013 | - printf ("fchown (%s): %m\n", execname); | |
3014 | - goto err; | |
3015 | - } | |
3016 | - if (fchmod (outfd, 02750) < 0) | |
3017 | - { | |
3018 | - printf ("fchmod (%s): %m\n", execname); | |
3019 | - goto err; | |
3020 | - } | |
3021 | - if (close (outfd) < 0) | |
3022 | - { | |
3023 | - printf ("close (outfd): %m\n"); | |
3024 | - goto err; | |
3025 | - } | |
3026 | - if (close (infd) < 0) | |
3027 | - { | |
3028 | - printf ("close (infd): %m\n"); | |
3029 | - goto err; | |
3030 | - } | |
3031 | - | |
3032 | - int kid = fork (); | |
3033 | - if (kid < 0) | |
3034 | - { | |
3035 | - printf ("fork: %m\n"); | |
3036 | - goto err; | |
3037 | - } | |
3038 | - if (kid == 0) | |
3039 | - { | |
3040 | - /* Child process. */ | |
3041 | - char *args[] = { execname, MAGIC_ARGUMENT, NULL }; | |
3042 | - execve (execname, args, environ); | |
3043 | - printf ("execve (%s): %m\n", execname); | |
3044 | - _exit (1); | |
3045 | - } | |
3046 | - int status; | |
3047 | - if (waitpid (kid, &status, 0) < 0) | |
3048 | - { | |
3049 | - printf ("waitpid: %m\n"); | |
3050 | - goto err; | |
3051 | - } | |
3052 | - if (!WIFEXITED (status) || WEXITSTATUS (status) != MAGIC_STATUS) | |
3053 | - { | |
3054 | - printf ("Unexpected exit status %d from child process\n", | |
3055 | - status); | |
3056 | - goto err; | |
3057 | - } | |
3058 | - ret = 0; | |
3059 | - | |
3060 | -err: | |
3061 | - if (outfd >= 0) | |
3062 | - close (outfd); | |
3063 | - if (infd >= 0) | |
3064 | - close (infd); | |
3065 | - if (execname) | |
3066 | - { | |
3067 | - unlink (execname); | |
3068 | - free (execname); | |
3069 | - } | |
3070 | - if (dirname) | |
3071 | - { | |
3072 | - rmdir (dirname); | |
3073 | - free (dirname); | |
3074 | - } | |
3075 | - return ret; | |
3076 | -} | |
3077 | ||
3078 | static int | |
3079 | do_test (void) | |
3080 | @@ -212,15 +57,15 @@ do_test (void) | |
3081 | exit (1); | |
3082 | } | |
3083 | ||
3084 | - gid_t target = choose_gid (); | |
3085 | - if (target == 0) | |
3086 | - { | |
3087 | - fprintf (stderr, | |
3088 | - "Could not find a suitable GID for user %jd, skipping test\n", | |
3089 | - (intmax_t) getuid ()); | |
3090 | - exit (0); | |
3091 | - } | |
3092 | - return run_executable_sgid (target); | |
3093 | + int status = support_capture_subprogram_self_sgid (MAGIC_ARGUMENT); | |
3094 | + | |
3095 | + if (WEXITSTATUS (status) == EXIT_UNSUPPORTED) | |
3096 | + return EXIT_UNSUPPORTED; | |
3097 | + | |
3098 | + if (!WIFEXITED (status)) | |
3099 | + FAIL_EXIT1 ("Unexpected exit status %d from child process\n", status); | |
3100 | + | |
3101 | + return 0; | |
3102 | } | |
3103 | ||
3104 | static void | |
3105 | @@ -229,23 +74,15 @@ alternative_main (int argc, char **argv) | |
3106 | if (argc == 2 && strcmp (argv[1], MAGIC_ARGUMENT) == 0) | |
3107 | { | |
3108 | if (getgid () == getegid ()) | |
3109 | - { | |
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); | |
3114 | - } | |
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) | |
3119 | - { | |
3120 | - printf ("PATH variable not present\n"); | |
3121 | - exit (3); | |
3122 | - } | |
3123 | + FAIL_EXIT (3, "PATH variable not present\n"); | |
3124 | if (secure_getenv ("PATH") != NULL) | |
3125 | - { | |
3126 | - printf ("PATH variable not filtered out\n"); | |
3127 | - exit (4); | |
3128 | - } | |
3129 | - exit (MAGIC_STATUS); | |
3130 | + FAIL_EXIT (4, "PATH variable not filtered out\n"); | |
3131 | + | |
3132 | + exit (EXIT_SUCCESS); | |
3133 | } | |
3134 | } | |
3135 | ||
2d5de23a VM |
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 | |
3140 | @@ -22,11 +22,6 @@ | |
3141 | # error "Never use <bits/string_fortified.h> directly; include <string.h> instead." | |
3142 | #endif | |
3143 | ||
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"); | |
3147 | -#endif | |
3148 | - | |
3149 | __fortify_function void * | |
3150 | __NTH (memcpy (void *__restrict __dest, const void *__restrict __src, | |
3151 | size_t __len)) | |
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)) | |
3155 | { | |
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)) | |
3161 | - { | |
3162 | - __warn_memset_zero_len (); | |
3163 | - return __dest; | |
3164 | - } | |
3165 | -#endif | |
3166 | return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest)); | |
3167 | } | |
3168 | ||
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 = \ | |
3174 | ignore_stderr \ | |
3175 | next_to_fault \ | |
3176 | oom_error \ | |
3177 | + resolv_response_context_duplicate \ | |
3178 | + resolv_response_context_free \ | |
3179 | resolv_test \ | |
3180 | set_fortify_handler \ | |
3181 | support-xfstat \ | |
ad3e853a VM |
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[]); | |
3189 | ||
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 | |
3194 | + (char *child_id); | |
3195 | + | |
3196 | /* Deallocate the subprocess data captured by | |
3197 | support_capture_subprocess. */ | |
3198 | void support_capture_subprocess_free (struct support_capture_subprocess *); | |
2d5de23a VM |
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 | |
3202 | --- /dev/null | |
3203 | +++ b/support/resolv_response_context_duplicate.c | |
3204 | @@ -0,0 +1,37 @@ | |
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. | |
3208 | + | |
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. | |
3213 | + | |
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. | |
3218 | + | |
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/>. */ | |
3222 | + | |
3223 | +#include <string.h> | |
3224 | +#include <support/resolv_test.h> | |
3225 | +#include <support/support.h> | |
3226 | + | |
3227 | +struct resolv_response_context * | |
3228 | +resolv_response_context_duplicate (const struct resolv_response_context *ctx) | |
3229 | +{ | |
3230 | + struct resolv_response_context *result = xmalloc (sizeof (*result)); | |
3231 | + memcpy (result, ctx, sizeof (*result)); | |
3232 | + if (result->client_address != NULL) | |
3233 | + { | |
3234 | + result->client_address = xmalloc (result->client_address_length); | |
3235 | + memcpy (result->client_address, ctx->client_address, | |
3236 | + result->client_address_length); | |
3237 | + } | |
3238 | + result->query_buffer = xmalloc (result->query_length); | |
3239 | + memcpy (result->query_buffer, ctx->query_buffer, result->query_length); | |
3240 | + return result; | |
3241 | +} | |
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 | |
3245 | --- /dev/null | |
3246 | +++ b/support/resolv_response_context_free.c | |
3247 | @@ -0,0 +1,28 @@ | |
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. | |
3251 | + | |
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. | |
3256 | + | |
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. | |
3261 | + | |
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/>. */ | |
3265 | + | |
3266 | +#include <stdlib.h> | |
3267 | +#include <support/resolv_test.h> | |
3268 | + | |
3269 | +void | |
3270 | +resolv_response_context_free (struct resolv_response_context *ctx) | |
3271 | +{ | |
3272 | + free (ctx->query_buffer); | |
3273 | + free (ctx->client_address); | |
3274 | + free (ctx); | |
3275 | +} | |
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. */ | |
3282 | if (flags.tc) | |
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; | |
3288 | if (flags.ad) | |
3289 | b->buffer[3] |= 0x20; | |
3290 | ||
3291 | @@ -434,9 +436,9 @@ resolv_response_buffer (const struct resolv_response_builder *b) | |
3292 | return result; | |
3293 | } | |
3294 | ||
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) | |
3301 | { | |
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 | |
3305 | return b; | |
3306 | } | |
3307 | ||
3308 | -static void | |
3309 | -response_builder_free (struct resolv_response_builder *b) | |
3310 | +void | |
3311 | +resolv_response_builder_free (struct resolv_response_builder *b) | |
3312 | { | |
3313 | tdestroy (b->compression_offsets, free); | |
3314 | free (b); | |
3315 | @@ -661,13 +663,17 @@ server_thread_udp_process_one (struct resolv_test *obj, int server_index) | |
3316 | ||
3317 | struct resolv_response_context ctx = | |
3318 | { | |
3319 | + .test = obj, | |
3320 | + .client_address = &peer, | |
3321 | + .client_address_length = peerlen, | |
3322 | .query_buffer = query, | |
3323 | .query_length = length, | |
3324 | .server_index = server_index, | |
3325 | .tcp = false, | |
3326 | .edns = qinfo.edns, | |
3327 | }; | |
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); | |
3333 | ||
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); | |
3341 | else | |
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); | |
3346 | } | |
3347 | - size_t to_send = b->offset; | |
3348 | - if (to_send < b->truncate_bytes) | |
3349 | - to_send = 0; | |
3350 | - else | |
3351 | - to_send -= b->truncate_bytes; | |
3352 | - | |
3353 | - /* Ignore most errors here because the other end may have closed | |
3354 | - the socket. */ | |
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); | |
3360 | } | |
3361 | - response_builder_free (b); | |
3362 | + resolv_response_builder_free (b); | |
3363 | return true; | |
3364 | } | |
3365 | ||
3366 | +void | |
3367 | +resolv_response_send_udp (const struct resolv_response_context *ctx, | |
3368 | + struct resolv_response_builder *b) | |
3369 | +{ | |
3370 | + TEST_VERIFY_EXIT (!ctx->tcp); | |
3371 | + size_t to_send = b->offset; | |
3372 | + if (to_send < b->truncate_bytes) | |
3373 | + to_send = 0; | |
3374 | + else | |
3375 | + to_send -= b->truncate_bytes; | |
3376 | + | |
3377 | + /* Ignore most errors here because the other end may have closed | |
3378 | + the socket. */ | |
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); | |
3383 | +} | |
3384 | + | |
3385 | /* UDP thread_callback function. Variant for one thread per | |
3386 | server. */ | |
3387 | static void | |
3388 | @@ -897,14 +911,15 @@ server_thread_tcp_client (void *arg) | |
3389 | ||
3390 | struct resolv_response_context ctx = | |
3391 | { | |
3392 | + .test = closure->obj, | |
3393 | .query_buffer = query_buffer, | |
3394 | .query_length = query_length, | |
3395 | .server_index = closure->server_index, | |
3396 | .tcp = true, | |
3397 | .edns = qinfo.edns, | |
3398 | }; | |
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); | |
3405 | ||
3406 | @@ -936,7 +951,7 @@ server_thread_tcp_client (void *arg) | |
3407 | writev_fully (closure->client_socket, buffers, 2); | |
3408 | } | |
3409 | bool close_flag = b->close; | |
3410 | - response_builder_free (b); | |
3411 | + resolv_response_builder_free (b); | |
3412 | free (query_buffer); | |
3413 | if (close_flag) | |
3414 | break; | |
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; | |
3421 | }; | |
3422 | ||
3423 | +/* This opaque struct collects information about the resolver testing | |
3424 | + currently in progress. */ | |
3425 | +struct resolv_test; | |
3426 | + | |
3427 | /* This struct provides context information when the response callback | |
3428 | specified in struct resolv_redirect_config is invoked. */ | |
3429 | struct resolv_response_context | |
3430 | { | |
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; | |
3437 | int server_index; | |
3438 | bool tcp; | |
3439 | struct resolv_edns_info edns; | |
3440 | }; | |
3441 | ||
3442 | +/* Produces a deep copy of the context. */ | |
3443 | +struct resolv_response_context * | |
3444 | + resolv_response_context_duplicate (const struct resolv_response_context *); | |
3445 | + | |
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 *); | |
3449 | + | |
3450 | /* This opaque struct is used to construct responses from within the | |
3451 | response callback function. */ | |
3452 | struct resolv_response_builder; | |
3453 | ||
3454 | -/* This opaque struct collects information about the resolver testing | |
3455 | - currently in progress. */ | |
3456 | -struct resolv_test; | |
3457 | - | |
3458 | enum | |
3459 | { | |
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. */ | |
3463 | bool ad; | |
3464 | ||
3465 | + /* If true, do not set the RA (recursion available) flag in the | |
3466 | + response. */ | |
3467 | + bool clear_ra; | |
3468 | + | |
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 *); | |
3475 | ||
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); | |
3481 | + | |
3482 | +/* Deallocates a response buffer. */ | |
3483 | +void resolv_response_builder_free (struct resolv_response_builder *); | |
3484 | + | |
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 *); | |
3491 | + | |
3492 | __END_DECLS | |
3493 | ||
3494 | #endif /* SUPPORT_RESOLV_TEST_H */ | |
ad3e853a VM |
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[]); | |
3502 | ||
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[]); | |
3507 | + | |
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 | |
3515 | @@ -20,11 +20,14 @@ | |
3516 | #include <support/capture_subprocess.h> | |
3517 | ||
3518 | #include <errno.h> | |
3519 | +#include <fcntl.h> | |
3520 | #include <stdlib.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> | |
3527 | ||
3528 | static void | |
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) | |
3531 | if (ret < 0) | |
3532 | { | |
3533 | support_record_failure (); | |
3534 | - printf ("error: reading from subprocess %s: %m", what); | |
3535 | + printf ("error: reading from subprocess %s: %m\n", what); | |
3536 | pfd->events = 0; | |
3537 | pfd->revents = 0; | |
3538 | } | |
3539 | @@ -102,6 +105,129 @@ support_capture_subprogram (const char *file, char *const argv[]) | |
3540 | return result; | |
3541 | } | |
3542 | ||
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 | |
3545 | + executable. */ | |
3546 | +static int | |
3547 | +copy_and_spawn_sgid (char *child_id, gid_t gid) | |
3548 | +{ | |
3549 | + char *dirname = xasprintf ("%s/tst-tunables-setuid.%jd", | |
3550 | + test_dir, (intmax_t) getpid ()); | |
3551 | + char *execname = xasprintf ("%s/bin", dirname); | |
3552 | + int infd = -1; | |
3553 | + int outfd = -1; | |
3554 | + int ret = 1, status = 1; | |
3555 | + | |
3556 | + TEST_VERIFY (mkdir (dirname, 0700) == 0); | |
3557 | + if (support_record_failure_is_failed ()) | |
3558 | + goto err; | |
3559 | + | |
3560 | + infd = open ("/proc/self/exe", O_RDONLY); | |
3561 | + if (infd < 0) | |
3562 | + FAIL_UNSUPPORTED ("unsupported: Cannot read binary from procfs\n"); | |
3563 | + | |
3564 | + outfd = open (execname, O_WRONLY | O_CREAT | O_EXCL, 0700); | |
3565 | + TEST_VERIFY (outfd >= 0); | |
3566 | + if (support_record_failure_is_failed ()) | |
3567 | + goto err; | |
3568 | + | |
3569 | + char buf[4096]; | |
3570 | + for (;;) | |
3571 | + { | |
3572 | + ssize_t rdcount = read (infd, buf, sizeof (buf)); | |
3573 | + TEST_VERIFY (rdcount >= 0); | |
3574 | + if (support_record_failure_is_failed ()) | |
3575 | + goto err; | |
3576 | + if (rdcount == 0) | |
3577 | + break; | |
3578 | + char *p = buf; | |
3579 | + char *end = buf + rdcount; | |
3580 | + while (p != end) | |
3581 | + { | |
3582 | + ssize_t wrcount = write (outfd, buf, end - p); | |
3583 | + if (wrcount == 0) | |
3584 | + errno = ENOSPC; | |
3585 | + TEST_VERIFY (wrcount > 0); | |
3586 | + if (support_record_failure_is_failed ()) | |
3587 | + goto err; | |
3588 | + p += wrcount; | |
3589 | + } | |
3590 | + } | |
3591 | + TEST_VERIFY (fchown (outfd, getuid (), gid) == 0); | |
3592 | + if (support_record_failure_is_failed ()) | |
3593 | + goto err; | |
3594 | + TEST_VERIFY (fchmod (outfd, 02750) == 0); | |
3595 | + if (support_record_failure_is_failed ()) | |
3596 | + goto err; | |
3597 | + TEST_VERIFY (close (outfd) == 0); | |
3598 | + if (support_record_failure_is_failed ()) | |
3599 | + goto err; | |
3600 | + TEST_VERIFY (close (infd) == 0); | |
3601 | + if (support_record_failure_is_failed ()) | |
3602 | + goto err; | |
3603 | + | |
3604 | + /* We have the binary, now spawn the subprocess. Avoid using | |
3605 | + support_subprogram because we only want the program exit status, not the | |
3606 | + contents. */ | |
3607 | + ret = 0; | |
3608 | + | |
3609 | + char * const args[] = {execname, child_id, NULL}; | |
3610 | + | |
3611 | + status = support_subprogram_wait (args[0], args); | |
3612 | + | |
3613 | +err: | |
3614 | + if (outfd >= 0) | |
3615 | + close (outfd); | |
3616 | + if (infd >= 0) | |
3617 | + close (infd); | |
3618 | + if (execname != NULL) | |
3619 | + { | |
3620 | + unlink (execname); | |
3621 | + free (execname); | |
3622 | + } | |
3623 | + if (dirname != NULL) | |
3624 | + { | |
3625 | + rmdir (dirname); | |
3626 | + free (dirname); | |
3627 | + } | |
3628 | + | |
3629 | + if (ret != 0) | |
3630 | + FAIL_EXIT1("Failed to make sgid executable for test\n"); | |
3631 | + | |
3632 | + return status; | |
3633 | +} | |
3634 | + | |
3635 | +int | |
3636 | +support_capture_subprogram_self_sgid (char *child_id) | |
3637 | +{ | |
3638 | + gid_t target = 0; | |
3639 | + const int count = 64; | |
3640 | + gid_t groups[count]; | |
3641 | + | |
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); | |
3645 | + if (ret < 0) | |
3646 | + FAIL_UNSUPPORTED("Could not get group list for user %jd\n", | |
3647 | + (intmax_t) getuid ()); | |
3648 | + | |
3649 | + gid_t current = getgid (); | |
3650 | + for (int i = 0; i < ret; ++i) | |
3651 | + { | |
3652 | + if (groups[i] != current) | |
3653 | + { | |
3654 | + target = groups[i]; | |
3655 | + break; | |
3656 | + } | |
3657 | + } | |
3658 | + | |
3659 | + if (target == 0) | |
3660 | + FAIL_UNSUPPORTED("Could not find a suitable GID for user %jd\n", | |
3661 | + (intmax_t) getuid ()); | |
3662 | + | |
3663 | + return copy_and_spawn_sgid (child_id, target); | |
3664 | +} | |
3665 | + | |
3666 | void | |
3667 | support_capture_subprocess_free (struct support_capture_subprocess *p) | |
3668 | { | |
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 | |
3673 | @@ -27,7 +27,7 @@ | |
3674 | #include <support/subprocess.h> | |
3675 | ||
3676 | static struct support_subprocess | |
3677 | -support_suprocess_init (void) | |
3678 | +support_subprocess_init (void) | |
3679 | { | |
3680 | struct support_subprocess result; | |
3681 | ||
3682 | @@ -48,7 +48,7 @@ support_suprocess_init (void) | |
3683 | struct support_subprocess | |
3684 | support_subprocess (void (*callback) (void *), void *closure) | |
3685 | { | |
3686 | - struct support_subprocess result = support_suprocess_init (); | |
3687 | + struct support_subprocess result = support_subprocess_init (); | |
3688 | ||
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[]) | |
3694 | { | |
3695 | - struct support_subprocess result = support_suprocess_init (); | |
3696 | + struct support_subprocess result = support_subprocess_init (); | |
3697 | ||
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]); | |
3703 | ||
3704 | - result.pid = xposix_spawn (file, &fa, NULL, argv, NULL); | |
3705 | + result.pid = xposix_spawn (file, &fa, NULL, argv, environ); | |
3706 | ||
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[]) | |
3710 | return result; | |
3711 | } | |
3712 | ||
3713 | +int | |
3714 | +support_subprogram_wait (const char *file, char *const argv[]) | |
3715 | +{ | |
3716 | + posix_spawn_file_actions_t fa; | |
3717 | + | |
3718 | + posix_spawn_file_actions_init (&fa); | |
3719 | + struct support_subprocess res = support_subprocess_init (); | |
3720 | + | |
3721 | + res.pid = xposix_spawn (file, &fa, NULL, argv, environ); | |
3722 | + | |
3723 | + return support_process_wait (&res); | |
3724 | +} | |
3725 | + | |
3726 | int | |
3727 | support_process_wait (struct support_subprocess *proc) | |
3728 | { | |
2d5de23a VM |
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 | |
3733 | @@ -19,43 +19,76 @@ | |
3734 | #include <errno.h> | |
3735 | #include <libintl.h> | |
3736 | #include <ldsodefs.h> | |
3737 | +#include <sys/mman.h> | |
3738 | ||
3739 | -static int | |
3740 | -enable_bti (struct link_map *map, const char *program) | |
3741 | +/* See elf/dl-load.h. */ | |
3742 | +#ifndef MAP_COPY | |
3743 | +# define MAP_COPY (MAP_PRIVATE | MAP_DENYWRITE) | |
3744 | +#endif | |
3745 | + | |
3746 | +/* Enable BTI protection for MAP. */ | |
3747 | + | |
3748 | +void | |
3749 | +_dl_bti_protect (struct link_map *map, int fd) | |
3750 | { | |
3751 | + const size_t pagesz = GLRO(dl_pagesize); | |
3752 | const ElfW(Phdr) *phdr; | |
3753 | - unsigned prot; | |
3754 | ||
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)) | |
3757 | { | |
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; | |
3765 | ||
3766 | - prot = PROT_EXEC | PROT_BTI; | |
3767 | + unsigned prot = PROT_EXEC | PROT_BTI; | |
3768 | if (phdr->p_flags & PF_R) | |
3769 | prot |= PROT_READ; | |
3770 | if (phdr->p_flags & PF_W) | |
3771 | prot |= PROT_WRITE; | |
3772 | ||
3773 | - if (__mprotect (start, len, prot) < 0) | |
3774 | - { | |
3775 | - if (program) | |
3776 | - _dl_fatal_printf ("%s: mprotect failed to turn on BTI\n", | |
3777 | - map->l_name); | |
3778 | - else | |
3779 | - _dl_signal_error (errno, map->l_name, "dlopen", | |
3780 | - N_("mprotect failed to turn on BTI")); | |
3781 | - } | |
3782 | + if (fd == -1) | |
3783 | + /* Ignore failures for kernel mapped binaries. */ | |
3784 | + __mprotect (start, len, prot); | |
3785 | + else | |
3786 | + map->l_mach.bti_fail = __mmap (start, len, prot, | |
3787 | + MAP_FIXED|MAP_COPY|MAP_FILE, | |
3788 | + fd, off) == MAP_FAILED; | |
3789 | } | |
3790 | - return 0; | |
3791 | } | |
3792 | ||
3793 | -/* Enable BTI for L if required. */ | |
3794 | + | |
3795 | +static void | |
3796 | +bti_failed (struct link_map *l, const char *program) | |
3797 | +{ | |
3798 | + if (program) | |
3799 | + _dl_fatal_printf ("%s: %s: failed to turn on BTI protection\n", | |
3800 | + program, l->l_name); | |
3801 | + else | |
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")); | |
3805 | +} | |
3806 | + | |
3807 | + | |
3808 | +/* Enable BTI for L and its dependencies. */ | |
3809 | ||
3810 | void | |
3811 | _dl_bti_check (struct link_map *l, const char *program) | |
3812 | { | |
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) | |
3816 | + return; | |
3817 | + | |
3818 | + if (l->l_mach.bti_fail) | |
3819 | + bti_failed (l, program); | |
3820 | + | |
3821 | + unsigned int i = l->l_searchlist.r_nlist; | |
3822 | + while (i-- > 0) | |
3823 | + { | |
3824 | + struct link_map *dep = l->l_initfini[i]; | |
3825 | + if (dep->l_mach.bti_fail) | |
3826 | + bti_failed (dep, program); | |
3827 | + } | |
3828 | } | |
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)) | |
3836 | { | |
3837 | - if (map->l_mach.plt == 0) | |
3838 | - { | |
3839 | - /* Prelinking. */ | |
3840 | - *reloc_addr += l_addr; | |
3841 | - return; | |
3842 | - } | |
3843 | - | |
3844 | if (__glibc_unlikely (map->l_info[DT_AARCH64 (VARIANT_PCS)] != NULL)) | |
3845 | { | |
3846 | /* Check the symbol table for variant PCS symbols. */ | |
3847 | @@ -425,7 +418,10 @@ elf_machine_lazy_rel (struct link_map *map, | |
3848 | } | |
3849 | } | |
3850 | ||
3851 | - *reloc_addr = map->l_mach.plt; | |
3852 | + if (map->l_mach.plt == 0) | |
3853 | + *reloc_addr += l_addr; | |
3854 | + else | |
3855 | + *reloc_addr = map->l_mach.plt; | |
3856 | } | |
3857 | else if (__builtin_expect (r_type == AARCH64_R(TLSDESC), 1)) | |
3858 | { | |
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 | |
3863 | @@ -19,6 +19,8 @@ | |
3864 | #ifndef _DL_PROP_H | |
3865 | #define _DL_PROP_H | |
3866 | ||
3867 | +extern void _dl_bti_protect (struct link_map *, int) attribute_hidden; | |
3868 | + | |
3869 | extern void _dl_bti_check (struct link_map *, const char *) | |
3870 | attribute_hidden; | |
3871 | ||
3872 | @@ -35,14 +37,18 @@ _dl_open_check (struct link_map *m) | |
3873 | } | |
3874 | ||
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) | |
3878 | { | |
5685e009 | 3879 | } |
2d5de23a VM |
3880 | |
3881 | static inline int | |
3882 | -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, | |
3883 | - void *data) | |
3884 | +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, | |
3885 | + uint32_t datasz, void *data) | |
3886 | { | |
3887 | + if (!GLRO(dl_aarch64_cpu_features).bti) | |
3888 | + /* Skip note processing. */ | |
3889 | + return 0; | |
3890 | + | |
3891 | if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) | |
3892 | { | |
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, | |
3895 | ||
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); | |
3900 | ||
3901 | /* Stop if we processed the property note. */ | |
3902 | return 0; | |
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 | |
3908 | { | |
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. */ | |
3913 | }; | |
5685e009 VM |
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, | |
3919 | ? __memcpy_falkor | |
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) | |
3925 | ? __memcpy_simd | |
3926 | : __memcpy_generic))))); | |
3927 | ||
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) | |
3934 | ||
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) | |
3948 | ||
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, | |
3954 | ? __memmove_falkor | |
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) | |
3960 | ? __memmove_simd | |
3961 | : __memmove_generic))))); | |
3962 | ||
2d5de23a VM |
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 | |
3967 | @@ -43,11 +43,9 @@ | |
3968 | */ | |
3969 | ||
3970 | .text | |
3971 | - .globl _start | |
3972 | - .type _start,#function | |
3973 | -_start: | |
3974 | - BTI_C | |
3975 | +ENTRY(_start) | |
3976 | /* Create an initial frame with 0 LR and FP */ | |
3977 | + cfi_undefined (x30) | |
3978 | mov x29, #0 | |
3979 | mov x30, #0 | |
3980 | ||
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. */ | |
3984 | __wrap_main: | |
3985 | + BTI_C | |
3986 | b main | |
3987 | #endif | |
3988 | +END(_start) | |
3989 | ||
3990 | /* Define a symbol for the first piece of initialized data. */ | |
3991 | .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) | |
3997 | } | |
3998 | ||
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) | |
4002 | { | |
4003 | } | |
4004 | ||
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, | |
4009 | - void *data) | |
4010 | +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, | |
4011 | + uint32_t datasz, void *data) | |
4012 | { | |
4013 | return 0; | |
4014 | } | |
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); | |
4021 | ||
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); | |
4028 | ||
4029 | ||
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, | |
4036 | ||
4037 | struct _Unwind_Exception | |
4038 | { | |
4039 | - _Unwind_Exception_Class exception_class; | |
4040 | - _Unwind_Exception_Cleanup_Fn exception_cleanup; | |
4041 | - _Unwind_Word private_1; | |
4042 | - _Unwind_Word private_2; | |
4043 | - | |
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__)); | |
4048 | + union | |
4049 | + { | |
4050 | + struct | |
4051 | + { | |
4052 | + _Unwind_Exception_Class exception_class; | |
4053 | + _Unwind_Exception_Cleanup_Fn exception_cleanup; | |
4054 | + _Unwind_Word private_1; | |
4055 | + _Unwind_Word private_2; | |
4056 | + }; | |
4057 | + | |
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)))); | |
4061 | + }; | |
4062 | +}; | |
4063 | ||
4064 | ||
4065 | /* The ACTIONS argument to the personality routine is a bitwise OR of one | |
5685e009 VM |
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 | |
4070 | @@ -1,24 +1,21 @@ | |
4071 | -#ifndef ERR_MAP | |
4072 | -#define ERR_MAP(value) value | |
4073 | -#endif | |
4074 | -_S(ERR_MAP(0), N_("Success")) | |
4075 | +_S(0, N_("Success")) | |
4076 | #ifdef EPERM | |
4077 | /* | |
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")) | |
4082 | #endif | |
4083 | #ifdef ENOENT | |
4084 | /* | |
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")) | |
4090 | #endif | |
4091 | #ifdef ESRCH | |
4092 | /* | |
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")) | |
4096 | #endif | |
4097 | #ifdef EINTR | |
4098 | /* | |
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")) | |
4105 | #endif | |
4106 | #ifdef EIO | |
4107 | /* | |
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")) | |
4111 | #endif | |
4112 | #ifdef ENXIO | |
4113 | /* | |
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 | |
4117 | TRANS computer. */ | |
4118 | -_S(ERR_MAP(ENXIO), N_("No such device or address")) | |
4119 | +_S(ENXIO, N_("No such device or address")) | |
4120 | #endif | |
4121 | #ifdef E2BIG | |
4122 | /* | |
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")) | |
4129 | #endif | |
4130 | #ifdef ENOEXEC | |
4131 | /* | |
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")) | |
4136 | #endif | |
4137 | #ifdef EBADF | |
4138 | /* | |
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 | |
4141 | TRANS versa). */ | |
4142 | -_S(ERR_MAP(EBADF), N_("Bad file descriptor")) | |
4143 | +_S(EBADF, N_("Bad file descriptor")) | |
4144 | #endif | |
4145 | #ifdef ECHILD | |
4146 | /* | |
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")) | |
4152 | #endif | |
4153 | #ifdef EDEADLK | |
4154 | /* | |
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")) | |
4161 | #endif | |
4162 | #ifdef ENOMEM | |
4163 | /* | |
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")) | |
4168 | #endif | |
4169 | #ifdef EACCES | |
4170 | /* | |
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")) | |
4174 | #endif | |
4175 | #ifdef EFAULT | |
4176 | /* | |
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")) | |
4181 | #endif | |
4182 | #ifdef ENOTBLK | |
4183 | /* | |
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")) | |
4189 | #endif | |
4190 | #ifdef EBUSY | |
4191 | /* | |
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")) | |
4197 | #endif | |
4198 | #ifdef EEXIST | |
4199 | /* | |
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")) | |
4204 | #endif | |
4205 | #ifdef EXDEV | |
4206 | /* | |
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")) | |
4212 | #endif | |
4213 | #ifdef ENODEV | |
4214 | /* | |
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")) | |
4219 | #endif | |
4220 | #ifdef ENOTDIR | |
4221 | /* | |
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")) | |
4225 | #endif | |
4226 | #ifdef EISDIR | |
4227 | /* | |
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")) | |
4232 | #endif | |
4233 | #ifdef EINVAL | |
4234 | /* | |
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")) | |
4239 | #endif | |
4240 | #ifdef EMFILE | |
4241 | /* | |
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")) | |
4248 | #endif | |
4249 | #ifdef ENFILE | |
4250 | /* | |
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")) | |
4256 | #endif | |
4257 | #ifdef ENOTTY | |
4258 | /* | |
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")) | |
4263 | #endif | |
4264 | #ifdef ETXTBSY | |
4265 | /* | |
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")) | |
4272 | #endif | |
4273 | #ifdef EFBIG | |
4274 | /* | |
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")) | |
4278 | #endif | |
4279 | #ifdef ENOSPC | |
4280 | /* | |
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")) | |
4285 | #endif | |
4286 | #ifdef ESPIPE | |
4287 | /* | |
4288 | TRANS Invalid seek operation (such as on a pipe). */ | |
4289 | -_S(ERR_MAP(ESPIPE), N_("Illegal seek")) | |
4290 | +_S(ESPIPE, N_("Illegal seek")) | |
4291 | #endif | |
4292 | #ifdef EROFS | |
4293 | /* | |
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")) | |
4297 | #endif | |
4298 | #ifdef EMLINK | |
4299 | /* | |
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")) | |
4305 | #endif | |
4306 | #ifdef EPIPE | |
4307 | /* | |
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")) | |
4314 | #endif | |
4315 | #ifdef EDOM | |
4316 | /* | |
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")) | |
4321 | #endif | |
4322 | #ifdef ERANGE | |
4323 | /* | |
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")) | |
4328 | #endif | |
4329 | #ifdef EAGAIN | |
4330 | /* | |
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")) | |
4337 | #endif | |
4338 | #ifdef EINPROGRESS | |
4339 | /* | |
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")) | |
4346 | #endif | |
4347 | #ifdef EALREADY | |
4348 | /* | |
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")) | |
4353 | #endif | |
4354 | #ifdef ENOTSOCK | |
4355 | /* | |
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")) | |
4359 | #endif | |
4360 | #ifdef EMSGSIZE | |
4361 | /* | |
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")) | |
4366 | #endif | |
4367 | #ifdef EPROTOTYPE | |
4368 | /* | |
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")) | |
4372 | #endif | |
4373 | #ifdef ENOPROTOOPT | |
4374 | /* | |
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")) | |
4379 | #endif | |
4380 | #ifdef EPROTONOSUPPORT | |
4381 | /* | |
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")) | |
4387 | #endif | |
4388 | #ifdef ESOCKTNOSUPPORT | |
4389 | /* | |
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")) | |
4393 | #endif | |
4394 | #ifdef EOPNOTSUPP | |
4395 | /* | |
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")) | |
4402 | #endif | |
4403 | #ifdef EPFNOSUPPORT | |
4404 | /* | |
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")) | |
4408 | #endif | |
4409 | #ifdef EAFNOSUPPORT | |
4410 | /* | |
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")) | |
4415 | #endif | |
4416 | #ifdef EADDRINUSE | |
4417 | /* | |
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")) | |
4421 | #endif | |
4422 | #ifdef EADDRNOTAVAIL | |
4423 | /* | |
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")) | |
4429 | #endif | |
4430 | #ifdef ENETDOWN | |
4431 | /* | |
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")) | |
4435 | #endif | |
4436 | #ifdef ENETUNREACH | |
4437 | /* | |
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")) | |
4442 | #endif | |
4443 | #ifdef ENETRESET | |
4444 | /* | |
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")) | |
4448 | #endif | |
4449 | #ifdef ECONNABORTED | |
4450 | /* | |
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")) | |
4454 | #endif | |
4455 | #ifdef ECONNRESET | |
4456 | /* | |
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")) | |
4462 | #endif | |
4463 | #ifdef ENOBUFS | |
4464 | /* | |
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")) | |
4470 | #endif | |
4471 | #ifdef EISCONN | |
4472 | /* | |
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")) | |
4477 | #endif | |
4478 | #ifdef ENOTCONN | |
4479 | /* | |
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")) | |
4486 | #endif | |
4487 | #ifdef EDESTADDRREQ | |
4488 | /* | |
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")) | |
4494 | #endif | |
4495 | #ifdef ESHUTDOWN | |
4496 | /* | |
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")) | |
4500 | #endif | |
4501 | #ifdef ETOOMANYREFS | |
4502 | -_S(ERR_MAP(ETOOMANYREFS), N_("Too many references: cannot splice")) | |
4503 | +_S(ETOOMANYREFS, N_("Too many references: cannot splice")) | |
4504 | #endif | |
4505 | #ifdef ETIMEDOUT | |
4506 | /* | |
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")) | |
4511 | #endif | |
4512 | #ifdef ECONNREFUSED | |
4513 | /* | |
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")) | |
4518 | #endif | |
4519 | #ifdef ELOOP | |
4520 | /* | |
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")) | |
4525 | #endif | |
4526 | #ifdef ENAMETOOLONG | |
4527 | /* | |
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")) | |
4533 | #endif | |
4534 | #ifdef EHOSTDOWN | |
4535 | /* | |
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")) | |
4539 | #endif | |
4540 | /* | |
4541 | TRANS The remote host for a requested network connection is not reachable. */ | |
4542 | #ifdef EHOSTUNREACH | |
4543 | -_S(ERR_MAP(EHOSTUNREACH), N_("No route to host")) | |
4544 | +_S(EHOSTUNREACH, N_("No route to host")) | |
4545 | #endif | |
4546 | #ifdef ENOTEMPTY | |
4547 | /* | |
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")) | |
4552 | #endif | |
4553 | #ifdef EUSERS | |
4554 | /* | |
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")) | |
4559 | #endif | |
4560 | #ifdef EDQUOT | |
4561 | /* | |
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")) | |
4565 | #endif | |
4566 | #ifdef ESTALE | |
4567 | /* | |
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")) | |
4574 | #endif | |
4575 | #ifdef EREMOTE | |
4576 | /* | |
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")) | |
4583 | #endif | |
4584 | #ifdef ENOLCK | |
4585 | /* | |
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")) | |
4592 | #endif | |
4593 | #ifdef ENOSYS | |
4594 | /* | |
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")) | |
4601 | #endif | |
4602 | #ifdef EILSEQ | |
4603 | /* | |
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")) | |
4608 | #endif | |
4609 | #ifdef EBADMSG | |
4610 | -_S(ERR_MAP(EBADMSG), N_("Bad message")) | |
4611 | +_S(EBADMSG, N_("Bad message")) | |
4612 | #endif | |
4613 | #ifdef EIDRM | |
4614 | -_S(ERR_MAP(EIDRM), N_("Identifier removed")) | |
4615 | +_S(EIDRM, N_("Identifier removed")) | |
4616 | #endif | |
4617 | #ifdef EMULTIHOP | |
4618 | -_S(ERR_MAP(EMULTIHOP), N_("Multihop attempted")) | |
4619 | +_S(EMULTIHOP, N_("Multihop attempted")) | |
4620 | #endif | |
4621 | #ifdef ENODATA | |
4622 | -_S(ERR_MAP(ENODATA), N_("No data available")) | |
4623 | +_S(ENODATA, N_("No data available")) | |
4624 | #endif | |
4625 | #ifdef ENOLINK | |
4626 | -_S(ERR_MAP(ENOLINK), N_("Link has been severed")) | |
4627 | +_S(ENOLINK, N_("Link has been severed")) | |
4628 | #endif | |
4629 | #ifdef ENOMSG | |
4630 | -_S(ERR_MAP(ENOMSG), N_("No message of desired type")) | |
4631 | +_S(ENOMSG, N_("No message of desired type")) | |
4632 | #endif | |
4633 | #ifdef ENOSR | |
4634 | -_S(ERR_MAP(ENOSR), N_("Out of streams resources")) | |
4635 | +_S(ENOSR, N_("Out of streams resources")) | |
4636 | #endif | |
4637 | #ifdef ENOSTR | |
4638 | -_S(ERR_MAP(ENOSTR), N_("Device not a stream")) | |
4639 | +_S(ENOSTR, N_("Device not a stream")) | |
4640 | #endif | |
4641 | #ifdef EOVERFLOW | |
4642 | -_S(ERR_MAP(EOVERFLOW), N_("Value too large for defined data type")) | |
4643 | +_S(EOVERFLOW, N_("Value too large for defined data type")) | |
4644 | #endif | |
4645 | #ifdef EPROTO | |
4646 | -_S(ERR_MAP(EPROTO), N_("Protocol error")) | |
4647 | +_S(EPROTO, N_("Protocol error")) | |
4648 | #endif | |
4649 | #ifdef ETIME | |
4650 | -_S(ERR_MAP(ETIME), N_("Timer expired")) | |
4651 | +_S(ETIME, N_("Timer expired")) | |
4652 | #endif | |
4653 | #ifdef ECANCELED | |
4654 | /* | |
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")) | |
4661 | #endif | |
4662 | #ifdef EOWNERDEAD | |
4663 | -_S(ERR_MAP(EOWNERDEAD), N_("Owner died")) | |
4664 | +_S(EOWNERDEAD, N_("Owner died")) | |
4665 | #endif | |
4666 | #ifdef ENOTRECOVERABLE | |
4667 | -_S(ERR_MAP(ENOTRECOVERABLE), N_("State not recoverable")) | |
4668 | +_S(ENOTRECOVERABLE, N_("State not recoverable")) | |
4669 | #endif | |
4670 | #ifdef ERESTART | |
4671 | -_S(ERR_MAP(ERESTART), N_("Interrupted system call should be restarted")) | |
4672 | +_S(ERESTART, N_("Interrupted system call should be restarted")) | |
4673 | #endif | |
4674 | #ifdef ECHRNG | |
4675 | -_S(ERR_MAP(ECHRNG), N_("Channel number out of range")) | |
4676 | +_S(ECHRNG, N_("Channel number out of range")) | |
4677 | #endif | |
4678 | #ifdef EL2NSYNC | |
4679 | -_S(ERR_MAP(EL2NSYNC), N_("Level 2 not synchronized")) | |
4680 | +_S(EL2NSYNC, N_("Level 2 not synchronized")) | |
4681 | #endif | |
4682 | #ifdef EL3HLT | |
4683 | -_S(ERR_MAP(EL3HLT), N_("Level 3 halted")) | |
4684 | +_S(EL3HLT, N_("Level 3 halted")) | |
4685 | #endif | |
4686 | #ifdef EL3RST | |
4687 | -_S(ERR_MAP(EL3RST), N_("Level 3 reset")) | |
4688 | +_S(EL3RST, N_("Level 3 reset")) | |
4689 | #endif | |
4690 | #ifdef ELNRNG | |
4691 | -_S(ERR_MAP(ELNRNG), N_("Link number out of range")) | |
4692 | +_S(ELNRNG, N_("Link number out of range")) | |
4693 | #endif | |
4694 | #ifdef EUNATCH | |
4695 | -_S(ERR_MAP(EUNATCH), N_("Protocol driver not attached")) | |
4696 | +_S(EUNATCH, N_("Protocol driver not attached")) | |
4697 | #endif | |
4698 | #ifdef ENOCSI | |
4699 | -_S(ERR_MAP(ENOCSI), N_("No CSI structure available")) | |
4700 | +_S(ENOCSI, N_("No CSI structure available")) | |
4701 | #endif | |
4702 | #ifdef EL2HLT | |
4703 | -_S(ERR_MAP(EL2HLT), N_("Level 2 halted")) | |
4704 | +_S(EL2HLT, N_("Level 2 halted")) | |
4705 | #endif | |
4706 | #ifdef EBADE | |
4707 | -_S(ERR_MAP(EBADE), N_("Invalid exchange")) | |
4708 | +_S(EBADE, N_("Invalid exchange")) | |
4709 | #endif | |
4710 | #ifdef EBADR | |
4711 | -_S(ERR_MAP(EBADR), N_("Invalid request descriptor")) | |
4712 | +_S(EBADR, N_("Invalid request descriptor")) | |
4713 | #endif | |
4714 | #ifdef EXFULL | |
4715 | -_S(ERR_MAP(EXFULL), N_("Exchange full")) | |
4716 | +_S(EXFULL, N_("Exchange full")) | |
4717 | #endif | |
4718 | #ifdef ENOANO | |
4719 | -_S(ERR_MAP(ENOANO), N_("No anode")) | |
4720 | +_S(ENOANO, N_("No anode")) | |
4721 | #endif | |
4722 | #ifdef EBADRQC | |
4723 | -_S(ERR_MAP(EBADRQC), N_("Invalid request code")) | |
4724 | +_S(EBADRQC, N_("Invalid request code")) | |
4725 | #endif | |
4726 | #ifdef EBADSLT | |
4727 | -_S(ERR_MAP(EBADSLT), N_("Invalid slot")) | |
4728 | +_S(EBADSLT, N_("Invalid slot")) | |
4729 | #endif | |
4730 | #ifdef EBFONT | |
4731 | -_S(ERR_MAP(EBFONT), N_("Bad font file format")) | |
4732 | +_S(EBFONT, N_("Bad font file format")) | |
4733 | #endif | |
4734 | #ifdef ENONET | |
4735 | -_S(ERR_MAP(ENONET), N_("Machine is not on the network")) | |
4736 | +_S(ENONET, N_("Machine is not on the network")) | |
4737 | #endif | |
4738 | #ifdef ENOPKG | |
4739 | -_S(ERR_MAP(ENOPKG), N_("Package not installed")) | |
4740 | +_S(ENOPKG, N_("Package not installed")) | |
4741 | #endif | |
4742 | #ifdef EADV | |
4743 | -_S(ERR_MAP(EADV), N_("Advertise error")) | |
4744 | +_S(EADV, N_("Advertise error")) | |
4745 | #endif | |
4746 | #ifdef ESRMNT | |
4747 | -_S(ERR_MAP(ESRMNT), N_("Srmount error")) | |
4748 | +_S(ESRMNT, N_("Srmount error")) | |
4749 | #endif | |
4750 | #ifdef ECOMM | |
4751 | -_S(ERR_MAP(ECOMM), N_("Communication error on send")) | |
4752 | +_S(ECOMM, N_("Communication error on send")) | |
4753 | #endif | |
4754 | #ifdef EDOTDOT | |
4755 | -_S(ERR_MAP(EDOTDOT), N_("RFS specific error")) | |
4756 | +_S(EDOTDOT, N_("RFS specific error")) | |
4757 | #endif | |
4758 | #ifdef ENOTUNIQ | |
4759 | -_S(ERR_MAP(ENOTUNIQ), N_("Name not unique on network")) | |
4760 | +_S(ENOTUNIQ, N_("Name not unique on network")) | |
4761 | #endif | |
4762 | #ifdef EBADFD | |
4763 | -_S(ERR_MAP(EBADFD), N_("File descriptor in bad state")) | |
4764 | +_S(EBADFD, N_("File descriptor in bad state")) | |
4765 | #endif | |
4766 | #ifdef EREMCHG | |
4767 | -_S(ERR_MAP(EREMCHG), N_("Remote address changed")) | |
4768 | +_S(EREMCHG, N_("Remote address changed")) | |
4769 | #endif | |
4770 | #ifdef ELIBACC | |
4771 | -_S(ERR_MAP(ELIBACC), N_("Can not access a needed shared library")) | |
4772 | +_S(ELIBACC, N_("Can not access a needed shared library")) | |
4773 | #endif | |
4774 | #ifdef ELIBBAD | |
4775 | -_S(ERR_MAP(ELIBBAD), N_("Accessing a corrupted shared library")) | |
4776 | +_S(ELIBBAD, N_("Accessing a corrupted shared library")) | |
4777 | #endif | |
4778 | #ifdef ELIBSCN | |
4779 | -_S(ERR_MAP(ELIBSCN), N_(".lib section in a.out corrupted")) | |
4780 | +_S(ELIBSCN, N_(".lib section in a.out corrupted")) | |
4781 | #endif | |
4782 | #ifdef ELIBMAX | |
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")) | |
4785 | #endif | |
4786 | #ifdef ELIBEXEC | |
4787 | -_S(ERR_MAP(ELIBEXEC), N_("Cannot exec a shared library directly")) | |
4788 | +_S(ELIBEXEC, N_("Cannot exec a shared library directly")) | |
4789 | #endif | |
4790 | #ifdef ESTRPIPE | |
4791 | -_S(ERR_MAP(ESTRPIPE), N_("Streams pipe error")) | |
4792 | +_S(ESTRPIPE, N_("Streams pipe error")) | |
4793 | #endif | |
4794 | #ifdef EUCLEAN | |
4795 | -_S(ERR_MAP(EUCLEAN), N_("Structure needs cleaning")) | |
4796 | +_S(EUCLEAN, N_("Structure needs cleaning")) | |
4797 | #endif | |
4798 | #ifdef ENOTNAM | |
4799 | -_S(ERR_MAP(ENOTNAM), N_("Not a XENIX named type file")) | |
4800 | +_S(ENOTNAM, N_("Not a XENIX named type file")) | |
4801 | #endif | |
4802 | #ifdef ENAVAIL | |
4803 | -_S(ERR_MAP(ENAVAIL), N_("No XENIX semaphores available")) | |
4804 | +_S(ENAVAIL, N_("No XENIX semaphores available")) | |
4805 | #endif | |
4806 | #ifdef EISNAM | |
4807 | -_S(ERR_MAP(EISNAM), N_("Is a named type file")) | |
4808 | +_S(EISNAM, N_("Is a named type file")) | |
4809 | #endif | |
4810 | #ifdef EREMOTEIO | |
4811 | -_S(ERR_MAP(EREMOTEIO), N_("Remote I/O error")) | |
4812 | +_S(EREMOTEIO, N_("Remote I/O error")) | |
4813 | #endif | |
4814 | #ifdef ENOMEDIUM | |
4815 | -_S(ERR_MAP(ENOMEDIUM), N_("No medium found")) | |
4816 | +_S(ENOMEDIUM, N_("No medium found")) | |
4817 | #endif | |
4818 | #ifdef EMEDIUMTYPE | |
4819 | -_S(ERR_MAP(EMEDIUMTYPE), N_("Wrong medium type")) | |
4820 | +_S(EMEDIUMTYPE, N_("Wrong medium type")) | |
4821 | #endif | |
4822 | #ifdef ENOKEY | |
4823 | -_S(ERR_MAP(ENOKEY), N_("Required key not available")) | |
4824 | +_S(ENOKEY, N_("Required key not available")) | |
4825 | #endif | |
4826 | #ifdef EKEYEXPIRED | |
4827 | -_S(ERR_MAP(EKEYEXPIRED), N_("Key has expired")) | |
4828 | +_S(EKEYEXPIRED, N_("Key has expired")) | |
4829 | #endif | |
4830 | #ifdef EKEYREVOKED | |
4831 | -_S(ERR_MAP(EKEYREVOKED), N_("Key has been revoked")) | |
4832 | +_S(EKEYREVOKED, N_("Key has been revoked")) | |
4833 | #endif | |
4834 | #ifdef EKEYREJECTED | |
4835 | -_S(ERR_MAP(EKEYREJECTED), N_("Key was rejected by service")) | |
4836 | +_S(EKEYREJECTED, N_("Key was rejected by service")) | |
4837 | #endif | |
4838 | #ifdef ERFKILL | |
4839 | -_S(ERR_MAP(ERFKILL), N_("Operation not possible due to RF-kill")) | |
4840 | +_S(ERFKILL, N_("Operation not possible due to RF-kill")) | |
4841 | #endif | |
4842 | #ifdef EHWPOISON | |
4843 | -_S(ERR_MAP(EHWPOISON), N_("Memory page has hardware error")) | |
4844 | +_S(EHWPOISON, N_("Memory page has hardware error")) | |
4845 | #endif | |
4846 | #ifdef EBADRPC | |
4847 | -_S(ERR_MAP(EBADRPC), N_("RPC struct is bad")) | |
4848 | +_S(EBADRPC, N_("RPC struct is bad")) | |
4849 | #endif | |
4850 | #ifdef EFTYPE | |
4851 | /* | |
4852 | @@ -693,40 +690,40 @@ TRANS operation, or a data file had the wrong format. | |
4853 | TRANS | |
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")) | |
4858 | #endif | |
4859 | #ifdef EPROCUNAVAIL | |
4860 | -_S(ERR_MAP(EPROCUNAVAIL), N_("RPC bad procedure for program")) | |
4861 | +_S(EPROCUNAVAIL, N_("RPC bad procedure for program")) | |
4862 | #endif | |
4863 | #ifdef EAUTH | |
4864 | -_S(ERR_MAP(EAUTH), N_("Authentication error")) | |
4865 | +_S(EAUTH, N_("Authentication error")) | |
4866 | #endif | |
4867 | #ifdef EDIED | |
4868 | /* | |
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")) | |
4874 | #endif | |
4875 | #ifdef ERPCMISMATCH | |
4876 | -_S(ERR_MAP(ERPCMISMATCH), N_("RPC version wrong")) | |
4877 | +_S(ERPCMISMATCH, N_("RPC version wrong")) | |
4878 | #endif | |
4879 | #ifdef EGREGIOUS | |
4880 | /* | |
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")) | |
4884 | #endif | |
4885 | #ifdef EPROCLIM | |
4886 | /* | |
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")) | |
4892 | #endif | |
4893 | #ifdef EGRATUITOUS | |
4894 | /* | |
4895 | TRANS This error code has no purpose. */ | |
4896 | -_S(ERR_MAP(EGRATUITOUS), N_("Gratuitous error")) | |
4897 | +_S(EGRATUITOUS, N_("Gratuitous error")) | |
4898 | #endif | |
4899 | #if defined (ENOTSUP) && ENOTSUP != EOPNOTSUPP | |
4900 | /* | |
4901 | @@ -742,10 +739,10 @@ TRANS values. | |
4902 | TRANS | |
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")) | |
4907 | #endif | |
4908 | #ifdef EPROGMISMATCH | |
4909 | -_S(ERR_MAP(EPROGMISMATCH), N_("RPC program version wrong")) | |
4910 | +_S(EPROGMISMATCH, N_("RPC program version wrong")) | |
4911 | #endif | |
4912 | #ifdef EBACKGROUND | |
4913 | /* | |
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")) | |
4920 | #endif | |
4921 | #ifdef EIEIO | |
4922 | /* | |
4923 | @@ -773,7 +770,7 @@ TRANS @c "bought the farm" means "died". -jtobey | |
4924 | TRANS @c | |
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")) | |
4929 | #endif | |
4930 | #if defined (EWOULDBLOCK) && EWOULDBLOCK != EAGAIN | |
4931 | /* | |
4932 | @@ -782,18 +779,18 @@ TRANS The values are always the same, on every operating system. | |
4933 | TRANS | |
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")) | |
4938 | #endif | |
4939 | #ifdef ENEEDAUTH | |
4940 | -_S(ERR_MAP(ENEEDAUTH), N_("Need authenticator")) | |
4941 | +_S(ENEEDAUTH, N_("Need authenticator")) | |
4942 | #endif | |
4943 | #ifdef ED | |
4944 | /* | |
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_("?")) | |
4949 | +_S(ED, N_("?")) | |
4950 | #endif | |
4951 | #ifdef EPROGUNAVAIL | |
4952 | -_S(ERR_MAP(EPROGUNAVAIL), N_("RPC program not available")) | |
4953 | +_S(EPROGUNAVAIL, N_("RPC program not available")) | |
4954 | #endif | |
2d5de23a VM |
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, | |
4960 | { | |
4961 | # ifndef RTLD_BOOTSTRAP | |
4962 | if (sym_map != map | |
4963 | - && sym_map->l_type != lt_executable | |
4964 | && !sym_map->l_relocated) | |
4965 | { | |
4966 | const char *strtab | |
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, | |
4974 | + map->l_name); | |
4975 | + else | |
4976 | + _dl_error_printf ("\ | |
4977 | %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n", | |
4978 | - RTLD_PROGNAME, map->l_name, | |
4979 | - sym_map->l_name, | |
4980 | - strtab + refsym->st_name); | |
4981 | + RTLD_PROGNAME, map->l_name, | |
4982 | + sym_map->l_name, | |
4983 | + strtab + refsym->st_name); | |
4984 | } | |
4985 | # endif | |
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. */ | |
4993 | }; | |
4994 | ||
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 | |
5001 | + case. | |
5002 | + The vDSO branches with a 'bctrl' instruction, so checking either the | |
5003 | + vDSO address itself and the next instruction should cover all kernel | |
5004 | + versions. */ | |
5005 | static inline bool | |
5006 | is_sigtramp_address (void *nip) | |
5007 | { | |
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) | |
5012 | return true; | |
5013 | #endif | |
5014 | return false; | |
ad3e853a VM |
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" | |
5022 | "lghi %%r0,16 \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"); | |
5027 | } | |
5028 | EOF | |
5029 | if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c | |
5030 | @@ -271,7 +273,9 @@ else | |
5031 | void testinsn (char *buf) | |
5032 | { | |
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"); | |
5038 | } | |
5039 | EOF | |
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" | |
5048 | "lghi %%r0,16 \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"); | |
5053 | } | |
5054 | EOF | |
5055 | dnl test, if assembler supports S390 arch13 instructions | |
5056 | @@ -195,7 +197,9 @@ cat > conftest.c <<\EOF | |
5057 | void testinsn (char *buf) | |
5058 | { | |
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"); | |
5064 | } | |
5065 | EOF | |
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, | |
5073 | ({ | |
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)) | |
5078 | ? MEMMOVE_ARCH13 | |
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)), | |
5091 | MEMMOVE_ARCH13) | |
5092 | # endif | |
5093 | # if HAVE_MEMMOVE_Z13 | |
2d5de23a VM |
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 | |
5097 | --- /dev/null | |
5098 | +++ b/sysdeps/sh/be/sh4/fpu/Implies | |
5099 | @@ -0,0 +1 @@ | |
5100 | +sh/sh4/fpu | |
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 | |
5104 | --- /dev/null | |
5105 | +++ b/sysdeps/sh/le/sh4/fpu/Implies | |
5106 | @@ -0,0 +1 @@ | |
5107 | +sh/sh4/fpu | |
5685e009 VM |
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 \ | |
5116 | - tst-tgkill | |
5117 | + tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux | |
5118 | tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc | |
5119 | ||
5120 | CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables | |
5685e009 VM |
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 | |
5125 | @@ -54,6 +54,10 @@ | |
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) | |
5133 | ||
5134 | #define IS_EMAG(midr) (MIDR_IMPLEMENTOR(midr) == 'P' \ | |
5135 | && MIDR_PARTNUM(midr) == 0x000) | |
ad3e853a VM |
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); | |
5142 | } | |
5143 | else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED) | |
5144 | - /* The only state we keep is the copy of the thread attributes. */ | |
5145 | - free (data.attr); | |
5146 | + { | |
5147 | + /* The only state we keep is the copy of the thread attributes. */ | |
5148 | + pthread_attr_destroy (data.attr); | |
5149 | + free (data.attr); | |
5150 | + } | |
5151 | } | |
5152 | return NULL; | |
5153 | } | |
5154 | @@ -255,8 +258,14 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification) | |
5155 | if (data.attr == NULL) | |
5156 | return -1; | |
5157 | ||
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); | |
5162 | + if (ret != 0) | |
5163 | + { | |
5164 | + free (data.attr); | |
5165 | + __set_errno (ret); | |
5166 | + return -1; | |
5167 | + } | |
5168 | } | |
5169 | ||
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); | |
5173 | ||
5174 | /* If it failed, free the allocated memory. */ | |
5175 | - if (__glibc_unlikely (retval != 0)) | |
5176 | - free (data.attr); | |
5177 | + if (retval != 0 && data.attr != NULL) | |
5178 | + { | |
5179 | + pthread_attr_destroy (data.attr); | |
5180 | + free (data.attr); | |
5181 | + } | |
5182 | ||
5183 | return retval; | |
5184 | } | |
5685e009 VM |
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; | |
5191 | if (buf != NULL) | |
5192 | { | |
5193 | - msqid64_to_kmsqid64 (buf, &ksemid); | |
5194 | - arg = &ksemid; | |
5195 | + /* This is a Linux extension where kernel returns a 'struct msginfo' | |
5196 | + instead. */ | |
5197 | + if (cmd == IPC_INFO || cmd == MSG_INFO) | |
5198 | + arg = (struct kernel_msqid64_ds *) buf; | |
5199 | + else | |
5200 | + { | |
5201 | + msqid64_to_kmsqid64 (buf, &ksemid); | |
5202 | + arg = &ksemid; | |
5203 | + } | |
5204 | } | |
5205 | # ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T | |
5206 | if (cmd == IPC_SET) | |
5207 | @@ -169,8 +176,15 @@ __msgctl (int msqid, int cmd, struct msqid_ds *buf) | |
5208 | struct __msqid64_ds msqid64, *buf64 = NULL; | |
5209 | if (buf != NULL) | |
5210 | { | |
5211 | - msqid_to_msqid64 (&msqid64, buf); | |
5212 | - buf64 = &msqid64; | |
5213 | + /* This is a Linux extension where kernel returns a 'struct msginfo' | |
5214 | + instead. */ | |
5215 | + if (cmd == IPC_INFO || cmd == MSG_INFO) | |
5216 | + buf64 = (struct __msqid64_ds *) buf; | |
5217 | + else | |
5218 | + { | |
5219 | + msqid_to_msqid64 (&msqid64, buf); | |
5220 | + buf64 = &msqid64; | |
5221 | + } | |
5222 | } | |
5223 | ||
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; | |
5231 | break; | |
5232 | case SEM_STAT: | |
5233 | + case SEM_STAT_ANY: | |
5234 | case IPC_STAT: | |
5235 | case IPC_SET: | |
5236 | r.buf = buf; | |
5237 | @@ -150,6 +151,7 @@ __semctl64 (int semid, int semnum, int cmd, ...) | |
5238 | case IPC_STAT: /* arg.buf */ | |
5239 | case IPC_SET: | |
5240 | case SEM_STAT: | |
5241 | + case SEM_STAT_ANY: | |
5242 | case IPC_INFO: /* arg.__buf */ | |
5243 | case SEM_INFO: | |
5244 | va_start (ap, cmd); | |
5245 | @@ -238,6 +240,7 @@ semun_to_semun64 (int cmd, union semun semun, struct __semid64_ds *semid64) | |
5246 | r.array = semun.array; | |
5247 | break; | |
5248 | case SEM_STAT: | |
5249 | + case SEM_STAT_ANY: | |
5250 | case IPC_STAT: | |
5251 | case IPC_SET: | |
5252 | r.buf = semid64; | |
5253 | @@ -267,6 +270,7 @@ __semctl (int semid, int semnum, int cmd, ...) | |
5254 | case IPC_STAT: /* arg.buf */ | |
5255 | case IPC_SET: | |
5256 | case SEM_STAT: | |
5257 | + case SEM_STAT_ANY: | |
5258 | case IPC_INFO: /* arg.__buf */ | |
5259 | case SEM_INFO: | |
5260 | va_start (ap, cmd); | |
5261 | @@ -321,6 +325,7 @@ __semctl_mode16 (int semid, int semnum, int cmd, ...) | |
5262 | case IPC_STAT: /* arg.buf */ | |
5263 | case IPC_SET: | |
5264 | case SEM_STAT: | |
5265 | + case SEM_STAT_ANY: | |
5266 | case IPC_INFO: /* arg.__buf */ | |
5267 | case SEM_INFO: | |
5268 | va_start (ap, cmd); | |
5269 | @@ -354,6 +359,7 @@ __old_semctl (int semid, int semnum, int cmd, ...) | |
5270 | case IPC_STAT: /* arg.buf */ | |
5271 | case IPC_SET: | |
5272 | case SEM_STAT: | |
5273 | + case SEM_STAT_ANY: | |
5274 | case IPC_INFO: /* arg.__buf */ | |
5275 | case SEM_INFO: | |
5276 | va_start (ap, cmd); | |
2d5de23a VM |
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 | |
5280 | --- /dev/null | |
5281 | +++ b/sysdeps/unix/sysv/linux/sh/be/sh4/fpu/Implies | |
5282 | @@ -0,0 +1 @@ | |
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 | |
5287 | --- /dev/null | |
5288 | +++ b/sysdeps/unix/sysv/linux/sh/le/sh4/fpu/Implies | |
5289 | @@ -0,0 +1 @@ | |
5290 | +unix/sysv/linux/sh/sh4/fpu | |
5685e009 VM |
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; | |
5297 | if (buf != NULL) | |
5298 | { | |
5299 | - shmid64_to_kshmid64 (buf, &kshmid); | |
5300 | - arg = &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; | |
5305 | + else | |
5306 | + { | |
5307 | + shmid64_to_kshmid64 (buf, &kshmid); | |
5308 | + arg = &kshmid; | |
5309 | + } | |
5310 | } | |
5311 | # ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T | |
5312 | if (cmd == IPC_SET) | |
5313 | @@ -107,7 +114,6 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf) | |
5314 | ||
5315 | switch (cmd) | |
5316 | { | |
5317 | - case IPC_INFO: | |
5318 | case IPC_STAT: | |
5319 | case SHM_STAT: | |
5320 | case SHM_STAT_ANY: | |
5321 | @@ -168,8 +174,15 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf) | |
5322 | struct __shmid64_ds shmid64, *buf64 = NULL; | |
5323 | if (buf != NULL) | |
5324 | { | |
5325 | - shmid_to_shmid64 (&shmid64, buf); | |
5326 | - buf64 = &shmid64; | |
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; | |
5331 | + else | |
5332 | + { | |
5333 | + shmid_to_shmid64 (&shmid64, buf); | |
5334 | + buf64 = &shmid64; | |
5335 | + } | |
5336 | } | |
5337 | ||
5338 | int ret = __shmctl64 (shmid, cmd, buf64); | |
5339 | @@ -178,7 +191,6 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf) | |
5340 | ||
5341 | switch (cmd) | |
5342 | { | |
5343 | - case IPC_INFO: | |
5344 | case IPC_STAT: | |
5345 | case SHM_STAT: | |
5346 | case SHM_STAT_ANY: | |
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 | |
5350 | --- /dev/null | |
5351 | +++ b/sysdeps/unix/sysv/linux/tst-sysvmsg-linux.c | |
5352 | @@ -0,0 +1,177 @@ | |
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. | |
5356 | + | |
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. | |
5361 | + | |
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. | |
5366 | + | |
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/>. */ | |
5370 | + | |
5371 | +#include <sys/ipc.h> | |
5372 | +#include <sys/msg.h> | |
5373 | +#include <errno.h> | |
5374 | +#include <stdlib.h> | |
5375 | +#include <stdbool.h> | |
5376 | +#include <stdio.h> | |
5377 | + | |
5378 | +#include <support/check.h> | |
5379 | +#include <support/temp_file.h> | |
5380 | + | |
5381 | +#define MSGQ_MODE 0644 | |
5382 | + | |
5383 | +/* These are for the temporary file we generate. */ | |
5384 | +static char *name; | |
5385 | +static int msqid; | |
5386 | + | |
5387 | +static void | |
5388 | +remove_msq (void) | |
5389 | +{ | |
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); | |
5393 | +} | |
5394 | + | |
5395 | +static void | |
5396 | +do_prepare (int argc, char *argv[]) | |
5397 | +{ | |
5398 | + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvmsg.", &name) != -1); | |
5399 | +} | |
5400 | + | |
5401 | +#define PREPARE do_prepare | |
5402 | + | |
5403 | +struct test_msginfo | |
5404 | +{ | |
5405 | + int msgmax; | |
5406 | + int msgmnb; | |
5407 | + int msgmni; | |
5408 | +}; | |
5409 | + | |
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. | |
5413 | + | |
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. */ | |
5417 | + | |
5418 | +static int | |
5419 | +read_proc_file (const char *file) | |
5420 | +{ | |
5421 | + FILE *f = fopen (file, "r"); | |
5422 | + if (f == NULL) | |
5423 | + FAIL_UNSUPPORTED ("/proc is not mounted or %s is not available", file); | |
5424 | + | |
5425 | + int v; | |
5426 | + int r = fscanf (f, "%d", & v); | |
5427 | + TEST_VERIFY_EXIT (r == 1); | |
5428 | + | |
5429 | + fclose (f); | |
5430 | + return v; | |
5431 | +} | |
5432 | + | |
5433 | + | |
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 | |
5436 | + MSG_STAT_ANY. */ | |
5437 | + | |
5438 | +static bool | |
5439 | +check_msginfo (int idx, key_t key, int cmd) | |
5440 | +{ | |
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) | |
5446 | + return false; | |
5447 | + | |
5448 | + if (mid == -1) | |
5449 | + FAIL_EXIT1 ("msgctl with %s failed: %m", | |
5450 | + cmd == MSG_STAT ? "MSG_STAT" : "MSG_STAT_ANY"); | |
5451 | + | |
5452 | + TEST_COMPARE (msginfo.msg_perm.__key, key); | |
5453 | + TEST_COMPARE (msginfo.msg_perm.mode, MSGQ_MODE); | |
5454 | + TEST_COMPARE (msginfo.msg_qnum, 0); | |
5455 | + | |
5456 | + return true; | |
5457 | +} | |
5458 | + | |
5459 | +static int | |
5460 | +do_test (void) | |
5461 | +{ | |
5462 | + atexit (remove_msq); | |
5463 | + | |
5464 | + key_t key = ftok (name, 'G'); | |
5465 | + if (key == -1) | |
5466 | + FAIL_EXIT1 ("ftok failed: %m"); | |
5467 | + | |
5468 | + msqid = msgget (key, MSGQ_MODE | IPC_CREAT); | |
5469 | + if (msqid == -1) | |
5470 | + FAIL_EXIT1 ("msgget failed: %m"); | |
5471 | + | |
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"); | |
5476 | + | |
5477 | + int msqidx; | |
5478 | + | |
5479 | + { | |
5480 | + struct msginfo ipcinfo; | |
5481 | + msqidx = msgctl (msqid, IPC_INFO, (struct msqid_ds *) &ipcinfo); | |
5482 | + if (msqidx == -1) | |
5483 | + FAIL_EXIT1 ("msgctl with IPC_INFO failed: %m"); | |
5484 | + | |
5485 | + TEST_COMPARE (ipcinfo.msgmax, tipcinfo.msgmax); | |
5486 | + TEST_COMPARE (ipcinfo.msgmnb, tipcinfo.msgmnb); | |
5487 | + TEST_COMPARE (ipcinfo.msgmni, tipcinfo.msgmni); | |
5488 | + } | |
5489 | + | |
5490 | + /* Same as before but with MSG_INFO. */ | |
5491 | + { | |
5492 | + struct msginfo ipcinfo; | |
5493 | + msqidx = msgctl (msqid, MSG_INFO, (struct msqid_ds *) &ipcinfo); | |
5494 | + if (msqidx == -1) | |
5495 | + FAIL_EXIT1 ("msgctl with IPC_INFO failed: %m"); | |
5496 | + | |
5497 | + TEST_COMPARE (ipcinfo.msgmax, tipcinfo.msgmax); | |
5498 | + TEST_COMPARE (ipcinfo.msgmnb, tipcinfo.msgmnb); | |
5499 | + TEST_COMPARE (ipcinfo.msgmni, tipcinfo.msgmni); | |
5500 | + } | |
5501 | + | |
5502 | + /* We check if the created message queue shows in global list. */ | |
5503 | + bool found = false; | |
5504 | + for (int i = 0; i <= msqidx; i++) | |
5505 | + { | |
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 | |
5509 | + queue. */ | |
5510 | + check_msginfo (i, key, MSG_STAT_ANY); | |
5511 | + | |
5512 | + if (check_msginfo (i, key, MSG_STAT)) | |
5513 | + { | |
5514 | + found = true; | |
5515 | + break; | |
5516 | + } | |
5517 | + } | |
5518 | + | |
5519 | + if (!found) | |
5520 | + FAIL_EXIT1 ("msgctl with MSG_STAT/MSG_STAT_ANY could not find the " | |
5521 | + "created message queue"); | |
5522 | + | |
5523 | + if (msgctl (msqid, IPC_RMID, NULL) == -1) | |
5524 | + FAIL_EXIT1 ("msgctl failed"); | |
5525 | + | |
5526 | + return 0; | |
5527 | +} | |
5528 | + | |
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 | |
5533 | --- /dev/null | |
5534 | +++ b/sysdeps/unix/sysv/linux/tst-sysvsem-linux.c | |
5535 | @@ -0,0 +1,184 @@ | |
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. | |
5539 | + | |
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. | |
5544 | + | |
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. | |
5549 | + | |
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/>. */ | |
5553 | + | |
5554 | +#include <sys/ipc.h> | |
5555 | +#include <sys/sem.h> | |
5556 | +#include <errno.h> | |
5557 | +#include <stdlib.h> | |
5558 | +#include <stdbool.h> | |
5559 | +#include <stdio.h> | |
5560 | + | |
5561 | +#include <support/check.h> | |
5562 | +#include <support/temp_file.h> | |
5563 | + | |
5564 | +/* These are for the temporary file we generate. */ | |
5565 | +static char *name; | |
5566 | +static int semid; | |
5567 | + | |
5568 | +static void | |
5569 | +remove_sem (void) | |
5570 | +{ | |
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); | |
5574 | +} | |
5575 | + | |
5576 | +static void | |
5577 | +do_prepare (int argc, char *argv[]) | |
5578 | +{ | |
5579 | + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvsem.", &name) != -1); | |
5580 | +} | |
5581 | + | |
5582 | +#define PREPARE do_prepare | |
5583 | + | |
5584 | +#define SEM_MODE 0644 | |
5585 | + | |
5586 | +union semun | |
5587 | +{ | |
5588 | + int val; | |
5589 | + struct semid_ds *buf; | |
5590 | + unsigned short *array; | |
5591 | + struct seminfo *__buf; | |
5592 | +}; | |
5593 | + | |
5594 | +struct test_seminfo | |
5595 | +{ | |
5596 | + int semmsl; | |
5597 | + int semmns; | |
5598 | + int semopm; | |
5599 | + int semmni; | |
5600 | +}; | |
5601 | + | |
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. | |
5605 | + | |
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. */ | |
5609 | + | |
5610 | +static void | |
5611 | +read_sem_stat (struct test_seminfo *tseminfo) | |
5612 | +{ | |
5613 | + FILE *f = fopen ("/proc/sys/kernel/sem", "r"); | |
5614 | + if (f == NULL) | |
5615 | + FAIL_UNSUPPORTED ("/proc is not mounted or /proc/sys/kernel/sem is not " | |
5616 | + "available"); | |
5617 | + | |
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); | |
5622 | + | |
5623 | + fclose (f); | |
5624 | +} | |
5625 | + | |
5626 | + | |
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. */ | |
5629 | + | |
5630 | +static bool | |
5631 | +check_seminfo (int idx, key_t key, int cmd) | |
5632 | +{ | |
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) | |
5638 | + return false; | |
5639 | + | |
5640 | + if (sid == -1) | |
5641 | + FAIL_EXIT1 ("semctl with SEM_STAT failed (errno=%d)", errno); | |
5642 | + | |
5643 | + TEST_COMPARE (seminfo.sem_perm.__key, key); | |
5644 | + TEST_COMPARE (seminfo.sem_perm.mode, SEM_MODE); | |
5645 | + TEST_COMPARE (seminfo.sem_nsems, 1); | |
5646 | + | |
5647 | + return true; | |
5648 | +} | |
5649 | + | |
5650 | +static int | |
5651 | +do_test (void) | |
5652 | +{ | |
5653 | + atexit (remove_sem); | |
5654 | + | |
5655 | + key_t key = ftok (name, 'G'); | |
5656 | + if (key == -1) | |
5657 | + FAIL_EXIT1 ("ftok failed: %m"); | |
5658 | + | |
5659 | + semid = semget (key, 1, IPC_CREAT | IPC_EXCL | SEM_MODE); | |
5660 | + if (semid == -1) | |
5661 | + FAIL_EXIT1 ("semget failed: %m"); | |
5662 | + | |
5663 | + struct test_seminfo tipcinfo; | |
5664 | + read_sem_stat (&tipcinfo); | |
5665 | + | |
5666 | + int semidx; | |
5667 | + | |
5668 | + { | |
5669 | + struct seminfo ipcinfo; | |
5670 | + semidx = semctl (semid, 0, IPC_INFO, (union semun) { .__buf = &ipcinfo }); | |
5671 | + if (semidx == -1) | |
5672 | + FAIL_EXIT1 ("semctl with IPC_INFO failed: %m"); | |
5673 | + | |
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); | |
5678 | + } | |
5679 | + | |
5680 | + /* Same as before but with SEM_INFO. */ | |
5681 | + { | |
5682 | + struct seminfo ipcinfo; | |
5683 | + semidx = semctl (semid, 0, SEM_INFO, (union semun) { .__buf = &ipcinfo }); | |
5684 | + if (semidx == -1) | |
5685 | + FAIL_EXIT1 ("semctl with IPC_INFO failed: %m"); | |
5686 | + | |
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); | |
5691 | + } | |
5692 | + | |
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++) | |
5696 | + { | |
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); | |
5701 | + | |
5702 | + if (check_seminfo (i, key, SEM_STAT)) | |
5703 | + { | |
5704 | + found = true; | |
5705 | + break; | |
5706 | + } | |
5707 | + } | |
5708 | + | |
5709 | + if (!found) | |
5710 | + FAIL_EXIT1 ("semctl with SEM_STAT/SEM_STAT_ANY could not find the " | |
5711 | + "created semaphore"); | |
5712 | + | |
5713 | + if (semctl (semid, 0, IPC_RMID, 0) == -1) | |
5714 | + FAIL_EXIT1 ("semctl failed: %m"); | |
5715 | + | |
5716 | + return 0; | |
5717 | +} | |
5718 | + | |
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 | |
5723 | --- /dev/null | |
5724 | +++ b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c | |
5725 | @@ -0,0 +1,185 @@ | |
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. | |
5729 | + | |
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. | |
5734 | + | |
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. | |
5739 | + | |
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/>. */ | |
5743 | + | |
5744 | +#include <sys/ipc.h> | |
5745 | +#include <sys/shm.h> | |
5746 | +#include <errno.h> | |
5747 | +#include <stdlib.h> | |
5748 | +#include <stdbool.h> | |
5749 | +#include <stdio.h> | |
5750 | +#include <unistd.h> | |
5751 | +#include <inttypes.h> | |
5752 | +#include <limits.h> | |
5753 | + | |
5754 | +#include <support/check.h> | |
5755 | +#include <support/temp_file.h> | |
5756 | + | |
5757 | +#define SHM_MODE 0644 | |
5758 | + | |
5759 | +/* These are for the temporary file we generate. */ | |
5760 | +static char *name; | |
5761 | +static int shmid; | |
5762 | +static long int pgsz; | |
5763 | + | |
5764 | +static void | |
5765 | +remove_shm (void) | |
5766 | +{ | |
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); | |
5770 | +} | |
5771 | + | |
5772 | +static void | |
5773 | +do_prepare (int argc, char *argv[]) | |
5774 | +{ | |
5775 | + TEST_VERIFY_EXIT (create_temp_file ("tst-sysvshm.", &name) != -1); | |
5776 | +} | |
5777 | + | |
5778 | +#define PREPARE do_prepare | |
5779 | + | |
5780 | +struct test_shminfo | |
5781 | +{ | |
5782 | + unsigned long int shmall; | |
5783 | + unsigned long int shmmax; | |
5784 | + unsigned long int shmmni; | |
5785 | +}; | |
5786 | + | |
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. */ | |
5790 | + | |
5791 | +static uint64_t | |
5792 | +read_proc_file (const char *file) | |
5793 | +{ | |
5794 | + FILE *f = fopen (file, "r"); | |
5795 | + if (f == NULL) | |
5796 | + FAIL_UNSUPPORTED ("/proc is not mounted or %s is not available", file); | |
5797 | + | |
5798 | + /* Handle 32-bit binaries running on 64-bit kernels. */ | |
5799 | + uint64_t v; | |
5800 | + int r = fscanf (f, "%" SCNu64, &v); | |
5801 | + TEST_VERIFY_EXIT (r == 1); | |
5802 | + | |
5803 | + fclose (f); | |
5804 | + return v; | |
5805 | +} | |
5806 | + | |
5807 | + | |
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 | |
5810 | + SHM_STAT_ANY. */ | |
5811 | + | |
5812 | +static bool | |
5813 | +check_shminfo (int idx, key_t key, int cmd) | |
5814 | +{ | |
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) | |
5820 | + return false; | |
5821 | + | |
5822 | + if (sid == -1) | |
5823 | + FAIL_EXIT1 ("shmctl with %s failed: %m", | |
5824 | + cmd == SHM_STAT ? "SHM_STAT" : "SHM_STAT_ANY"); | |
5825 | + | |
5826 | + TEST_COMPARE (shminfo.shm_perm.__key, key); | |
5827 | + TEST_COMPARE (shminfo.shm_perm.mode, SHM_MODE); | |
5828 | + TEST_COMPARE (shminfo.shm_segsz, pgsz); | |
5829 | + | |
5830 | + return true; | |
5831 | +} | |
5832 | + | |
5833 | +static int | |
5834 | +do_test (void) | |
5835 | +{ | |
5836 | + atexit (remove_shm); | |
5837 | + | |
5838 | + pgsz = sysconf (_SC_PAGESIZE); | |
5839 | + if (pgsz == -1) | |
5840 | + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE) failed: %m"); | |
5841 | + | |
5842 | + key_t key = ftok (name, 'G'); | |
5843 | + if (key == -1) | |
5844 | + FAIL_EXIT1 ("ftok failed: %m"); | |
5845 | + | |
5846 | + shmid = shmget (key, pgsz, IPC_CREAT | IPC_EXCL | SHM_MODE); | |
5847 | + if (shmid == -1) | |
5848 | + FAIL_EXIT1 ("shmget failed: %m"); | |
5849 | + | |
5850 | + struct test_shminfo tipcinfo; | |
5851 | + { | |
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). */ | |
5856 | + if (v > INT_MAX) | |
5857 | + v = INT_MAX; | |
5858 | +#endif | |
5859 | + tipcinfo.shmmax = v; | |
5860 | + } | |
5861 | + tipcinfo.shmall = read_proc_file ("/proc/sys/kernel/shmall"); | |
5862 | + tipcinfo.shmmni = read_proc_file ("/proc/sys/kernel/shmmni"); | |
5863 | + | |
5864 | + int shmidx; | |
5865 | + | |
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 | |
5870 | + well. */ | |
5871 | + | |
5872 | + { | |
5873 | + struct shminfo ipcinfo; | |
5874 | + shmidx = shmctl (shmid, IPC_INFO, (struct shmid_ds *) &ipcinfo); | |
5875 | + if (shmidx == -1) | |
5876 | + FAIL_EXIT1 ("shmctl with IPC_INFO failed: %m"); | |
5877 | + | |
5878 | + TEST_COMPARE (ipcinfo.shmall, tipcinfo.shmall); | |
5879 | + TEST_COMPARE (ipcinfo.shmmax, tipcinfo.shmmax); | |
5880 | + TEST_COMPARE (ipcinfo.shmmni, tipcinfo.shmmni); | |
5881 | + } | |
5882 | + | |
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++) | |
5886 | + { | |
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 | |
5890 | + queue. */ | |
5891 | + check_shminfo (i, key, SHM_STAT_ANY); | |
5892 | + | |
5893 | + if (check_shminfo (i, key, SHM_STAT)) | |
5894 | + { | |
5895 | + found = true; | |
5896 | + break; | |
5897 | + } | |
5898 | + } | |
5899 | + | |
5900 | + if (!found) | |
5901 | + FAIL_EXIT1 ("shmctl with SHM_STAT/SHM_STAT_ANY could not find the " | |
5902 | + "created shared memory"); | |
5903 | + | |
5904 | + if (shmctl (shmid, IPC_RMID, NULL) == -1) | |
5905 | + FAIL_EXIT1 ("shmctl failed"); | |
5906 | + | |
5907 | + return 0; | |
5908 | +} | |
5909 | + | |
5910 | +#include <support/test-driver.c> | |
2d5de23a VM |
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 | |
5923 | +endif | |
5924 | +endif | |
5925 | endif | |
5685e009 | 5926 | |
2d5de23a VM |
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); | |
5934 | } | |
5935 | ||
5936 | - if (threads == 0) | |
5937 | + if (threads == 0 || cpu_features->basic.family >= 0x17) | |
5938 | { | |
5939 | /* If APIC ID width is not available, use logical | |
5940 | processor count. */ | |
5941 | @@ -823,8 +823,22 @@ init_cacheinfo (void) | |
5942 | if (threads > 0) | |
5943 | shared /= threads; | |
5944 | ||
5945 | - /* Account for exclusive L2 and L3 caches. */ | |
5946 | - shared += core; | |
5947 | + /* Get shared cache per ccx for Zen architectures. */ | |
5948 | + if (cpu_features->basic.family >= 0x17) | |
5949 | + { | |
5950 | + unsigned int eax; | |
5951 | + | |
5952 | + /* Get number of threads share the L3 cache in CCX. */ | |
5953 | + __cpuid_count (0x8000001D, 0x3, eax, ebx, ecx, edx); | |
5954 | + | |
5955 | + unsigned int threads_per_ccx = ((eax >> 14) & 0xfff) + 1; | |
5956 | + shared *= threads_per_ccx; | |
5957 | + } | |
5958 | + else | |
5959 | + { | |
5960 | + /* Account for exclusive L2 and L3 caches. */ | |
5961 | + shared += core; | |
5962 | + } | |
5963 | } | |
5964 | } | |
5965 | ||
5966 | @@ -854,14 +868,20 @@ init_cacheinfo (void) | |
5967 | __x86_shared_cache_size = shared; | |
5968 | } | |
5969 | ||
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); | |
5989 | ||
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) | |
6000 | - return; | |
6001 | + { | |
6002 | + THREAD_SETMEM (THREAD_SELF, header.feature_1, GL(dl_x86_feature_1)); | |
6003 | + return; | |
6004 | + } | |
6005 | ||
6006 | /* Check if IBT is enabled by kernel. */ | |
6007 | bool ibt_enabled | |
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, | |
6013 | } | |
6014 | ||
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) | |
6018 | { | |
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); | |
6021 | } | |
6022 | ||
6023 | static inline int __attribute__ ((always_inline)) | |
6024 | -_dl_process_gnu_property (struct link_map *l, uint32_t type, uint32_t datasz, | |
6025 | - void *data) | |
6026 | +_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type, | |
6027 | + uint32_t datasz, void *data) | |
6028 | { | |
6029 | return 0; | |
6030 | } | |
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 | |
6034 | --- /dev/null | |
6035 | +++ b/sysdeps/x86/tst-setjmp-cet.c | |
6036 | @@ -0,0 +1 @@ | |
6037 | +#include <setjmp/tst-setjmp.c> | |
ad3e853a VM |
6038 | diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure |
6039 | old mode 100644 | |
6040 | new mode 100755 | |
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 | |
6045 | build_mathvec=yes | |
6046 | fi | |
6047 | ||
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 | |
6053 | -else | |
6054 | - cat > conftest.s <<\EOF | |
6055 | - .text | |
6056 | - .global _start | |
6057 | - .weak foo | |
6058 | -_start: | |
6059 | - leaq foo(%rip), %rax | |
6060 | -EOF | |
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 | |
6065 | - ac_status=$? | |
6066 | - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
6067 | - test $ac_status = 0; }; }; then | |
6068 | - libc_cv_ld_static_pie=yes | |
6069 | - else | |
6070 | - libc_cv_ld_static_pie=no | |
6071 | - fi | |
6072 | -rm -f conftest* | |
6073 | -fi | |
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 | |
6078 | - fi | |
6079 | -fi | |
6080 | - | |
6081 | $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h | |
6082 | ||
6083 | ||
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 | |
6089 | build_mathvec=yes | |
6090 | fi | |
6091 | ||
6092 | -dnl Check if linker supports static PIE with the fix for | |
6093 | -dnl | |
6094 | -dnl https://sourceware.org/bugzilla/show_bug.cgi?id=21782 | |
6095 | -dnl | |
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 | |
6099 | - .text | |
6100 | - .global _start | |
6101 | - .weak foo | |
6102 | -_start: | |
6103 | - leaq foo(%rip), %rax | |
6104 | -EOF | |
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 | |
6108 | - else | |
6109 | - libc_cv_ld_static_pie=no | |
6110 | - fi | |
6111 | -rm -f conftest*]) | |
6112 | - if test "$libc_cv_ld_static_pie" != yes; then | |
6113 | - AC_MSG_ERROR([linker support for static PIE needed]) | |
6114 | - fi | |
6115 | -fi | |
6116 | - | |
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) | |
2d5de23a VM |
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, | |
6125 | { | |
6126 | # ifndef RTLD_BOOTSTRAP | |
6127 | if (sym_map != map | |
6128 | - && sym_map->l_type != lt_executable | |
6129 | && !sym_map->l_relocated) | |
6130 | { | |
6131 | const char *strtab | |
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, | |
6139 | + map->l_name); | |
6140 | + else | |
6141 | + _dl_error_printf ("\ | |
6142 | %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n", | |
6143 | - RTLD_PROGNAME, map->l_name, | |
6144 | - sym_map->l_name, | |
6145 | - strtab + refsym->st_name); | |
6146 | + RTLD_PROGNAME, map->l_name, | |
6147 | + sym_map->l_name, | |
6148 | + strtab + refsym->st_name); | |
6149 | } | |
6150 | # endif | |
6151 | value = ((ElfW(Addr) (*) (void)) value) (); | |
5685e009 VM |
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); | |
6159 | ||
6160 | - if (CPU_FEATURE_USABLE_P (cpu_features, FMA)) | |
6161 | + if (CPU_FEATURE_USABLE_P (cpu_features, FMA4)) | |
6162 | return OPTIMIZE (fma4); | |
6163 | ||
6164 | return OPTIMIZE (sse2); | |
2d5de23a VM |
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 | |
6169 | @@ -56,6 +56,13 @@ | |
6170 | # endif | |
6171 | #endif | |
6172 | ||
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) | |
6176 | +#else | |
6177 | +# define AVOID_SHORT_DISTANCE_REP_MOVSB 0 | |
6178 | +#endif | |
6179 | + | |
6180 | #ifndef PREFETCH | |
6181 | # define PREFETCH(addr) prefetcht0 addr | |
6182 | #endif | |
6183 | @@ -243,7 +250,21 @@ L(movsb): | |
6184 | cmpq %r9, %rdi | |
6185 | /* Avoid slow backward REP MOVSB. */ | |
6186 | jb L(more_8x_vec_backward) | |
6187 | +# if AVOID_SHORT_DISTANCE_REP_MOVSB | |
6188 | + movq %rdi, %rcx | |
6189 | + subq %rsi, %rcx | |
6190 | + jmp 2f | |
6191 | +# endif | |
6192 | 1: | |
6193 | +# if AVOID_SHORT_DISTANCE_REP_MOVSB | |
6194 | + movq %rsi, %rcx | |
6195 | + subq %rdi, %rcx | |
6196 | +2: | |
6197 | +/* Avoid "rep movsb" if RCX, the distance between source and destination, | |
6198 | + is N*4GB + [1..63] with N >= 0. */ | |
6199 | + cmpl $63, %ecx | |
6200 | + jbe L(more_2x_vec) /* Avoid "rep movsb" if ECX <= 63. */ | |
6201 | +# endif | |
6202 | mov %RDX_LP, %RCX_LP | |
6203 | rep movsb | |
6204 | L(nop): | |
5685e009 VM |
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 | |
6209 | @@ -20,6 +20,7 @@ | |
6210 | #include <stdlib.h> | |
6211 | #include <errno.h> | |
6212 | #include <string.h> | |
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 | |
6219 | --- a/version.h | |
6220 | +++ b/version.h | |
6221 | @@ -1,4 +1,4 @@ | |
6222 | /* This file just defines the current version number of libc. */ | |
6223 | ||
6224 | -#define RELEASE "release" | |
6225 | +#define RELEASE "stable" | |
6226 | #define VERSION "2.32" | |
2d5de23a VM |
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 | |
6231 | @@ -4,10 +4,10 @@ | |
6232 | test -n "$libc_cv_slibdir" || | |
6233 | case "$prefix" in | |
6234 | /usr | /usr/) | |
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' | |
6244 | fi | |
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 | |
6249 | @@ -18,9 +18,9 @@ | |
6250 | #include <sysdeps/generic/ldconfig.h> | |
6251 | ||
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 }, |