Compare commits

...
Author SHA1 Message Date
Gabriel F. T. Gomes 567785e2b5 Merge branch release/2.24/master into ibm/2.24/master 2017-12-19 15:18:07 -02:00
Florian Weimer c5b38f2ece elf: Count components of the expanded path in _dl_init_path [BZ #22607]
(cherry picked from commit 3ff3dfa5af)
2017-12-16 19:22:10 +01:00
Florian Weimer 28aa53341a elf: Compute correct array size in _dl_init_paths [BZ #22606]
(cherry picked from commit 8a0b17e48b)
2017-12-16 19:21:59 +01:00
Florian Weimer a4fc3a0ceb <array_length.h>: New array_length and array_end macros
(cherry picked from commit c94a5688fb)
2017-12-16 19:21:20 +01:00
Aurelien Jarno d81254d2ef Update NEWS to add CVE-2017-15804 entry
(cherry picked from commit 15e84c63c0)
2017-12-02 22:59:06 +01:00
Florian Weimer bddc572881 posix/tst-glob-tilde.c: Add test for bug 22332
(cherry picked from commit 2fac6a6cd5)
2017-12-02 22:58:29 +01:00
Paul Eggert 94825c8924 glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]
(cherry picked from commit a159b53fa0)
2017-12-02 22:58:11 +01:00
Florian Weimer 1e53b88296 Update NEWS and ChangeLog for CVE-2017-15671
(cherry picked from commit 914c9994d2)
2017-12-02 22:56:28 +01:00
Florian Weimer 5ff2eb52b2 glob: Add new test tst-glob-tilde
The new test checks for memory leaks (see bug 22325) and attempts
to trigger the buffer overflow in bug 22320.

(cherry picked from commit e80fc1fc98)
2017-12-02 22:51:47 +01:00
Paul Eggert 1f523e3c6e CVE-2017-15670: glob: Fix one-byte overflow [BZ #22320]
(cherry picked from commit c369d66e54)
2017-12-02 22:50:14 +01:00
Adhemerval Zanella 832e2ec567 posix: Sync glob with gnulib [BZ #1062]
This patch syncs posix/glob.c implementation with gnulib version
b5ec983 (glob: simplify symlink detection).  The only difference
to gnulib code is

  * DT_UNKNOWN, DT_DIR, and DT_LNK definition in the case there
    were not already defined.  Gnulib code which uses
    HAVE_STRUCT_DIRENT_D_TYPE will redefine them wrongly because
    GLIBC does not define HAVE_STRUCT_DIRENT_D_TYPE.  Instead
    the patch check for each definition instead.

Also, the patch requires additional globfree and globfree64 files
for compatibility version on some architectures.  Also the code
simplification leads to not macro simplification (not need for
NO_GLOB_PATTERN_P anymore).

Checked on x86_64-linux-gnu and on a build using build-many-glibcs.py
for all major architectures.

	[BZ #1062]
	* posix/Makefile (routines): Add globfree, globfree64, and
	glob_pattern_p.
	* posix/flexmember.h: New file.
	* posix/glob_internal.h: Likewise.
	* posix/glob_pattern_p.c: Likewise.
	* posix/globfree.c: Likewise.
	* posix/globfree64.c: Likewise.
	* sysdeps/gnu/globfree64.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/globfree.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/globfree64.c: Likewise.
	* sysdeps/unix/sysv/linux/oldglob.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/globfree64.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/globfree.c: Likewise.
	* sysdeps/wordsize-64/globfree.c: Likewise.
	* sysdeps/wordsize-64/globfree64.c: Likewise.
	* posix/glob.c (HAVE_CONFIG_H): Use !_LIBC instead.
	[NDEBUG): Remove comments.
	(GLOB_ONLY_P, _AMIGA, VMS): Remove define.
	(dirent_type): New type.  Use uint_fast8_t not
	uint8_t, as C99 does not require uint8_t.
	(DT_UNKNOWN, DT_DIR, DT_LNK): New macros.
	(struct readdir_result): Use dirent_type.  Do not define skip_entry
	unless it is needed; this saves a byte on platforms lacking d_ino.
	(readdir_result_type, readdir_result_skip_entry):
	New functions, replacing ...
	(readdir_result_might_be_symlink, readdir_result_might_be_dir):
	 these functions, which were removed.  This makes the callers
	easier to read.  All callers changed.
	(D_INO_TO_RESULT): Now empty if there is no d_ino.
	(size_add_wrapv, glob_use_alloca): New static functions.
	(glob, glob_in_dir): Check for size_t overflow in several places,
	and fix some size_t checks that were not quite right.
	Remove old code using SHELL since Bash no longer
	uses this.
	(glob, prefix_array): Separate MS code better.
	(glob_in_dir): Remove old Amiga and VMS code.
	(globfree, __glob_pattern_type, __glob_pattern_p): Move to
	separate files.
	(glob_in_dir): Do not rely on undefined behavior in accessing
	struct members beyond their bounds.  Use a flexible array member
	instead
	(link_stat): Rename from link_exists2_p and return -1/0 instead of
	0/1.  Caller changed.
	(glob): Fix memory leaks.
	* posix/glob64 (globfree64): Move to separate file.
	* sysdeps/gnu/glob64.c (NO_GLOB_PATTERN_P): Remove define.
	(globfree64): Remove hidden alias.
	* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Add
	oldglob.
	* sysdeps/unix/sysv/linux/alpha/glob.c (__new_globfree): Move to
	separate file.
	* sysdeps/unix/sysv/linux/i386/glob64.c (NO_GLOB_PATTERN_P): Remove
	define.
	Move compat code to separate file.
	* sysdeps/wordsize-64/glob.c (globfree): Move definitions to
	separate file.

(cherry picked from commit c66c908230)
2017-12-02 22:42:47 +01:00
H.J. Lu 89bf8ef2db i386: Hide __old_glob64 [BZ #18822]
Hide internal __old_glob64 function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* sysdeps/unix/sysv/linux/i386/glob64.c (__old_glob64): Add
	libc_hidden_proto and libc_hidden_def.

(cherry picked from commit 2585d7b839)
(cherry picked from commit 2b54f16a8a)
2017-12-02 22:42:31 +01:00
H.J. Lu bea3f92405 x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve [BZ #21265]
In _dl_runtime_resolve, use fxsave/xsave/xsavec to preserve all vector,
mask and bound registers.  It simplifies _dl_runtime_resolve and supports
different calling conventions.  ld.so code size is reduced by more than
1 KB.  However, use fxsave/xsave/xsavec takes a little bit more cycles
than saving and restoring vector and bound registers individually.

Latency for _dl_runtime_resolve to lookup the function, foo, from one
shared library plus libc.so:

                             Before    After     Change

Westmere (SSE)/fxsave         345      866       151%
IvyBridge (AVX)/xsave         420      643       53%
Haswell (AVX)/xsave           713      1252      75%
Skylake (AVX+MPX)/xsavec      559      719       28%
Skylake (AVX512+MPX)/xsavec   145      272       87%
Ryzen (AVX)/xsavec            280      553       97%

This is the worst case where portion of time spent for saving and
restoring registers is bigger than majority of cases.  With smaller
_dl_runtime_resolve code size, overall performance impact is negligible.

On IvyBridge, differences in build and test time of binutils with lazy
binding GCC and binutils are noises.  On Westmere, differences in
bootstrap and "makc check" time of GCC 7 with lazy binding GCC and
binutils are also noises.

	[BZ #21265]
	* sysdeps/x86/cpu-features-offsets.sym (XSAVE_STATE_SIZE_OFFSET):
	New.
	* sysdeps/x86/cpu-features.c: Include <libc-internal.h>.
	(get_common_indeces): Set xsave_state_size and
	bit_arch_XSAVEC_Usable if needed.
	(init_cpu_features): Remove bit_arch_Use_dl_runtime_resolve_slow
	and bit_arch_Use_dl_runtime_resolve_opt.
	* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
	Removed.
	(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
	(bit_arch_Prefer_No_AVX512): Updated.
	(bit_arch_MathVec_Prefer_No_AVX512): Likewise.
	(bit_arch_XSAVEC_Usable): New.
	(STATE_SAVE_OFFSET): Likewise.
	(STATE_SAVE_MASK): Likewise.
	[__ASSEMBLER__]: Include <cpu-features-offsets.h>.
	(cpu_features): Add xsave_state_size.
	(index_arch_Use_dl_runtime_resolve_opt): Removed.
	(index_arch_Use_dl_runtime_resolve_slow): Likewise.
	(index_arch_XSAVEC_Usable): New.
	* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
	Replace _dl_runtime_resolve_sse, _dl_runtime_resolve_avx,
	_dl_runtime_resolve_avx_slow, _dl_runtime_resolve_avx_opt,
	_dl_runtime_resolve_avx512 and _dl_runtime_resolve_avx512_opt
	with _dl_runtime_resolve_fxsave, _dl_runtime_resolve_xsave and
	_dl_runtime_resolve_xsavec.
	* sysdeps/x86_64/dl-trampoline.S (DL_RUNTIME_UNALIGNED_VEC_SIZE):
	Removed.
	(DL_RUNTIME_RESOLVE_REALIGN_STACK): Check STATE_SAVE_ALIGNMENT
	instead of VEC_SIZE.
	(REGISTER_SAVE_BND0): Removed.
	(REGISTER_SAVE_BND1): Likewise.
	(REGISTER_SAVE_BND3): Likewise.
	(REGISTER_SAVE_RAX): Always defined to 0.
	(VMOV): Removed.
	(_dl_runtime_resolve_avx): Likewise.
	(_dl_runtime_resolve_avx_slow): Likewise.
	(_dl_runtime_resolve_avx_opt): Likewise.
	(_dl_runtime_resolve_avx512): Likewise.
	(_dl_runtime_resolve_avx512_opt): Likewise.
	(_dl_runtime_resolve_sse): Likewise.
	(_dl_runtime_resolve_sse_vex): Likewise.
	(USE_FXSAVE): New.
	(_dl_runtime_resolve_fxsave): Likewise.
	(USE_XSAVE): Likewise.
	(_dl_runtime_resolve_xsave): Likewise.
	(USE_XSAVEC): Likewise.
	(_dl_runtime_resolve_xsavec): Likewise.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx512):
	Removed.
	(_dl_runtime_resolve_avx512_opt): Likewise.
	(_dl_runtime_resolve_avx): Likewise.
	(_dl_runtime_resolve_avx_opt): Likewise.
	(_dl_runtime_resolve_sse): Likewise.
	(_dl_runtime_resolve_sse_vex): Likewise.
	(_dl_runtime_resolve_fxsave): New.
	(_dl_runtime_resolve_xsave): Likewise.
	(_dl_runtime_resolve_xsavec): Likewise.

(cherry picked from commit b52b0d793d)
2017-10-22 08:24:29 -07:00
H.J. Lu 5084717ffa x86-64: Verify that _dl_runtime_resolve preserves vector registers
On x86-64, _dl_runtime_resolve must preserve the first 8 vector
registers.  Add 3 _dl_runtime_resolve tests to verify that SSE,
AVX and AVX512 registers are preserved.

	* sysdeps/x86_64/Makefile (tests): Add tst-sse, tst-avx and
	tst-avx512.
	(test-extras): Add tst-avx-aux and tst-avx512-aux.
	(extra-test-objs): Add tst-avx-aux.o and tst-avx512-aux.o.
	(modules-names): Add tst-ssemod, tst-avxmod and tst-avx512mod.
	($(objpfx)tst-sse): New rule.
	($(objpfx)tst-avx): Likewise.
	($(objpfx)tst-avx512): Likewise.
	(CFLAGS-tst-avx-aux.c): New.
	(CFLAGS-tst-avxmod.c): Likewise.
	(CFLAGS-tst-avx512-aux.c): Likewise.
	(CFLAGS-tst-avx512mod.c): Likewise.
	* sysdeps/x86_64/tst-avx-aux.c: New file.
	* sysdeps/x86_64/tst-avx.c: Likewise.
	* sysdeps/x86_64/tst-avx512-aux.c: Likewise.
	* sysdeps/x86_64/tst-avx512.c: Likewise.
	* sysdeps/x86_64/tst-avx512mod.c: Likewise.
	* sysdeps/x86_64/tst-avxmod.c: Likewise.
	* sysdeps/x86_64/tst-sse.c: Likewise.
	* sysdeps/x86_64/tst-ssemod.c: Likewise.

(cherry picked from commit 3403a17fea)
2017-10-19 08:53:02 -07:00
H.J. Lu 37f4c94e1f X86-64: Correct CFA in _dl_runtime_resolve
When stack is re-aligned in _dl_runtime_resolve, there is no need to
adjust CFA when allocating register save area on stack.

	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Don't
	adjust CFA when allocating register save area on re-aligned
	stack.

(cherry picked from commit 0ac8ee53e8)
2017-10-19 08:50:28 -07:00
Joseph Myers 79c6f51428 Fix nss_nisplus build with mainline GCC (bug 20978).
glibc build with current mainline GCC fails because
nis/nss_nisplus/nisplus-alias.c contains code

  if (name != NULL)
    {
      *errnop = EINVAL;
      return NSS_STATUS_UNAVAIL;
    }

  char buf[strlen (name) + 9 + tablename_len];

producing an error about strlen being called on a pointer that is
always NULL (and a subsequent use of that pointer with a %s format in
snprintf).

As Andreas noted, the bogus conditional comes from a 1997 change:

-  if (name == NULL || strlen(name) > 8)
-    return NSS_STATUS_NOTFOUND;
-  else
+  if (name != NULL || strlen(name) <= 8)

So the intention is clearly to return an error for NULL name.

This patch duly inverts the sense of the conditional.  It fixes the
build with GCC mainline, and passes usual glibc testsuite testing for
x86_64.  However, I have not tried any actual substantive nisplus
testing, do not have an environment for such testing, and do not know
whether it is possible that strlen (name) or tablename_len might be
large so that the VLA for buf is actually a security issue.  However,
if it is a security issue, there are plenty of other similar instances
in the nisplus code (that haven't been hidden by a bogus comparison
with NULL) - and nis_table.c:__create_ib_request uses strdupa on the
string passed to nis_list, so a local fix in the caller wouldn't
suffice anyway (see bug 20987).  (Calls to strdupa and other such
macros that use alloca must be considered equally questionable
regarding stack overflow issues as direct calls to alloca and VLA
declarations.)

	[BZ #20978]
	* nis/nss_nisplus/nisplus-alias.c (_nss_nisplus_getaliasbyname_r):
	Compare name == NULL, not name != NULL.

(cherry picked from commit f88759ea9b)
2017-10-07 13:44:49 +02:00
Joseph Myers 7fca94796b Fix rpcgen buffer overrun (bug 20790).
Building with GCC 7 produces an error building rpcgen:

rpc_parse.c: In function 'get_prog_declaration':
rpc_parse.c:543:25: error: may write a terminating nul past the end of the destination [-Werror=format-length=]
     sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
                     ~~~~^
rpc_parse.c:543:5: note: format output between 5 and 14 bytes into a destination of size 10
     sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That buffer overrun is for the case where the .x file declares a
program with a million arguments.  The strcpy two lines above can
generate a buffer overrun much more simply for a long argument name.

The limit on length of line read by rpcgen (MAXLINESIZE == 1024)
provides a bound on the buffer size needed, so this patch just changes
the buffer size to MAXLINESIZE to avoid both possible buffer
overruns.  A testcase is added that rpcgen does not crash with a
500-character argument name, where it previously crashed.

It would not at all surprise me if there are many other ways of
crashing rpcgen with either valid or invalid input; fuzz testing would
likely find various such bugs, though I don't think they are that
important to fix (rpcgen is not that likely to be used with untrusted
.x files as input).  (As well as fuzz-findable bugs there are probably
also issues when various int variables get overflowed on very large
input.)  The test infrastructure for rpcgen-not-crashing tests would
need extending if tests are to be added for cases where rpcgen should
produce an error, as opposed to cases where it should succeed.

Tested for x86_64 and x86.

	[BZ #20790]
	* sunrpc/rpc_parse.c (get_prog_declaration): Increase buffer size
	to MAXLINESIZE.
	* sunrpc/bug20790.x: New file.
	* sunrpc/Makefile [$(run-built-tests) = yes] (rpcgen-tests): New
	variable.
	[$(run-built-tests) = yes] (tests-special): Add $(rpcgen-tests).
	[$(run-built-tests) = yes] ($(rpcgen-tests)): New rule.

(cherry picked from commit 5874510faa)
2017-10-07 13:42:41 +02:00
steve ellcey-CA Eng-Software b3c498b834 Fix warnings from latest GCC.
* sysdeps/ieee754/dbl-64/e_pow.c (checkint) Make conditions explicitly
	boolean.

(cherry picked from commit e223d1fe72)
2017-10-07 13:39:15 +02:00
DJ Delorie b70f43dcef Fix cast-after-dereference
Original code was dereferencing a char*, then casting the value
to size_t.  Should cast the pointer to size_t* then deference.

(cherry picked from commit f8cef4d07d)
2017-10-07 13:32:01 +02:00
DJ Delorie caa97d7a46 Fix BZ #21654 - grp-merge.c alignment
* grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
alignment not char alignment.
(__merge_grp): Likewise.

(cherry picked from commit 4fa8ae49aa)
2017-10-07 13:30:00 +02:00
H.J. Lu d5a4092c36 x86-64: Use _dl_runtime_resolve_opt only with AVX512F [BZ #21871]
On AVX machines with XGETBV (ECX == 1) like Skylake processors,

(gdb) disass _dl_runtime_resolve_avx_opt
Dump of assembler code for function _dl_runtime_resolve_avx_opt:
   0x0000000000015890 <+0>:	push   %rax
   0x0000000000015891 <+1>:	push   %rcx
   0x0000000000015892 <+2>:	push   %rdx
   0x0000000000015893 <+3>:	mov    $0x1,%ecx
   0x0000000000015898 <+8>:	xgetbv
   0x000000000001589b <+11>:	mov    %eax,%r11d
   0x000000000001589e <+14>:	pop    %rdx
   0x000000000001589f <+15>:	pop    %rcx
   0x00000000000158a0 <+16>:	pop    %rax
   0x00000000000158a1 <+17>:	and    $0x4,%r11d
   0x00000000000158a5 <+21>:	bnd je 0x16200 <_dl_runtime_resolve_sse_vex>
End of assembler dump.

is slower than:

(gdb) disass _dl_runtime_resolve_avx_slow
Dump of assembler code for function _dl_runtime_resolve_avx_slow:
   0x0000000000015850 <+0>:	vorpd  %ymm0,%ymm1,%ymm8
   0x0000000000015854 <+4>:	vorpd  %ymm2,%ymm3,%ymm9
   0x0000000000015858 <+8>:	vorpd  %ymm4,%ymm5,%ymm10
   0x000000000001585c <+12>:	vorpd  %ymm6,%ymm7,%ymm11
   0x0000000000015860 <+16>:	vorpd  %ymm8,%ymm9,%ymm9
   0x0000000000015865 <+21>:	vorpd  %ymm10,%ymm11,%ymm10
   0x000000000001586a <+26>:	vpcmpeqd %xmm8,%xmm8,%xmm8
   0x000000000001586f <+31>:	vorpd  %ymm9,%ymm10,%ymm10
   0x0000000000015874 <+36>:	vptest %ymm10,%ymm8
   0x0000000000015879 <+41>:	bnd jae 0x158b0 <_dl_runtime_resolve_avx>
   0x000000000001587c <+44>:	vzeroupper
   0x000000000001587f <+47>:	bnd jmpq 0x16200 <_dl_runtime_resolve_sse_vex>
End of assembler dump.
(gdb)

since xgetbv takes much more cycles than single cycle operations like
vpord/vvpcmpeq/ptest.  _dl_runtime_resolve_opt should be used only with
AVX512 where AVX512 instructions lead to lower CPU frequency on Skylake
server.

	[BZ #21871]
	* sysdeps/x86/cpu-features.c (init_cpu_features): Set
	bit_arch_Use_dl_runtime_resolve_opt only with AVX512F.

(cherry picked from commit d2cf37c0a2)
2017-08-06 11:55:44 -07:00
Florian Weimer 36f173ab37 sunrpc: Avoid use-after-free read access in clntudp_call [BZ #21115]
After commit bc779a1a5b
(CVE-2016-4429: sunrpc: Do not use alloca in clntudp_call
[BZ #20112]), ancillary data is stored on the heap,
but it is accessed after it has been freed.

The test case must be run under a heap debugger such as valgrind
to observe the invalid access.  A malloc implementation which
immediately calls munmap on free would catch this bug as well.

(cherry picked from commit d42eed4a04)
2017-08-05 02:19:16 +02:00
James Clarke 6aacb5befa Bug 21053: sh: Reduce namespace pollution from sys/ucontext.h
The problem is basically that sys/ucontext.h is defining R0..R15
which happens to conflict with some packages like Firefox when
trying to build on SH.

The very same problem existed on arm back then [1] and it was fixed by
renaming R0..R15 to REG_R0..REG_R15.  This patch imploy a similar
strategy for SH.

Checked on sh4-linux-gnu with run-built-tests=no and I also got reports
that it fixes Firefox build on Debian sh4.

	* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym: Use new REG_R*
	constants instead of the old R* ones.
	* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGPREG): Rename...
	(NGREG): ... to this, to fit in with other architectures.
	(gpregset_t): Use new NGREG macro.
	[__USE_GNU]: Remove condition; all architectures other than tile
	are unconditional.
	(R*): Rename to REG_R*.

(cherry picked from commit 3e1b518550)
2017-07-31 22:36:13 +02:00
H.J. Lu fd5fade305 Avoid .symver on common symbols [BZ #21666]
The .symver directive on common symbol just creates a new common symbol,
not an alias and the newer assembler with the bug fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21661

will issue an error.  Before the fix, we got

$ readelf -sW libc.so | grep "loc[12s]"
  5109: 00000000003a0608     8 OBJECT  LOCAL  DEFAULT   36 loc1
  5188: 00000000003a0610     8 OBJECT  LOCAL  DEFAULT   36 loc2
  5455: 00000000003a0618     8 OBJECT  LOCAL  DEFAULT   36 locs
  6575: 00000000003a05f0     8 OBJECT  GLOBAL DEFAULT   36 locs@GLIBC_2.2.5
  7156: 00000000003a05f8     8 OBJECT  GLOBAL DEFAULT   36 loc1@GLIBC_2.2.5
  7312: 00000000003a0600     8 OBJECT  GLOBAL DEFAULT   36 loc2@GLIBC_2.2.5

in libc.so.  The versioned loc1, loc2 and locs have the wrong addresses.
After the fix, we got

$ readelf -sW libc.so | grep "loc[12s]"
  6570: 000000000039e3b8     8 OBJECT  GLOBAL DEFAULT   34 locs@GLIBC_2.2.5
  7151: 000000000039e3c8     8 OBJECT  GLOBAL DEFAULT   34 loc1@GLIBC_2.2.5
  7307: 000000000039e3c0     8 OBJECT  GLOBAL DEFAULT   34 loc2@GLIBC_2.2.5

	[BZ #21666]
	* misc/regexp.c (loc1): Add __attribute__ ((nocommon));
	(loc2): Likewise.
	(locs): Likewise.

(cherry picked from commit 388b4f1a02)
2017-07-26 10:14:08 -07:00
Szabolcs Nagy cc392d6339 [AArch64] Use hidden __GI__dl_argv in rtld startup code
We rely on the symbol being locally defined so using extern symbol
is not correct and the linker may complain about the relocations.
2017-07-12 17:41:57 +01:00
Aurelien Jarno 605e6f9f4a conform tests: call perl with '-I.'
Historically perl includes the current directory in the module search
path. Over the time this has been considered as a security issue and
the recent vulnerabilities [1] made people to reconsider this behaviour.
It is almost sure that this will be removed in the future [2], possibly
for the 5.26 release, although this is not yet firmly decided.

Debian has decided to backport the patches [3], so the perl binary in
unstable do not have '.' in @INC anymore.

This behaviour is used in the conform perl scripts to include the
GlibcConform module. This patch fixes that by calling perl with '-I.'.
This is not a security issue in this case as make ensures that the
current directory is $(srcdir)/conform/ when the scripts are called.
Passing the full path would do exactly the same.

[1] CVE-2016-1238 CVE-2016-6185
[2] https://rt.perl.org/Public/Bug/Display.html?id=127810
[3] https://lists.debian.org/debian-devel-announce/2016/08/msg00013.html

Changelog:
	* conform/Makefile (conformtest-header-tests): Pass -I. to $(PERL).
	(linknamespace-symlists-tests): Likewise.
	(linknamespace-header-tests): Likewise.

(cherry picked from commit 6d5336211d)
2017-07-06 15:14:47 +02:00
H.J. Lu 8c04a73813 x86-64: Align the stack in __tls_get_addr [BZ #21609]
This change forces realignment of the stack pointer in __tls_get_addr, so
that binaries compiled by GCCs older than GCC 4.9:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066

continue to work even if vector instructions are used in glibc which
require the ABI stack realignment.

__tls_get_addr_slow is added to handle the slow paths in the default
implementation of__tls_get_addr in elf/dl-tls.c.  The new __tls_get_addr
calls __tls_get_addr_slow after realigning the stack.  Internal calls
within ld.so go directly to the default implementation of __tls_get_addr
because they do not need stack realignment.

	[BZ #21609]
	* sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
	(gen-as-const-headers): Add rtld-offsets.sym.
	* sysdeps/x86_64/dl-tls.c: New file.
	* sysdeps/x86_64/rtld-offsets.sym: Likwise.
	* sysdeps/x86_64/tls_get_addr.S: Likewise.
	* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
	* sysdeps/x86_64/tlsdesc.sym (TI_MODULE_OFFSET): New.
	(TI_OFFSET_OFFSET): Likwise.

(cherry picked from commit 031e519c95)
2017-07-06 15:05:53 +02:00
Tulio Magno Quites Machado Filho 0f0074a4f1 Merge branch 'release/2.24/master' into ibm/2.24/master 2017-06-21 11:18:55 -03:00
Florian Weimer 86ac4a78a9 i686: Add missing IS_IN (libc) guards to vectorized strcspn
Since commit d957c4d3fa (i386: Compile
rtld-*.os with -mno-sse -mno-mmx -mfpmath=387), vector intrinsics can
no longer be used in ld.so, even if the compiled code never makes it
into the final ld.so link.  This commit adds the missing IS_IN (libc)
guard to the SSE 4.2 strcspn implementation, so that it can be used from
ld.so in the future.

(cherry picked from commit 69052a3a95)
2017-06-20 06:27:56 +02:00
Siddhesh Poyarekar 0578ef88fd Ignore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209)
The LD_HWCAP_MASK environment variable may alter the selection of
function variants for some architectures.  For AT_SECURE process it
means that if an outdated routine has a bug that would otherwise not
affect newer platforms by default, LD_HWCAP_MASK will allow that bug
to be exploited.

To be on the safe side, ignore and disable LD_HWCAP_MASK for setuid
binaries.

	[BZ #21209]
	* elf/rtld.c (process_envvars): Ignore LD_HWCAP_MASK for
	AT_SECURE processes.
	* sysdeps/generic/unsecvars.h: Add LD_HWCAP_MASK.

(cherry picked from commit 1c1243b6fc)
2017-06-20 06:05:02 +02:00
Florian Weimer 2febff860b ld.so: Reject overly long LD_AUDIT path elements
Also only process the last LD_AUDIT entry.

(cherry picked from commit 81b82fb966)
2017-06-19 22:46:18 +02:00
Florian Weimer aab04ca5d3 ld.so: Reject overly long LD_PRELOAD path elements
(cherry picked from commit 6d0ba62289)
2017-06-19 22:46:18 +02:00
Florian Weimer 87bd4186da CVE-2017-1000366: Ignore LD_LIBRARY_PATH for AT_SECURE=1 programs [BZ #21624]
LD_LIBRARY_PATH can only be used to reorder system search paths, which
is not useful functionality.

This makes an exploitable unbounded alloca in _dl_init_paths unreachable
for AT_SECURE=1 programs.

(cherry picked from commit f6110a8fee)
2017-06-19 18:33:26 +02:00
Andreas Schwab 600b10a871 m68k: fix 64bit atomic ops
(cherry picked from commit 64ae9fe456)
2017-06-17 01:27:09 +02:00
Santhosh Thottingal 4e291e7c52 Correct collation rules for Malayalam.
[BZ #19922]
	* locales/iso14651_t1_common: Add collation rules for U+07DA to U+07DF.

	[BZ #19919]
	* locales/iso14651_t1_common: Correct collation of U+0D36 and U+0D37.
2017-06-11 10:28:08 -04:00
Florian Weimer 0505a57d43 fork: Remove bogus parent PID assertions [BZ #21386]
(cherry picked from commit 1d2bc2eae9)
2017-06-09 12:00:48 +02:00
Arjun Shankar 7b60553e36 Use test-driver in sysdeps/unix/sysv/linux/tst-clone2.c
(cherry picked from commit fdc543919a)
2017-06-07 14:19:53 +02:00
Adhemerval Zanella 206e03248c Remove cached PID/TID in clone
This patch remove the PID cache and usage in current GLIBC code.  Current
usage is mainly used a performance optimization to avoid the syscall,
however it adds some issues:

  - The exposed clone syscall will try to set pid/tid to make the new
    thread somewhat compatible with current GLIBC assumptions.  This cause
    a set of issue with new workloads and usecases (such as BZ#17214 and
    [1]) as well for new internal usage of clone to optimize other algorithms
    (such as clone plus CLONE_VM for posix_spawn, BZ#19957).

  - The caching complexity also added some bugs in the past [2] [3] and
    requires more effort of each port to handle such requirements (for
    both clone and vfork implementation).

  - Caching performance gain in mainly on getpid and some specific
    code paths.  The getpid performance leverage is questionable [4],
    either by the idea of getpid being a hotspot as for the getpid
    implementation itself (if it is indeed a justifiable hotspot a
    vDSO symbol could let to a much more simpler solution).

    Other usage is mainly for non usual code paths, such as pthread
    cancellation signal and handling.

For thread creation (on stack allocation) the code simplification in fact
adds some performance gain due the no need of transverse the stack cache
and invalidate each element pid.

Other thread usages will require a direct getpid syscall, such as
cancellation/setxid signal, thread cancellation, thread fail path (at
create_thread), and thread signal (pthread_kill and pthread_sigqueue).
However these are hardly usual hotspots and I think adding a syscall is
justifiable.

It also simplifies both the clone and vfork arch-specific implementation.
And by review each fork implementation there are some discrepancies that
this patch also solves:

  - microblaze clone/vfork does not set/reset the pid/tid field
  - hppa uses the default vfork implementation that fallback to fork.
    Since vfork is deprecated I do not think we should bother with it.

The patch also removes the TID caching in clone. My understanding for
such semantic is try provide some pthread usage after a user program
issue clone directly (as done by thread creation with CLONE_PARENT_SETTID
and pthread tid member).  However, as stated before in multiple discussions
threads, GLIBC provides clone syscalls without further supporting all this
semantics.

I ran a full make check on x86_64, x32, i686, armhf, aarch64, and powerpc64le.
For sparc32, sparc64, and mips I ran the basic fork and vfork tests from
posix/ folder (on a qemu system).  So it would require further testing
on alpha, hppa, ia64, m68k, nios2, s390, sh, and tile (I excluded microblaze
because it is already implementing the patch semantic regarding clone/vfork).

[1] https://codereview.chromium.org/800183004/
[2] https://sourceware.org/ml/libc-alpha/2006-07/msg00123.html
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=15368
[4] http://yarchive.net/comp/linux/getpid_caching.html

	* sysdeps/nptl/fork.c (__libc_fork): Remove pid cache setting.
	* nptl/allocatestack.c (allocate_stack): Likewise.
	(__reclaim_stacks): Likewise.
	(setxid_signal_thread): Obtain pid through syscall.
	* nptl/nptl-init.c (sigcancel_handler): Likewise.
	(sighandle_setxid): Likewise.
	* nptl/pthread_cancel.c (pthread_cancel): Likewise.
	* sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
	Likewise.
	* sysdeps/unix/sysv/linux/createthread.c (create_thread): Likewise.
	* sysdeps/unix/sysv/linux/getpid.c: Remove file.
	* nptl/descr.h (struct pthread): Change comment about pid value.
	* nptl/pthread_getattr_np.c (pthread_getattr_np): Remove thread
	pid assert.
	* sysdeps/unix/sysv/linux/pthread-pids.h (__pthread_initialize_pids):
	Do not set pid value.
	* nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove thread
	pid cache check.
	* nptl_db/td_thr_validate.c (td_thr_validate): Likewise.
	* sysdeps/aarch64/nptl/tcb-offsets.sym: Remove pid offset.
	* sysdeps/alpha/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/arm/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/hppa/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/i386/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/ia64/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/m68k/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/microblaze/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/mips/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/nios2/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/powerpc/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/s390/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/sh/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/sparc/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/tile/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/x86_64/nptl/tcb-offsets.sym: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/clone.S: Remove pid and tid caching.
	* sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/hppa/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/nios2/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/tile/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/vfork.S: Remove pid set and reset.
	* sysdeps/unix/sysv/linux/alpha/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/arm/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/ia64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/mips/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/nios2/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/sh/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/tile/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
	* sysdeps/unix/sysv/linux/tst-clone2.c (f): Remove direct pthread
	struct access.
	(clone_test): Remove function.
	(do_test): Rewrite to take in consideration pid is not cached anymore.

(cherry picked from commit c579f48edb)
2017-06-07 12:42:53 +02:00
Adhemerval Zanella 8071849934 Add INTERNAL_SYSCALL_CALL
This patch adds two new macros for internal and inline syscall to use
within GLIBC: INTERNAL_SYSCALL_CALL and INLINE_SYSCALL_CALL.  They are
similar to the old INTERNAL_SYSCALL and INLINE_SYSCALL with the difference
the new macros accept a variable argument call and do not require to pass
the expected argument size.

The advantage is it is possible to use variable argument macros like
SYSCALL_LL{64} without the need to also handle the argument size.  So
for an ABI where SYSCALL_LL might split the argument in high and low
parts, instead of:

  INTERNAL_SYSCALL_DECL (err);
 #if ...
  INTERNAL_SYSCALL (syscall, err, 2, SYSCALL_LL (len));
 #else
  INTERNAL_SYSCALL (syscall, err, 1, SYSCALL_LL (len));
 #endif

It will be just:

  INTERNAL_SYSCALL_CALL (syscall, err, SYSCALL_LL (len));

The INLINE_SYSCALL_CALL follows the same semanthic regarding the argument
and is similar to INLINE_SYSCALL regarding setting errno.

Checked with a build for x86_64, i386, aach64, armhf, powerpc64le, powerpc32,
and mips32.  No code generation changed.

	* sysdeps/unix/sysdep.h (__INTERNAL_SYSCALL0): New macro.
	(__INTERNAL_SYSCALL1): Likewise.
	(__INTERNAL_SYSCALL2): Likewise.
	(__INTERNAL_SYSCALL3): Likewise.
	(__INTERNAL_SYSCALL4): Likewise.
	(__INTERNAL_SYSCALL5): Likewise.
	(__INTERNAL_SYSCALL6): Likewise.
	(__INTERNAL_SYSCALL7): Likewise.
	(__INTERNAL_SYSCALL_NARGS_X): Likewise.
	(__INTERNAL_SYSCALL_NARGS): Likewise.
	(__INTERNAL_SYSCALL_DISP): Likewise.
	(INTERNAL_SYSCALL_CALL): Likewise.
	(__SYSCALL0): Rename to __INLINE_SYSCALL0.
	(__SYSCALL1): Rename to __INLINE_SYSCALL1.
	(__SYSCALL2): Rename to __INLINE_SYSCALL2.
	(__SYSCALL3): Rename to __INLINE_SYSCALL3.
	(__SYSCALL4): Rename to __INLINE_SYSCALL4.
	(__SYSCALL5): Rename to __INLINE_SYSCALL5.
	(__SYSCALL6): Rename to __INLINE_SYSCALL6.
	(__SYSCALL7): Rename to __INLINE_SYSCALL7.
	(__SYSCALL_NARGS_X): Rename to __INLINE_SYSCALL_NARGS_X.
	(__SYSCALL_NARGS): Rename to __INLINE_SYSCALL_NARGS.
	(__SYSCALL_DISP): Rename to __INLINE_SYSCALL_DISP.
	(__SYSCALL_CALL): Rename to INLINE_SYSCALL_CALL.
	(SYSCALL_CANCEL): Replace __SYSCALL_CALL with INLINE_SYSCALL_CALL.

(cherry picked from commit e33a23fbe8)
2017-06-07 12:42:44 +02:00
Arjun Shankar 4c5785aa12 Synchronize support/ infrastructure with master
This commit updates the support/ subdirectory to
commit 2714c5f3c9
on the master branch and modifies Makeconfig,
Rules, and extra-lib.mk accordingly.
2017-06-07 12:36:15 +02:00
Florian Weimer 2667457e45 malloc: Simplify static malloc interposition [BZ #20432]
Existing interposed mallocs do not define the glibc-internal
fork callbacks (and they should not), so statically interposed
mallocs lead to link failures because the strong reference from
fork pulls in glibc's malloc, resulting in multiple definitions
of malloc-related symbols.

(cherry picked from commit ef4f97648d)

Conflicts:
	nptl/tst-tls3-malloc.c
2017-05-26 16:09:27 -03:00
Florian Weimer 6d03be1cb5 malloc: Run tests without calling mallopt [BZ #19469]
The compiled tests no longer refer to the mallopt symbol
from their main functions.  (Some tests still call mallopt
explicitly, which is fine.)

(cherry picked from commit f690b56979)
2017-05-26 14:57:22 -03:00
H.J. Lu a29331702f x86: Use AVX2 memcpy/memset on Skylake server [BZ #21396]
On Skylake server, AVX512 load/store instructions in memcpy/memset may
lead to lower CPU turbo frequency in certain situations.  Use of AVX2
in memcpy/memset has been observed to have improved overall performance
in many workloads due to the higher frequency.

Since AVX512ER is unique to Xeon Phi, this patch sets Prefer_No_AVX512
if AVX512ER isn't available so that AVX2 versions of memcpy/memset are
used on Skylake server.

	[BZ #21396]
	* sysdeps/x86/cpu-features.c (init_cpu_features): Set
	Prefer_No_AVX512 if AVX512ER isn't available.
	* sysdeps/x86/cpu-features.h (bit_arch_Prefer_No_AVX512): New.
	(index_arch_Prefer_No_AVX512): Likewise.
	* sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Don't use
	AVX512 version if Prefer_No_AVX512 is set.
	* sysdeps/x86_64/multiarch/memcpy_chk.S (__memcpy_chk):
	Likewise.
	* sysdeps/x86_64/multiarch/memmove.S (__libc_memmove): Likewise.
	* sysdeps/x86_64/multiarch/memmove_chk.S (__memmove_chk):
	Likewise.
	* sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Likewise.
	* sysdeps/x86_64/multiarch/mempcpy_chk.S (__mempcpy_chk):
	Likewise.
	* sysdeps/x86_64/multiarch/memset.S (memset): Likewise.
	* sysdeps/x86_64/multiarch/memset_chk.S (__memset_chk):
	Likewise.

(cherry picked from commit 4cb334c4d6)
2017-04-28 10:27:54 -07:00
H.J. Lu 5f85ab2869 x86: Set Prefer_No_VZEROUPPER if AVX512ER is available
AVX512ER won't be implemented in any Xeon processors and will be in
all Xeon Phi processors.  Don't check CPU model number when setting
Prefer_No_VZEROUPPER for Xeon Phi.  Instead, set Prefer_No_VZEROUPPER
if AVX512ER is available.  It works with current and future Xeon Phi
and non-Xeon Phi processors.

	* sysdeps/x86/cpu-features.c (init_cpu_features): Set
	Prefer_No_VZEROUPPER if AVX512ER is available.
	* sysdeps/x86/cpu-features.h
	(bit_cpu_AVX512PF): New.
	(bit_cpu_AVX512ER): Likewise.
	(bit_cpu_AVX512CD): Likewise.
	(bit_cpu_AVX512BW): Likewise.
	(bit_cpu_AVX512VL): Likewise.
	(index_cpu_AVX512PF): Likewise.
	(index_cpu_AVX512ER): Likewise.
	(index_cpu_AVX512CD): Likewise.
	(index_cpu_AVX512BW): Likewise.
	(index_cpu_AVX512VL): Likewise.
	(reg_AVX512PF): Likewise.
	(reg_AVX512ER): Likewise.
	(reg_AVX512CD): Likewise.
	(reg_AVX512BW): Likewise.
	(reg_AVX512VL): Likewise.

(cherry picked from commit 1c53cb49de)
2017-04-28 10:27:42 -07:00
Tulio Magno Quites Machado Filho 3af49a0209 Merge branch release/2.24/master into ibm/2.24/master 2017-04-25 13:24:52 -03:00
Joseph Myers b2e8c40afc Fix MIPS n64 readahead (bug 21026).
As noted in bug 20126, MIPS n64 uses an incorrect implementation of
readahead intended for 32-bit systems.  This patch adds a
syscalls.list entry to fix this.  An updated version of the
consolidation patch
<https://sourceware.org/ml/libc-alpha/2016-09/msg00527.html> could
remove this syscalls.list entry again.

Tested with compilation (only) for mips64; the nature of the syscall
doesn't allow for a glibc test to detect this issue.

	[BZ #21026]
	* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
	(readahead): New syscall entry.

(cherry picked from commit 30733525c6)
2017-04-09 19:51:08 +02:00
H.J. Lu 3966298a45 x86-64: Improve branch predication in _dl_runtime_resolve_avx512_opt [BZ #21258]
On Skylake server, _dl_runtime_resolve_avx512_opt is used to preserve
the first 8 vector registers.  The code layout is

  if only %xmm0 - %xmm7 registers are used
     preserve %xmm0 - %xmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %zmm0 - %zmm7 registers

Branch predication always executes the fallthrough code path to preserve
%zmm0 - %zmm7 registers speculatively, even though only %xmm0 - %xmm7
registers are used.  This leads to lower CPU frequency on Skylake
server.  This patch changes the fallthrough code path to preserve
%xmm0 - %xmm7 registers instead:

  if whole %zmm0 - %zmm7 registers are used
    preserve %zmm0 - %zmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %xmm0 - %xmm7 registers

Tested on Skylake server.

	[BZ #21258]
	* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve_opt):
	Define only if _dl_runtime_resolve is defined to
	_dl_runtime_resolve_sse_vex.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_opt):
	Fallthrough to _dl_runtime_resolve_sse_vex.

(cherry picked from commit c15f8eb50c)
2017-04-07 10:06:58 -07:00
Mike Frysinger cc5dcd8803 posix_spawn: use a larger min stack for -fstack-check [BZ #21253]
When glibc is built with -fstack-check, trying to use posix_spawn can
lead to segfaults due to gcc internally probing stack memory too far.
The new spawn API will allocate a minimum of 1 page, but the stack
checking logic might probe a couple of pages.  When it tries to walk
them, everything falls apart.

The gcc internal docs [1] state the default interval checking is one
page.  Which means we need two pages (the current one, and the next
probed).  No target currently defines it larger.

Further, it mentions that the default minimum stack size needed to
recover from an overflow is 4/8KiB for sjlj or 8/12KiB for others.
But some Linux targets (like mips and ppc) go up to 16KiB (and some
non-Linux targets go up to 24KiB).

Let's create each child with a minimum of 32KiB slack space to support
them all, and give us future breathing room.

No test is added as existing ones crash.  Even a simple call is
enough to trigger the problem:
	char *argv[] = { "/bin/ls", NULL };
	posix_spawn(NULL, "/bin/ls", NULL, NULL, argv, NULL);

[1] https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gccint/Stack-Checking.html

(cherry picked from commit 21f042c804)
2017-04-03 15:20:45 -04:00
Slava Barinov 8cc2792743 fts: Fix symbol redirect for fts_set [BZ #21289]
In a 32-bit environment with _FILE_OFFSET_BITS=64, the __REDIRECT macro
combined with __THROW generates an invalid C++ declaration.

(cherry picked from commit ce39613205)
2017-03-31 10:02:53 +02:00
Mike Frysinger 7043946c79 posix_spawn: fix stack setup on ia64 [BZ #21275]
The ia64-specific clone2 call expects the base of the stack mapping and
the stack size as sep arguments, not an initial stack value as on other
stack-grows-down architectures.  Reuse the stack-grows-up macro so we
pass in the right stack base.

Reported-by: Matt Turner <mattst88@gentoo.org>
(cherry picked from commit ddc3fb3334)
2017-03-20 10:55:45 -04:00
John David Anglin 658b0abcff hppa: Fix setting of __libc_stack_end
The binutils package was recently changed to fix -z relro support on hppa.
See ld/21000 for details:
https://sourceware.org/bugzilla/show_bug.cgi?id=21000

This exposed a problem with the _dl_start_user function in the RTLD_START
define.  We need to set __libc_stack_end before it is made read only.  For
this, we need to define DL_STACK_END.  The offset of 0x160 gives the same
stack end as the code in _dl_start_user.

A build log with the attached patch is here:
https://buildd.debian.org/status/fetch.php?pkg=glibc&arch=hppa&ver=2.24-9&stamp=1487639205&raw=0

(cherry picked from commit 5d20a49aac)
2017-03-15 14:30:48 -07:00
H.J. Lu 4d393a8831 Add VZEROUPPER to memset-vec-unaligned-erms.S [BZ #21081]
Since memset-vec-unaligned-erms.S has VDUP_TO_VEC0_AND_SET_RETURN at
function entry, memset optimized for AVX2 and AVX512 will always use
ymm/zmm register. VZEROUPPER should be placed before ret in

L(stosb):
        movq    %rdx, %rcx
        movzbl  %sil, %eax
        movq    %rdi, %rdx
        rep stosb
        movq    %rdx, %rax
        ret

since it can be reached from

L(stosb_more_2x_vec):
        cmpq    $REP_STOSB_THRESHOLD, %rdx
        ja      L(stosb)

	[BZ #21081]
	* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
	(L(stosb)): Add VZEROUPPER before ret.

(cherry picked from commit 02b78ff749)
2017-02-24 09:46:15 -08:00
H.J. Lu d012ea8506 X86_64: Don't use PLT nor GOT in static archives [BZ #20750]
There is no need to use PLT nor GOT in static archives to branch to a
function, regardless whether static archives is compiled with PIC or
not.  When static archives are used to create dynamic executable,
PLT/GOT may be used.  The resulting executable still works correctly.

	[BZ #20750]
	* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
	of PIC.

(cherry picked from commit c9070e6305)
2017-02-09 11:05:18 -05:00
Florian Weimer b3b37f1a55 CVE-2015-5180: resolv: Fix crash with internal QTYPE [BZ #18784]
Also rename T_UNSPEC because an upcoming public header file
update will use that name.

(cherry picked from commit fc82b0a2df)
2017-02-09 00:24:02 -05:00
Tulio Magno Quites Machado Filho 5939404d49 Merge branch 'release/2.24/master' into ibm/2.24/master 2017-02-08 09:46:11 -02:00
Siddhesh Poyarekar 537a06fbde Drop GLIBC_TUNABLES in setxid processes
Drop the GLIBC_TUNABLES environment variable from the environment of
setxid processes to avoid passing it on to non-setxid children.  This
prevents potentially insecure tunables in the GLIBC_TUNABLES envvar
from crossing over into a child that may use a libc that has tunables
support.

	* sysdeps/generic/unsecvars.h: Add GLIBC_TUNABLES.
2017-02-02 16:15:45 +05:30
Tulio Magno Quites Machado Filho 2762a7145b powerpc: Fix write-after-destroy in lock elision [BZ #20822]
The update of *adapt_count after the release of the lock causes a race
condition when thread A unlocks, thread B continues and destroys the
mutex, and thread A writes to *adapt_count.

(cherry picked from commit e9a96ea1ac)
(with changes from commit eb1321f291)
2017-01-23 14:39:47 -02:00
Mike Frysinger 7e4405c50f localedata: bs_BA: fix yesexpr/noexpr [BZ #20974]
Both regexes end with a "*." which means the previous match can be
omitted, and then the . allows them to match any input at all.

This means tools like coreutils' `rm -i` will always delete things
when prompted because the yesexpr regex matches all inputs (even
the negative ones).

(cherry picked from commit a035eb6928)
2016-12-30 01:50:33 -05:00
Carlos O'Donell e9e69e4680 Bug 11941: ld.so: Improper assert map->l_init_called in dlclose
There is at least one use case where during exit a library destructor
might call dlclose() on a valid handle and have it fail with an
assertion. We must allow this case, it is a valid handle, and dlclose()
should not fail with an assert. In the future we might be able to return
an error that the dlclose() could not be completed because the opened
library has already been unloaded and destructors have run as part of
exit processing.

For more details see:
https://www.sourceware.org/ml/libc-alpha/2016-12/msg00859.html

(cherry picked from commit 57707b7fcc)
2016-12-23 15:41:57 -05:00
Aurelien Jarno e6eab16cc3 alpha: fix trunc for big input values
The alpha specific version of trunc and truncf always add and subtract
0x1.0p23 or 0x1.0p52 even for big values. This causes this kind of
errors in the testsuite:

  Failure: Test: trunc_towardzero (0x1p107)
  Result:
   is:          1.6225927682921334e+32   0x1.fffffffffffffp+106
   should be:   1.6225927682921336e+32   0x1.0000000000000p+107
   difference:  1.8014398509481984e+16   0x1.0000000000000p+54
   ulp       :  0.5000
   max.ulp   :  0.0000

Change this by returning the input value when its absolute value is
greater than 0x1.0p23 or 0x1.0p52. NaN have to go through the add and
subtract operations to get possibly silenced.

Finally remove the code to handle inexact exception, trunc should never
generate such an exception.

Changelog:
	* sysdeps/alpha/fpu/s_trunc.c (__trunc): Return the input value
	when its absolute value is greater than 0x1.0p52.
	[_IEEE_FP_INEXACT] Remove.
	* sysdeps/alpha/fpu/s_truncf.c (__truncf): Return the input value
	when its absolute value is greater than 0x1.0p23.
	[_IEEE_FP_INEXACT] Remove.

(cherry picked from commit b74d259fe7)
2016-12-08 00:57:11 -05:00
Aurelien Jarno 8eb9a92e05 alpha: fix rint on sNaN input
The alpha version of rint wrongly return sNaN for sNaN input. Fix that
by checking for NaN and by returning the input value added with itself
in that case.

Changelog:
	* sysdeps/alpha/fpu/s_rint.c (__rint): Add argument with itself
	when it is a NaN.
	* sysdeps/alpha/fpu/s_rintf.c (__rintf): Likewise.

(cherry picked from commit cb7f9d63b9)
2016-12-08 00:57:05 -05:00
Aurelien Jarno 1912cc082d alpha: fix floor on sNaN input
The alpha version of floor wrongly return sNaN for sNaN input. Fix that
by checking for NaN and by returning the input value added with itself
in that case.

Finally remove the code to handle inexact exception, floor should never
generate such an exception.

Changelog:
	* sysdeps/alpha/fpu/s_floor.c (__floor): Add argument with itself
	when it is a NaN.
	[_IEEE_FP_INEXACT] Remove.
	* sysdeps/alpha/fpu/s_floorf.c (__floorf): Likewise.

(cherry picked from commit 65cc568cf5)
2016-12-08 00:56:59 -05:00
Aurelien Jarno 3eff6f8431 alpha: fix ceil on sNaN input
The alpha version of ceil wrongly return sNaN for sNaN input. Fix that
by checking for NaN and by returning the input value added with itself
in that case.

Finally remove the code to handle inexact exception, ceil should never
generate such an exception.

Changelog:
	* sysdeps/alpha/fpu/s_ceil.c (__ceil): Add argument with itself
	when it is a NaN.
	[_IEEE_FP_INEXACT] Remove.
	* sysdeps/alpha/fpu/s_ceilf.c (__ceilf): Likewise.

(cherry picked from commit 062e53c195)
2016-12-08 00:56:55 -05:00
H.J. Lu 4b8790c81c X86-64: Add _dl_runtime_resolve_avx[512]_{opt|slow} [BZ #20508]
There is transition penalty when SSE instructions are mixed with 256-bit
AVX or 512-bit AVX512 load instructions.  Since _dl_runtime_resolve_avx
and _dl_runtime_profile_avx512 save/restore 256-bit YMM/512-bit ZMM
registers, there is transition penalty when SSE instructions are used
with lazy binding on AVX and AVX512 processors.

To avoid SSE transition penalty, if only the lower 128 bits of the first
8 vector registers are non-zero, we can preserve %xmm0 - %xmm7 registers
with the zero upper bits.

For AVX and AVX512 processors which support XGETBV with ECX == 1, we can
use XGETBV with ECX == 1 to check if the upper 128 bits of YMM registers
or the upper 256 bits of ZMM registers are zero.  We can restore only the
non-zero portion of vector registers with AVX/AVX512 load instructions
which will zero-extend upper bits of vector registers.

This patch adds _dl_runtime_resolve_sse_vex which saves and restores
XMM registers with 128-bit AVX store/load instructions.  It is used to
preserve YMM/ZMM registers when only the lower 128 bits are non-zero.
_dl_runtime_resolve_avx_opt and _dl_runtime_resolve_avx512_opt are added
and used on AVX/AVX512 processors supporting XGETBV with ECX == 1 so
that we store and load only the non-zero portion of vector registers.
This avoids SSE transition penalty caused by _dl_runtime_resolve_avx and
_dl_runtime_profile_avx512 when only the lower 128 bits of vector
registers are used.

_dl_runtime_resolve_avx_slow is added and used for AVX processors which
don't support XGETBV with ECX == 1.  Since there is no SSE transition
penalty on AVX512 processors which don't support XGETBV with ECX == 1,
_dl_runtime_resolve_avx512_slow isn't provided.

	[BZ #20495]
	[BZ #20508]
	* sysdeps/x86/cpu-features.c (init_cpu_features): For Intel
	processors, set Use_dl_runtime_resolve_slow and set
	Use_dl_runtime_resolve_opt if XGETBV suports ECX == 1.
	* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
	New.
	(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
	(index_arch_Use_dl_runtime_resolve_opt): Likewise.
	(index_arch_Use_dl_runtime_resolve_slow): Likewise.
	* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup): Use
	_dl_runtime_resolve_avx512_opt and _dl_runtime_resolve_avx_opt
	if Use_dl_runtime_resolve_opt is set.  Use
	_dl_runtime_resolve_slow if Use_dl_runtime_resolve_slow is set.
	* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features.h>.
	(_dl_runtime_resolve_opt): New.  Defined for AVX and AVX512.
	(_dl_runtime_resolve): Add one for _dl_runtime_resolve_sse_vex.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx_slow):
	New.
	(_dl_runtime_resolve_opt): Likewise.
	(_dl_runtime_profile): Define only if _dl_runtime_profile is
	defined.

(cherry picked from commit fb0f7a6755)
2016-11-30 08:37:50 -08:00
Aurelien Jarno 2d16e81bab x86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE
When glibc is compiled with gcc 6.2 that has been configured with
to default to PIC/PIE, the static version of __memcpy_chk is not built,
as the test is done on PIC instead of SHARED. Fix the test to check for
SHARED, like it is done for similar functions like memmove_chk.

Changelog:
	* sysdeps/x86_64/memcpy_chk.S (__memcpy_chk): Check for SHARED
	instead of PIC.

(cherry picked from commit 380ec16d62)
2016-11-24 16:57:23 +01:00
Maciej W. Rozycki 65a2b63756 MIPS: Add `.insn' to ensure a text label is defined as code not data
Avoid a build error with microMIPS compilation and recent versions of
GAS which complain if a branch targets a label which is marked as data
rather than microMIPS code:

../sysdeps/mips/mips32/crti.S: Assembler messages:
../sysdeps/mips/mips32/crti.S:72: Error: branch to a symbol in another ISA mode
make[2]: *** [.../csu/crti.o] Error 1

as commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment of
branch and jump targets") closed a hole in branch processing, making
relocation calculation respect the ISA mode of the symbol referred.
This allowed diagnosing the situation where an attempt is made to pass
control from code assembled for one ISA mode to code assembled for a
different ISA mode and either relaxing the branch to a cross-mode jump
or if that is not possible, then reporting this as an error rather than
letting such code build and then fail unpredictably at the run time.

This however requires the correct annotation of branch targets as code,
because the ISA mode is not relevant for data symbols and is therefore
not recorded for them.  The `.insn' pseudo-op is used for this purpose
and has been supported by GAS since:

Wed Feb 12 14:36:29 1997  Ian Lance Taylor  <ian@cygnus.com>

	* config/tc-mips.c (mips_pseudo_table): Add "insn".
	(s_insn): New static function.
	* doc/c-mips.texi: Document .insn.

so there has been no reason to avoid it where required.  More recently
this pseudo-op has been documented, by the microMIPS architecture
specification[1][2], as required for the correct interpretation of any
code label which is not followed by an actual instruction in an assembly
source.

Use it in our crti.S files then, to mark that the trailing label there
with no instructions following is indeed not a code bug and the branch
is legitimate.

References:

[1] "MIPS Architecture for Programmers, Volume II-B: The microMIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00582,
    Revision 5.04, January 15, 2014, Section 7.1 "Assembly-Level
    Compatibility", p. 533

[2] "MIPS Architecture for Programmers, Volume II-B: The microMIPS64
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00594,
    Revision 5.04, January 15, 2014, Section 8.1 "Assembly-Level
    Compatibility", p. 623

2016-11-23  Matthew Fortune  <Matthew.Fortune@imgtec.com>
            Maciej W. Rozycki  <macro@imgtec.com>

	* sysdeps/mips/mips32/crti.S (_init): Add `.insn' pseudo-op at
	`.Lno_weak_fn' label.
	* sysdeps/mips/mips64/n32/crti.S (_init): Likewise.
	* sysdeps/mips/mips64/n64/crti.S (_init): Likewise.

(cherry picked from commit cfaf1949ff)
2016-11-23 12:55:45 +00:00
Adhemerval Zanella d174436712 Fix writes past the allocated array bounds in execvpe (BZ#20847)
This patch fixes an invalid write out or stack allocated buffer in
2 places at execvpe implementation:

  1. On 'maybe_script_execute' function where it allocates the new
     argument list and it does not account that a minimum of argc
     plus 3 elements (default shell path, script name, arguments,
     and ending null pointer) should be considered.  The straightforward
     fix is just to take account of the correct list size on argument
     copy.

  2. On '__execvpe' where the executable file name lenght may not
     account for ending '\0' and thus subsequent path creation may
     write past array bounds because it requires to add the terminating
     null.  The fix is to change how to calculate the executable name
     size to add the final '\0' and adjust the rest of the code
     accordingly.

As described in GCC bug report 78433 [1], these issues were masked off by
GCC because it allocated several bytes more than necessary so that many
off-by-one bugs went unnoticed.

Checked on x86_64 with a latest GCC (7.0.0 20161121) with -O3 on CFLAGS.

	[BZ #20847]
	* posix/execvpe.c (maybe_script_execute): Remove write past allocated
	array bounds.
	(__execvpe): Likewise.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78433
2016-11-22 10:56:07 -02:00
Denis Kaganovich 2bdb3d2ee1 configure: accept __stack_chk_fail_local for ssp support too [BZ #20662]
When glibc is compiled with gcc 6.2 that has been configured with
--enable-default-pie and --enable-default-ssp, the configure script
fails to detect that the compiler has ssp turned on by default when
being built for i686-linux-gnu.

This is because gcc is emitting __stack_chk_fail_local but the
script is only looking for __stack_chk_fail.  Support both.

Example output:
checking whether x86_64-pc-linux-gnu-gcc -m32 -Wl,-O1 -Wl,--as-needed
implicitly enables -fstack-protector... no

(cherry picked from commit c7409aded4)
2016-11-15 14:30:27 -05:00
Joseph Myers 822305be76 Fix linknamespace parallel test failures.
Having found that with my script to build many glibc variants I could
reproduce the linknamespace test failures in parallel builds (that
various people had previously reported but I hadn't seen myself), I
investigated those failures further.  This patch adds a missing
dependency to those tests.

Tested for x86_64, including the configuration where I saw those
failures and where I don't see them with this patch.

	* conform/Makefile ($(linknamespace-header-tests)): Also depend on
	$(linknamespace-symlists-tests).

(cherry picked from commit 6c50bb532b)
2016-11-06 21:37:27 +01:00
Aurelien Jarno fe783a26a5 gconv.h: fix build with GCC 7
gconv.h is using a flex array to define the __gconv_info member in an
invalid way, causing GCC 7 to issue an error:

| In file included from ../include/gconv.h:1:0,
|                  from ../sysdeps/unix/sysv/linux/_G_config.h:32,
|                  from ../libio/libio.h:31,
|                  from ../include/libio.h:4,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../iconv/gconv.h:142:50: error: flexible array member '__gconv_info::__data' not at end of 'struct _IO_codecvt'
| In file included from ../include/libio.h:4:0,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../libio/libio.h:211:14: note: next member '_G_iconv_t _IO_codecvt::__cd_out' declared here
| ../libio/libio.h:187:8: note: in the definition of 'struct _IO_codecvt'
| In file included from ../include/gconv.h:1:0,
|                  from ../sysdeps/unix/sysv/linux/_G_config.h:32,
|                  from ../libio/libio.h:31,
|                  from ../include/libio.h:4,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../iconv/gconv.h:142:50: error: flexible array member '__gconv_info::__data' not at end of 'struct _IO_wide_data'
| In file included from ../include/libio.h:4:0,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../libio/libio.h:211:14: note: next member '_G_iconv_t _IO_codecvt::__cd_out' declared here
| ../libio/libio.h:215:8: note: in the definition of 'struct _IO_wide_data'

This is basically a revert to the code from 15 years ago. More details
are available in the GCC bug:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78039

Changelog:
	* iconv/gconv.h (__gconv_info): Define __data element using a
	zero-length array.

(cherry picked from commit 0623b9e6a9)
2016-11-06 21:34:19 +01:00
Joseph Myers 797c7fb197 Fix cmpli usage in power6 memset.
Building glibc for powerpc64 with recent (2.27.51.20161012) binutils,
with multi-arch enabled, I get the error:

../sysdeps/powerpc/powerpc64/power6/memset.S: Assembler messages:
../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: operand out of range (5 is not between 0 and 1)
../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: operand out of range (128 is not between 0 and 31)
../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: missing operand

Indeed, cmpli is documented as a four-operand instruction, and looking
at nearby code it seems likely cmpldi was intended.  This patch fixes
this powerpc64 code accordingly, and makes a corresponding change to
the powerpc32 code.

Tested for powerpc, powerpc64 and powerpc64le by Tulio Magno Quites
Machado Filho

	* sysdeps/powerpc/powerpc32/power6/memset.S (memset): Use cmplwi
	instead of cmpli.
	* sysdeps/powerpc/powerpc64/power6/memset.S (memset): Use cmpldi
	instead of cmpli.

(cherry picked from commit 78b7adbaea)
2016-11-06 21:19:21 +01:00
Adhemerval Zanella ccebcff824 Fix Linux sh4 pread/pwrite argument passing
Although conceptually correct for p{read,write}{64} offset argument passing,
sh4 implementation does not generate the correct expected code.  The
__ALIGNMENT_ARG redefinition is incorrect for two reasons: 1. the
kernel-features.h header is included multiple times (since it contains no
guards) and 2. the value it redefines is also incorrect (should be '0, '
instead of empty definition).

This patch fixes it by adding another macro, SYSCALL_LL_PRW{64}, meant to be
used to pass the offset argument on p{read,write}64.  It is basically the
already define SYSCALL_LL{64} plus __ALIGNMENT_ARG unless __ASSUME_PRW_DUMMY_ARG
is define.  In this case an empty dummy argument is used regardless how
__ALIGNMENT_ARG is defined (sh4 case).

Checked on x86_64, i686, aarch64, armhf, and powerpc64le (basically a sanity
check).  Also, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> and
James Clarke <jrtc27@jrtc27.com> help me check on a debian sh4 bootstrap using
2.24 plus this patch to verify it also corrected fixed the regression issue.

I also verified the generated object for a 2.24 build and master with this
patch for sh4 and both look identical.

	* sysdeps/unix/sysv/linux/pread.c (__libc_pread): Use SYSCALL_LL_PRW.
	* sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise.
	* sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Use
	SYSCALL_LL64_PRW.
	* sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h: Define
	__ASSUME_PRW_DUMMY_ARG.
	* sysdeps/unix/sysv/linux/sh/pread.c: Remove file.
	* sysdeps/unix/sysv/linux/sh/pread64.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise.
	* sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise.
	* sysdeps/unix/sysv/linux/sysdep.h: Define SYSCALL_LL_PRW and
	SYSCALL_LL_PRW64 based on __ASSUME_PRW_DUMMY_ARG.
2016-10-24 15:29:11 -02:00
Tulio Magno Quites Machado Filho 0271fac6ad powerpc: Add a POWER8 implementation for GET|SET_FLOAT_WORD
Provides a POWER8 implementation for GET_FLOAT_WORD and SET_FLOAT_WORD
that is able to extract or set a float using only VSR and GPR.

This is a workaround for GCC bug #70568.
2016-10-18 15:36:59 -02:00
Tulio Magno Quites Machado Filho 4467e53ab2 powerpc: Regenerate ULPs
* sysdeps/powerpc/fpu/libm-test-ulps: Regenerated.
2016-10-05 11:00:04 -03:00
Adhemerval Zanella 066437ad32 posix: Correctly block/unblock all signals on Linux posix_spawn
This patch correctly block and unblocks all signals when executing
Linux posix_spawn by using the __libc_signal_{un}block_all functions
instead of default sigprocmask.  The latter might remove both
SIGCANCEL and SIGSETXID from the blocked signal list.

Checked on x86_64, i686, powerpc64le, and aarch64.

	* sysdeps/unix/sysv/linux/spawni.c (__spawnix): Correctly block and unblock
	all signals when executing the clone vfork child.
	(SIGALL_SET): Remove macro.
2016-09-28 15:30:07 -07:00
Adhemerval Zanella 28202d1341 posix: Correctly enable/disable cancellation on Linux posix_spawn
This patch correctly enable and disable asynchronous cancellation on
Linux posix_spawn.  Current code invert the logic by enabling and
disabling instead.  It also adds a new test to check if posix_spawn
is not a cancellation entrypoint.

Checked on x86_64, i686, powerpc64le, and aarch64.

	* nptl/Makefile (tests): Add tst-exec5.
	* nptl/tst-exec5.c: New file.
	* sysdeps/unix/sysv/linux/spawni.c (__spawni): Correctly enable and disable
	asynchronous cancellation.
2016-09-28 15:29:59 -07:00
Tulio Magno Quites Machado Filho 24033104e3 Merge branch release/2.24/master into ibm/2.24/master 2016-09-19 17:03:27 -03:00
Tulio Magno Quites Machado Filho 66b8f3d8ec powerpc: Fix POWER9 implies
Fix multiarch build for POWER9 by correcting the order of the
directories listed at sysnames configure variable.

(cherry picked from commit 1850ce5a2e)
2016-09-19 11:02:49 -03:00
Roland McGrath e591222f99 NaCl: Fix libc.abilist missing GLIBC_2.24 A.
* sysdeps/arm/nacl/libc.abilist: Add GLIBC_2.24 A.
2016-09-02 17:19:31 -07:00
Roland McGrath a7a8929491 NaCl: Fix compile error for __dup after libc_hidden_proto addition.
* sysdeps/nacl/dup.c: Add libc_hidden_def.

(cherry picked from commit 6b75ba1388)
2016-09-02 16:59:57 -07:00
Roland McGrath d289049cf5 Fix generic wait3 after union wait_status removal.
* sysdeps/posix/wait3.c: Don't treat STAT_LOC as a union, since it's
	not any more.

(cherry picked from commit 9a3d16ac15)
2016-09-02 16:59:49 -07:00
Roland McGrath 5370672480 NaCl: Fix compile error in clock function.
* sysdeps/nacl/clock.c (clock): nacl_abi_clock_t -> nacl_irt_clock_t

(cherry picked from commit 307c2c2dff)
2016-09-02 16:59:45 -07:00
Florian Weimer 8c716c2e2f nptl/tst-once5: Reduce time to expected failure
(cherry picked from commit 1f645571d2)
2016-08-18 12:00:11 +02:00
Florian Weimer 58ef663c94 argp: Do not override GCC keywords with macros [BZ #16907]
glibc provides fallback definitions already.  It is not necessary to
suppress warnings for unknown attributes because GCC does this
automatically for system headers.

This commit does not sync with gnulib because gnulib has started to use
_GL_* macros in the header file, which are arguably in the gnulib
implementation space and not suitable for an installed glibc header
file.

(cherry picked from commit 2c820533c6)
2016-08-18 11:40:21 +02:00
Andreas Schwab 72450627ba arm: mark __startcontext as .cantunwind (bug 20435)
__startcontext marks the bottom of the call stack of the contexts created
by makecontext.

(cherry picked from commit 9e2ff6c9cc)

Also includes the NEWS update, cherry-picked from commits
056dd72af8 and
4d047efdbc.
2016-08-18 11:38:28 +02:00
Florian Weimer e2e4984ad6 Do not override objects in libc.a in other static libraries [BZ #20452]
With this change, we no longer add sysdep.o and similar objects which
are present in libc.a to other static libraries.

(cherry picked from commit d9067fca40)
2016-08-18 11:35:45 +02:00
Aurelien Jarno 0ba4a7522b sparc: remove fdim sparc specific implementations
The fdim and fdimf functions on sparc do not fully follow the standard
and do not set errno to ERANGE when the result overflows. Since glibc
2.24 this causes the two following tests to fail:

  Failure: fdim (max_value, -max_value): errno set to 0, expected 34 (ERANGE)
  Failure: fdim_upward (max_value, -max_value): errno set to 0, expected 34 (ERANGE)

It happens that using GCC with the generic C code generates very similar
code to the sparc specific implementations. Therefore this patches
remove them. Note it might still worth adding a vis3 specific version of
fdim on sparc32/sparcv9, this is done in a following patch to ease
backporting.

Changelog:
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
	[$(subdir) = math && $(have-as-vis3) = yes] (libm-sysdep_routines):
	Remove s_fdimf-vis3, s_fdim-vis3.
	* sysdeps/sparc/sparc32/fpu/s_fdim.S: Delete file.
	* sysdeps/sparc/sparc32/fpu/s_fdimf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf-vis3.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_fdim.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_fdimf.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/s_fdim.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/s_fdimf.S: Likewise.

(cherry picked from commit 8a9f4eb958)
2016-08-15 00:29:30 +02:00
David S. Miller b3012e4d56 Fix sNaN handling in nearbyint on 32-bit sparc.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
	(__nearbyint_vis3): Don't check for sNaN before float register is
	loaded with the incoming argument.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
	(__nearbyintf_vis3): Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S (__nearbyint):
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S (__nearbyintf):
	Likewise.

(cherry picked from commit 3ef3f1b93f)
2016-08-15 00:28:58 +02:00
Aurelien Jarno f038a42f54 powerpc: fix ifunc-sel.h fix asm constraints and clobber list
As pointer out on the mailing list, the inline assembly code in
sysdeps/powerpc/ifunc-sel.h doesn't have a list of clobbered registers
and used wrong constraints.

This patch fixes that. I verified it doesn't introduce any change in the
generated code.

Changelog:
	* sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Add "11", "12", "cr0" to the
	clobber list. Use "i" constraint instead of "X".
	(ifunc_one): Add "12" to the clobber list. Use "i" constraint instead
	of "X".

(cherry picked from commit 30f926d3b3)
2016-08-14 22:48:23 +02:00
Aurelien Jarno 8026e9db17 powerpc: fix ifunc-sel.h with GCC 6
On 32-bit PowerPC GCC 6 always saves the PIC register on the stack in
the prologue and adjust the stack in the epilogue. It is therefore not
possible anymore to just exit the function in the inline asm code,
otherwise it corrupts the stack pointer. This causes the following tests
to fail when using GCC 6:

FAIL: elf/ifuncmain1
FAIL: elf/ifuncmain1pic
FAIL: elf/ifuncmain1picstatic
FAIL: elf/ifuncmain1pie
FAIL: elf/ifuncmain1staticpic
FAIL: elf/ifuncmain1staticpie
FAIL: elf/ifuncmain1vis
FAIL: elf/ifuncmain1vispic
FAIL: elf/ifuncmain1vispie
FAIL: elf/ifuncmain2pic
FAIL: elf/ifuncmain2picstatic
FAIL: elf/ifuncmain3
FAIL: elf/ifuncmain4picstatic
FAIL: elf/ifuncmain5
FAIL: elf/ifuncmain5picstatic
FAIL: elf/ifuncmain5staticpic

The solution is to replace the beqlr instructions by a beq to the end
of the inline asm code. This fixes all the above failures.

ChangeLog:
	* sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Replace beqlr instructions
	by beq instructions jumping to the end of the function.

(cherry picked from commit ee71e5b6dd)
2016-08-14 22:48:18 +02:00
Tulio Magno Quites Machado Filho c3e9a246c1 Remove assert if DT_RUNPATH and DT_RPATH flags are found in ld.so 2016-08-10 18:39:21 -03:00
Carlos O'Donell ea23815a79 Update from Translation Project. 2016-08-04 12:21:42 -04:00
Florian Weimer 96cd434f66 malloc: Preserve arena free list/thread count invariant [BZ #20370]
It is necessary to preserve the invariant that if an arena is
on the free list, it has thread attach count zero.  Otherwise,
when arena_thread_freeres sees the zero attach count, it will
add it, and without the invariant, an arena could get pushed
to the list twice, resulting in a cycle.

One possible execution trace looks like this:

Thread 1 examines free list and observes it as empty.
Thread 2 exits and adds its arena to the free list,
  with attached_threads == 0).
Thread 1 selects this arena in reused_arena (not from the free list).
Thread 1 increments attached_threads and attaches itself.
  (The arena remains on the free list.)
Thread 1 exits, decrements attached_threads,
  and adds the arena to the free list.

The final step creates a cycle in the usual way (by overwriting the
next_free member with the former list head, while there is another
list item pointing to the arena structure).

tst-malloc-thread-exit exhibits this issue, but it was only visible
with a debugger because the incorrect fix in bug 19243 removed
the assert from get_free_list.

(cherry picked from commit f88aab5d50)
2016-08-04 11:49:55 +02:00
Florian Weimer d39c4a5ec0 x86: Use sysdep.o from libc.a in static libraries
Static libraries can use the sysdep.o copy in libc.a without
a performance penalty.  This results in a visible difference
if libpthread.a is relinked into a single object file (which
is needed to support libraries which check for the presence
of certain symbols to enable threading support, which generally
fails with static linking unless libpthread.a is relinked).

(cherry picked from commit e67330ab57)
2016-08-04 11:45:53 +02:00
358 changed files with 11678 additions and 2208 deletions
+894
View File
@@ -1,3 +1,897 @@
2017-12-14 Florian Weimer <fweimer@redhat.com>
[BZ #22607]
CVE-2017-1000409
* elf/dl-load.c (_dl_init_paths): Compute number of components in
the expanded path string.
2017-12-14 Florian Weimer <fweimer@redhat.com>
[BZ #22606]
CVE-2017-1000408
* elf/dl-load.c (system_dirs): Update comment.
(nsystem_dirs_len): Use array_length.
(_dl_init_paths): Use nsystem_dirs_len to compute the array size.
2017-11-02 Florian Weimer <fweimer@redhat.com>
Add array_length and array_end macros.
* include/array_length.h: New file.
2017-11-02 Florian Weimer <fweimer@redhat.com>
[BZ #22332]
* posix/tst-glob-tilde.c (do_noescape): New variable.
(one_test): Process it.
(do_test): Set do_noescape. Add unescaping test case.
2017-10-22 Paul Eggert <eggert@cs.ucla.edu>
[BZ #22332]
* posix/glob.c (__glob): Fix buffer overflow during GLOB_TILDE
unescaping.
2017-10-21 Florian Weimer <fweimer@redhat.com>
* posix/Makefile (tests): Add tst-glob-tilde.
(tests-special): Add tst-glob-tilde-mem.out
(tst-glob-tilde-ENV): Set MALLOC_TRACE.
(tst-glob-tilde-mem.out): Add mtrace check.
* posix/tst-glob-tilde.c: New file.
2017-10-20 Paul Eggert <eggert@cs.ucla.edu>
[BZ #22320]
CVE-2017-15670
* posix/glob.c (__glob): Fix one-byte overflow.
2017-09-08 Adhemerval Zanella <adhemerval.zanella@linaro.org>
[BZ #1062]
CVE-2017-15671
* posix/Makefile (routines): Add globfree, globfree64, and
glob_pattern_p.
* posix/flexmember.h: New file.
* posix/glob_internal.h: Likewise.
* posix/glob_pattern_p.c: Likewise.
* posix/globfree.c: Likewise.
* posix/globfree64.c: Likewise.
* sysdeps/gnu/globfree64.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/globfree.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/globfree64.c: Likewise.
* sysdeps/unix/sysv/linux/oldglob.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/globfree64.c: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/globfree.c: Likewise.
* sysdeps/wordsize-64/globfree.c: Likewise.
* sysdeps/wordsize-64/globfree64.c: Likewise.
* posix/glob.c (HAVE_CONFIG_H): Use !_LIBC instead.
[NDEBUG): Remove comments.
(GLOB_ONLY_P, _AMIGA, VMS): Remove define.
(dirent_type): New type. Use uint_fast8_t not
uint8_t, as C99 does not require uint8_t.
(DT_UNKNOWN, DT_DIR, DT_LNK): New macros.
(struct readdir_result): Use dirent_type. Do not define skip_entry
unless it is needed; this saves a byte on platforms lacking d_ino.
(readdir_result_type, readdir_result_skip_entry):
New functions, replacing ...
(readdir_result_might_be_symlink, readdir_result_might_be_dir):
these functions, which were removed. This makes the callers
easier to read. All callers changed.
(D_INO_TO_RESULT): Now empty if there is no d_ino.
(size_add_wrapv, glob_use_alloca): New static functions.
(glob, glob_in_dir): Check for size_t overflow in several places,
and fix some size_t checks that were not quite right.
Remove old code using SHELL since Bash no longer
uses this.
(glob, prefix_array): Separate MS code better.
(glob_in_dir): Remove old Amiga and VMS code.
(globfree, __glob_pattern_type, __glob_pattern_p): Move to
separate files.
(glob_in_dir): Do not rely on undefined behavior in accessing
struct members beyond their bounds. Use a flexible array member
instead
(link_stat): Rename from link_exists2_p and return -1/0 instead of
0/1. Caller changed.
(glob): Fix memory leaks.
* posix/glob64 (globfree64): Move to separate file.
* sysdeps/gnu/glob64.c (NO_GLOB_PATTERN_P): Remove define.
(globfree64): Remove hidden alias.
* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Add
oldglob.
* sysdeps/unix/sysv/linux/alpha/glob.c (__new_globfree): Move to
separate file.
* sysdeps/unix/sysv/linux/i386/glob64.c (NO_GLOB_PATTERN_P): Remove
define.
Move compat code to separate file.
* sysdeps/wordsize-64/glob.c (globfree): Move definitions to
separate file.
2017-08-20 H.J. Lu <hongjiu.lu@intel.com>
[BZ #18822]
* sysdeps/unix/sysv/linux/i386/glob64.c (__old_glob64): Add
libc_hidden_proto and libc_hidden_def.
2017-10-22 H.J. Lu <hongjiu.lu@intel.com>
[BZ #21265]
* sysdeps/x86/cpu-features-offsets.sym (XSAVE_STATE_SIZE_OFFSET):
New.
* sysdeps/x86/cpu-features.c: Include <libc-internal.h>.
(get_common_indeces): Set xsave_state_size and
bit_arch_XSAVEC_Usable if needed.
(init_cpu_features): Remove bit_arch_Use_dl_runtime_resolve_slow
and bit_arch_Use_dl_runtime_resolve_opt.
* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
Removed.
(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
(bit_arch_Prefer_No_AVX512): Updated.
(bit_arch_MathVec_Prefer_No_AVX512): Likewise.
(bit_arch_XSAVEC_Usable): New.
(STATE_SAVE_OFFSET): Likewise.
(STATE_SAVE_MASK): Likewise.
[__ASSEMBLER__]: Include <cpu-features-offsets.h>.
(cpu_features): Add xsave_state_size.
(index_arch_Use_dl_runtime_resolve_opt): Removed.
(index_arch_Use_dl_runtime_resolve_slow): Likewise.
(index_arch_XSAVEC_Usable): New.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Replace _dl_runtime_resolve_sse, _dl_runtime_resolve_avx,
_dl_runtime_resolve_avx_slow, _dl_runtime_resolve_avx_opt,
_dl_runtime_resolve_avx512 and _dl_runtime_resolve_avx512_opt
with _dl_runtime_resolve_fxsave, _dl_runtime_resolve_xsave and
_dl_runtime_resolve_xsavec.
* sysdeps/x86_64/dl-trampoline.S (DL_RUNTIME_UNALIGNED_VEC_SIZE):
Removed.
(DL_RUNTIME_RESOLVE_REALIGN_STACK): Check STATE_SAVE_ALIGNMENT
instead of VEC_SIZE.
(REGISTER_SAVE_BND0): Removed.
(REGISTER_SAVE_BND1): Likewise.
(REGISTER_SAVE_BND3): Likewise.
(REGISTER_SAVE_RAX): Always defined to 0.
(VMOV): Removed.
(_dl_runtime_resolve_avx): Likewise.
(_dl_runtime_resolve_avx_slow): Likewise.
(_dl_runtime_resolve_avx_opt): Likewise.
(_dl_runtime_resolve_avx512): Likewise.
(_dl_runtime_resolve_avx512_opt): Likewise.
(_dl_runtime_resolve_sse): Likewise.
(_dl_runtime_resolve_sse_vex): Likewise.
(USE_FXSAVE): New.
(_dl_runtime_resolve_fxsave): Likewise.
(USE_XSAVE): Likewise.
(_dl_runtime_resolve_xsave): Likewise.
(USE_XSAVEC): Likewise.
(_dl_runtime_resolve_xsavec): Likewise.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx512):
Removed.
(_dl_runtime_resolve_avx512_opt): Likewise.
(_dl_runtime_resolve_avx): Likewise.
(_dl_runtime_resolve_avx_opt): Likewise.
(_dl_runtime_resolve_sse): Likewise.
(_dl_runtime_resolve_sse_vex): Likewise.
(_dl_runtime_resolve_fxsave): New.
(_dl_runtime_resolve_xsave): Likewise.
(_dl_runtime_resolve_xsavec): Likewise.
2017-10-19 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86_64/Makefile (tests): Add tst-sse, tst-avx and
tst-avx512.
(test-extras): Add tst-avx-aux and tst-avx512-aux.
(extra-test-objs): Add tst-avx-aux.o and tst-avx512-aux.o.
(modules-names): Add tst-ssemod, tst-avxmod and tst-avx512mod.
($(objpfx)tst-sse): New rule.
($(objpfx)tst-avx): Likewise.
($(objpfx)tst-avx512): Likewise.
(CFLAGS-tst-avx-aux.c): New.
(CFLAGS-tst-avxmod.c): Likewise.
(CFLAGS-tst-avx512-aux.c): Likewise.
(CFLAGS-tst-avx512mod.c): Likewise.
* sysdeps/x86_64/tst-avx-aux.c: New file.
* sysdeps/x86_64/tst-avx.c: Likewise.
* sysdeps/x86_64/tst-avx512-aux.c: Likewise.
* sysdeps/x86_64/tst-avx512.c: Likewise.
* sysdeps/x86_64/tst-avx512mod.c: Likewise.
* sysdeps/x86_64/tst-avxmod.c: Likewise.
* sysdeps/x86_64/tst-sse.c: Likewise.
* sysdeps/x86_64/tst-ssemod.c: Likewise.
2017-10-19 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Don't
adjust CFA when allocating register save area on re-aligned
stack.
2016-12-21 Joseph Myers <joseph@codesourcery.com>
[BZ #20978]
* nis/nss_nisplus/nisplus-alias.c (_nss_nisplus_getaliasbyname_r):
Compare name == NULL, not name != NULL.
2016-11-08 Joseph Myers <joseph@codesourcery.com>
[BZ #20790]
* sunrpc/rpc_parse.c (get_prog_declaration): Increase buffer size
to MAXLINESIZE.
* sunrpc/bug20790.x: New file.
* sunrpc/Makefile [$(run-built-tests) = yes] (rpcgen-tests): New
variable.
[$(run-built-tests) = yes] (tests-special): Add $(rpcgen-tests).
[$(run-built-tests) = yes] ($(rpcgen-tests)): New rule.
2016-10-14 Steve Ellcey <sellcey@caviumnetworks.com>
* sysdeps/ieee754/dbl-64/e_pow.c (checkint) Make conditions explicitly
boolean.
2017-07-19 DJ Delorie <dj@delorie.com>
[BZ #21654]
* grp/grp-merge.c (libc_hidden_def): Fix cast-after-dereference.
2017-07-14 DJ Delorie <dj@redhat.com>
[BZ #21654]
* grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
alignment not char alignment.
(__merge_grp): Likewise.
2017-08-06 H.J. Lu <hongjiu.lu@intel.com>
[BZ #21871]
* sysdeps/x86/cpu-features.c (init_cpu_features): Set
bit_arch_Use_dl_runtime_resolve_opt only with AVX512F.
2017-02-27 Florian Weimer <fweimer@redhat.com>
[BZ #21115]
* sunrpc/clnt_udp.c (clntudp_call): Free ancillary data later.
* sunrpc/Makefile (tests): Add tst-udp-error.
(tst-udp-error): Link against libc.so explicitly.
* sunrpc/tst-udp-error: New file.
2017-01-24 James Clarke <jrtc27@jrtc27.com>
* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym: Use new REG_R*
constants instead of the old R* ones.
* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym: Likewise.
* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGPREG): Rename...
(NGREG): ... to this, to fit in with other architectures.
(gpregset_t): Use new NGREG macro.
[__USE_GNU]: Remove condition; all architectures other than tile
are unconditional.
(R*): Rename to REG_R*.
2017-07-26 H.J. Lu <hongjiu.lu@intel.com>
[BZ #21666]
* misc/regexp.c (loc1): Add __attribute__ ((nocommon));
(loc2): Likewise.
(locs): Likewise.
2017-07-12 Szabolcs Nagy <szabolcs.nagy@arm.com>
* sysdeps/aarch64/dl-machine.h (RTLD_START_1): Change _dl_argv to the
hidden __GI__dl_argv symbol.
2016-09-05 Aurelien Jarno <aurelien@aurel32.net>
* conform/Makefile (conformtest-header-tests): Pass -I. to $(PERL).
(linknamespace-symlists-tests): Likewise.
(linknamespace-header-tests): Likewise.
2017-07-06 Florian Weimer <fweimer@redhat.com>
H.J. Lu <hongjiu.lu@intel.com>
[BZ #21609]
* sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
(gen-as-const-headers): Add rtld-offsets.sym.
* sysdeps/x86_64/dl-tls.c: New file.
* sysdeps/x86_64/rtld-offsets.sym: Likwise.
* sysdeps/x86_64/tls_get_addr.S: Likewise.
* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
* sysdeps/x86_64/tlsdesc.sym (TI_MODULE_OFFSET): New.
(TI_OFFSET_OFFSET): Likwise.
2017-06-14 Florian Weimer <fweimer@redhat.com>
* sysdeps/i386/i686/multiarch/strcspn-c.c: Add IS_IN (libc) guard.
* sysdeps/i386/i686/multiarch/varshift.c: Likewise.
2017-03-07 Siddhesh Poyarekar <siddhesh@sourceware.org>
[BZ #21209]
* elf/rtld.c (process_envvars): Ignore LD_HWCAP_MASK for
AT_SECURE processes.
* sysdeps/generic/unsecvars.h: Add LD_HWCAP_MASK.
2017-06-19 Florian Weimer <fweimer@redhat.com>
* elf/rtld.c (audit_list_string): New variable.
(audit_list): Update comment.
(struct audit_list_iter): Define.
(audit_list_iter_init, audit_list_iter_next): New function.
(dl_main): Use struct audit_list_iter to process audit modules.
(process_dl_audit): Call dso_name_valid_for_suid.
(process_envvars): Set audit_list_string instead of calling
process_dl_audit.
2017-06-19 Florian Weimer <fweimer@redhat.com>
* elf/rtld.c (SECURE_NAME_LIMIT, SECURE_PATH_LIMIT): Define.
(dso_name_valid_for_suid): New function.
(handle_ld_preload): Likewise.
(dl_main): Call it. Remove alloca.
2017-06-19 Florian Weimer <fweimer@redhat.com>
[BZ #21624]
CVE-2017-1000366
* elf/rtld.c (process_envvars): Ignore LD_LIBRARY_PATH for
__libc_enable_secure.
2017-02-01 Andreas Schwab <schwab@linux-m68k.org>
* sysdeps/m68k/m680x0/m68020/atomic-machine.h
(__arch_compare_and_exchange_val_64_acq, atomic_exchange_acq)
(atomic_exchange_and_add, atomic_add): Add casts to 64 bit asm
operands.
2017-05-12 Florian Weimer <fweimer@redhat.com>
[BZ #21386]
* sysdeps/nptl/fork.c (__libc_fork): Remove assertions on the
parent PID. The assertion in the child is incorrect with PID
namespaces.
2017-06-07 Arjun Shankar <arjun.is@lostca.se>
* sysdeps/unix/sysv/linux/tst-clone2.c: Do not
include test-skeleton.c.
Include support/check.h and support/test-driver.c.
2016-11-24 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/nptl/fork.c (__libc_fork): Remove pid cache setting.
* nptl/allocatestack.c (allocate_stack): Likewise.
(__reclaim_stacks): Likewise.
(setxid_signal_thread): Obtain pid through syscall.
* nptl/nptl-init.c (sigcancel_handler): Likewise.
(sighandle_setxid): Likewise.
* nptl/pthread_cancel.c (pthread_cancel): Likewise.
* sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise.
* sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
Likewise.
* sysdeps/unix/sysv/linux/createthread.c (create_thread): Likewise.
* sysdeps/unix/sysv/linux/raise.c (raise): Remove old behaviour
comment.
* sysdeps/unix/sysv/linux/getpid.c: Remove file.
* nptl/descr.h (struct pthread): Change comment about pid value.
* nptl/pthread_getattr_np.c (pthread_getattr_np): Remove thread
pid assert.
* sysdeps/unix/sysv/linux/pthread-pids.h (__pthread_initialize_pids):
Do not set pid value.
* nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove thread
pid cache check.
* nptl_db/td_thr_validate.c (td_thr_validate): Likewise.
* sysdeps/aarch64/nptl/tcb-offsets.sym: Remove pid offset.
* sysdeps/alpha/nptl/tcb-offsets.sym: Likewise.
* sysdeps/arm/nptl/tcb-offsets.sym: Likewise.
* sysdeps/hppa/nptl/tcb-offsets.sym: Likewise.
* sysdeps/i386/nptl/tcb-offsets.sym: Likewise.
* sysdeps/ia64/nptl/tcb-offsets.sym: Likewise.
* sysdeps/m68k/nptl/tcb-offsets.sym: Likewise.
* sysdeps/microblaze/nptl/tcb-offsets.sym: Likewise.
* sysdeps/mips/nptl/tcb-offsets.sym: Likewise.
* sysdeps/nios2/nptl/tcb-offsets.sym: Likewise.
* sysdeps/powerpc/nptl/tcb-offsets.sym: Likewise.
* sysdeps/s390/nptl/tcb-offsets.sym: Likewise.
* sysdeps/sh/nptl/tcb-offsets.sym: Likewise.
* sysdeps/sparc/nptl/tcb-offsets.sym: Likewise.
* sysdeps/tile/nptl/tcb-offsets.sym: Likewise.
* sysdeps/x86_64/nptl/tcb-offsets.sym: Likewise.
* sysdeps/unix/sysv/linux/aarch64/clone.S: Remove pid and tid caching.
* sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
* sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
* sysdeps/unix/sysv/linux/hppa/clone.S: Likewise.
* sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
* sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
* sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
* sysdeps/unix/sysv/linux/nios2/clone.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/tile/clone.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/aarch64/vfork.S: Remove pid set and reset.
* sysdeps/unix/sysv/linux/alpha/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/arm/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/ia64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
* sysdeps/unix/sysv/linux/m68k/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/mips/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/nios2/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sh/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/tile/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/hppa/pt-vfork.S: Likewise.
* sysdeps/unix/sysv/linux/tst-clone2.c (f): Remove direct pthread
struct access.
(clone_test): Remove function.
(do_test): Rewrite to take in consideration pid is not cached anymore.
2016-09-26 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/unix/sysdep.h (__INTERNAL_SYSCALL0): New macro.
(__INTERNAL_SYSCALL1): Likewise.
(__INTERNAL_SYSCALL2): Likewise.
(__INTERNAL_SYSCALL3): Likewise.
(__INTERNAL_SYSCALL4): Likewise.
(__INTERNAL_SYSCALL5): Likewise.
(__INTERNAL_SYSCALL6): Likewise.
(__INTERNAL_SYSCALL7): Likewise.
(__INTERNAL_SYSCALL_NARGS_X): Likewise.
(__INTERNAL_SYSCALL_NARGS): Likewise.
(__INTERNAL_SYSCALL_DISP): Likewise.
(INTERNAL_SYSCALL_CALL): Likewise.
(__SYSCALL0): Rename to __INLINE_SYSCALL0.
(__SYSCALL1): Rename to __INLINE_SYSCALL1.
(__SYSCALL2): Rename to __INLINE_SYSCALL2.
(__SYSCALL3): Rename to __INLINE_SYSCALL3.
(__SYSCALL4): Rename to __INLINE_SYSCALL4.
(__SYSCALL5): Rename to __INLINE_SYSCALL5.
(__SYSCALL6): Rename to __INLINE_SYSCALL6.
(__SYSCALL7): Rename to __INLINE_SYSCALL7.
(__SYSCALL_NARGS_X): Rename to __INLINE_SYSCALL_NARGS_X.
(__SYSCALL_NARGS): Rename to __INLINE_SYSCALL_NARGS.
(__SYSCALL_DISP): Rename to __INLINE_SYSCALL_DISP.
(__SYSCALL_CALL): Rename to INLINE_SYSCALL_CALL.
(SYSCALL_CANCEL): Replace __SYSCALL_CALL with INLINE_SYSCALL_CALL.
2017-04-28 H.J. Lu <hongjiu.lu@intel.com>
[BZ #21396]
* sysdeps/x86/cpu-features.c (init_cpu_features): Set
Prefer_No_AVX512 if AVX512ER isn't available.
* sysdeps/x86/cpu-features.h (bit_arch_Prefer_No_AVX512): New.
(index_arch_Prefer_No_AVX512): Likewise.
* sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Don't use
AVX512 version if Prefer_No_AVX512 is set.
* sysdeps/x86_64/multiarch/memcpy_chk.S (__memcpy_chk):
Likewise.
* sysdeps/x86_64/multiarch/memmove.S (__libc_memmove): Likewise.
* sysdeps/x86_64/multiarch/memmove_chk.S (__memmove_chk):
Likewise.
* sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Likewise.
* sysdeps/x86_64/multiarch/mempcpy_chk.S (__mempcpy_chk):
Likewise.
* sysdeps/x86_64/multiarch/memset.S (memset): Likewise.
* sysdeps/x86_64/multiarch/memset_chk.S (__memset_chk):
Likewise.
2017-04-28 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86/cpu-features.c (init_cpu_features): Set
Prefer_No_VZEROUPPER if AVX512ER is available.
* sysdeps/x86/cpu-features.h
(bit_cpu_AVX512PF): New.
(bit_cpu_AVX512ER): Likewise.
(bit_cpu_AVX512CD): Likewise.
(bit_cpu_AVX512BW): Likewise.
(bit_cpu_AVX512VL): Likewise.
(index_cpu_AVX512PF): Likewise.
(index_cpu_AVX512ER): Likewise.
(index_cpu_AVX512CD): Likewise.
(index_cpu_AVX512BW): Likewise.
(index_cpu_AVX512VL): Likewise.
(reg_AVX512PF): Likewise.
(reg_AVX512ER): Likewise.
(reg_AVX512CD): Likewise.
(reg_AVX512BW): Likewise.
(reg_AVX512VL): Likewise.
2016-08-26 Florian Weimer <fweimer@redhat.com>
[BZ #20432]
Avoid strong references to malloc-internal symbols when linking
statically, to support statically interposed mallocs.
* include/libc-symbols.h (call_function_static_weak): New macro.
* malloc/Makefile (extra-tests-objs): Add tst-interpose-aux-nothread.o,
tst-interpose-aux-thread.o.
(test-extras): Add tst-interpose-aux-nothread,
tst-interpose-aux-thread.
* malloc/tst-interpose-aux-nothread.c: New file.
* malloc/tst-interpose-aux-thread.c: Likewise.
* malloc/tst-interpose-aux.c: Likewise.
* malloc/tst-interpose-aux.h: Likewise.
* sysdeps/mach/hurd/fork.c (__fork): Only call
__malloc_fork_lock_parent, __malloc_fork_unlock_parent,
__malloc_fork_unlock_child if defined.
* sysdeps/nptl/fork.c (__libc_fork): Likewise.
2016-08-02 Florian Weimer <fweimer@redhat.com>
[BZ #19469]
* malloc/Makefile (CPPFLAGS): Compile tests with
-DTEST_NO_MALLOPT.
* test-skeleton.c (main): Only call mallopt if !TEST_NO_MALLOPT.
2017-01-05 Joseph Myers <joseph@codesourcery.com>
[BZ #21026]
* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
(readahead): New syscall entry.
2017-04-07 H.J. Lu <hongjiu.lu@intel.com>
[BZ #21258]
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve_opt):
Define only if _dl_runtime_resolve is defined to
_dl_runtime_resolve_sse_vex.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_opt):
Fallthrough to _dl_runtime_resolve_sse_vex.
2017-04-03 Mike Frysinger <vapier@gentoo.org>
[BZ #21253]
* sysdeps/unix/sysv/linux/spawni.c (__spawnix): Increase argv_size
slack space by 32KiB.
2017-03-31 Slava Barinov <v.barinov@samsung.com>
[BZ #21289]
* io/fts.h (fts_set): Replace __REDIRECT with __REDIRECT_NTH.
2017-03-20 Mike Frysinger <vapier@gentoo.org>
[BZ #21275]
* sysdeps/unix/sysv/linux/spawni.c [__ia64__] (CLONE): Rename
__stack to __stackbase.
(STACK): Invert _STACK_GROWS_DOWN and _STACK_GROWS_UP order of
checks so we can include defined(__ia64__) first.
2017-03-15 John David Anglin <danglin@gcc.gnu.org>
* sysdeps/hppa/dl-machine.h (DL_STACK_END): Define.
(RTLD_START): Don't record stack end address in _dl_start_user.
2017-01-30 H.J. Lu <hongjiu.lu@intel.com>
[BZ #21081]
* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(L(stosb)): Add VZEROUPPER before ret.
2016-11-28 H.J. Lu <hongjiu.lu@intel.com>
[BZ #20750]
* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
of PIC.
2016-12-31 Florian Weimer <fweimer@redhat.com>
[BZ #18784]
CVE-2015-5180
* include/arpa/nameser_compat.h (T_QUERY_A_AND_AAAA): Rename from
T_UNSPEC. Adjust value.
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname4_r): Use it.
* resolv/res_query.c (__libc_res_nquery): Likewise.
* resolv/res_mkquery.c (res_nmkquery): Check for out-of-range
QTYPEs.
* resolv/tst-resolv-qtypes.c: New file.
* resolv/Makefile (xtests): Add tst-resolv-qtypes.
(tst-resolv-qtypes): Link against libresolv and libpthread.
2017-02-02 Siddhesh Poyarekar <siddhesh@sourceware.org>
* sysdeps/generic/unsecvars.h: Add GLIBC_TUNABLES.
2017-01-23 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Steven Munroe <sjmunroe@us.ibm.com>
Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
[BZ #20822]
* sysdeps/unix/sysv/linux/powerpc/elision-lock.c
(__lll_lock_elision): Access adapt_count via C11 atomics.
* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
(__lll_trylock_elision): Likewise.
* sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
(__lll_unlock_elision): Update adapt_count variable inside the
critical section using C11 atomics.
2016-12-24 Carlos O'Donell <carlos@redhat.com>
[BZ #11941]
* elf/dl-close.c (_dl_close): Take dl_load_lock to examine map.
Remove assert (map->l_init_called); if DF_1_NODELETE is set.
* elf/Makefile [ifeq (yes,$(build-shared))] (tests): Add
tst-nodelete-dlclose.
(modules-names): Add tst-nodelete-dlclose-dso and
tst-nodelete-dlclose-plugin.
($(objpfx)tst-nodelete-dlclose-dso.so): Define.
($(objpfx)tst-nodelete-dlclose-plugin.so): Define.
($(objpfx)tst-nodelete-dlclose): Define.
($(objpfx)tst-nodelete-dlclose.out): Define.
2016-08-02 Aurelien Jarno <aurelien@aurel32.net>
2016-08-02 Aurelien Jarno <aurelien@aurel32.net>
* sysdeps/alpha/fpu/s_ceil.c (__ceil): Add argument with itself
when it is a NaN.
[_IEEE_FP_INEXACT] Remove.
* sysdeps/alpha/fpu/s_ceilf.c (__ceilf): Likewise.
* sysdeps/alpha/fpu/s_floor.c (__floor): Add argument with itself
when it is a NaN.
[_IEEE_FP_INEXACT] Remove.
* sysdeps/alpha/fpu/s_floorf.c (__floorf): Likewise.
* sysdeps/alpha/fpu/s_rint.c (__rint): Add argument with itself
when it is a NaN.
* sysdeps/alpha/fpu/s_rintf.c (__rintf): Likewise.
* sysdeps/alpha/fpu/s_trunc.c (__trunc): Return the input value
when its absolute value is greater than 0x1.0p52.
[_IEEE_FP_INEXACT] Remove.
* sysdeps/alpha/fpu/s_truncf.c (__truncf): Return the input value
when its absolute value is greater than 0x1.0p23.
[_IEEE_FP_INEXACT] Remove.
2016-11-30 H.J. Lu <hongjiu.lu@intel.com>
[BZ #20495]
[BZ #20508]
* sysdeps/x86/cpu-features.c (init_cpu_features): For Intel
processors, set Use_dl_runtime_resolve_slow and set
Use_dl_runtime_resolve_opt if XGETBV suports ECX == 1.
* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
New.
(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
(index_arch_Use_dl_runtime_resolve_opt): Likewise.
(index_arch_Use_dl_runtime_resolve_slow): Likewise.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup): Use
_dl_runtime_resolve_avx512_opt and _dl_runtime_resolve_avx_opt
if Use_dl_runtime_resolve_opt is set. Use
_dl_runtime_resolve_slow if Use_dl_runtime_resolve_slow is set.
* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features.h>.
(_dl_runtime_resolve_opt): New. Defined for AVX and AVX512.
(_dl_runtime_resolve): Add one for _dl_runtime_resolve_sse_vex.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx_slow):
New.
(_dl_runtime_resolve_opt): Likewise.
(_dl_runtime_profile): Define only if _dl_runtime_profile is
defined.
2016-11-24 Aurelien Jarno <aurelien@aurel32.net>
* sysdeps/x86_64/memcpy_chk.S (__memcpy_chk): Check for SHARED
instead of PIC.
2016-11-23 Matthew Fortune <Matthew.Fortune@imgtec.com>
Maciej W. Rozycki <macro@imgtec.com>
* sysdeps/mips/mips32/crti.S (_init): Add `.insn' pseudo-op at
`.Lno_weak_fn' label.
* sysdeps/mips/mips64/n32/crti.S (_init): Likewise.
* sysdeps/mips/mips64/n64/crti.S (_init): Likewise.
2016-11-22 Adhemerval Zanella <adhemerva.zanella@linaro.org>
[BZ #20847]
* posix/execvpe.c (maybe_script_execute): Remove write past allocated
array bounds.
(__execvpe): Likewise.
2016-11-15 Denis Kaganovich <mahatma@eu.by>
Magnus Granberg <zorry@gentoo.org>
Mike Frysinger <vapier@gentoo.org>
[BZ #20662]
* configure.ac (libc_cv_predef_stack_protector): Also check for
__stack_chk_fail_local symbols.
* configure: Regenerated.
2016-11-03 Joseph Myers <joseph@codesourcery.com>
* conform/Makefile ($(linknamespace-header-tests)): Also depend on
$(linknamespace-symlists-tests).
2016-11-06 Aurelien Jarno <aurelien@aurel32.net>
* iconv/gconv.h (__gconv_info): Define __data element using a
zero-length array.
2016-10-25 Joseph Myers <joseph@codesourcery.com>
* sysdeps/powerpc/powerpc32/power6/memset.S (memset): Use cmplwi
instead of cmpli.
* sysdeps/powerpc/powerpc64/power6/memset.S (memset): Use cmpldi
instead of cmpli.
2016-10-24 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/unix/sysv/linux/pread.c (__libc_pread): Use SYSCALL_LL_PRW.
* sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise.
* sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Use
SYSCALL_LL64_PRW.
* sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h: Define
__ASSUME_PRW_DUMMY_ARG.
* sysdeps/unix/sysv/linux/sh/pread.c: Remove file.
* sysdeps/unix/sysv/linux/sh/pread64.c: Likewise.
* sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise.
* sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise.
* sysdeps/unix/sysv/linux/sysdep.h: Define SYSCALL_LL_PRW and
SYSCALL_LL_PRW64 based on __ASSUME_PRW_DUMMY_ARG.
2016-10-05 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* sysdeps/powerpc/fpu/libm-test-ulps: Regenerated.
2016-09-20 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/unix/sysv/linux/spawni.c (__spawnix): Correctly block and unblock
all signals when executing the clone vfork child.
(SIGALL_SET): Remove macro.
* nptl/Makefile (tests): Add tst-exec5.
* nptl/tst-exec5.c: New file.
* sysdeps/unix/sysv/linux/spawni.c (__spawni): Correctly enable and disable
asynchronous cancellation.
2016-10-18 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* sysdeps/powerpc/powerpc64/power8/fpu/math_private.h (GET_FLOAT_WORD):
(SET_FLOAT_WORD): New macros.
2016-09-19 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
[BZ #20615]
* sysdeps/powerpc/powerpc32/power9/multiarch/Implies: Replace
fpu directory by non-fpu.
* sysdeps/powerpc/powerpc64/power9/fpu/Implies: Remove dependency
on non-fpu directory from a fpu directory.
2016-09-02 Roland McGrath <roland@hack.frob.com>
* sysdeps/arm/nacl/libc.abilist: Add GLIBC_2.24 A.
* sysdeps/nacl/dup.c: Add libc_hidden_def.
2016-09-02 Roland McGrath <roland@hack.frob.com>
* sysdeps/posix/wait3.c: Don't treat STAT_LOC as a union, since it's
not any more.
2016-09-02 Roland McGrath <roland@hack.frob.com>
* sysdeps/nacl/clock.c (clock): nacl_abi_clock_t -> nacl_irt_clock_t
2016-08-17 Florian Weimer <fweimer@redhat.com>
Reduce time to expected nptl/tst-once5 failure.
* nptl/tst-once5.cc (TIMEOUT): Define.
2016-08-18 Florian Weimer <fweimer@redhat.com>
[BZ #16907]
* argp/argp.h: Switch to __BEGIN_DECLS and __END_DECLS.
(__THROW, __NTH, __attribute__, __restrict): Remove definitions.
* argp/argp-fmtstream.h: Add __BEGIN_DECLS and __END_DECLS.
(__attribute__): Remove definition.
2016-08-15 Andreas Schwab <schwab@suse.de>
[BZ #20435]
* sysdeps/unix/sysv/linux/arm/setcontext.S (__startcontext): Mark
as .cantunwind.
2016-08-17 Florian Weimer <fweimer@redhat.com>
[BZ #20452]
Avoid additional copies of objects in libc.a in static libraries.
* sysdeps/ia64/nptl/Makefile (libpthread-shared-only-routines):
Add ptw-sysdep, ptw-sigblock, ptw-sigprocmask.
* sysdeps/mips/Makefile (librt-shared-only-routines): Add
rt-sysdep.
* sysdeps/mips/nptl/Makefile (libpthread-shared-only-routines):
Add nptl-sysdep.
* sysdeps/s390/nptl/Makefile (libpthread-shared-only-routines):
Add ptw-sysdep.
* sysdeps/unix/alpha/Makefile (librt-shared-only-routines): Add
rt-sysdep.
* sysdeps/unix/sysv/linux/alpha/Makefile
(libpthread-shared-only-routines): Add ptw-sysdep,
ptw-sigprocmask, ptw-rt_sigaction.
* sysdeps/unix/sysv/linux/ia64/Makefile
(librt-shared-only-routines): Add rt-sysdep.
* sysdeps/unix/sysv/linux/i386/Makefile
(libpthread-shared-only-routines): Add libc-do-syscall.
* sysdeps/unix/sysv/linux/microblaze/Makefile
(libpthread-shared-only-routines): Add sysdep.
* sysdeps/unix/sysv/linux/powerpc/Makefile
(librt-shared-only-routines): Add rt-sysdep.
(libpthread-shared-only-routines): Add sysdep.
* sysdeps/unix/sysv/linux/s390/Makefile
(librt-shared-only-routines): Add rt-sysdep.
* sysdeps/unix/sysv/linux/sparc/Makefile
(librt-shared-only-routines): Add rt-sysdep.
(libpthread-shared-only-routines): Add sysdep.
* sysdeps/unix/sysv/linux/tile/Makefile
(libpthread-shared-only-routines): Likewise.
2016-08-05 Aurelien Jarno <aurelien@aurel32.net>
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
[$(subdir) = math && $(have-as-vis3) = yes] (libm-sysdep_routines):
Remove s_fdimf-vis3, s_fdim-vis3.
* sysdeps/sparc/sparc32/fpu/s_fdim.S: Delete file.
* sysdeps/sparc/sparc32/fpu/s_fdimf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf-vis3.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdimf.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_fdim.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_fdimf.S: Likewise.
* sysdeps/sparc/sparc64/fpu/s_fdim.S: Likewise.
* sysdeps/sparc/sparc64/fpu/s_fdimf.S: Likewise.
2016-08-02 David S. Miller <davem@davemloft.net>
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
(__nearbyint_vis3): Don't check for sNaN before float register is
loaded with the incoming argument.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
(__nearbyintf_vis3): Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyint.S (__nearbyint):
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/s_nearbyintf.S (__nearbyintf):
Likewise.
2016-08-03 Aurelien Jarno <aurelien@aurel32.net>
* sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Replace beqlr instructions
by beq instructions jumping to the end of the function.
* sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Add "11", "12", "cr0" to the
clobber list. Use "i" constraint instead of "X".
(ifunc_one): Add "12" to the clobber list. Use "i" constraint instead
of "X".
2015-08-06 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* elf/get-dynamic-info.h (elf_get_dynamic_info): Remove assert
if DT_RUNPATH and DT_RPATH flags are found in ld.so.
2016-08-04 Carlos O'Donell <carlos@redhat.com>
* po/de.po: Update from Translation Project.
* po/fi.po: Likewise.
* po/sv.po: Likewise.
2016-08-02 Florian Weimer <fweimer@redhat.com>
[BZ #20370]
* malloc/arena.c (get_free_list): Update comment. Assert that
arenas on the free list have no attached threads.
(remove_from_free_list): New function.
(reused_arena): Call it.
2016-08-04 Florian Weimer <fweimer@redhat.com>
Use sysdep.o from libc.a in static libraries.
* sysdeps/unix/sysv/linux/i386/Makefile
(libpthread-shared-only-routines): Add sysdep.
(librt-shared-only-routines): Likewise.
2016-08-01 Carlos O'Donell <carlos@redhat.com>
* version.h (RELEASE): Set to "stable"
+12 -3
View File
@@ -394,6 +394,9 @@ ifndef after-link
after-link =
endif
# Additional libraries to link into every test.
link-extra-libs-tests = $(libsupport)
# Command for linking PIE programs with the C library.
ifndef +link-pie
+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
@@ -503,7 +506,7 @@ link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib)
link-libc-tests = $(link-libc-tests-rpath-link) \
$(link-libc-before-gnulib) $(gnulib-tests)
# This is how to find at build-time things that will be installed there.
rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec
rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec support
rpath-link = \
$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
else
@@ -850,7 +853,7 @@ libio-include = -I$(..)libio
# List of non-library modules that we build.
built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
libSegFault libpcprofile librpcsvc locale-programs \
memusagestat nonlib nscd extramodules libnldbl
memusagestat nonlib nscd extramodules libnldbl libsupport
in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
$(libof-$(<F)) \
@@ -1089,6 +1092,12 @@ libm = $(common-objpfx)math/libm.a
libmvec = $(common-objpfx)mathvec/libmvec.a
endif
ifeq ($(build-shared),yes)
libsupport = $(common-objpfx)support/libsupport_nonshared.a
else
libsupport = $(common-objpfx)support/libsupport.a
endif
# These are the subdirectories containing the library source. The order
# is more or less arbitrary. The sorting step will take care of the
# dependencies.
@@ -1096,7 +1105,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
stdlib stdio-common libio malloc string wcsmbs time dirent \
grp pwd posix io termios resource misc socket sysvipc gmon \
gnulib iconv iconvdata wctype manual shadow gshadow po argp \
crypt localedata timezone rt conform debug mathvec \
crypt localedata timezone rt conform debug mathvec support \
$(add-on-subdirs) dlfcn elf
ifndef avoid-generated
+52
View File
@@ -5,6 +5,58 @@ See the end for copying conditions.
Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
using `glibc' in the "product" field.
Version 2.24.1
Security related changes:
* On ARM EABI (32-bit), generating a backtrace for execution contexts which
have been created with makecontext could fail to terminate due to a
missing .cantunwind annotation. This has been observed to lead to a hang
(denial of service) in some Go applications compiled with gccgo. Reported
by Andreas Schwab. (CVE-2016-6323)
* The DNS stub resolver functions would crash due to a NULL pointer
dereference when processing a query with a valid DNS question type which
was used internally in the implementation. The stub resolver now uses a
question type which is outside the range of valid question type values.
(CVE-2015-5180)
* CVE-2017-15670: The glob function, when invoked with GLOB_TILDE, suffered
from a one-byte overflow during ~ operator processing (either on the stack
or the heap, depending on the length of the user name).
* CVE-2017-15671: The glob function, when invoked with GLOB_TILDE,
would sometimes fail to free memory allocated during ~ operator
processing, leading to a memory leak and, potentially, to a denial
of service.
* CVE-2017-15804: The glob function, when invoked with GLOB_TILDE and
without GLOB_NOESCAPE, could write past the end of a buffer while
unescaping user names. Reported by Tim Rühsen.
* CVE-2017-1000408: Incorrect array size computation in _dl_init_paths leads
to the allocation of too much memory. (This is not a security bug per se,
it is mentioned here only because of the CVE assignment.) Reported by
Qualys.
* CVE-2017-1000409: Buffer overflow in _dl_init_paths due to miscomputation
of the number of search path components. (This is not a security
vulnerability per se because no trust boundary is crossed if the fix for
CVE-2017-1000366 has been applied, but it is mentioned here only because
of the CVE assignment.) Reported by Qualys.
The following bugs are resolved with this release:
[20790] Fix rpcgen buffer overrun
[20978] Fix strlen on null pointer in nss_nisplus
[21209] Ignore and remove LD_HWCAP_MASK for AT_SECURE programs
[21265] x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve
[21289] Fix symbol redirect for fts_set
[21386] Assertion in fork for distinct parent PID is incorrect
[21609] x86-64: Align the stack in __tls_get_addr
[21624] Unsafe alloca allows local attackers to alias stack and heap (CVE-2017-1000366)
[21654] nss: Fix invalid cast in group merging
Version 2.24
* The minimum Linux kernel version that this version of the GNU C Library
+3
View File
@@ -149,6 +149,7 @@ endif
ifneq "$(strip $(binaries-shared-tests))" ""
$(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
$(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-tests)
@@ -156,6 +157,7 @@ endif
ifneq "$(strip $(binaries-pie-tests))" ""
$(addprefix $(objpfx),$(binaries-pie-tests)): %: %.o \
$(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-pie-tests)
@@ -177,6 +179,7 @@ endif
ifneq "$(strip $(binaries-static-tests))" ""
$(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
$(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc-static-tests))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-static-tests)
+4 -15
View File
@@ -29,21 +29,6 @@
#include <string.h>
#include <unistd.h>
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \
defined __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
defined __STRICT_ANSI__
# define __format__ format
# define __printf__ printf
# endif
#endif
#if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)
/* line_wrap_stream is available, so use that. */
#define ARGP_FMTSTREAM_USE_LINEWRAP
@@ -111,6 +96,8 @@ struct argp_fmtstream
typedef struct argp_fmtstream *argp_fmtstream_t;
__BEGIN_DECLS
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
written on it with LMARGIN spaces and limits them to RMARGIN columns
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
@@ -297,6 +284,8 @@ __argp_fmtstream_point (argp_fmtstream_t __fs)
#endif /* __OPTIMIZE__ */
__END_DECLS
#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
#endif /* argp-fmtstream.h */
+2 -40
View File
@@ -28,48 +28,12 @@
#define __need_error_t
#include <errno.h>
#ifndef __THROW
# define __THROW
#endif
#ifndef __NTH
# define __NTH(fct) fct __THROW
#endif
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \
defined __STRICT_ANSI__
# define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \
defined __STRICT_ANSI__
# define __format__ format
# define __printf__ printf
# endif
#endif
/* GCC 2.95 and later have "__restrict"; C99 compilers have
"restrict", and "configure" may have defined "restrict". */
#ifndef __restrict
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
# if defined restrict || 199901L <= __STDC_VERSION__
# define __restrict restrict
# else
# define __restrict
# endif
# endif
#endif
#ifndef __error_t_defined
typedef int error_t;
# define __error_t_defined
#endif
#ifdef __cplusplus
extern "C" {
#endif
__BEGIN_DECLS
/* A description of a particular option. A pointer to an array of
these is passed in the OPTIONS field of an argp structure. Each option
@@ -590,8 +554,6 @@ __NTH (__option_is_end (const struct argp_option *__opt))
# endif
#endif /* Use extern inlines. */
#ifdef __cplusplus
}
#endif
__END_DECLS
#endif /* argp.h */
Vendored
+5 -3
View File
@@ -6289,12 +6289,14 @@ echo >&5 "libc_undefs='$libc_undefs'"
# symbols (resolved by the linker), so filter out unknown symbols.
# This will fail to produce the correct result if the compiler
# defaults to -fstack-protector but this produces an undefined symbol
# other than __stack_chk_fail. However, compilers like that have not
# been encountered in practice.
libc_undefs=`echo "$libc_undefs" | egrep '^(foobar|__stack_chk_fail)$'`
# other than __stack_chk_fail or __stack_chk_fail_local. However,
# compilers like that have not been encountered in practice.
libc_undefs=`echo "$libc_undefs" | \
egrep '^(foobar|__stack_chk_fail|__stack_chk_fail_local)$'`
case "$libc_undefs" in
foobar) libc_cv_predef_stack_protector=no ;;
'__stack_chk_fail
foobar'|'__stack_chk_fail_local
foobar') libc_cv_predef_stack_protector=yes ;;
*) as_fn_error $? "unexpected symbols in test: $libc_undefs" "$LINENO" 5 ;;
esac
+5 -3
View File
@@ -1626,12 +1626,14 @@ echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
# symbols (resolved by the linker), so filter out unknown symbols.
# This will fail to produce the correct result if the compiler
# defaults to -fstack-protector but this produces an undefined symbol
# other than __stack_chk_fail. However, compilers like that have not
# been encountered in practice.
libc_undefs=`echo "$libc_undefs" | egrep '^(foobar|__stack_chk_fail)$'`
# other than __stack_chk_fail or __stack_chk_fail_local. However,
# compilers like that have not been encountered in practice.
libc_undefs=`echo "$libc_undefs" | \
egrep '^(foobar|__stack_chk_fail|__stack_chk_fail_local)$'`
case "$libc_undefs" in
foobar) libc_cv_predef_stack_protector=no ;;
'__stack_chk_fail
foobar'|'__stack_chk_fail_local
foobar') libc_cv_predef_stack_protector=yes ;;
*) AC_MSG_ERROR([unexpected symbols in test: $libc_undefs]) ;;
esac],
+4 -3
View File
@@ -196,13 +196,13 @@ $(conformtest-header-tests): $(objpfx)%/conform.out: \
conformtest.pl $(conformtest-headers-data)
(set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
mkdir -p $(@D)/scratch; \
$(PERL) conformtest.pl --tmpdir=$(@D)/scratch --cc='$(CC)' \
$(PERL) -I. conformtest.pl --tmpdir=$(@D)/scratch --cc='$(CC)' \
--flags='$(conformtest-cc-flags)' --standard=$$std \
--headers=$$hdr > $@); \
$(evaluate-test)
$(linknamespace-symlists-tests): $(objpfx)symlist-%: list-header-symbols.pl
$(PERL) -w $< --tmpdir=$(objpfx) --cc='$(CC)' \
$(PERL) -I. -w $< --tmpdir=$(objpfx) --cc='$(CC)' \
--flags='$(conformtest-cc-flags)' --standard=$* \
--headers="$(strip $(conformtest-headers-$*))" \
> $@ 2> $@.err; \
@@ -229,10 +229,11 @@ $(linknamespace-symlist-stdlibs-tests): $(objpfx)symlist-stdlibs-%: \
$(linknamespace-header-tests): $(objpfx)%/linknamespace.out: \
linknamespace.pl \
$(linknamespace-symlists-tests) \
$(linknamespace-symlist-stdlibs-tests)
(set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
mkdir -p $(@D)/scratch; \
$(PERL) -w $< --tmpdir=$(@D)/scratch --cc='$(CC)' \
$(PERL) -I. -w $< --tmpdir=$(@D)/scratch --cc='$(CC)' \
--flags='$(conformtest-cc-flags)' --standard=$$std \
--stdsyms=$(objpfx)symlist-$$std --header=$$hdr \
--libsyms=$(objpfx)symlist-stdlibs-$$std \
+13 -2
View File
@@ -149,7 +149,8 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
tst-nodelete) \
tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \
tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \
tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error
tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error \
tst-nodelete-dlclose
# reldep9
ifeq ($(build-hardcoded-path-in-tests),yes)
tests += tst-dlopen-aout
@@ -223,7 +224,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
tst-array5dep tst-null-argv-lib \
tst-tlsalign-lib tst-nodelete-opened-lib tst-nodelete2mod \
tst-audit11mod1 tst-audit11mod2 tst-auditmod11 \
tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12
tst-audit12mod1 tst-audit12mod2 tst-audit12mod3 tst-auditmod12 \
tst-nodelete-dlclose-dso tst-nodelete-dlclose-plugin
ifeq (yes,$(have-mtls-dialect-gnu2))
tests += tst-gnu2-tls1
modules-names += tst-gnu2-tls1mod
@@ -1267,3 +1269,12 @@ $(objpfx)tst-ldconfig-X.out : tst-ldconfig-X.sh $(objpfx)ldconfig
$(evaluate-test)
$(objpfx)tst-dlsym-error: $(libdl)
# The application depends on the DSO, and the DSO loads the plugin.
# The plugin also depends on the DSO. This creates the circular
# dependency via dlopen that we're testing to make sure works.
$(objpfx)tst-nodelete-dlclose-dso.so: $(libdl)
$(objpfx)tst-nodelete-dlclose-plugin.so: $(objpfx)tst-nodelete-dlclose-dso.so
$(objpfx)tst-nodelete-dlclose: $(objpfx)tst-nodelete-dlclose-dso.so
$(objpfx)tst-nodelete-dlclose.out: $(objpfx)tst-nodelete-dlclose-dso.so \
$(objpfx)tst-nodelete-dlclose-plugin.so
+24 -6
View File
@@ -805,19 +805,37 @@ _dl_close (void *_map)
{
struct link_map *map = _map;
/* First see whether we can remove the object at all. */
/* We must take the lock to examine the contents of map and avoid
concurrent dlopens. */
__rtld_lock_lock_recursive (GL(dl_load_lock));
/* At this point we are guaranteed nobody else is touching the list of
loaded maps, but a concurrent dlclose might have freed our map
before we took the lock. There is no way to detect this (see below)
so we proceed assuming this isn't the case. First see whether we
can remove the object at all. */
if (__glibc_unlikely (map->l_flags_1 & DF_1_NODELETE))
{
assert (map->l_init_called);
/* Nope. Do nothing. */
__rtld_lock_unlock_recursive (GL(dl_load_lock));
return;
}
/* At present this is an unreliable check except in the case where the
caller has recursively called dlclose and we are sure the link map
has not been freed. In a non-recursive dlclose the map itself
might have been freed and this access is potentially a data race
with whatever other use this memory might have now, or worse we
might silently corrupt memory if it looks enough like a link map.
POSIX has language in dlclose that appears to guarantee that this
should be a detectable case and given that dlclose should be threadsafe
we need this to be a reliable detection.
This is bug 20990. */
if (__builtin_expect (map->l_direct_opencount, 1) == 0)
GLRO(dl_signal_error) (0, map->l_name, NULL, N_("shared object not open"));
/* Acquire the lock. */
__rtld_lock_lock_recursive (GL(dl_load_lock));
{
__rtld_lock_unlock_recursive (GL(dl_load_lock));
_dl_signal_error (0, map->l_name, NULL, N_("shared object not open"));
}
_dl_close_worker (map, false);
+11 -16
View File
@@ -37,6 +37,7 @@
#include <sysdep.h>
#include <stap-probe.h>
#include <libc-internal.h>
#include <array_length.h>
#include <dl-dst.h>
#include <dl-load.h>
@@ -103,7 +104,9 @@ static size_t ncapstr attribute_relro;
static size_t max_capstrlen attribute_relro;
/* Get the generated information about the trusted directories. */
/* Get the generated information about the trusted directories. Use
an array of concatenated strings to avoid relocations. See
gen-trusted-dirs.awk. */
#include "trusted-dirs.h"
static const char system_dirs[] = SYSTEM_DIRS;
@@ -111,9 +114,7 @@ static const size_t system_dirs_len[] =
{
SYSTEM_DIRS_LEN
};
#define nsystem_dirs_len \
(sizeof (system_dirs_len) / sizeof (system_dirs_len[0]))
#define nsystem_dirs_len array_length (system_dirs_len)
static bool
is_trusted_path (const char *path, size_t len)
@@ -688,9 +689,8 @@ _dl_init_paths (const char *llp)
+ ncapstr * sizeof (enum r_dir_status))
/ sizeof (struct r_search_path_elem));
rtld_search_dirs.dirs[0] = (struct r_search_path_elem *)
malloc ((sizeof (system_dirs) / sizeof (system_dirs[0]))
* round_size * sizeof (struct r_search_path_elem));
rtld_search_dirs.dirs[0] = malloc (nsystem_dirs_len * round_size
* sizeof (*rtld_search_dirs.dirs[0]));
if (rtld_search_dirs.dirs[0] == NULL)
{
errstring = N_("cannot create cache for search path");
@@ -776,8 +776,6 @@ _dl_init_paths (const char *llp)
if (llp != NULL && *llp != '\0')
{
size_t nllp;
const char *cp = llp;
char *llp_tmp;
#ifdef SHARED
@@ -800,13 +798,10 @@ _dl_init_paths (const char *llp)
/* Decompose the LD_LIBRARY_PATH contents. First determine how many
elements it has. */
nllp = 1;
while (*cp)
{
if (*cp == ':' || *cp == ';')
++nllp;
++cp;
}
size_t nllp = 1;
for (const char *cp = llp_tmp; *cp != '\0'; ++cp)
if (*cp == ':' || *cp == ';')
++nllp;
env_path_list.dirs = (struct r_search_path_elem **)
malloc ((nllp + 1) * sizeof (struct r_search_path_elem *));
-3
View File
@@ -138,9 +138,6 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
|| (info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val & ~DF_1_NOW) == 0);
assert (info[DT_FLAGS] == NULL
|| (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
/* Flags must not be set for ld.so. */
assert (info[DT_RUNPATH] == NULL);
assert (info[DT_RPATH] == NULL);
#else
if (info[DT_FLAGS] != NULL)
{
+165 -33
View File
@@ -99,14 +99,121 @@ uintptr_t __pointer_chk_guard_local
strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
#endif
/* Length limits for names and paths, to protect the dynamic linker,
particularly when __libc_enable_secure is active. */
#ifdef NAME_MAX
# define SECURE_NAME_LIMIT NAME_MAX
#else
# define SECURE_NAME_LIMIT 255
#endif
#ifdef PATH_MAX
# define SECURE_PATH_LIMIT PATH_MAX
#else
# define SECURE_PATH_LIMIT 1024
#endif
/* List of auditing DSOs. */
/* Check that AT_SECURE=0, or that the passed name does not contain
directories and is not overly long. Reject empty names
unconditionally. */
static bool
dso_name_valid_for_suid (const char *p)
{
if (__glibc_unlikely (__libc_enable_secure))
{
/* Ignore pathnames with directories for AT_SECURE=1
programs, and also skip overlong names. */
size_t len = strlen (p);
if (len >= SECURE_NAME_LIMIT || memchr (p, '/', len) != NULL)
return false;
}
return *p != '\0';
}
/* LD_AUDIT variable contents. Must be processed before the
audit_list below. */
const char *audit_list_string;
/* Cyclic list of auditing DSOs. audit_list->next is the first
element. */
static struct audit_list
{
const char *name;
struct audit_list *next;
} *audit_list;
/* Iterator for audit_list_string followed by audit_list. */
struct audit_list_iter
{
/* Tail of audit_list_string still needing processing, or NULL. */
const char *audit_list_tail;
/* The list element returned in the previous iteration. NULL before
the first element. */
struct audit_list *previous;
/* Scratch buffer for returning a name which is part of
audit_list_string. */
char fname[SECURE_NAME_LIMIT];
};
/* Initialize an audit list iterator. */
static void
audit_list_iter_init (struct audit_list_iter *iter)
{
iter->audit_list_tail = audit_list_string;
iter->previous = NULL;
}
/* Iterate through both audit_list_string and audit_list. */
static const char *
audit_list_iter_next (struct audit_list_iter *iter)
{
if (iter->audit_list_tail != NULL)
{
/* First iterate over audit_list_string. */
while (*iter->audit_list_tail != '\0')
{
/* Split audit list at colon. */
size_t len = strcspn (iter->audit_list_tail, ":");
if (len > 0 && len < sizeof (iter->fname))
{
memcpy (iter->fname, iter->audit_list_tail, len);
iter->fname[len] = '\0';
}
else
/* Do not return this name to the caller. */
iter->fname[0] = '\0';
/* Skip over the substring and the following delimiter. */
iter->audit_list_tail += len;
if (*iter->audit_list_tail == ':')
++iter->audit_list_tail;
/* If the name is valid, return it. */
if (dso_name_valid_for_suid (iter->fname))
return iter->fname;
/* Otherwise, wrap around and try the next name. */
}
/* Fall through to the procesing of audit_list. */
}
if (iter->previous == NULL)
{
if (audit_list == NULL)
/* No pre-parsed audit list. */
return NULL;
/* Start of audit list. The first list element is at
audit_list->next (cyclic list). */
iter->previous = audit_list->next;
return iter->previous->name;
}
if (iter->previous == audit_list)
/* Cyclic list wrap-around. */
return NULL;
iter->previous = iter->previous->next;
return iter->previous->name;
}
#ifndef HAVE_INLINED_SYSCALLS
/* Set nonzero during loading and initialization of executable and
libraries, cleared before the executable's entry point runs. This
@@ -730,6 +837,42 @@ static const char *preloadlist attribute_relro;
/* Nonzero if information about versions has to be printed. */
static int version_info attribute_relro;
/* The LD_PRELOAD environment variable gives list of libraries
separated by white space or colons that are loaded before the
executable's dependencies and prepended to the global scope list.
(If the binary is running setuid all elements containing a '/' are
ignored since it is insecure.) Return the number of preloads
performed. */
unsigned int
handle_ld_preload (const char *preloadlist, struct link_map *main_map)
{
unsigned int npreloads = 0;
const char *p = preloadlist;
char fname[SECURE_PATH_LIMIT];
while (*p != '\0')
{
/* Split preload list at space/colon. */
size_t len = strcspn (p, " :");
if (len > 0 && len < sizeof (fname))
{
memcpy (fname, p, len);
fname[len] = '\0';
}
else
fname[0] = '\0';
/* Skip over the substring and the following delimiter. */
p += len;
if (*p != '\0')
++p;
if (dso_name_valid_for_suid (fname))
npreloads += do_preload (fname, main_map, "LD_PRELOAD");
}
return npreloads;
}
static void
dl_main (const ElfW(Phdr) *phdr,
ElfW(Word) phnum,
@@ -1257,11 +1400,13 @@ of this helper program; chances are you did not intend to run this program.\n\
GL(dl_rtld_map).l_tls_modid = _dl_next_tls_modid ();
/* If we have auditing DSOs to load, do it now. */
if (__glibc_unlikely (audit_list != NULL))
bool need_security_init = true;
if (__glibc_unlikely (audit_list != NULL)
|| __glibc_unlikely (audit_list_string != NULL))
{
/* Iterate over all entries in the list. The order is important. */
struct audit_ifaces *last_audit = NULL;
struct audit_list *al = audit_list->next;
struct audit_list_iter al_iter;
audit_list_iter_init (&al_iter);
/* Since we start using the auditing DSOs right away we need to
initialize the data structures now. */
@@ -1272,9 +1417,14 @@ of this helper program; chances are you did not intend to run this program.\n\
use different values (especially the pointer guard) and will
fail later on. */
security_init ();
need_security_init = false;
do
while (true)
{
const char *name = audit_list_iter_next (&al_iter);
if (name == NULL)
break;
int tls_idx = GL(dl_tls_max_dtv_idx);
/* Now it is time to determine the layout of the static TLS
@@ -1283,7 +1433,7 @@ of this helper program; chances are you did not intend to run this program.\n\
no DF_STATIC_TLS bit is set. The reason is that we know
glibc will use the static model. */
struct dlmopen_args dlmargs;
dlmargs.fname = al->name;
dlmargs.fname = name;
dlmargs.map = NULL;
const char *objname;
@@ -1296,7 +1446,7 @@ of this helper program; chances are you did not intend to run this program.\n\
not_loaded:
_dl_error_printf ("\
ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
al->name, err_str);
name, err_str);
if (malloced)
free ((char *) err_str);
}
@@ -1400,10 +1550,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
goto not_loaded;
}
}
al = al->next;
}
while (al != audit_list->next);
/* If we have any auditing modules, announce that we already
have two objects loaded. */
@@ -1481,23 +1628,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
if (__glibc_unlikely (preloadlist != NULL))
{
/* The LD_PRELOAD environment variable gives list of libraries
separated by white space or colons that are loaded before the
executable's dependencies and prepended to the global scope
list. If the binary is running setuid all elements
containing a '/' are ignored since it is insecure. */
char *list = strdupa (preloadlist);
char *p;
HP_TIMING_NOW (start);
/* Prevent optimizing strsep. Speed is not important here. */
while ((p = (strsep) (&list, " :")) != NULL)
if (p[0] != '\0'
&& (__builtin_expect (! __libc_enable_secure, 1)
|| strchr (p, '/') == NULL))
npreloads += do_preload (p, main_map, "LD_PRELOAD");
npreloads += handle_ld_preload (preloadlist, main_map);
HP_TIMING_NOW (stop);
HP_TIMING_DIFF (diff, start, stop);
HP_TIMING_ACCUM_NT (load_time, diff);
@@ -1682,7 +1814,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
if (tcbp == NULL)
tcbp = init_tls ();
if (__glibc_likely (audit_list == NULL))
if (__glibc_likely (need_security_init))
/* Initialize security features. But only if we have not done it
earlier. */
security_init ();
@@ -2313,9 +2445,7 @@ process_dl_audit (char *str)
char *p;
while ((p = (strsep) (&str, ":")) != NULL)
if (p[0] != '\0'
&& (__builtin_expect (! __libc_enable_secure, 1)
|| strchr (p, '/') == NULL))
if (dso_name_valid_for_suid (p))
{
/* This is using the local malloc, not the system malloc. The
memory can never be freed. */
@@ -2379,7 +2509,7 @@ process_envvars (enum mode *modep)
break;
}
if (memcmp (envline, "AUDIT", 5) == 0)
process_dl_audit (&envline[6]);
audit_list_string = &envline[6];
break;
case 7:
@@ -2423,7 +2553,8 @@ process_envvars (enum mode *modep)
case 10:
/* Mask for the important hardware capabilities. */
if (memcmp (envline, "HWCAP_MASK", 10) == 0)
if (!__libc_enable_secure
&& memcmp (envline, "HWCAP_MASK", 10) == 0)
GLRO(dl_hwcap_mask) = __strtoul_internal (&envline[11], NULL,
0, 0);
break;
@@ -2437,7 +2568,8 @@ process_envvars (enum mode *modep)
case 12:
/* The library search path. */
if (memcmp (envline, "LIBRARY_PATH", 12) == 0)
if (!__libc_enable_secure
&& memcmp (envline, "LIBRARY_PATH", 12) == 0)
{
library_path = &envline[13];
break;
+90
View File
@@ -0,0 +1,90 @@
/* Bug 11941: Improper assert map->l_init_called in dlclose.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This is the primary DSO that is loaded by the appliation. This DSO
then loads a plugin with RTLD_NODELETE. This plugin depends on this
DSO. This dependency chain means that at application shutdown the
plugin will be destructed first. Thus by the time this DSO is
destructed we will be calling dlclose on an object that has already
been destructed. It is allowed to call dlclose in this way and
should not assert. */
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
/* Plugin to load. */
static void *plugin_lib = NULL;
/* Plugin function. */
static void (*plugin_func) (void);
#define LIB_PLUGIN "tst-nodelete-dlclose-plugin.so"
/* This function is never called but the plugin references it.
We do this to avoid any future --as-needed from removing the
plugin's DT_NEEDED on this DSO (required for the test). */
void
primary_reference (void)
{
printf ("INFO: Called primary_reference function.\n");
}
void
primary (void)
{
char *error;
plugin_lib = dlopen (LIB_PLUGIN, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
if (plugin_lib == NULL)
{
printf ("ERROR: Unable to load plugin library.\n");
exit (EXIT_FAILURE);
}
dlerror ();
plugin_func = (void (*) (void)) dlsym (plugin_lib, "plugin_func");
error = dlerror ();
if (error != NULL)
{
printf ("ERROR: Unable to find symbol with error \"%s\".",
error);
exit (EXIT_FAILURE);
}
return;
}
__attribute__ ((destructor))
static void
primary_dtor (void)
{
int ret;
printf ("INFO: Calling primary destructor.\n");
/* The destructor runs in the test driver also, which
hasn't called primary, in that case do nothing. */
if (plugin_lib == NULL)
return;
ret = dlclose (plugin_lib);
if (ret != 0)
{
printf ("ERROR: Calling dlclose failed with \"%s\"\n",
dlerror ());
exit (EXIT_FAILURE);
}
}
+40
View File
@@ -0,0 +1,40 @@
/* Bug 11941: Improper assert map->l_init_called in dlclose.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This DSO simulates a plugin with a dependency on the
primary DSO loaded by the appliation. */
#include <stdio.h>
extern void primary_reference (void);
void
plugin_func (void)
{
printf ("INFO: Calling plugin function.\n");
/* Need a reference to the DSO to ensure that a potential --as-needed
doesn't remove the DT_NEEDED entry which we rely upon to ensure
destruction ordering. */
primary_reference ();
}
__attribute__ ((destructor))
static void
plugin_dtor (void)
{
printf ("INFO: Calling plugin destructor.\n");
}
+36
View File
@@ -0,0 +1,36 @@
/* Bug 11941: Improper assert map->l_init_called in dlclose.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This simulates an application using the primary DSO which loads the
plugin DSO. */
#include <stdio.h>
#include <stdlib.h>
extern void primary (void);
static int
do_test (void)
{
printf ("INFO: Starting application.\n");
primary ();
printf ("INFO: Exiting application.\n");
return 0;
}
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
+5
View File
@@ -5,6 +5,9 @@
# The variable $($(lib)-routines) defines the list of modules
# to be included in that library. A sysdep Makefile can add to
# $(lib)-sysdep_routines to include additional modules.
#
# Libraries listed in $(extra-libs-noinstall) are built, but not
# installed.
lib := $(firstword $(extra-libs-left))
extra-libs-left := $(filter-out $(lib),$(extra-libs-left))
@@ -28,7 +31,9 @@ extra-objs := $(extra-objs)
all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
# Add each flavor of library to the lists of things to build and install.
ifeq (,$(filter $(lib), $(extra-libs-noinstall)))
install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
endif
extra-objs += $(foreach o,$(filter-out .os .oS,$(object-suffixes-$(lib))),\
$(patsubst %,%$o,$(filter-out \
$($(lib)-shared-only-routines),\
+17 -1
View File
@@ -85,6 +85,14 @@ __copy_grp (const struct group srcgrp, const size_t buflen,
}
members[i] = NULL;
/* Align for pointers. We can't simply align C because we need to
align destbuf[c]. */
if ((((uintptr_t)destbuf + c) & (__alignof__(char **) - 1)) != 0)
{
uintptr_t mis_align = ((uintptr_t)destbuf + c) & (__alignof__(char **) - 1);
c += __alignof__(char **) - mis_align;
}
/* Copy the pointers from the members array into the buffer and assign them
to the gr_mem member of destgrp. */
destgrp->gr_mem = (char **) &destbuf[c];
@@ -129,7 +137,7 @@ __merge_grp (struct group *savedgrp, char *savedbuf, char *savedend,
/* Get the count of group members from the last sizeof (size_t) bytes in the
mergegrp buffer. */
savedmemcount = (size_t) *(savedend - sizeof (size_t));
savedmemcount = *(size_t *) (savedend - sizeof (size_t));
/* Get the count of new members to add. */
for (memcount = 0; mergegrp->gr_mem[memcount]; memcount++)
@@ -168,6 +176,14 @@ __merge_grp (struct group *savedgrp, char *savedbuf, char *savedend,
/* Add the NULL-terminator. */
members[savedmemcount + memcount] = NULL;
/* Align for pointers. We can't simply align C because we need to
align savedbuf[c]. */
if ((((uintptr_t)savedbuf + c) & (__alignof__(char **) - 1)) != 0)
{
uintptr_t mis_align = ((uintptr_t)savedbuf + c) & (__alignof__(char **) - 1);
c += __alignof__(char **) - mis_align;
}
/* Copy the member array back into the buffer after the member list and free
the member array. */
savedgrp->gr_mem = (char **) &savedbuf[c];
+1 -1
View File
@@ -139,7 +139,7 @@ typedef struct __gconv_info
{
size_t __nsteps;
struct __gconv_step *__steps;
__extension__ struct __gconv_step_data __data __flexarr;
__extension__ struct __gconv_step_data __data[0];
} *__gconv_t;
/* Transliteration using the locale's data. */
+3 -3
View File
@@ -1,8 +1,8 @@
#ifndef _ARPA_NAMESER_COMPAT_
#include <resolv/arpa/nameser_compat.h>
/* Picksome unused number to represent lookups of IPv4 and IPv6 (i.e.,
T_A and T_AAAA). */
#define T_UNSPEC 62321
/* The number is outside the 16-bit RR type range and is used
internally by the implementation. */
#define T_QUERY_A_AND_AAAA 439963904
#endif
+36
View File
@@ -0,0 +1,36 @@
/* The array_length and array_end macros.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _ARRAY_LENGTH_H
#define _ARRAY_LENGTH_H
/* array_length (VAR) is the number of elements in the array VAR. VAR
must evaluate to an array, not a pointer. */
#define array_length(var) \
__extension__ ({ \
_Static_assert (!__builtin_types_compatible_p \
(__typeof (var), __typeof (&(var)[0])), \
"argument must be an array"); \
sizeof (var) / sizeof ((var)[0]); \
})
/* array_end (VAR) is a pointer one past the end of the array VAR.
VAR must evaluate to an array, not a pointer. */
#define array_end(var) (&(var)[array_length (var)])
#endif /* _ARRAY_LENGTH_H */
+15
View File
@@ -121,6 +121,21 @@
# define weak_extern(symbol) _weak_extern (weak symbol)
# define _weak_extern(expr) _Pragma (#expr)
/* In shared builds, the expression call_function_static_weak
(FUNCTION-SYMBOL, ARGUMENTS) invokes FUNCTION-SYMBOL (an
identifier) unconditionally, with the (potentially empty) argument
list ARGUMENTS. In static builds, if FUNCTION-SYMBOL has a
definition, the function is invoked as before; if FUNCTION-SYMBOL
is NULL, no call is performed. */
# ifdef SHARED
# define call_function_static_weak(func, ...) func (__VA_ARGS__)
# else /* !SHARED */
# define call_function_static_weak(func, ...) \
({ \
extern __typeof__ (func) func weak_function; \
(func != NULL ? func (__VA_ARGS__) : (void)0); \
})
# endif
#else /* __ASSEMBLER__ */
+1 -1
View File
@@ -193,7 +193,7 @@ FTS *__REDIRECT (fts_open, (char * const *, int,
int (*)(const FTSENT **, const FTSENT **)),
fts64_open);
FTSENT *__REDIRECT (fts_read, (FTS *), fts64_read);
int __REDIRECT (fts_set, (FTS *, FTSENT *, int), fts64_set) __THROW;
int __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), fts64_set);
# else
# define fts_children fts64_children
# define fts_close fts64_close
+14
View File
@@ -1,3 +1,17 @@
2017-06-11 Santhosh Thottingal <santhosh.thottingal@gmail.com>
[BZ #19922]
* locales/iso14651_t1_common: Add collation rules for U+07DA to U+07DF.
[BZ #19919]
* locales/iso14651_t1_common: Correct collation of U+0D36 and U+0D37.
2016-12-30 Mike Frysinger <vapier@gentoo.org>
[BZ #20974]
* localedata/bs_BA (LC_MESSAGES): Delete "*." from the end of
yesexpr and noexpr.
2016-07-07 Aurelien Jarno <aurelien@aurel32.net>
* locales/de_LI (postal_fmt): Fix indentation.
+2 -2
View File
@@ -148,8 +148,8 @@ copy "en_DK"
END LC_CTYPE
LC_MESSAGES
yesexpr "<U005E><U005B><U002B><U0031><U0064><U0044><U0079><U0059><U005D><U002A><U002E>"
noexpr "<U005E><U005B><U002D><U0030><U006E><U004E><U005D><U002A><U002E>"
yesexpr "<U005E><U005B><U002B><U0031><U0064><U0044><U0079><U0059><U005D>"
noexpr "<U005E><U005B><U002D><U0030><U006E><U004E><U005D>"
yesstr "<U0064><U0061>"
nostr "<U006E><U0065>"
END LC_MESSAGES
+22 -4
View File
@@ -1042,9 +1042,9 @@ collating-element <ml-bh> from "<U0D2D><U0D4D>"
collating-element <ml-m> from "<U0D2E><U0D4D>"
collating-element <ml-y> from "<U0D2F><U0D4D>"
collating-element <ml-v> from "<U0D35><U0D4D>"
collating-element <ml-s> from "<U0D38><U0D4D>"
collating-element <ml-ss> from "<U0D36><U0D4D>"
collating-element <ml-sh> from "<U0D37><U0D4D>"
collating-element <ml-s> from "<U0D38><U0D4D>"
collating-element <ml-h> from "<U0D39><U0D4D>"
collating-element <ml-zh> from "<U0D34><U0D4D>"
collating-element <ml-rr> from "<U0D31><U0D4D>"
@@ -1103,8 +1103,8 @@ collating-symbol <ml-rra>
collating-symbol <ml-la>
collating-symbol <ml-lla>
collating-symbol <ml-va>
collating-symbol <ml-sha>
collating-symbol <ml-ssa>
collating-symbol <ml-sha>
collating-symbol <ml-sa>
collating-symbol <ml-ha>
collating-symbol <ml-avagrah>
@@ -1126,6 +1126,12 @@ collating-symbol <mlvs-o>
collating-symbol <mlvs-au>
collating-symbol <ml-visarga>
collating-symbol <ml-virama>
collating-symbol <ml-atomic-chillu-k>
collating-symbol <ml-atomic-chillu-n>
collating-symbol <ml-atomic-chillu-nn>
collating-symbol <ml-atomic-chillu-l>
collating-symbol <ml-atomic-chillu-ll>
collating-symbol <ml-atomic-chillu-r>
#
# <BENGALI>
#
@@ -4552,6 +4558,12 @@ collating-symbol <TIB-subA>
<mlvs-o>
<mlvs-au>
<ml-visarga>
<ml-atomic-chillu-k>
<ml-atomic-chillu-n>
<ml-atomic-chillu-nn>
<ml-atomic-chillu-l>
<ml-atomic-chillu-ll>
<ml-atomic-chillu-r>
#
# <BENGALI>
#
@@ -7252,6 +7264,7 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<U0D13> <mlvw-o>;<BAS>;<MIN>;IGNORE
<U0D14> <mlvw-au>;<BAS>;<MIN>;IGNORE
<ml-chillu-k> "<ml-ka><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D7F> "<ml-ka><ml-virama>";<ml-atomic-chillu-k>;<MIN>;IGNORE
<U0D15> "<ml-ka><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-kh> "<ml-kha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D16> "<ml-kha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
@@ -7280,6 +7293,7 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<ml-dh> "<ml-dha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D22> "<ml-dha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-nn> "<ml-nna><ml-virama>";<BAS>;<MIN>;IGNORE # ണ്‍ = ണ + ് + zwj
<U0D7A> "<ml-nna><ml-virama>";<ml-atomic-chillu-nn>;<MIN>;IGNORE
<U0D23> "<ml-nna><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ണ = ണ + ് + അ
<ml-th> "<ml-tha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D24> "<ml-tha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
@@ -7290,6 +7304,7 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<ml-ddh> "<ml-ddha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D27> "<ml-ddha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-n> "<ml-na><ml-virama>";<BAS>;<MIN>;IGNORE # ന്‍= ന + ് + zwj
<U0D7B> "<ml-na><ml-virama>";<ml-atomic-chillu-n>;<MIN>;IGNORE
<U0D28> "<ml-na><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE #ന = ന + ് + അ
<ml-p> "<ml-pa><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D2A> "<ml-pa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
@@ -7305,20 +7320,23 @@ order_start <MALAYALAM>;forward;forward;forward;forward,position
<ml-y> "<ml-ya><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D2F> "<ml-ya><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-r> "<ml-ra><ml-virama>";<BAS>;<MIN>;IGNORE # ര = ര + ് + zwj
<U0D7C> "<ml-ra><ml-virama>";<ml-atomic-chillu-r>;<MIN>;IGNORE
<U0D30> "<ml-ra><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ര = ര + ് + അ
<ml-chillu-l> <ml-la>;<BAS>;<MIN>;IGNORE # ല്‍ = ല + ് + zwj
<U0D7D> "<ml-la><ml-virama>";<ml-atomic-chillu-l>;<MIN>;IGNORE
<U0D32> "<ml-la><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ല = ല + ് + അ
<ml-v> "<ml-va><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D35> "<ml-va><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-ss> "<ml-ssa><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D37> "<ml-ssa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<U0D36> "<ml-ssa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-sh> "<ml-sha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D36> "<ml-sha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<U0D37> "<ml-sha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-s> "<ml-sa><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D38> "<ml-sa><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-h> "<ml-ha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D39> "<ml-ha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
<ml-chillu-ll> "<ml-lla><ml-virama>";<BAS>;<MIN>;IGNORE # ള്‍ = ള + ് + zwj
<U0D7E> "<ml-lla><ml-virama>";<ml-atomic-chillu-ll>;<MIN>;IGNORE
<U0D33> "<ml-lla><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE # ള = ള + ് + അ
<ml-zh> "<ml-zha><ml-virama>";<BAS>;<MIN>;IGNORE
<U0D34> "<ml-zha><ml-virama><mlvw-shorta>";<BAS>;<MIN>;IGNORE
+14
View File
@@ -31,6 +31,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
tst-malloc-backtrace tst-malloc-thread-exit \
tst-malloc-thread-fail tst-malloc-fork-deadlock \
tst-mallocfork2
test-srcs = tst-mtrace
routines = malloc morecore mcheck mtrace obstack \
@@ -44,6 +45,15 @@ non-lib.a := libmcheck.a
extra-libs = libmemusage
extra-libs-others = $(extra-libs)
# Helper objects for some tests.
extra-tests-objs += \
tst-interpose-aux-nothread.o \
tst-interpose-aux-thread.o \
test-extras = \
tst-interpose-aux-nothread \
tst-interpose-aux-thread \
libmemusage-routines = memusage
libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
@@ -166,3 +176,7 @@ $(objpfx)libmemusage.so: $(libdl)
# Extra dependencies
$(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c
# Compile the tests with a flag which suppresses the mallopt call in
# the test skeleton.
$(tests:%=$(objpfx)%.o): CPPFLAGS += -DTEST_NO_MALLOPT
+36 -5
View File
@@ -702,8 +702,7 @@ _int_new_arena (size_t size)
}
/* Remove an arena from free_list. The arena may be in use because it
was attached concurrently to a thread by reused_arena below. */
/* Remove an arena from free_list. */
static mstate
get_free_list (void)
{
@@ -718,7 +717,8 @@ get_free_list (void)
free_list = result->next_free;
/* The arena will be attached to this thread. */
++result->attached_threads;
assert (result->attached_threads == 0);
result->attached_threads = 1;
detach_arena (replaced_arena);
}
@@ -735,6 +735,26 @@ get_free_list (void)
return result;
}
/* Remove the arena from the free list (if it is present).
free_list_lock must have been acquired by the caller. */
static void
remove_from_free_list (mstate arena)
{
mstate *previous = &free_list;
for (mstate p = free_list; p != NULL; p = p->next_free)
{
assert (p->attached_threads == 0);
if (p == arena)
{
/* Remove the requested arena from the list. */
*previous = p->next_free;
break;
}
else
previous = &p->next_free;
}
}
/* Lock and return an arena that can be reused for memory allocation.
Avoid AVOID_ARENA as we have already failed to allocate memory in
it and it is currently locked. */
@@ -782,14 +802,25 @@ reused_arena (mstate avoid_arena)
(void) mutex_lock (&result->mutex);
out:
/* Attach the arena to the current thread. Note that we may have
selected an arena which was on free_list. */
/* Attach the arena to the current thread. */
{
/* Update the arena thread attachment counters. */
mstate replaced_arena = thread_arena;
(void) mutex_lock (&free_list_lock);
detach_arena (replaced_arena);
/* We may have picked up an arena on the free list. We need to
preserve the invariant that no arena on the free list has a
positive attached_threads counter (otherwise,
arena_thread_freeres cannot use the counter to determine if the
arena needs to be put on the free list). We unconditionally
remove the selected arena from the free list. The caller of
reused_arena checked the free list and observed it to be empty,
so the list is very short. */
remove_from_free_list (result);
++result->attached_threads;
(void) mutex_unlock (&free_list_lock);
}
+20
View File
@@ -0,0 +1,20 @@
/* Interposed malloc, version without threading support.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>. */
#define INTERPOSE_THREADS 0
#include "tst-interpose-aux.c"
+20
View File
@@ -0,0 +1,20 @@
/* Interposed malloc, version with threading support.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>. */
#define INTERPOSE_THREADS 1
#include "tst-interpose-aux.c"
+270
View File
@@ -0,0 +1,270 @@
/* Minimal malloc implementation for interposition tests.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>. */
#include "tst-interpose-aux.h"
#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/uio.h>
#include <unistd.h>
#if INTERPOSE_THREADS
#include <pthread.h>
#endif
/* Print the error message and terminate the process with status 1. */
__attribute__ ((noreturn))
__attribute__ ((format (printf, 1, 2)))
static void *
fail (const char *format, ...)
{
/* This assumes that vsnprintf will not call malloc. It does not do
so for the format strings we use. */
char message[4096];
va_list ap;
va_start (ap, format);
vsnprintf (message, sizeof (message), format, ap);
va_end (ap);
enum { count = 3 };
struct iovec iov[count];
iov[0].iov_base = (char *) "error: ";
iov[1].iov_base = (char *) message;
iov[2].iov_base = (char *) "\n";
for (int i = 0; i < count; ++i)
iov[i].iov_len = strlen (iov[i].iov_base);
int unused __attribute__ ((unused));
unused = writev (STDOUT_FILENO, iov, count);
_exit (1);
}
#if INTERPOSE_THREADS
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static void
lock (void)
{
#if INTERPOSE_THREADS
int ret = pthread_mutex_lock (&mutex);
if (ret != 0)
{
errno = ret;
fail ("pthread_mutex_lock: %m");
}
#endif
}
static void
unlock (void)
{
#if INTERPOSE_THREADS
int ret = pthread_mutex_unlock (&mutex);
if (ret != 0)
{
errno = ret;
fail ("pthread_mutex_unlock: %m");
}
#endif
}
struct __attribute__ ((aligned (__alignof__ (max_align_t)))) allocation_header
{
size_t allocation_index;
size_t allocation_size;
};
/* Array of known allocations, to track invalid frees. */
enum { max_allocations = 65536 };
static struct allocation_header *allocations[max_allocations];
static size_t allocation_index;
static size_t deallocation_count;
/* Sanity check for successful malloc interposition. */
__attribute__ ((destructor))
static void
check_for_allocations (void)
{
if (allocation_index == 0)
{
/* Make sure that malloc is called at least once from libc. */
void *volatile ptr = strdup ("ptr");
free (ptr);
/* Compiler barrier. The strdup function calls malloc, which
updates allocation_index, but strdup is marked __THROW, so
the compiler could optimize away the reload. */
__asm__ volatile ("" ::: "memory");
/* If the allocation count is still zero, it means we did not
interpose malloc successfully. */
if (allocation_index == 0)
fail ("malloc does not seem to have been interposed");
}
}
static struct allocation_header *get_header (const char *op, void *ptr)
{
struct allocation_header *header = ((struct allocation_header *) ptr) - 1;
if (header->allocation_index >= allocation_index)
fail ("%s: %p: invalid allocation index: %zu (not less than %zu)",
op, ptr, header->allocation_index, allocation_index);
if (allocations[header->allocation_index] != header)
fail ("%s: %p: allocation pointer does not point to header, but %p",
op, ptr, allocations[header->allocation_index]);
return header;
}
/* Internal helper functions. Those must be called while the lock is
acquired. */
static void *
malloc_internal (size_t size)
{
if (allocation_index == max_allocations)
{
errno = ENOMEM;
return NULL;
}
size_t allocation_size = size + sizeof (struct allocation_header);
if (allocation_size < size)
{
errno = ENOMEM;
return NULL;
}
size_t index = allocation_index++;
void *result = mmap (NULL, allocation_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (result == MAP_FAILED)
return NULL;
allocations[index] = result;
*allocations[index] = (struct allocation_header)
{
.allocation_index = index,
.allocation_size = allocation_size
};
return allocations[index] + 1;
}
static void
free_internal (const char *op, struct allocation_header *header)
{
size_t index = header->allocation_index;
int result = mprotect (header, header->allocation_size, PROT_NONE);
if (result != 0)
fail ("%s: mprotect (%p, %zu): %m", op, header, header->allocation_size);
/* Catch double-free issues. */
allocations[index] = NULL;
++deallocation_count;
}
static void *
realloc_internal (void *ptr, size_t new_size)
{
struct allocation_header *header = get_header ("realloc", ptr);
size_t old_size = header->allocation_size - sizeof (struct allocation_header);
if (old_size >= new_size)
return ptr;
void *newptr = malloc_internal (new_size);
if (newptr == NULL)
return NULL;
memcpy (newptr, ptr, old_size);
free_internal ("realloc", header);
return newptr;
}
/* Public interfaces. These functions must perform locking. */
size_t
malloc_allocation_count (void)
{
lock ();
size_t count = allocation_index;
unlock ();
return count;
}
size_t
malloc_deallocation_count (void)
{
lock ();
size_t count = deallocation_count;
unlock ();
return count;
}
void *
malloc (size_t size)
{
lock ();
void *result = malloc_internal (size);
unlock ();
return result;
}
void
free (void *ptr)
{
if (ptr == NULL)
return;
lock ();
struct allocation_header *header = get_header ("free", ptr);
free_internal ("free", header);
unlock ();
}
void *
calloc (size_t a, size_t b)
{
if (b > 0 && a > SIZE_MAX / b)
{
errno = ENOMEM;
return NULL;
}
lock ();
/* malloc_internal uses mmap, so the memory is zeroed. */
void *result = malloc_internal (a * b);
unlock ();
return result;
}
void *
realloc (void *ptr, size_t n)
{
if (n ==0)
{
free (ptr);
return NULL;
}
else if (ptr == NULL)
return malloc (n);
else
{
lock ();
void *result = realloc_internal (ptr, n);
unlock ();
return result;
}
}
+30
View File
@@ -0,0 +1,30 @@
/* Statistics interface for the minimal malloc implementation.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>. */
#ifndef TST_INTERPOSE_AUX_H
#define TST_INTERPOSE_AUX_H
#include <stddef.h>
/* Return the number of allocations performed. */
size_t malloc_allocation_count (void);
/* Return the number of deallocations performed. */
size_t malloc_deallocation_count (void);
#endif /* TST_INTERPOSE_AUX_H */
+5 -4
View File
@@ -29,14 +29,15 @@
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
/* Define the variables used for the interface. */
char *loc1;
char *loc2;
/* Define the variables used for the interface. Avoid .symver on common
symbol, which just creates a new common symbol, not an alias. */
char *loc1 __attribute__ ((nocommon));
char *loc2 __attribute__ ((nocommon));
compat_symbol (libc, loc1, loc1, GLIBC_2_0);
compat_symbol (libc, loc2, loc2, GLIBC_2_0);
/* Although we do not support the use we define this variable as well. */
char *locs;
char *locs __attribute__ ((nocommon));
compat_symbol (libc, locs, locs, GLIBC_2_0);
+1 -1
View File
@@ -291,7 +291,7 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias,
return status;
}
if (name != NULL)
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
+1 -1
View File
@@ -268,7 +268,7 @@ tests = tst-typesizes \
tst-flock1 tst-flock2 \
tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
tst-signal6 tst-signal7 \
tst-exec1 tst-exec2 tst-exec3 tst-exec4 \
tst-exec1 tst-exec2 tst-exec3 tst-exec4 tst-exec5 \
tst-exit1 tst-exit2 tst-exit3 \
tst-stdio1 tst-stdio2 \
tst-stack1 tst-stack2 tst-stack3 tst-stack4 tst-pthread-getattr \
+2 -18
View File
@@ -440,9 +440,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
SETUP_THREAD_SYSINFO (pd);
#endif
/* The process ID is also the same as that of the caller. */
pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
/* Don't allow setxid until cloned. */
pd->setxid_futex = -1;
@@ -579,9 +576,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
/* Don't allow setxid until cloned. */
pd->setxid_futex = -1;
/* The process ID is also the same as that of the caller. */
pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
/* Allocate the DTV for this thread. */
if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
{
@@ -875,9 +869,6 @@ __reclaim_stacks (void)
/* This marks the stack as free. */
curp->tid = 0;
/* The PID field must be initialized for the new process. */
curp->pid = self->pid;
/* Account for the size of the stack. */
stack_cache_actsize += curp->stackblock_size;
@@ -903,13 +894,6 @@ __reclaim_stacks (void)
}
}
/* Reset the PIDs in any cached stacks. */
list_for_each (runp, &stack_cache)
{
struct pthread *curp = list_entry (runp, struct pthread, list);
curp->pid = self->pid;
}
/* Add the stack of all running threads to the cache. */
list_splice (&stack_used, &stack_cache);
@@ -1054,9 +1038,9 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
return 0;
int val;
pid_t pid = __getpid ();
INTERNAL_SYSCALL_DECL (err);
val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
t->tid, SIGSETXID);
val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, t->tid, SIGSETXID);
/* If this failed, it must have had not started yet or else exited. */
if (!INTERNAL_SYSCALL_ERROR_P (val, err))
+2 -2
View File
@@ -167,8 +167,8 @@ struct pthread
therefore stack) used' flag. */
pid_t tid;
/* Process ID - thread group ID in kernel speak. */
pid_t pid;
/* Ununsed. */
pid_t pid_ununsed;
/* List of robust mutexes the thread is holding. */
#ifdef __PTHREAD_MUTEX_HAVE_PREV
+2 -13
View File
@@ -184,18 +184,12 @@ __nptl_set_robust (struct pthread *self)
static void
sigcancel_handler (int sig, siginfo_t *si, void *ctx)
{
/* Determine the process ID. It might be negative if the thread is
in the middle of a fork() call. */
pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
if (__glibc_unlikely (pid < 0))
pid = -pid;
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGCANCEL
|| si->si_pid != pid
|| si->si_pid != __getpid()
|| si->si_code != SI_TKILL)
return;
@@ -243,19 +237,14 @@ struct xid_command *__xidcmd attribute_hidden;
static void
sighandler_setxid (int sig, siginfo_t *si, void *ctx)
{
/* Determine the process ID. It might be negative if the thread is
in the middle of a fork() call. */
pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
int result;
if (__glibc_unlikely (pid < 0))
pid = -pid;
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGSETXID
|| si->si_pid != pid
|| si->si_pid != __getpid ()
|| si->si_code != SI_TKILL)
return;
+5 -13
View File
@@ -22,7 +22,7 @@
#include "pthreadP.h"
#include <atomic.h>
#include <sysdep.h>
#include <unistd.h>
int
pthread_cancel (pthread_t th)
@@ -66,19 +66,11 @@ pthread_cancel (pthread_t th)
#ifdef SIGCANCEL
/* The cancellation handler will take care of marking the
thread as canceled. */
pid_t pid = getpid ();
INTERNAL_SYSCALL_DECL (err);
/* One comment: The PID field in the TCB can temporarily be
changed (in fork). But this must not affect this code
here. Since this function would have to be called while
the thread is executing fork, it would have to happen in
a signal handler. But this is no allowed, pthread_cancel
is not guaranteed to be async-safe. */
int val;
val = INTERNAL_SYSCALL (tgkill, err, 3,
THREAD_GETMEM (THREAD_SELF, pid), pd->tid,
SIGCANCEL);
int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, pd->tid,
SIGCANCEL);
if (INTERNAL_SYSCALL_ERROR_P (val, err))
result = INTERNAL_SYSCALL_ERRNO (val, err);
#else
-1
View File
@@ -68,7 +68,6 @@ pthread_getattr_np (pthread_t thread_id, pthread_attr_t *attr)
{
/* No stack information available. This must be for the initial
thread. Get the info in some magical way. */
assert (abs (thread->pid) == thread->tid);
/* Stack size limit. */
struct rlimit rl;
+196
View File
@@ -0,0 +1,196 @@
/* Check if posix_spawn does not act as a cancellation entrypoint.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <paths.h>
#include <pthread.h>
#include <signal.h>
#include <spawn.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
static int do_test (void);
#define TEST_FUNCTION do_test ()
#include <test-skeleton.c>
static pthread_barrier_t b;
static pid_t pid;
static int pipefd[2];
static void *
tf (void *arg)
{
int r = pthread_barrier_wait (&b);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("error: pthread_barrier_wait failed");
exit (1);
}
posix_spawn_file_actions_t a;
if (posix_spawn_file_actions_init (&a) != 0)
{
puts ("error: spawn_file_actions_init failed");
exit (1);
}
if (posix_spawn_file_actions_adddup2 (&a, pipefd[1], STDOUT_FILENO) != 0)
{
puts ("error: spawn_file_actions_adddup2 failed");
exit (1);
}
if (posix_spawn_file_actions_addclose (&a, pipefd[0]) != 0)
{
puts ("error: spawn_file_actions_addclose");
exit (1);
}
char *argv[] = { (char *) _PATH_BSHELL, (char *) "-c", (char *) "echo $$",
NULL };
if (posix_spawn (&pid, _PATH_BSHELL, &a, NULL, argv, NULL) != 0)
{
puts ("error: spawn failed");
exit (1);
}
return NULL;
}
static int
do_test (void)
{
/* The test basically pipe a 'echo $$' created by a thread with a
cancellation pending. It then checks if the thread is not cancelled,
the process is created and if the output is the expected one. */
if (pipe (pipefd) != 0)
{
puts ("error: pipe failed");
exit (1);
}
/* Not interested in knowing when the pipe is closed. */
if (sigignore (SIGPIPE) != 0)
{
puts ("error: sigignore failed");
exit (1);
}
/* To synchronize with the thread. */
if (pthread_barrier_init (&b, NULL, 2) != 0)
{
puts ("error: pthread_barrier_init failed");
exit (1);
}
pthread_t th;
if (pthread_create (&th, NULL, &tf, NULL) != 0)
{
puts ("error: pthread_create failed");
exit (1);
}
if (pthread_cancel (th) != 0)
{
puts ("error: pthread_cancel failed");
exit (1);
}
int r = pthread_barrier_wait (&b);
if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("error: pthread_barrier_wait");
exit (1);
}
void *retval;
if (pthread_join (th, &retval) != 0)
{
puts ("error: pthread_join failed\n");
}
if (retval == PTHREAD_CANCELED)
{
puts ("error: thread cancelled");
exit (1);
}
close (pipefd[1]);
/* The global 'pid' should be set by thread posix_spawn calling. Check
below if it was executed correctly and with expected output. */
char buf[64];
ssize_t n;
bool seen_pid = false;
while (TEMP_FAILURE_RETRY ((n = read (pipefd[0], buf, sizeof (buf)))) > 0)
{
/* We only expect to read the PID. */
char *endp;
long int rpid = strtol (buf, &endp, 10);
if (*endp != '\n')
{
printf ("error: didn't parse whole line: \"%s\"\n", buf);
exit (1);
}
if (endp == buf)
{
puts ("error: read empty line");
exit (1);
}
if (rpid != pid)
{
printf ("error: found \"%s\", expected PID %ld\n", buf,
(long int) pid);
exit (1);
}
if (seen_pid)
{
puts ("error: found more than one PID line");
exit (1);
}
seen_pid = true;
}
close (pipefd[0]);
int status;
int err = waitpid (pid, &status, 0);
if (err != pid)
{
puts ("errnor: waitpid failed");
exit (1);
}
if (!seen_pid)
{
puts ("error: didn't get PID");
exit (1);
}
return 0;
}
+2
View File
@@ -75,5 +75,7 @@ do_test (void)
return result;
}
// The test currently hangs and is XFAILed. Reduce the timeout.
#define TIMEOUT 1
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
-1
View File
@@ -48,7 +48,6 @@ DB_STRUCT (pthread)
DB_STRUCT_FIELD (pthread, list)
DB_STRUCT_FIELD (pthread, report_events)
DB_STRUCT_FIELD (pthread, tid)
DB_STRUCT_FIELD (pthread, pid)
DB_STRUCT_FIELD (pthread, start_routine)
DB_STRUCT_FIELD (pthread, cancelhandling)
DB_STRUCT_FIELD (pthread, schedpolicy)
+18 -38
View File
@@ -76,48 +76,28 @@ iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback,
if (ps_pdread (ta->ph, addr, copy, ta->ta_sizeof_pthread) != PS_OK)
return TD_ERR;
/* Verify that this thread's pid field matches the child PID.
If its pid field is negative, it's about to do a fork or it
is the sole thread in a fork child. */
psaddr_t pid;
err = DB_GET_FIELD_LOCAL (pid, ta, copy, pthread, pid, 0);
if (err == TD_OK && (pid_t) (uintptr_t) pid < 0)
{
if (-(pid_t) (uintptr_t) pid == match_pid)
/* It is about to do a fork, but is really still the parent PID. */
pid = (psaddr_t) (uintptr_t) match_pid;
else
/* It must be a fork child, whose new PID is in the tid field. */
err = DB_GET_FIELD_LOCAL (pid, ta, copy, pthread, tid, 0);
}
err = DB_GET_FIELD_LOCAL (schedpolicy, ta, copy, pthread,
schedpolicy, 0);
if (err != TD_OK)
break;
err = DB_GET_FIELD_LOCAL (schedprio, ta, copy, pthread,
schedparam_sched_priority, 0);
if (err != TD_OK)
break;
if ((pid_t) (uintptr_t) pid == match_pid)
/* Now test whether this thread matches the specified conditions. */
/* Only if the priority level is as high or higher. */
int descr_pri = ((uintptr_t) schedpolicy == SCHED_OTHER
? 0 : (uintptr_t) schedprio);
if (descr_pri >= ti_pri)
{
err = DB_GET_FIELD_LOCAL (schedpolicy, ta, copy, pthread,
schedpolicy, 0);
if (err != TD_OK)
break;
err = DB_GET_FIELD_LOCAL (schedprio, ta, copy, pthread,
schedparam_sched_priority, 0);
if (err != TD_OK)
break;
/* Now test whether this thread matches the specified conditions. */
/* Only if the priority level is as high or higher. */
int descr_pri = ((uintptr_t) schedpolicy == SCHED_OTHER
? 0 : (uintptr_t) schedprio);
if (descr_pri >= ti_pri)
{
/* Yep, it matches. Call the callback function. */
td_thrhandle_t th;
th.th_ta_p = (td_thragent_t *) ta;
th.th_unique = addr;
if (callback (&th, cbdata_p) != 0)
return TD_DBERR;
}
/* Yep, it matches. Call the callback function. */
td_thrhandle_t th;
th.th_ta_p = (td_thragent_t *) ta;
th.th_unique = addr;
if (callback (&th, cbdata_p) != 0)
return TD_DBERR;
}
/* Get the pointer to the next element. */
-23
View File
@@ -80,28 +80,5 @@ td_thr_validate (const td_thrhandle_t *th)
err = TD_OK;
}
if (err == TD_OK)
{
/* Verify that this is not a stale element in a fork child. */
pid_t match_pid = ps_getpid (th->th_ta_p->ph);
psaddr_t pid;
err = DB_GET_FIELD (pid, th->th_ta_p, th->th_unique, pthread, pid, 0);
if (err == TD_OK && (pid_t) (uintptr_t) pid < 0)
{
/* This was a thread that was about to fork, or it is the new sole
thread in a fork child. In the latter case, its tid was stored
via CLONE_CHILD_SETTID and so is already the proper child PID. */
if (-(pid_t) (uintptr_t) pid == match_pid)
/* It is about to do a fork, but is really still the parent PID. */
pid = (psaddr_t) (uintptr_t) match_pid;
else
/* It must be a fork child, whose new PID is in the tid field. */
err = DB_GET_FIELD (pid, th->th_ta_p, th->th_unique,
pthread, tid, 0);
}
if (err == TD_OK && (pid_t) (uintptr_t) pid != match_pid)
err = TD_NOTHR;
}
return err;
}
+3 -3
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GNU libc 2.22-pre1\n"
"POT-Creation-Date: 2015-07-31 00:10-0400\n"
"PO-Revision-Date: 2015-08-31 18:30+0200\n"
"PO-Revision-Date: 2016-04-22 18:44+0200\n"
"Last-Translator: Jochen Hein <jochen@jochen.org>\n"
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
"Language: de\n"
@@ -4479,13 +4479,13 @@ msgstr ""
"%15s Cache ist dauerhaft\n"
"%15s Cache wird gemeinsam verwendet\n"
"%15Zu vorgeschlagene Größe\n"
"%15Zu Gesamtröße des Data-Pools\n"
"%15Zu Gesamtgröße des Data-Pools\n"
"%15Zu Benutzter Speicher im Data-Pool\n"
"%15lu Time to Live für positive Einträge in Sekunden\n"
"%15lu Time to Live für negative Einträge in Sekunden\n"
"%15<PRIuMAX> Cache-Hits bei positiven Einträgen\n"
"%15<PRIuMAX> Cache-Hits bei positiven Einträgen\n"
"%15<PRIuMAX> Cache-Misses bei positiven Einträgen\n"
"%15<PRIuMAX> Cache-Misses bei positiven Einträgen\n"
"%15<PRIuMAX> Cache-Misses bei negativen Einträgen\n"
"%15lu%% Cache-Hit Verhältnis\n"
"%15zu aktuelle Anzahl der Werte im Cache\n"
+40 -50
View File
@@ -24,16 +24,16 @@
#
msgid ""
msgstr ""
"Project-Id-Version: libc 2.21-pre1\n"
"Project-Id-Version: libc 2.22-pre1\n"
"POT-Creation-Date: 2015-07-31 00:10-0400\n"
"PO-Revision-Date: 2015-07-28 20:29+0300\n"
"PO-Revision-Date: 2016-05-26 21:14+0300\n"
"Last-Translator: Lauri Nurmi <lanurmi@iki.fi>\n"
"Language-Team: Finnish <translation-team-fi@lists.sourceforge.net>\n"
"Language: fi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.3\n"
"X-Generator: Poedit 1.8.7\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: argp/argp-help.c:227
@@ -126,7 +126,7 @@ msgid "%s%s%s:%u: %s%sUnexpected error: %s.\n"
msgstr "%s%s%s:%u: %s%sOdottamaton virhe: %s.\n"
#: assert/assert.c:101
#, fuzzy, c-format
#, c-format
msgid ""
"%s%s%s:%u: %s%sAssertion `%s' failed.\n"
"%n"
@@ -169,12 +169,12 @@ msgstr ""
#: malloc/memusagestat.c:563 nss/getent.c:973 nss/makedb.c:369
#: posix/getconf.c:486 sunrpc/rpcinfo.c:691
#: sysdeps/unix/sysv/linux/lddlibc4.c:61
#, fuzzy, c-format
#, c-format
msgid ""
"For bug reporting instructions, please see:\n"
"%s.\n"
msgstr ""
"Ohjeet ohjelmistovioista ilmoittamiseen ovat osoitteessa\n"
"Katso ohjeet vikailmoitusten tekemiseen osoitteesta:\n"
"%s.\n"
#: catgets/gencat.c:245 debug/pcprofiledump.c:225 debug/xtrace.sh:64
@@ -321,9 +321,8 @@ msgstr "Käyttö: xtrace [VALITSIN]... OHJELMA [OHJELMANVALITSIN]...\\n"
#: debug/xtrace.sh:32 elf/sotruss.sh:56 elf/sotruss.sh:67 elf/sotruss.sh:135
#: malloc/memusage.sh:26
#, fuzzy
msgid "Try \\`%s --help' or \\`%s --usage' for more information.\\n"
msgstr "Kokeile ”%s --help” tai ”%s --usage” saadaksesi lisää tietoa.\n"
msgstr "Kokeile ”%s --help” tai ”%s --usage” saadaksesi lisää tietoa.\\n"
#: debug/xtrace.sh:38
#, fuzzy
@@ -594,9 +593,8 @@ msgid "cannot enable executable stack as shared object requires"
msgstr "jaettua objektikahvaa ei voi luoda"
#: elf/dl-load.c:1339
#, fuzzy
msgid "cannot close file descriptor"
msgstr "tiedostoa %s ei voi sulkea"
msgstr "tiedostokahvaa ei voi sulkea"
#: elf/dl-load.c:1568
msgid "file too short"
@@ -796,9 +794,8 @@ msgid "Format to use: new, old or compat (default)"
msgstr "Käytettävä muoto: ”new”, ”old” tai ”compat” (oletus)"
#: elf/ldconfig.c:151
#, fuzzy
msgid "Ignore auxiliary cache file"
msgstr "Käytä CACHEa välimuistitiedostona"
msgstr "Jätä huomiotta apuvälimuistitiedosto"
#: elf/ldconfig.c:159
msgid "Configure Dynamic Linker Run Time Bindings."
@@ -1087,9 +1084,9 @@ msgid "invalid process ID '%s'"
msgstr "virheellinen prosessi-ID ”%s”"
#: elf/pldd.c:120
#, fuzzy, c-format
#, c-format
msgid "cannot open %s"
msgstr "laitetta %s ei voi avata"
msgstr "tiedostoa %s ei voi avata"
#: elf/pldd.c:152
#, fuzzy, c-format
@@ -1102,24 +1099,24 @@ msgid "cannot prepare reading %s/task"
msgstr "ei voi avata laitetta %s lukutilaan"
#: elf/pldd.c:168
#, fuzzy, c-format
#, c-format
msgid "invalid thread ID '%s'"
msgstr "virheellinen prosessi-ID ”%s”"
msgstr "virheellinen säie-ID ”%s”"
#: elf/pldd.c:179
#, fuzzy, c-format
#, c-format
msgid "cannot attach to process %lu"
msgstr "tiedostoa ”%s” ei voi avata"
msgstr "ei voida kiinnittyä prosessiin %lu"
#: elf/pldd.c:294
#, c-format
msgid "cannot get information about process %lu"
msgstr ""
msgstr "tietojen saaminen prosessista %lu ei onnistu"
#: elf/pldd.c:307
#, fuzzy, c-format
#, c-format
msgid "process %lu is no ELF program"
msgstr "ohjelma %lu ei ole käytettävissä\n"
msgstr "prosessi %lu ei ole ELF-ohjelma"
#: elf/readelflib.c:34
#, c-format
@@ -1203,7 +1200,7 @@ msgstr "%s kohde ei saa olla hakemisto\n"
#: elf/sln.c:184
#, c-format
msgid "%s: failed to remove the old destination\n"
msgstr ""
msgstr "%s: vanhan kohteen poistaminen epäonnistui\n"
#: elf/sln.c:192
#, c-format
@@ -1237,9 +1234,8 @@ msgid "Mandatory arguments to long options are also mandatory for any correspond
msgstr "Pakolliset argumentit pitkille valitsimille ovat pakollisia kaikille vastaaville lyhyille valitsimille.\\n"
#: elf/sotruss.sh:55
#, fuzzy
msgid "%s: option requires an argument -- '%s'\\n"
msgstr "%s: valitsin ”%s” vaatii argumentin\n"
msgstr "%s: valitsin vaatii argumentin -- ”%c”\\n"
#: elf/sotruss.sh:61
msgid "%s: option is ambiguous; possibilities:"
@@ -1507,7 +1503,6 @@ msgid "unknown iconv() error %d"
msgstr "tuntematon iconv()-virhe %d"
#: iconv/iconv_prog.c:791
#, fuzzy
msgid ""
"The following list contains all the coded character sets known. This does\n"
"not necessarily mean that all combinations of these names can be used for\n"
@@ -1516,9 +1511,9 @@ msgid ""
"\n"
" "
msgstr ""
"Seuraavassa listassa ovat kaikki tunnetut koodatut merkistöt. Se ei\n"
"Seuraavassa listassa ovat kaikki tunnetut koodatut merkistöt. Tämä ei\n"
"kuitenkaan välttämättä tarkoita sitä, että kaikkia näiden nimien\n"
"yhdistelmiä voidaan käyttää FROM- ja TO-komentoriviparametreina. Yksi\n"
"yhdistelmiä voisi käyttää FROM- ja TO-komentoriviparametreina. Yksi\n"
"koodattu merkistö voi olla listalla useilla eri nimillä (aliaksilla).\n"
"\n"
" "
@@ -2733,14 +2728,12 @@ msgid "locale.alias file to consult when making archive"
msgstr "Arkistoa luotaessa käytettävä locale.alias-tiedosto"
#: locale/programs/localedef.c:150
#, fuzzy
msgid "Generate little-endian output"
msgstr "Tuota little-endian-koodia"
msgstr "Tuota little-endian-muotoa"
#: locale/programs/localedef.c:152
#, fuzzy
msgid "Generate big-endian output"
msgstr "Tuota big-endian-koodia"
msgstr "Tuota big-endian-muotoa"
#: locale/programs/localedef.c:157
msgid "Compile locale specification"
@@ -4275,10 +4268,9 @@ msgid ""
msgstr ""
#: nscd/nscd.c:635
#, fuzzy, c-format
#| msgid "lstat failed"
#, c-format
msgid "'wait' failed\n"
msgstr "tiedoston tilan luku epäonnistui"
msgstr "”wait” epäonnistui\n"
#: nscd/nscd.c:642
#, c-format
@@ -4670,9 +4662,9 @@ msgid "cannot create temporary file"
msgstr "tilapäistä tiedostoa ei voi luoda"
#: nss/makedb.c:304
#, fuzzy, c-format
#, c-format
msgid "cannot stat newly created file"
msgstr "tiedoston ”%s” tilaa ei voi lukea: %s"
msgstr "juuri luodun tiedoston tilaa ei voi lukea"
#: nss/makedb.c:315
#, c-format
@@ -4680,9 +4672,9 @@ msgid "cannot rename temporary file"
msgstr "tilapäistä tiedostoa ei voi nimetä uudelleen"
#: nss/makedb.c:531 nss/makedb.c:554
#, fuzzy, c-format
#, c-format
msgid "cannot create search tree"
msgstr "hakupolulle ei voi luoda välimuistia"
msgstr "hakupuuta ei voi luoda"
#: nss/makedb.c:560
msgid "duplicate key"
@@ -4699,9 +4691,9 @@ msgid "failed to write new database file"
msgstr "uuden tietokantatiedoston kirjoittaminen epäonnistui"
#: nss/makedb.c:812
#, fuzzy, c-format
#, c-format
msgid "cannot stat database file"
msgstr "tiedoston ”%s” tilaa ei voi lukea: %s"
msgstr "tietokantatiedoston tilaa ei voi lukea"
#: nss/makedb.c:817
#, fuzzy, c-format
@@ -4709,9 +4701,9 @@ msgid "cannot map database file"
msgstr "Karttatietokannassa ei ole enempää tietueita"
#: nss/makedb.c:820
#, fuzzy, c-format
#, c-format
msgid "file not a database file"
msgstr "luettaessa profilointidatatiedoston tilaa"
msgstr "tiedosto ei ole tietokantatiedosto"
#: nss/makedb.c:871
#, fuzzy, c-format
@@ -4726,7 +4718,7 @@ msgstr "Käyttö: %s [-v määrittely] muuttujanimi [polku]\n"
#: posix/getconf.c:403
#, c-format
msgid " %s -a [pathname]\n"
msgstr ""
msgstr " %s -a [polku]\n"
#: posix/getconf.c:479
#, c-format
@@ -5094,11 +5086,11 @@ msgstr "Laitetta irrotettu"
#: stdio-common/psiginfo.c:139
msgid "Signal sent by kill()"
msgstr ""
msgstr "Signaalin lähetti kill()"
#: stdio-common/psiginfo.c:142
msgid "Signal sent by sigqueue()"
msgstr ""
msgstr "Signaalin lähetti sigqueue()"
#: stdio-common/psiginfo.c:145
msgid "Signal generated by the expiration of a timer"
@@ -5114,7 +5106,7 @@ msgstr ""
#: stdio-common/psiginfo.c:157
msgid "Signal sent by tkill()"
msgstr ""
msgstr "Signaalin lähetti tkill()"
#: stdio-common/psiginfo.c:162
msgid "Signal generated by the completion of an asynchronous name lookup request"
@@ -5296,9 +5288,8 @@ msgid "Failed (unspecified error)"
msgstr "Epäonnistui (määrittelemätön virhe)"
#: sunrpc/clnt_raw.c:115
#, fuzzy
msgid "clnt_raw.c: fatal header serialization error"
msgstr "clnt_raw.c: vakava otsikon serialisointivirhe"
msgstr "clnt_raw.c: vakava otsikon sarjallistamisvirhe"
#: sunrpc/pm_getmaps.c:77
msgid "pmap_getmaps.c: rpc problem"
@@ -6825,9 +6816,8 @@ msgid "Interrupted by a signal"
msgstr "Signaalin keskeyttämä"
#: sysdeps/posix/gai_strerror-strs.h:17
#, fuzzy
msgid "Parameter string not correctly encoded"
msgstr "Parametrimerkkijono on väärin koodattu"
msgstr "Parametrimerkkijono ei ole koodattu oikein"
#: sysdeps/unix/sysv/linux/i386/readelflib.c:65
#, c-format
+65 -78
View File
@@ -1,13 +1,17 @@
# GNU libc message catalog for Swedish
# Copyright © 1996, 1998, 2001, 2002, 2003, 2006, 2008, 2009, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
# Copyright © 1996, 1998, 2001, 2002, 2003, 2006, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
# This file is distributed under the same license as the glibc package.
# Jan Djärv <jan.h.d@swipnet.se>, 1996, 1998, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015
#
# Jan Djärv <jan.h.d@swipnet.se>, 1996, 1998, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015.
# Göran Uddeborg <goeran@uddeborg.se>, 2016.
#
# $Revision: 1.3 $
msgid ""
msgstr ""
"Project-Id-Version: libc 2.21-pre1\n"
"Project-Id-Version: libc 2.22-pre1\n"
"POT-Creation-Date: 2015-07-31 00:10-0400\n"
"PO-Revision-Date: 2015-01-24 10:35+0100\n"
"Last-Translator: Jan Djärv <jan.h.d@swipnet.se>\n"
"PO-Revision-Date: 2016-08-02 17:17+0200\n"
"Last-Translator: Göran Uddeborg <goeran@uddeborg.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
@@ -48,7 +52,7 @@ msgstr " [FLAGGA...]"
#: argp/argp-help.c:1643
#, c-format
msgid "Try `%s --help' or `%s --usage' for more information.\n"
msgstr "Försök med \"%s --help\" eller \"%s --usage\" för mer information\n"
msgstr "Försök med %s --help eller %s --usage för mer information.\n"
#: argp/argp-help.c:1671
#, c-format
@@ -304,11 +308,11 @@ msgstr "Användning: xtrace [FLAGGA]... PROGRAM [PROGRAMFLAGGA}...\\n"
#: debug/xtrace.sh:32 elf/sotruss.sh:56 elf/sotruss.sh:67 elf/sotruss.sh:135
#: malloc/memusage.sh:26
msgid "Try \\`%s --help' or \\`%s --usage' for more information.\\n"
msgstr "Försök med \\\"%s --help\\\" eller \\\"%s --usage\\\" för mer information\\n"
msgstr "Försök med %s --help eller %s --usage för mer information\\n"
#: debug/xtrace.sh:38
msgid "%s: option '%s' requires an argument.\\n"
msgstr "%s: flaggan \\\"%s\\\" kräver ett argument\\n"
msgstr "%s: flaggan ”%s” kräver ett argument.\\n"
#: debug/xtrace.sh:45
msgid ""
@@ -332,19 +336,17 @@ msgstr ""
" --usage Visa en kort hjälptext\n"
" -V,--version Visa versionsinformation och avsluta\n"
"\n"
"Obligatoriska argument för långa flaggor är obligatoriska även för\n"
"Obligatoriska argument för långa flaggor är obligatoriska även för\n"
"motsvarande korta.\n"
#: debug/xtrace.sh:57 elf/ldd.bash.in:55 elf/sotruss.sh:49
#: malloc/memusage.sh:64
msgid "For bug reporting instructions, please see:\\\\n%s.\\\\n"
msgstr ""
"För felrapporteringsinstruktioner, se:\\\\n%s.\\\\n\n"
"Rapportera fel eller synpunkter på översättningen till <tp-sv@listor.tp-sv.se>.\\\\n"
msgstr "För felrapporteringsinstruktioner, se:\\\\n%s.\\\\nRapportera fel eller synpunkter på översättningen till:\\\\n<tp-sv@listor.tp-sv.se>.\\\\n"
#: debug/xtrace.sh:125
msgid "xtrace: unrecognized option \\`$1'\\n"
msgstr "xtrace: okänd flagga \"$1\"\\n"
msgstr "xtrace: okänd flagga ”$1”\\n"
#: debug/xtrace.sh:138
msgid "No program name given\\n"
@@ -353,12 +355,12 @@ msgstr "Inget programnamn givet\\n"
#: debug/xtrace.sh:146
#, sh-format
msgid "executable \\`$program' not found\\n"
msgstr "program \"$program\" hittades inte\\n"
msgstr "program $program hittades inte\\n"
#: debug/xtrace.sh:150
#, sh-format
msgid "\\`$program' is no executable\\n"
msgstr "\"$program\" är inte en körbar binär\\n"
msgstr "$program är inte en körbar binär\\n"
#: dlfcn/dlinfo.c:63
msgid "RTLD_SELF used in code not dynamically loaded"
@@ -396,7 +398,7 @@ msgstr ", OS ABI: %s %d.%d.%d"
#: elf/cache.c:157 elf/ldconfig.c:1340
#, c-format
msgid "Can't open cache file %s\n"
msgstr "Kan inte öppna cache-fil \"%s\"\n"
msgstr "Kan inte öppna cache-filen %s\n"
#: elf/cache.c:171
#, c-format
@@ -416,7 +418,7 @@ msgstr "%d bibliotek hittades i cache \"%s\"\n"
#: elf/cache.c:426
#, c-format
msgid "Can't create temporary cache file %s"
msgstr "Kan inte skapa temporär cache-fil \"%s\""
msgstr "Kan inte skapa en temporär cache-fil %s"
#: elf/cache.c:434 elf/cache.c:444 elf/cache.c:448 elf/cache.c:453
#, c-format
@@ -829,7 +831,7 @@ msgstr "Kan inte ta status (lstat) på %s"
#: elf/ldconfig.c:609
#, c-format
msgid "Ignored file %s since it is not a regular file."
msgstr "Ignorerar fil %s eftersom den inte är en vanlig fil"
msgstr "Ignorerar fil %s eftersom den inte är en vanlig fil."
#: elf/ldconfig.c:618
#, c-format
@@ -951,7 +953,7 @@ msgstr ""
#: elf/ldd.bash.in:80
msgid "ldd: option \\`$1' is ambiguous"
msgstr "ldd: flaggan \"$1\" är tvetydig"
msgstr "ldd: flaggan ”$1” är tvetydig"
#: elf/ldd.bash.in:87
msgid "unrecognized option"
@@ -959,7 +961,7 @@ msgstr "okänd flagga"
#: elf/ldd.bash.in:88 elf/ldd.bash.in:125
msgid "Try \\`ldd --help' for more information."
msgstr "Försök med \"ldd --help\" för mer information"
msgstr "Försök med \"ldd --help\" för mer information."
#: elf/ldd.bash.in:124
msgid "missing file arguments"
@@ -1028,10 +1030,9 @@ msgid "cannot read object name"
msgstr "kan inte läsa objektnamn"
#: elf/pldd-xx.c:219
#, fuzzy, c-format
#| msgid "cannot allocate memory for program header"
#, c-format
msgid "cannot allocate buffer for object name"
msgstr "kan inte allokera minne för programhuvud"
msgstr "kan inte allokera en buffert för objektnamn"
#: elf/pldd.c:64
msgid "List dynamic shared objects loaded into process."
@@ -1212,11 +1213,11 @@ msgstr ""
#: elf/sotruss.sh:46
msgid "Mandatory arguments to long options are also mandatory for any corresponding\\nshort options.\\n"
msgstr "Obligatoriska respektive valfria argument för långa flaggor är obligatoriska respektive\\nvalfria även för korta.\\n"
msgstr "Obligatoriska respektive valfria argument för långa flaggor är obligatoriska\\nrespektive valfria även för korta.\\n"
#: elf/sotruss.sh:55
msgid "%s: option requires an argument -- '%s'\\n"
msgstr "%s: flaggan kräver ett argument -- \\\"%s\\\"\\n"
msgstr "%s: flaggan kräver ett argument — ”%s”\\n"
#: elf/sotruss.sh:61
msgid "%s: option is ambiguous; possibilities:"
@@ -1240,7 +1241,7 @@ msgstr ""
#: elf/sotruss.sh:134
msgid "%s: unrecognized option '%c%s'\\n"
msgstr "%s: okänd flagga \\\"%c%s\\\"\\n"
msgstr "%s: okänd flagga ”%c%s”\\n"
#: elf/sprof.c:77
msgid "Output selection:"
@@ -1260,7 +1261,7 @@ msgstr "generera anropsgraf"
#: elf/sprof.c:89
msgid "Read and display shared object profiling data."
msgstr "Läs och visa profildata för delat objekt"
msgstr "Läs och visa profildata för delat objekt."
#: elf/sprof.c:94
msgid "SHOBJ [PROFDATA]"
@@ -1622,7 +1623,7 @@ msgstr "Fel: .netrc kan läsas av andra."
#: inet/ruserpass.c:185
msgid "Remove password or make file unreadable by others."
msgstr "Ta bort lösenord eller gör filen oläsbar för andra"
msgstr "Ta bort lösenord eller gör filen oläsbar för andra."
#: inet/ruserpass.c:277
#, c-format
@@ -2182,12 +2183,12 @@ msgstr "Inget namn definierat i teckenuppsättning"
#: locale/programs/ld-ctype.c:479
#, c-format
msgid "character L'\\u%0*x' in class `%s' must be in class `%s'"
msgstr "tecken L\"\\u%0*x\" i klass \"%s\" måste vara i klass \"%s\""
msgstr "tecken L'\\u%0*x' i klassen ”%s” måste vara i klassen ”%s”"
#: locale/programs/ld-ctype.c:494
#, c-format
msgid "character L'\\u%0*x' in class `%s' must not be in class `%s'"
msgstr "tecken L\"\\u%0*x\" i klass \"%s\" får inte vara i klass \"%s\""
msgstr "tecken L'\\u%0*x' i klassen ”%s” får inte vara i klassen ”%s”"
#: locale/programs/ld-ctype.c:508 locale/programs/ld-ctype.c:566
#, c-format
@@ -2611,7 +2612,7 @@ msgstr "Skriv mer information"
#: locale/programs/locale.c:85
msgid "Get locale-specific information."
msgstr "Hämta lokalspecifik information"
msgstr "Hämta lokalspecifik information."
#: locale/programs/locale.c:88
msgid ""
@@ -3022,7 +3023,7 @@ msgstr "felaktig mcheck_status, biblioteket är felaktigt\n"
#: malloc/memusage.sh:32
msgid "%s: option '%s' requires an argument\\n"
msgstr "%s: flaggan \\\"%s\\\" kräver ett argument\\n"
msgstr "%s: flaggan ”%s” kräver ett argument\\n"
#: malloc/memusage.sh:38
msgid ""
@@ -3091,11 +3092,11 @@ msgstr ""
#: malloc/memusage.sh:191
msgid "memusage: option \\`${1##*=}' is ambiguous"
msgstr "memusage: flaggan \"${1##*=}\" är tvetydig"
msgstr "memusage: flaggan ${1##*=} är tvetydig"
#: malloc/memusage.sh:200
msgid "memusage: unrecognized option \\`$1'"
msgstr "memusage: okänd flagga \"$1\""
msgstr "memusage: okänd flagga ”$1”"
#: malloc/memusage.sh:213
msgid "No program name given"
@@ -3341,7 +3342,7 @@ msgstr "Kan inte skapa process hos server"
#: nis/nis_error.h:48
msgid "Master server busy, full dump rescheduled."
msgstr "Huvudserver är upptagen, full dump åter schemalagd"
msgstr "Huvudserver är upptagen, full dump åter schemalagd."
#: nis/nis_local_names.c:121
#, c-format
@@ -3511,7 +3512,7 @@ msgstr "\t\tRättigheter : "
#: nis/nis_print.c:290
msgid "Linked Object Type : "
msgstr "Länkad objekttyp: "
msgstr "Länkad objekttyp : "
#: nis/nis_print.c:292
#, c-format
@@ -3802,15 +3803,14 @@ msgid " (first)"
msgstr " (första)"
#: nscd/cache.c:288
#, fuzzy, c-format
#| msgid "cannot stat() file `%s': %s"
#, c-format
msgid "checking for monitored file `%s': %s"
msgstr "kan inte ta status på fil \"%s\": %s"
msgstr "kontrollerar den övervakade filen ”%s”: %s"
#: nscd/cache.c:298
#, c-format
msgid "monitored file `%s` changed (mtime)"
msgstr ""
msgstr "den övervakade filen ”%s” ändrades (mtime)"
#: nscd/cache.c:341
#, c-format
@@ -3906,34 +3906,32 @@ msgstr "kan inte få uttag (socket) att acceptera förbindelser: %s"
#: nscd/connections.c:973
#, c-format
msgid "disabled inotify-based monitoring for file `%s': %s"
msgstr ""
msgstr "avaktiverade inotify-baserad övervakning för filen ”%s”: %s"
#: nscd/connections.c:977
#, c-format
msgid "monitoring file `%s` (%d)"
msgstr ""
msgstr "övervakar filen ”%s” (%d)"
#: nscd/connections.c:990
#, c-format
msgid "disabled inotify-based monitoring for directory `%s': %s"
msgstr ""
msgstr "avaktiverade inotify-baserad övervakning av katalogen ”%s”: %s"
#: nscd/connections.c:994
#, fuzzy, c-format
#| msgid "Can't open directory %s"
#, c-format
msgid "monitoring directory `%s` (%d)"
msgstr "Kan inte öppna katalog %s"
msgstr "övervakar katalogen ”%s” (%d)"
#: nscd/connections.c:1022
#, fuzzy, c-format
#| msgid "register trace file %s for database %s"
#, c-format
msgid "monitoring file %s for database %s"
msgstr "registrera spårningsfil %s för databas %s"
msgstr "övervakar filen %s för databas %s"
#: nscd/connections.c:1032
#, c-format
msgid "stat failed for file `%s'; will try again later: %s"
msgstr ""
msgstr "stat misslyckades för filen ”%s”; kommer försöka igen senare: %s"
#: nscd/connections.c:1151
#, c-format
@@ -4032,44 +4030,42 @@ msgstr "handle_request: begäran mottagen (Version = %d)"
#: nscd/connections.c:1963
#, c-format
msgid "ignored inotify event for `%s` (file exists)"
msgstr ""
msgstr "ignorerade inotify-händelse för ”%s” (filen finns)"
#: nscd/connections.c:1968
#, c-format
msgid "monitored file `%s` was %s, removing watch"
msgstr ""
msgstr "den övervakade filen ”%s” var %s, tar bort vakten"
#: nscd/connections.c:1976 nscd/connections.c:2018
#, c-format
msgid "failed to remove file watch `%s`: %s"
msgstr ""
msgstr "misslyckades att ta bort filvakt ”%s”: %s"
#: nscd/connections.c:1991
#, c-format
msgid "monitored file `%s` was written to"
msgstr ""
msgstr "den övervakade filen ”%s” skrevs till"
#: nscd/connections.c:2015
#, c-format
msgid "monitored parent directory `%s` was %s, removing watch on `%s`"
msgstr ""
msgstr "den övervakade föräldrakatalogen ”%s” var %s, tar bort vakten av ”%s”"
#: nscd/connections.c:2041
#, c-format
msgid "monitored file `%s` was %s, adding watch"
msgstr ""
msgstr "den övervakade filen ”%s” var %s, lägger till vakt"
#: nscd/connections.c:2053
#, fuzzy, c-format
#| msgid "failed to load shared object `%s'"
#, c-format
msgid "failed to add file watch `%s`: %s"
msgstr "misslyckades med att ladda delat objekt \"%s\""
msgstr "misslyckades med att lägga till filvakt ”%s”: %s"
#: nscd/connections.c:2247 nscd/connections.c:2428
#, fuzzy, c-format
#| msgid "disabled inotify after read error %d"
#, c-format
msgid "disabled inotify-based monitoring after read error %d"
msgstr "inaktiverade inotify efter läsfel %d"
msgstr "avaktiverade inotify-baserad övervakning efter läsfel %d"
#: nscd/connections.c:2543
msgid "could not initialize conditional variable"
@@ -4199,7 +4195,7 @@ msgstr "Använd separat cache för varje användare"
#: nscd/nscd.c:122
msgid "Name Service Cache Daemon."
msgstr "Namntjänst cache-demon"
msgstr "Cache-demon för namntjänsten."
#: nscd/nscd.c:155 nss/getent.c:1007 nss/makedb.c:206
#, c-format
@@ -4531,11 +4527,11 @@ msgstr "Access Vector Cache (AVC) startad"
#: nscd/selinux.c:368
msgid "Error querying policy for undefined object classes or permissions."
msgstr "Fel när policy för odefinierade objektklasser eller rättigheter hämtades"
msgstr "Fel när policy för odefinierade objektklasser eller rättigheter hämtades."
#: nscd/selinux.c:375
msgid "Error getting security class for nscd."
msgstr "Fel när säkerhetsklass för nscd hämtades"
msgstr "Fel när säkerhetsklass för nscd hämtades."
#: nscd/selinux.c:380
#, c-format
@@ -4609,7 +4605,7 @@ msgstr "inaktivera DIN-kodning"
#: nss/getent.c:64
msgid "Get entries from administrative database."
msgstr "Hämta poster från den administrativa databasen"
msgstr "Hämta poster från den administrativa databasen."
#: nss/getent.c:148 nss/getent.c:477 nss/getent.c:522
#, c-format
@@ -4652,7 +4648,7 @@ msgstr "Genererad rad som inte ingår i iterationen"
#: nss/makedb.c:131
msgid "Create simple database from textual input."
msgstr "Skapa en enkel databas från textuell indata"
msgstr "Skapa en enkel databas från textuell indata."
#: nss/makedb.c:134
msgid ""
@@ -5412,7 +5408,7 @@ msgstr "Kan inte ange netid-flaggan utan TIRPC!\n"
#: sunrpc/rpc_main.c:1374
#, c-format
msgid "Cannot use table flags with newstyle!\n"
msgstr "Kan inte ange tabellflaggor med ny stil\n"
msgstr "Kan inte ange tabellflaggor med ny stil!\n"
#: sunrpc/rpc_main.c:1393
#, c-format
@@ -7270,18 +7266,9 @@ msgstr "tidszonsförkortning skiljer sig från POSIX-standarden"
#: timezone/zic.c:2789
msgid "too many, or too long, time zone abbreviations"
msgstr "för många eller för långa tidszonförkortningar"
msgstr "för många eller för långa tidszonsförkortningar"
#: timezone/zic.c:2829
#, c-format
msgid "%s: Can't create directory %s: %s\n"
msgstr "%s: Kan inte skapa katalog %s: %s\n"
#~ msgid "cannot load any more object with static TLS"
#~ msgstr "kan inte ladda fler objekt med statiskt TLS"
#~ msgid "%s: no PLTREL found in object %s\n"
#~ msgstr "%s: hittade inga PLTREL i objekt %s\n"
#~ msgid "cannot create internal descriptors"
#~ msgstr "kan inte skapa interna deskriptorer"
+10 -3
View File
@@ -43,7 +43,7 @@ routines := \
getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid \
getresuid getresgid setresuid setresgid \
pathconf sysconf fpathconf \
glob glob64 fnmatch regex \
glob glob64 globfree globfree64 glob_pattern_p fnmatch regex \
confstr \
getopt getopt1 getopt_init \
sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax \
@@ -90,7 +90,7 @@ tests := tstgetopt testfnm runtests runptests \
bug-getopt5 tst-getopt_long1 bug-regex34 bug-regex35 \
tst-pathconf tst-getaddrinfo4 tst-rxspencer-no-utf8 \
tst-fnmatch3 bug-regex36 tst-getaddrinfo5 \
tst-posix_spawn-fd
tst-posix_spawn-fd tst-glob-tilde
xtests := bug-ga2
ifeq (yes,$(build-shared))
test-srcs := globtest
@@ -133,7 +133,8 @@ tests-special += $(objpfx)bug-regex2-mem.out $(objpfx)bug-regex14-mem.out \
$(objpfx)tst-rxspencer-no-utf8-mem.out $(objpfx)tst-pcre-mem.out \
$(objpfx)tst-boost-mem.out $(objpfx)tst-getconf.out \
$(objpfx)bug-glob2-mem.out $(objpfx)tst-vfork3-mem.out \
$(objpfx)tst-fnmatch-mem.out $(objpfx)bug-regex36-mem.out
$(objpfx)tst-fnmatch-mem.out $(objpfx)bug-regex36-mem.out \
$(objpfx)tst-glob-tilde-mem.out
xtests-special += $(objpfx)bug-ga2-mem.out
endif
@@ -340,6 +341,12 @@ $(objpfx)bug-glob2-mem.out: $(objpfx)bug-glob2.out
$(common-objpfx)malloc/mtrace $(objpfx)bug-glob2.mtrace > $@; \
$(evaluate-test)
tst-glob-tilde-ENV = MALLOC_TRACE=$(objpfx)tst-glob-tilde.mtrace
$(objpfx)tst-glob-tilde-mem.out: $(objpfx)tst-glob-tilde.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-glob-tilde.mtrace > $@; \
$(evaluate-test)
$(inst_libexecdir)/getconf: $(inst_bindir)/getconf \
$(objpfx)getconf.speclist FORCE
$(addprefix $(..)./scripts/mkinstalldirs ,\
+10 -5
View File
@@ -48,12 +48,13 @@ maybe_script_execute (const char *file, char *const argv[], char *const envp[])
}
}
/* Construct an argument list for the shell. */
/* Construct an argument list for the shell. It will contain at minimum 3
arguments (current shell, script, and an ending NULL. */
char *new_argv[argc + 1];
new_argv[0] = (char *) _PATH_BSHELL;
new_argv[1] = (char *) file;
if (argc > 1)
memcpy (new_argv + 2, argv + 1, argc * sizeof(char *));
memcpy (new_argv + 2, argv + 1, (argc - 1) * sizeof(char *));
else
new_argv[2] = NULL;
@@ -91,10 +92,11 @@ __execvpe (const char *file, char *const argv[], char *const envp[])
/* Although GLIBC does not enforce NAME_MAX, we set it as the maximum
size to avoid unbounded stack allocation. Same applies for
PATH_MAX. */
size_t file_len = __strnlen (file, NAME_MAX + 1);
size_t file_len = __strnlen (file, NAME_MAX) + 1;
size_t path_len = __strnlen (path, PATH_MAX - 1) + 1;
if ((file_len > NAME_MAX)
/* NAME_MAX does not include the terminating null character. */
if (((file_len-1) > NAME_MAX)
|| !__libc_alloca_cutoff (path_len + file_len + 1))
{
errno = ENAMETOOLONG;
@@ -103,6 +105,9 @@ __execvpe (const char *file, char *const argv[], char *const envp[])
const char *subp;
bool got_eacces = false;
/* The resulting string maximum size would be potentially a entry
in PATH plus '/' (path_len + 1) and then the the resulting file name
plus '\0' (file_len since it already accounts for the '\0'). */
char buffer[path_len + file_len + 1];
for (const char *p = path; ; p = subp)
{
@@ -123,7 +128,7 @@ __execvpe (const char *file, char *const argv[], char *const envp[])
execute. */
char *pend = mempcpy (buffer, p, subp - p);
*pend = '/';
memcpy (pend + (p < subp), file, file_len + 1);
memcpy (pend + (p < subp), file, file_len);
__execve (buffer, argv, envp);
+45
View File
@@ -0,0 +1,45 @@
/* Sizes of structs with flexible array members.
Copyright 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>.
Written by Paul Eggert. */
#include <stddef.h>
/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
On older platforms without _Alignof, use a pessimistic bound that is
safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
On newer platforms, use _Alignof to get a tighter bound. */
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
#else
# define FLEXALIGNOF(type) _Alignof (type)
#endif
/* Upper bound on the size of a struct of type TYPE with a flexible
array member named MEMBER that is followed by N bytes of other data.
This is not simply sizeof (TYPE) + N, since it may require
alignment on unusually picky C11 platforms, and
FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms.
Yield a value less than N if and only if arithmetic overflow occurs. */
#define FLEXSIZEOF(type, member, n) \
((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
& ~ (FLEXALIGNOF (type) - 1))
+373 -407
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -43,10 +43,4 @@ glob64 (const char *pattern, int flags,
}
libc_hidden_def (glob64)
void
globfree64 (glob64_t *pglob)
{
}
libc_hidden_def (globfree64)
stub_warning (glob64)
+57
View File
@@ -0,0 +1,57 @@
/* Shared definition for glob and glob_pattern_p.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef GLOB_INTERNAL_H
# define GLOB_INTERNAL_H
static inline int
__glob_pattern_type (const char *pattern, int quote)
{
const char *p;
int ret = 0;
for (p = pattern; *p != '\0'; ++p)
switch (*p)
{
case '?':
case '*':
return 1;
case '\\':
if (quote)
{
if (p[1] != '\0')
++p;
ret |= 2;
}
break;
case '[':
ret |= 4;
break;
case ']':
if (ret & 4)
return 1;
break;
}
return ret;
}
#endif /* GLOB_INTERNAL_H */
+33
View File
@@ -0,0 +1,33 @@
/* Return nonzero if PATTERN contains any metacharacters.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
#endif
#include <glob.h>
#include "glob_internal.h"
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
int
__glob_pattern_p (const char *pattern, int quote)
{
return __glob_pattern_type (pattern, quote) == 1;
}
weak_alias (__glob_pattern_p, glob_pattern_p)
+41
View File
@@ -0,0 +1,41 @@
/* Frees the dynamically allocated storage from an earlier call to glob.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
#endif
#include <glob.h>
#include <stdlib.h>
/* Free storage allocated in PGLOB by a previous `glob' call. */
void
globfree (glob_t *pglob)
{
if (pglob->gl_pathv != NULL)
{
size_t i;
for (i = 0; i < pglob->gl_pathc; ++i)
free (pglob->gl_pathv[pglob->gl_offs + i]);
free (pglob->gl_pathv);
pglob->gl_pathv = NULL;
}
}
#ifndef globfree
libc_hidden_def (globfree)
#endif
@@ -1,6 +1,6 @@
/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
/* Frees the dynamically allocated storage from an earlier call to glob.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -16,8 +16,16 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* SH4 ABI does not really require argument alignment for 64-bits, but
the kernel interface for pread adds a dummy long argument before the
offset. */
#define __ALIGNMENT_ARG
#include <sysdeps/unix/sysv/linux/pread.c>
#ifndef _LIBC
# include <config.h>
#endif
#include <glob.h>
#include <stdlib.h>
/* Free storage allocated in PGLOB by a previous `glob' call. */
void
globfree64 (glob64_t *pglob)
{
}
libc_hidden_def (globfree64)
+143
View File
@@ -0,0 +1,143 @@
/* Check for GLOB_TIDLE heap allocation issues (bugs 22320, 22325, 22332).
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <glob.h>
#include <mcheck.h>
#include <nss.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <support/check.h>
#include <support/support.h>
/* Flag which indicates whether to pass the GLOB_ONLYDIR flag. */
static int do_onlydir;
/* Flag which indicates whether to pass the GLOB_NOCHECK flag. */
static int do_nocheck;
/* Flag which indicates whether to pass the GLOB_MARK flag. */
static int do_mark;
/* Flag which indicates whether to pass the GLOB_NOESCAPE flag. */
static int do_noescape;
static void
one_test (const char *prefix, const char *middle, const char *suffix)
{
char *pattern = xasprintf ("%s%s%s", prefix, middle, suffix);
int flags = GLOB_TILDE;
if (do_onlydir)
flags |= GLOB_ONLYDIR;
if (do_nocheck)
flags |= GLOB_NOCHECK;
if (do_mark)
flags |= GLOB_MARK;
if (do_noescape)
flags |= GLOB_NOESCAPE;
glob_t gl;
/* This glob call might result in crashes or memory leaks. */
if (glob (pattern, flags, NULL, &gl) == 0)
globfree (&gl);
free (pattern);
}
enum
{
/* The largest base being tested. */
largest_base_size = 500000,
/* The actual size is the base size plus a variable whose absolute
value is not greater than this. This helps malloc to trigger
overflows. */
max_size_skew = 16,
/* The maximum string length supported by repeating_string
below. */
repeat_size = largest_base_size + max_size_skew,
};
/* Used to construct strings which repeat a single character 'x'. */
static char *repeat;
/* Return a string of SIZE characters. */
const char *
repeating_string (int size)
{
TEST_VERIFY (size >= 0);
TEST_VERIFY (size <= repeat_size);
const char *repeated_shifted = repeat + repeat_size - size;
TEST_VERIFY (strlen (repeated_shifted) == size);
return repeated_shifted;
}
static int
do_test (void)
{
/* Avoid network-based NSS modules and initialize nss_files with a
dummy lookup. This has to come before mtrace because NSS does
not free all memory. */
__nss_configure_lookup ("passwd", "files");
(void) getpwnam ("root");
mtrace ();
repeat = xmalloc (repeat_size + 1);
memset (repeat, 'x', repeat_size);
repeat[repeat_size] = '\0';
/* These numbers control the size of the user name. The values
cover the minimum (0), a typical size (8), a large
stack-allocated size (100000), and a somewhat large
heap-allocated size (largest_base_size). */
static const int base_sizes[] = { 0, 8, 100, 100000, largest_base_size, -1 };
for (do_onlydir = 0; do_onlydir < 2; ++do_onlydir)
for (do_nocheck = 0; do_nocheck < 2; ++do_nocheck)
for (do_mark = 0; do_mark < 2; ++do_mark)
for (do_noescape = 0; do_noescape < 2; ++do_noescape)
for (int base_idx = 0; base_sizes[base_idx] >= 0; ++base_idx)
{
for (int size_skew = -max_size_skew; size_skew <= max_size_skew;
++size_skew)
{
int size = base_sizes[base_idx] + size_skew;
if (size < 0)
continue;
const char *user_name = repeating_string (size);
one_test ("~", user_name, "/a/b");
one_test ("~", user_name, "x\\x\\x////x\\a");
}
const char *user_name = repeating_string (base_sizes[base_idx]);
one_test ("~", user_name, "");
one_test ("~", user_name, "/");
one_test ("~", user_name, "/a");
one_test ("~", user_name, "/*/*");
one_test ("~", user_name, "\\/");
one_test ("/~", user_name, "");
one_test ("*/~", user_name, "/a/b");
}
free (repeat);
return 0;
}
#include <support/test-driver.c>
+5
View File
@@ -40,6 +40,9 @@ ifeq ($(have-thread-library),yes)
extra-libs += libanl
routines += gai_sigqueue
tests += tst-res_hconf_reorder
# This test sends millions of packets and is rather slow.
xtests += tst-resolv-qtypes
endif
extra-libs-others = $(extra-libs)
libresolv-routines := gethnamaddr res_comp res_debug \
@@ -117,3 +120,5 @@ tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace
$(objpfx)mtrace-tst-leaks2.out: $(objpfx)tst-leaks2.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace > $@; \
$(evaluate-test)
$(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library)
+1 -1
View File
@@ -323,7 +323,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
int olderr = errno;
enum nss_status status;
int n = __libc_res_nsearch (&_res, name, C_IN, T_UNSPEC,
int n = __libc_res_nsearch (&_res, name, C_IN, T_QUERY_A_AND_AAAA,
host_buffer.buf->buf, 2048, &host_buffer.ptr,
&ans2p, &nans2p, &resplen2, &ans2p_malloced);
if (n >= 0)
+4
View File
@@ -103,6 +103,10 @@ res_nmkquery(res_state statp,
int n;
u_char *dnptrs[20], **dpp, **lastdnptr;
if (class < 0 || class > 65535
|| type < 0 || type > 65535)
return -1;
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; res_nmkquery(%s, %s, %s, %s)\n",
+3 -3
View File
@@ -122,7 +122,7 @@ __libc_res_nquery(res_state statp,
int n, use_malloc = 0;
u_int oflags = statp->_flags;
size_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;
size_t bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * QUERYSIZE;
u_char *buf = alloca (bufsize);
u_char *query1 = buf;
int nquery1 = -1;
@@ -137,7 +137,7 @@ __libc_res_nquery(res_state statp,
printf(";; res_query(%s, %d, %d)\n", name, class, type);
#endif
if (type == T_UNSPEC)
if (type == T_QUERY_A_AND_AAAA)
{
n = res_nmkquery(statp, QUERY, name, class, T_A, NULL, 0, NULL,
query1, bufsize);
@@ -190,7 +190,7 @@ __libc_res_nquery(res_state statp,
if (__builtin_expect (n <= 0, 0) && !use_malloc) {
/* Retry just in case res_nmkquery failed because of too
short buffer. Shouldn't happen. */
bufsize = (type == T_UNSPEC ? 2 : 1) * MAXPACKET;
bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * MAXPACKET;
buf = malloc (bufsize);
if (buf != NULL) {
query1 = buf;
+185
View File
@@ -0,0 +1,185 @@
/* Exercise low-level query functions with different QTYPEs.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <resolv.h>
#include <string.h>
#include <support/check.h>
#include <support/check_nss.h>
#include <support/resolv_test.h>
#include <support/support.h>
#include <support/test-driver.h>
#include <support/xmemstream.h>
/* If ture, the response function will send the actual response packet
over TCP instead of UDP. */
static volatile bool force_tcp;
/* Send back a fake resource record matching the QTYPE. */
static void
response (const struct resolv_response_context *ctx,
struct resolv_response_builder *b,
const char *qname, uint16_t qclass, uint16_t qtype)
{
if (force_tcp && ctx->tcp)
{
resolv_response_init (b, (struct resolv_response_flags) { .tc = 1 });
resolv_response_add_question (b, qname, qclass, qtype);
return;
}
resolv_response_init (b, (struct resolv_response_flags) { });
resolv_response_add_question (b, qname, qclass, qtype);
resolv_response_section (b, ns_s_an);
resolv_response_open_record (b, qname, qclass, qtype, 0);
resolv_response_add_data (b, &qtype, sizeof (qtype));
resolv_response_close_record (b);
}
static const const char *domain = "www.example.com";
static int
wrap_res_query (int type, unsigned char *answer, int answer_length)
{
return res_query (domain, C_IN, type, answer, answer_length);
}
static int
wrap_res_search (int type, unsigned char *answer, int answer_length)
{
return res_query (domain, C_IN, type, answer, answer_length);
}
static int
wrap_res_querydomain (int type, unsigned char *answer, int answer_length)
{
return res_querydomain ("www", "example.com", C_IN, type,
answer, answer_length);
}
static int
wrap_res_send (int type, unsigned char *answer, int answer_length)
{
unsigned char buf[512];
int ret = res_mkquery (QUERY, domain, C_IN, type,
(const unsigned char *) "", 0, NULL,
buf, sizeof (buf));
if (type < 0 || type >= 65536)
{
/* res_mkquery fails for out-of-range record types. */
TEST_VERIFY_EXIT (ret == -1);
return -1;
}
TEST_VERIFY_EXIT (ret > 12); /* DNS header length. */
return res_send (buf, ret, answer, answer_length);
}
static int
wrap_res_nquery (int type, unsigned char *answer, int answer_length)
{
return res_nquery (&_res, domain, C_IN, type, answer, answer_length);
}
static int
wrap_res_nsearch (int type, unsigned char *answer, int answer_length)
{
return res_nquery (&_res, domain, C_IN, type, answer, answer_length);
}
static int
wrap_res_nquerydomain (int type, unsigned char *answer, int answer_length)
{
return res_nquerydomain (&_res, "www", "example.com", C_IN, type,
answer, answer_length);
}
static int
wrap_res_nsend (int type, unsigned char *answer, int answer_length)
{
unsigned char buf[512];
int ret = res_nmkquery (&_res, QUERY, domain, C_IN, type,
(const unsigned char *) "", 0, NULL,
buf, sizeof (buf));
if (type < 0 || type >= 65536)
{
/* res_mkquery fails for out-of-range record types. */
TEST_VERIFY_EXIT (ret == -1);
return -1;
}
TEST_VERIFY_EXIT (ret > 12); /* DNS header length. */
return res_nsend (&_res, buf, ret, answer, answer_length);
}
static void
test_function (const char *fname,
int (*func) (int type,
unsigned char *answer, int answer_length))
{
unsigned char buf[512];
for (int tcp = 0; tcp < 2; ++tcp)
{
force_tcp = tcp;
for (unsigned int type = 1; type <= 65535; ++type)
{
if (test_verbose)
printf ("info: sending QTYPE %d with %s (tcp=%d)\n",
type, fname, tcp);
int ret = func (type, buf, sizeof (buf));
if (ret != 47)
FAIL_EXIT1 ("%s tcp=%d qtype=%d return value %d",
fname,tcp, type, ret);
/* One question, one answer record. */
TEST_VERIFY (memcmp (buf + 4, "\0\1\0\1\0\0\0\0", 8) == 0);
/* Question section. */
static const char qname[] = "\3www\7example\3com";
size_t qname_length = sizeof (qname);
TEST_VERIFY (memcmp (buf + 12, qname, qname_length) == 0);
/* RDATA part of answer. */
uint16_t type16 = type;
TEST_VERIFY (memcmp (buf + ret - 2, &type16, sizeof (type16)) == 0);
}
}
TEST_VERIFY (func (-1, buf, sizeof (buf) == -1));
TEST_VERIFY (func (65536, buf, sizeof (buf) == -1));
}
static int
do_test (void)
{
struct resolv_redirect_config config =
{
.response_callback = response,
};
struct resolv_test *obj = resolv_test_start (config);
test_function ("res_query", &wrap_res_query);
test_function ("res_search", &wrap_res_search);
test_function ("res_querydomain", &wrap_res_querydomain);
test_function ("res_send", &wrap_res_send);
test_function ("res_nquery", &wrap_res_nquery);
test_function ("res_nsearch", &wrap_res_nsearch);
test_function ("res_nquerydomain", &wrap_res_nquerydomain);
test_function ("res_nsend", &wrap_res_nsend);
resolv_test_end (obj);
return 0;
}
#define TIMEOUT 300
#include <support/test-driver.c>
+110
View File
@@ -0,0 +1,110 @@
#!/bin/bash
# Create a patch which backports the support/ subdirectory.
# Copyright (C) 2017 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
# This script does not backport the Makefile tweaks outside the
# support/ directory (which need to be backported separately), or the
# changes to test-skeleton.c (which should not be backported).
set -e
export LC_ALL=C
export GIT_CONFIG=/dev/null
export GTT_CONFIG_NOSYSTEM=0
export GIT_PAGER=
usage () {
cat >&2 <<EOF
usage: $0 {patch|commit}
EOF
exit 1
}
if test $# -ne 1 ; then
usage
fi
command="$1"
case "$command" in
patch|commit)
;;
*)
usage
;;
esac
# The upstream branch to work on.
branch=origin/master
# The commit which added the support/ directory.
initial_commit=c23de0aacbeaa7a091609b35764bed931475a16d
# We backport the support directory and this script. Directories need
# to end in a /.
patch_targets="support/ scripts/backport-support.sh"
latest_commit="$(git log --max-count=1 --pretty=format:%H "$branch" -- \
$patch_targets)"
# Simplify the branch name somewhat for reporting.
branch_name="$(echo "$branch" | sed s,^origin/,,)"
command_patch () {
cat <<EOF
This patch creates the contents of the support/ directory up to this
upstream commit on the $branch_name branch:
EOF
git log --max-count=1 "$latest_commit"
echo
git diff "$initial_commit"^.."$latest_commit" $patch_targets
echo "# Before applying the patch, run this command:" >&2
echo "# rm -rf $patch_targets" >&2
}
command_commit () {
git status --porcelain | while read line ; do
echo "error: working copy is not clean, cannot commit" >&2
exit 1
done
for path in $patch_targets; do
echo "# Processing $path" >&2
case "$path" in
[a-zA-Z0-9]*/)
# Directory.
git rm --cached --ignore-unmatch -r "$path"
rm -rf "$path"
git read-tree --prefix="$path" "$latest_commit":"$path"
git checkout "$path"
;;
*)
# File.
git show "$latest_commit":"$path" > "$path"
git add "$path"
esac
done
git commit -m "Synchronize support/ infrastructure with $branch_name
This commit updates the support/ subdirectory to
commit $latest_commit
on the $branch_name branch.
"
}
command_$command
+13 -1
View File
@@ -96,13 +96,18 @@ rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
extra-objs = $(rpcgen-objs) $(addprefix cross-,$(rpcgen-objs))
others += rpcgen
tests = tst-xdrmem tst-xdrmem2 test-rpcent
tests = tst-xdrmem tst-xdrmem2 test-rpcent tst-udp-error
xtests := tst-getmyaddr
ifeq ($(have-thread-library),yes)
xtests += thrsvc
endif
ifeq ($(run-built-tests),yes)
rpcgen-tests := $(objpfx)bug20790.out
tests-special += $(rpcgen-tests)
endif
headers += $(rpcsvc:%.x=rpcsvc/%.h)
extra-libs := librpcsvc
extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
@@ -153,6 +158,7 @@ BUILD_CPPFLAGS += $(sunrpc-CPPFLAGS)
$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-udp-error: $(common-objpfx)linkobj/libc.so
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
@@ -225,3 +231,9 @@ endif
endif
$(objpfx)thrsvc: $(common-objpfx)linkobj/libc.so $(shared-thread-library)
ifeq ($(run-built-tests),yes)
$(rpcgen-tests): $(objpfx)%.out: %.x $(objpfx)rpcgen
$(built-program-cmd) -c $< -o $@; \
$(evaluate-test)
endif
+1
View File
@@ -0,0 +1 @@
program TPROG { version TVERS { int FUNC(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) = 1; } = 1; } = 1;
+1 -1
View File
@@ -421,9 +421,9 @@ send_again:
cmsg = CMSG_NXTHDR (&msg, cmsg))
if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
{
free (cbuf);
e = (struct sock_extended_err *) CMSG_DATA(cmsg);
cu->cu_error.re_errno = e->ee_errno;
free (cbuf);
return (cu->cu_error.re_status = RPC_CANTRECV);
}
free (cbuf);
+1 -1
View File
@@ -521,7 +521,7 @@ static void
get_prog_declaration (declaration * dec, defkind dkind, int num /* arg number */ )
{
token tok;
char name[10]; /* argument name */
char name[MAXLINESIZE]; /* argument name */
if (dkind == DEF_PROGRAM)
{
+62
View File
@@ -0,0 +1,62 @@
/* Check for use-after-free in clntudp_call (bug 21115).
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <netinet/in.h>
#include <rpc/clnt.h>
#include <rpc/svc.h>
#include <support/check.h>
#include <support/namespace.h>
#include <support/xsocket.h>
#include <unistd.h>
static int
do_test (void)
{
support_become_root ();
support_enter_network_namespace ();
/* Obtain a likely-unused port number. */
struct sockaddr_in sin =
{
.sin_family = AF_INET,
.sin_addr.s_addr = htonl (INADDR_LOOPBACK),
};
{
int fd = xsocket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
xbind (fd, (struct sockaddr *) &sin, sizeof (sin));
socklen_t sinlen = sizeof (sin);
xgetsockname (fd, (struct sockaddr *) &sin, &sinlen);
/* Close the socket, so that we will receive an error below. */
close (fd);
}
int sock = RPC_ANYSOCK;
CLIENT *clnt = clntudp_create
(&sin, 1, 2, (struct timeval) { 1, 0 }, &sock);
TEST_VERIFY_EXIT (clnt != NULL);
TEST_VERIFY (clnt_call (clnt, 3,
(xdrproc_t) xdr_void, NULL,
(xdrproc_t) xdr_void, NULL,
((struct timeval) { 3, 0 }))
== RPC_CANTRECV);
clnt_destroy (clnt);
return 0;
}
#include <support/test-driver.c>
+146
View File
@@ -0,0 +1,146 @@
# Makefile for support library, used only at build and test time
# Copyright (C) 2016-2017 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
subdir := support
include ../Makeconfig
extra-libs := libsupport
extra-libs-others = $(extra-libs)
extra-libs-noinstall := $(extra-libs)
libsupport-routines = \
check \
check_addrinfo \
check_dns_packet \
check_hostent \
check_netent \
delayed_exit \
ignore_stderr \
oom_error \
resolv_test \
set_fortify_handler \
support-xstat \
support_become_root \
support_can_chroot \
support_capture_subprocess \
support_capture_subprocess_check \
support_enter_network_namespace \
support_format_address_family \
support_format_addrinfo \
support_format_dns_packet \
support_format_herrno \
support_format_hostent \
support_format_netent \
support_isolate_in_subprocess \
support_record_failure \
support_run_diff \
support_shared_allocate \
support_write_file_string \
support_test_main \
support_test_verify_impl \
temp_file \
write_message \
xaccept \
xaccept4 \
xasprintf \
xbind \
xcalloc \
xchroot \
xclose \
xconnect \
xdup2 \
xfclose \
xfopen \
xfork \
xgetsockname \
xlisten \
xmalloc \
xmemstream \
xmkdir \
xmmap \
xmunmap \
xopen \
xpipe \
xpoll \
xpthread_attr_destroy \
xpthread_attr_init \
xpthread_attr_setdetachstate \
xpthread_attr_setstacksize \
xpthread_barrier_destroy \
xpthread_barrier_init \
xpthread_barrier_wait \
xpthread_cancel \
xpthread_check_return \
xpthread_cond_wait \
xpthread_create \
xpthread_detach \
xpthread_join \
xpthread_mutex_consistent \
xpthread_mutex_destroy \
xpthread_mutex_init \
xpthread_mutex_lock \
xpthread_mutex_unlock \
xpthread_mutexattr_destroy \
xpthread_mutexattr_init \
xpthread_mutexattr_setprotocol \
xpthread_mutexattr_setpshared \
xpthread_mutexattr_setrobust \
xpthread_mutexattr_settype \
xpthread_once \
xpthread_sigmask \
xpthread_spin_lock \
xpthread_spin_unlock \
xrealloc \
xrecvfrom \
xsendto \
xsetsockopt \
xsocket \
xstrdup \
xwaitpid \
xwrite \
libsupport-static-only-routines := $(libsupport-routines)
# Only build one variant of the library.
libsupport-inhibit-o := .os
ifeq ($(build-shared),yes)
libsupport-inhibit-o += .o
endif
tests = \
README-testing \
tst-support-namespace \
tst-support_capture_subprocess \
tst-support_format_dns_packet \
tst-support_record_failure \
ifeq ($(run-built-tests),yes)
tests-special = \
$(objpfx)tst-support_record_failure-2.out
$(objpfx)tst-support_record_failure-2.out: tst-support_record_failure-2.sh \
$(objpfx)tst-support_record_failure
$(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
'$(run-program-env)' '$(test-program-prefix-after-env)' \
> $@; \
$(evaluate-test)
endif
$(objpfx)tst-support_format_dns_packet: $(common-objpfx)resolv/libresolv.so
include ../Rules
+29
View File
@@ -0,0 +1,29 @@
This subdirectory contains infrastructure which is not put into
installed libraries, but may be linked into programs (installed or
not) and tests.
# Error-checking wrappers
These wrappers test for error return codes an terminate the process on
error. They are declared in these header files:
* support.h
* xsignal.h
* xthread.h
In general, new wrappers should be added to support.h if possible.
However, support.h must remain fully compatible with C90 and therefore
cannot include headers which use identifers not reserved in C90. If
the wrappers need additional types, additional headers such as
signal.h need to be introduced.
# Test framework
The test framework provides a main program for tests, including a
timeout for hanging tests. See README-testing.c for a minimal
example, and test-driver.c for details how to use it. The following
header files provide related declarations:
* check.h
* temp_file.h
* test-driver.h
+19
View File
@@ -0,0 +1,19 @@
/* This file contains an example test case which shows minimal use of
the test framework. Additional testing hooks are described in
<support/test-driver.c>. */
/* This function will be called from the test driver. */
static int
do_test (void)
{
if (3 == 5)
/* Indicate failure. */
return 1;
else
/* Indicate success. */
return 0;
}
/* This file references do_test above and contains the definition of
the main function. */
#include <support/test-driver.c>
+61
View File
@@ -0,0 +1,61 @@
/* Capture output from a subprocess.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_CAPTURE_SUBPROCESS_H
#define SUPPORT_CAPTURE_SUBPROCESS_H
#include <support/xmemstream.h>
struct support_capture_subprocess
{
struct xmemstream out;
struct xmemstream err;
int status;
};
/* Invoke CALLBACK (CLOSURE) in a subprocess and capture standard
output, standard error, and the exit status. The out.buffer and
err.buffer members in the result are null-terminated strings which
can be examined by the caller (out.out and err.out are NULL). */
struct support_capture_subprocess support_capture_subprocess
(void (*callback) (void *), void *closure);
/* Deallocate the subprocess data captured by
support_capture_subprocess. */
void support_capture_subprocess_free (struct support_capture_subprocess *);
enum support_capture_allow
{
/* No output is allowed. */
sc_allow_none = 0x01,
/* Output to stdout is permitted. */
sc_allow_stdout = 0x02,
/* Output to standard error is permitted. */
sc_allow_stderr = 0x04,
};
/* Check that the subprocess exited with STATUS and that only the
allowed outputs happened. ALLOWED is a combination of
support_capture_allow flags. Report errors under the CONTEXT
message. */
void support_capture_subprocess_check (struct support_capture_subprocess *,
const char *context, int status,
int allowed)
__attribute__ ((nonnull (1, 2)));
#endif /* SUPPORT_CAPTURE_SUBPROCESS_H */
+57
View File
@@ -0,0 +1,57 @@
/* Support code for reporting test results.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/check.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/test-driver.h>
static void
print_failure (const char *file, int line, const char *format, va_list ap)
{
printf ("error: %s:%d: ", file, line);
vprintf (format, ap);
puts ("");
}
int
support_print_failure_impl (const char *file, int line,
const char *format, ...)
{
support_record_failure ();
va_list ap;
va_start (ap, format);
print_failure (file, line, format, ap);
va_end (ap);
return 1;
}
void
support_exit_failure_impl (int status, const char *file, int line,
const char *format, ...)
{
if (status != EXIT_SUCCESS && status != EXIT_UNSUPPORTED)
support_record_failure ();
va_list ap;
va_start (ap, format);
print_failure (file, line, format, ap);
va_end (ap);
exit (status);
}
+94
View File
@@ -0,0 +1,94 @@
/* Functionality for reporting test results.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_CHECK_H
#define SUPPORT_CHECK_H
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Record a test failure, print the failure message to standard output
and return 1. */
#define FAIL_RET(...) \
return support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__)
/* Print the failure message and terminate the process with STATUS.
Record a the process as failed if STATUS is neither EXIT_SUCCESS
nor EXIT_UNSUPPORTED. */
#define FAIL_EXIT(status, ...) \
support_exit_failure_impl (status, __FILE__, __LINE__, __VA_ARGS__)
/* Record a test failure, print the failure message and terminate with
exit status 1. */
#define FAIL_EXIT1(...) \
support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__)
/* Print failure message and terminate with as unsupported test (exit
status of 77). */
#define FAIL_UNSUPPORTED(...) \
support_exit_failure_impl (77, __FILE__, __LINE__, __VA_ARGS__)
/* Record a test failure (but continue executing) if EXPR evaluates to
false. */
#define TEST_VERIFY(expr) \
({ \
if (expr) \
; \
else \
support_test_verify_impl (-1, __FILE__, __LINE__, #expr); \
})
/* Record a test failure and exit if EXPR evaluates to false. */
#define TEST_VERIFY_EXIT(expr) \
({ \
if (expr) \
; \
else \
support_test_verify_impl (1, __FILE__, __LINE__, #expr); \
})
int support_print_failure_impl (const char *file, int line,
const char *format, ...)
__attribute__ ((nonnull (1), format (printf, 3, 4)));
void support_exit_failure_impl (int exit_status,
const char *file, int line,
const char *format, ...)
__attribute__ ((noreturn, nonnull (2), format (printf, 4, 5)));
void support_test_verify_impl (int status, const char *file, int line,
const char *expr);
/* Record a test failure. This function returns and does not
terminate the process. The failure counter is stored in a shared
memory mapping, so that failures reported in child processes are
visible to the parent process and test driver. This function
depends on initialization by an ELF constructor, so it can only be
invoked after the test driver has run. Note that this function
does not support reporting failures from a DSO. */
void support_record_failure (void);
/* Internal function called by the test driver. */
int support_report_failure (int status)
__attribute__ ((weak, warn_unused_result));
/* Internal function used to test the failure recording framework. */
void support_record_failure_reset (void);
__END_DECLS
#endif /* SUPPORT_CHECK_H */
+42
View File
@@ -0,0 +1,42 @@
/* Compare struct addrinfo values against a formatted string.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/check_nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/check.h>
#include <support/format_nss.h>
#include <support/run_diff.h>
void
check_addrinfo (const char *query_description, struct addrinfo *ai, int ret,
const char *expected)
{
char *formatted = support_format_addrinfo (ai, ret);
if (strcmp (formatted, expected) != 0)
{
support_record_failure ();
printf ("error: addrinfo comparison failure\n");
if (query_description != NULL)
printf ("query: %s\n", query_description);
support_run_diff ("expected", expected,
"actual", formatted);
}
free (formatted);
}
+42
View File
@@ -0,0 +1,42 @@
/* Check that a DNS packet buffer has the expected contents.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/check_nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/check.h>
#include <support/format_nss.h>
#include <support/run_diff.h>
void
check_dns_packet (const char *query_description,
const unsigned char *buffer, size_t length,
const char *expected)
{
char *formatted = support_format_dns_packet (buffer, length);
if (strcmp (formatted, expected) != 0)
{
support_record_failure ();
printf ("error: packet comparison failure\n");
if (query_description != NULL)
printf ("query: %s\n", query_description);
support_run_diff ("expected", expected, "actual", formatted);
}
free (formatted);
}
+42
View File
@@ -0,0 +1,42 @@
/* Compare struct hostent values against a formatted string.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/check_nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/check.h>
#include <support/format_nss.h>
#include <support/run_diff.h>
void
check_hostent (const char *query_description, struct hostent *h,
const char *expected)
{
char *formatted = support_format_hostent (h);
if (strcmp (formatted, expected) != 0)
{
support_record_failure ();
printf ("error: hostent comparison failure\n");
if (query_description != NULL)
printf ("query: %s\n", query_description);
support_run_diff ("expected", expected,
"actual", formatted);
}
free (formatted);
}
+42
View File
@@ -0,0 +1,42 @@
/* Compare struct netent values against a formatted string.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/check_nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/check.h>
#include <support/format_nss.h>
#include <support/run_diff.h>
void
check_netent (const char *query_description, struct netent *e,
const char *expected)
{
char *formatted = support_format_netent (e);
if (strcmp (formatted, expected) != 0)
{
support_record_failure ();
printf ("error: netent comparison failure\n");
if (query_description != NULL)
printf ("query: %s\n", query_description);
support_run_diff ("expected", expected,
"actual", formatted);
}
free (formatted);
}
+42
View File
@@ -0,0 +1,42 @@
/* Test verification functions for NSS- and DNS-related data.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_CHECK_NSS_H
#define SUPPORT_CHECK_NSS_H
#include <netdb.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Compare the data structures against the expected values (which have
to be formatted according to the support_format_* functions in
<support/format_nss.h>). If there is a difference, a delayed test
failure is recorded, and a diff is written to standard output. */
void check_addrinfo (const char *query_description,
struct addrinfo *, int ret, const char *expected);
void check_dns_packet (const char *query_description,
const unsigned char *, size_t, const char *expected);
void check_hostent (const char *query_description,
struct hostent *, const char *expected);
void check_netent (const char *query_description,
struct netent *, const char *expected);
__END_DECLS
#endif /* SUPPORT_CHECK_NSS_H */
+55
View File
@@ -0,0 +1,55 @@
/* Time-triggered process termination.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/xthread.h>
#include <support/xsignal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/check.h>
#include <time.h>
static void *
delayed_exit_thread (void *seconds_as_ptr)
{
int seconds = (uintptr_t) seconds_as_ptr;
struct timespec delay = { seconds, 0 };
struct timespec remaining = { 0 };
if (nanosleep (&delay, &remaining) != 0)
FAIL_EXIT1 ("nanosleep: %m");
/* Exit the process sucessfully. */
exit (0);
return NULL;
}
void
delayed_exit (int seconds)
{
/* Create the new thread with all signals blocked. */
sigset_t all_blocked;
sigfillset (&all_blocked);
sigset_t old_set;
xpthread_sigmask (SIG_SETMASK, &all_blocked, &old_set);
/* Create a detached thread. */
pthread_t thr = xpthread_create
(NULL, delayed_exit_thread, (void *) (uintptr_t) seconds);
xpthread_detach (thr);
/* Restore the original signal mask. */
xpthread_sigmask (SIG_SETMASK, &old_set, NULL);
}
+41
View File
@@ -0,0 +1,41 @@
/* String formatting functions for NSS- and DNS-related data.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_FORMAT_NSS_H
#define SUPPORT_FORMAT_NSS_H
#include <netdb.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* The following functions format their arguments as human-readable
strings (which can span multiple lines). The caller must free the
returned buffer. For NULL pointers or failure status arguments,
error variables such as h_errno and errno are included in the
result. */
char *support_format_address_family (int);
char *support_format_addrinfo (struct addrinfo *, int ret);
char *support_format_dns_packet (const unsigned char *buffer, size_t length);
char *support_format_herrno (int);
char *support_format_hostent (struct hostent *);
char *support_format_netent (struct netent *);
__END_DECLS
#endif /* SUPPORT_FORMAT_NSS_H */
+38
View File
@@ -0,0 +1,38 @@
/* Avoid all the buffer overflow messages on stderr.
Copyright (C) 2015-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/support.h>
#include <fcntl.h>
#include <paths.h>
#include <stdlib.h>
#include <unistd.h>
void
ignore_stderr (void)
{
int fd = open (_PATH_DEVNULL, O_WRONLY);
if (fd == -1)
close (STDERR_FILENO);
else
{
dup2 (fd, STDERR_FILENO);
close (fd);
}
setenv ("LIBC_FATAL_STDERR_", "1", 1);
}
+65
View File
@@ -0,0 +1,65 @@
/* Entering namespaces for test case isolation.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_NAMESPACE_H
#define SUPPORT_NAMESPACE_H
#include <stdbool.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Attempts to become root (or acquire root-like privileges), possibly
with the help of user namespaces. Return true if (restricted) root
privileges could be attained in some way. Print diagnostics to
standard output.
Note that this function generally has to be called before a process
becomes multi-threaded, otherwise it may fail with insufficient
privileges on systems which would support this operation for
single-threaded processes. */
bool support_become_root (void);
/* Return true if this process can perform a chroot operation. In
general, this is only possible if support_become_root has been
called. Note that the actual test is performed in a subprocess,
after fork, so that the file system root of the original process is
not changed. */
bool support_can_chroot (void);
/* Enter a network namespace (and a UTS namespace if possible) and
configure the loopback interface. Return true if a network
namespace could be created. Print diagnostics to standard output.
If a network namespace could be created, but networking in it could
not be configured, terminate the process. It is recommended to
call support_become_root before this function so that the process
has sufficient privileges. */
bool support_enter_network_namespace (void);
/* Return true if support_enter_network_namespace managed to enter a
UTS namespace. */
bool support_in_uts_namespace (void);
/* Invoke CALLBACK (CLOSURE) in a subprocess created using fork.
Terminate the calling process if the subprocess exits with a
non-zero exit status. */
void support_isolate_in_subprocess (void (*callback) (void *), void *closure);
__END_DECLS
#endif
@@ -1,7 +1,6 @@
/* Compute positive difference, sparc 64-bit.
Copyright (C) 2013-2016 Free Software Foundation, Inc.
/* Reporting out-of-memory errors.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David S. Miller <davem@davemloft.net>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,15 +16,14 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <support/support.h>
ENTRY(__fdimf)
fcmps %f1, %f3
fbug 1f
nop
fzeros %f1
fnegs %f1, %f3
1: retl
fsubs %f1, %f3, %f0
END(__fdimf)
weak_alias (__fdimf, fdimf)
#include <stdio.h>
#include <stdlib.h>
void
oom_error (const char *function, size_t size)
{
printf ("%s: unable to allocate %zu bytes: %m\n", function, size);
exit (1);
}
File diff suppressed because it is too large Load Diff
+180
View File
@@ -0,0 +1,180 @@
/* DNS test framework and libresolv redirection.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_RESOLV_TEST_H
#define SUPPORT_RESOLV_TEST_H
#include <arpa/nameser.h>
#include <stdbool.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Information about EDNS properties of a DNS query. */
struct resolv_edns_info
{
bool active;
uint8_t extended_rcode;
uint8_t version;
uint16_t flags;
uint16_t payload_size;
};
/* This struct provides context information when the response callback
specified in struct resolv_redirect_config is invoked. */
struct resolv_response_context
{
const unsigned char *query_buffer;
size_t query_length;
int server_index;
bool tcp;
struct resolv_edns_info edns;
};
/* This opaque struct is used to construct responses from within the
response callback function. */
struct resolv_response_builder;
/* This opaque struct collects information about the resolver testing
currently in progress. */
struct resolv_test;
enum
{
/* Maximum number of test servers supported by the framework. */
resolv_max_test_servers = 3,
};
/* Configuration settings specific to individual test servers. */
struct resolv_redirect_server_config
{
bool disable_tcp; /* If true, no TCP server is listening. */
bool disable_udp; /* If true, no UDP server is listening. */
};
/* Instructions for setting up the libresolv redirection. */
struct resolv_redirect_config
{
/* The response_callback function is called for every incoming DNS
packet, over UDP or TCP. It must be specified, the other
configuration settings are optional. */
void (*response_callback) (const struct resolv_response_context *,
struct resolv_response_builder *,
const char *qname,
uint16_t qclass, uint16_t qtype);
/* Per-server configuration. */
struct resolv_redirect_server_config servers[resolv_max_test_servers];
/* Search path entries. The first entry serves as the default
domain name as well. */
const char *search[7];
/* Number of servers to activate in resolv. 0 means the default,
resolv_max_test_servers. */
int nscount;
/* If true, use a single thread to process all UDP queries. This
may results in more predictable ordering of queries and
responses. */
bool single_thread_udp;
};
/* Configure NSS to use, nss_dns only for aplicable databases, and try
to put the process into a network namespace for better isolation.
This may have to be called before resolv_test_start, before the
process creates any threads. Otherwise, initialization is
performed by resolv_test_start implicitly. */
void resolv_test_init (void);
/* Initiate resolver testing. This updates the _res variable as
needed. As a side effect, NSS is reconfigured to use nss_dns only
for aplicable databases, and the process may enter a network
namespace for better isolation. */
struct resolv_test *resolv_test_start (struct resolv_redirect_config);
/* Call this function at the end of resolver testing, to free
resources and report pending errors (if any). */
void resolv_test_end (struct resolv_test *);
/* The remaining facilities in this file are used for constructing
response packets from the response_callback function. */
/* Special settings for constructing responses from the callback. */
struct resolv_response_flags
{
/* 4-bit response code to incorporate into the response. */
unsigned char rcode;
/* If true, the TC (truncation) flag will be set. */
bool tc;
/* Initial section count values. Can be used to artificially
increase the counts, for malformed packet testing.*/
unsigned short qdcount;
unsigned short ancount;
unsigned short nscount;
unsigned short adcount;
};
/* Begin a new response with the requested flags. Must be called
first. */
void resolv_response_init (struct resolv_response_builder *,
struct resolv_response_flags);
/* Switches to the section in the response packet. Only forward
movement is supported. */
void resolv_response_section (struct resolv_response_builder *, ns_sect);
/* Add a question record to the question section. */
void resolv_response_add_question (struct resolv_response_builder *,
const char *name, uint16_t class,
uint16_t type);
/* Starts a new resource record with the specified owner name, class,
type, and TTL. Data is supplied with resolv_response_add_data or
resolv_response_add_name. */
void resolv_response_open_record (struct resolv_response_builder *,
const char *name, uint16_t class,
uint16_t type, uint32_t ttl);
/* Add unstructed bytes to the RDATA part of a resource record. */
void resolv_response_add_data (struct resolv_response_builder *,
const void *, size_t);
/* Add a compressed domain name to the RDATA part of a resource
record. */
void resolv_response_add_name (struct resolv_response_builder *,
const char *name);
/* Mark the end of the constructed record. Must be called last. */
void resolv_response_close_record (struct resolv_response_builder *);
/* Drop this query packet (that is, do not send a response, not even
an empty packet). */
void resolv_response_drop (struct resolv_response_builder *);
/* In TCP mode, close the connection after this packet (if a response
is sent). */
void resolv_response_close (struct resolv_response_builder *);
/* The size of the response packet built so far. */
size_t resolv_response_length (const struct resolv_response_builder *);
__END_DECLS
#endif /* SUPPORT_RESOLV_TEST_H */
+31
View File
@@ -0,0 +1,31 @@
/* Invoke the system diff tool to compare two strings.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef SUPPORT_RUN_DIFF_H
#define SUPPORT_RUN_DIFF_H
/* Compare the two NUL-terminated strings LEFT and RIGHT using the
diff tool. Label the sides of the diff with LEFT_LABEL and
RIGHT_LABEL, respectively.
This function assumes that LEFT and RIGHT are different
strings. */
void support_run_diff (const char *left_label, const char *left,
const char *right_label, const char *right);
#endif /* SUPPORT_RUN_DIFF_H */
+34
View File
@@ -0,0 +1,34 @@
/* Set signal handler for use in fortify tests.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/support.h>
#include <signal.h>
void
set_fortify_handler (void (*handler) (int sig))
{
struct sigaction sa;
sa.sa_handler = handler;
sa.sa_flags = 0;
sigemptyset (&sa.sa_mask);
sigaction (SIGABRT, &sa, NULL);
ignore_stderr ();
}
+30
View File
@@ -0,0 +1,30 @@
/* stat64 with error checking.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* NB: Non-standard file name to avoid sysdeps override for xstat. */
#include <support/check.h>
#include <support/xunistd.h>
#include <sys/stat.h>
void
xstat (const char *path, struct stat64 *result)
{
if (stat64 (path, result) != 0)
FAIL_EXIT1 ("stat64 (\"%s\"): %m", path);
}
+74
View File
@@ -0,0 +1,74 @@
/* Common extra functions.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header file should only contain definitions compatible with
C90. (Using __attribute__ is fine because <features.h> provides a
fallback.) */
#ifndef SUPPORT_H
#define SUPPORT_H
#include <stddef.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Write a message to standard output. Can be used in signal
handlers. */
void write_message (const char *message) __attribute__ ((nonnull (1)));
/* Avoid all the buffer overflow messages on stderr. */
void ignore_stderr (void);
/* Set fortification error handler. Used when tests want to verify that bad
code is caught by the library. */
void set_fortify_handler (void (*handler) (int sig));
/* Report an out-of-memory error for the allocation of SIZE bytes in
FUNCTION, terminating the process. */
void oom_error (const char *function, size_t size)
__attribute__ ((nonnull (1)));
/* Return a pointer to a memory region of SIZE bytes. The memory is
initialized to zero and will be shared with subprocesses (across
fork). The returned pointer must be freed using
support_shared_free; it is not compatible with the malloc
functions. */
void *support_shared_allocate (size_t size);
/* Deallocate a pointer returned by support_shared_allocate. */
void support_shared_free (void *);
/* Write CONTENTS to the file PATH. Create or truncate the file as
needed. The file mode is 0666 masked by the umask. Terminate the
process on error. */
void support_write_file_string (const char *path, const char *contents);
/* Error-checking wrapper functions which terminate the process on
error. */
void *xmalloc (size_t) __attribute__ ((malloc));
void *xcalloc (size_t n, size_t s) __attribute__ ((malloc));
void *xrealloc (void *p, size_t n);
char *xasprintf (const char *format, ...)
__attribute__ ((format (printf, 1, 2), malloc));
char *xstrdup (const char *);
__END_DECLS
#endif /* SUPPORT_H */
@@ -1,7 +1,6 @@
/* Compute positive difference, sparc 32-bit+v9.
Copyright (C) 2013-2016 Free Software Foundation, Inc.
/* Acquire root privileges.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David S. Miller <davem@davemloft.net>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,24 +16,25 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <math_ldbl_opt.h>
#include <support/namespace.h>
ENTRY(__fdim)
std %o0, [%sp + 72]
std %o2, [%sp + 80]
ldd [%sp + 72], %f0
ldd [%sp + 80], %f2
fcmpd %f0, %f2
fbug 1f
nop
fzero %f0
fnegd %f0, %f2
1: retl
fsubd %f0, %f2, %f0
END(__fdim)
weak_alias (__fdim, fdim)
#include <sched.h>
#include <stdio.h>
#include <unistd.h>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __fdim, fdiml, GLIBC_2_1);
bool
support_become_root (void)
{
#ifdef CLONE_NEWUSER
if (unshare (CLONE_NEWUSER | CLONE_NEWNS) == 0)
/* Even if we do not have UID zero, we have extended privileges at
this point. */
return true;
#endif
if (setuid (0) != 0)
{
printf ("warning: could not become root outside namespace (%m)\n");
return false;
}
return true;
}
+65
View File
@@ -0,0 +1,65 @@
/* Return true if the process can perform a chroot operation.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdio.h>
#include <support/check.h>
#include <support/namespace.h>
#include <support/support.h>
#include <sys/stat.h>
#include <unistd.h>
#include <xunistd.h>
static void
callback (void *closure)
{
int *result = closure;
struct stat64 before;
xstat ("/dev", &before);
if (chroot ("/dev") != 0)
{
*result = errno;
return;
}
struct stat64 after;
xstat ("/", &after);
TEST_VERIFY (before.st_dev == after.st_dev);
TEST_VERIFY (before.st_ino == after.st_ino);
*result = 0;
}
bool
support_can_chroot (void)
{
int *result = support_shared_allocate (sizeof (*result));
*result = 0;
support_isolate_in_subprocess (callback, result);
bool ok = *result == 0;
if (!ok)
{
static bool already_warned;
if (!already_warned)
{
already_warned = true;
errno = *result;
printf ("warning: this process does not support chroot: %m\n");
}
}
support_shared_free (result);
return ok;
}
+108
View File
@@ -0,0 +1,108 @@
/* Capture output from a subprocess.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/capture_subprocess.h>
#include <errno.h>
#include <stdlib.h>
#include <support/check.h>
#include <support/xunistd.h>
#include <support/xsocket.h>
static void
transfer (const char *what, struct pollfd *pfd, struct xmemstream *stream)
{
if (pfd->revents != 0)
{
char buf[1024];
ssize_t ret = TEMP_FAILURE_RETRY (read (pfd->fd, buf, sizeof (buf)));
if (ret < 0)
{
support_record_failure ();
printf ("error: reading from subprocess %s: %m", what);
pfd->events = 0;
pfd->revents = 0;
}
else if (ret == 0)
{
/* EOF reached. Stop listening. */
pfd->events = 0;
pfd->revents = 0;
}
else
/* Store the data just read. */
TEST_VERIFY (fwrite (buf, ret, 1, stream->out) == 1);
}
}
struct support_capture_subprocess
support_capture_subprocess (void (*callback) (void *), void *closure)
{
struct support_capture_subprocess result;
xopen_memstream (&result.out);
xopen_memstream (&result.err);
int stdout_pipe[2];
xpipe (stdout_pipe);
int stderr_pipe[2];
xpipe (stderr_pipe);
TEST_VERIFY (fflush (stdout) == 0);
TEST_VERIFY (fflush (stderr) == 0);
pid_t pid = xfork ();
if (pid == 0)
{
xclose (stdout_pipe[0]);
xclose (stderr_pipe[0]);
xdup2 (stdout_pipe[1], STDOUT_FILENO);
xdup2 (stderr_pipe[1], STDERR_FILENO);
callback (closure);
_exit (0);
}
xclose (stdout_pipe[1]);
xclose (stderr_pipe[1]);
struct pollfd fds[2] =
{
{ .fd = stdout_pipe[0], .events = POLLIN },
{ .fd = stderr_pipe[0], .events = POLLIN },
};
do
{
xpoll (fds, 2, -1);
transfer ("stdout", &fds[0], &result.out);
transfer ("stderr", &fds[1], &result.err);
}
while (fds[0].events != 0 || fds[1].events != 0);
xclose (stdout_pipe[0]);
xclose (stderr_pipe[0]);
xfclose_memstream (&result.out);
xfclose_memstream (&result.err);
xwaitpid (pid, &result.status, 0);
return result;
}
void
support_capture_subprocess_free (struct support_capture_subprocess *p)
{
free (p->out.buffer);
free (p->err.buffer);
}
@@ -0,0 +1,67 @@
/* Verify capture output from a subprocess.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <stdbool.h>
#include <stdio.h>
#include <support/capture_subprocess.h>
#include <support/check.h>
static void
print_context (const char *context, bool *failed)
{
if (*failed)
/* Do not duplicate message. */
return;
support_record_failure ();
printf ("error: subprocess failed: %s\n", context);
}
void
support_capture_subprocess_check (struct support_capture_subprocess *proc,
const char *context, int status,
int allowed)
{
TEST_VERIFY ((allowed & sc_allow_none)
|| (allowed & sc_allow_stdout)
|| (allowed & sc_allow_stderr));
TEST_VERIFY (!((allowed & sc_allow_none)
&& ((allowed & sc_allow_stdout)
|| (allowed & sc_allow_stderr))));
bool failed = false;
if (proc->status != status)
{
print_context (context, &failed);
printf ("error: expected exit status: %d\n", status);
printf ("error: actual exit status: %d\n", status);
}
if (!(allowed & sc_allow_stdout) && proc->out.length != 0)
{
print_context (context, &failed);
printf ("error: unexpected output from subprocess\n");
fwrite (proc->out.buffer, proc->out.length, 1, stdout);
puts ("\n");
}
if (!(allowed & sc_allow_stderr) && proc->err.length != 0)
{
print_context (context, &failed);
printf ("error: unexpected error output from subprocess\n");
fwrite (proc->err.buffer, proc->err.length, 1, stdout);
puts ("\n");
}
}
+75
View File
@@ -0,0 +1,75 @@
/* Enter a network namespace.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/namespace.h>
#include <net/if.h>
#include <sched.h>
#include <stdio.h>
#include <string.h>
#include <support/check.h>
#include <support/xsocket.h>
#include <support/xunistd.h>
#include <sys/ioctl.h>
#include <unistd.h>
static bool in_uts_namespace;
bool
support_enter_network_namespace (void)
{
#ifdef CLONE_NEWUTS
if (unshare (CLONE_NEWUTS) == 0)
in_uts_namespace = true;
else
printf ("warning: unshare (CLONE_NEWUTS) failed: %m\n");
#endif
#ifdef CLONE_NEWNET
if (unshare (CLONE_NEWNET) == 0)
{
/* Bring up the loopback interface. */
int fd = xsocket (AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
struct ifreq req;
strcpy (req.ifr_name, "lo");
TEST_VERIFY_EXIT (ioctl (fd, SIOCGIFFLAGS, &req) == 0);
bool already_up = req.ifr_flags & IFF_UP;
if (already_up)
/* This means that we likely have not achieved isolation from
the parent namespace. */
printf ("warning: loopback interface already exists"
" in new network namespace\n");
else
{
req.ifr_flags |= IFF_UP | IFF_RUNNING;
TEST_VERIFY_EXIT (ioctl (fd, SIOCSIFFLAGS, &req) == 0);
}
xclose (fd);
return !already_up;
}
#endif
printf ("warning: could not enter network namespace\n");
return false;
}
bool
support_in_uts_namespace (void)
{
return in_uts_namespace;
}
@@ -1,7 +1,6 @@
/* Compute positive difference, sparc 32-bit+v9.
Copyright (C) 2013-2016 Free Software Foundation, Inc.
/* Convert an address family to a string.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David S. Miller <davem@davemloft.net>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,19 +16,20 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <support/format_nss.h>
ENTRY(__fdimf)
st %o0, [%sp + 72]
st %o1, [%sp + 76]
ld [%sp + 72], %f0
ld [%sp + 76], %f1
fcmps %f0, %f1
fbug 1f
nop
fzeros %f0
fnegs %f0, %f1
1: retl
fsubs %f0, %f1, %f0
END(__fdimf)
weak_alias (__fdimf, fdimf)
#include <support/support.h>
char *
support_format_address_family (int family)
{
switch (family)
{
case AF_INET:
return xstrdup ("INET");
case AF_INET6:
return xstrdup ("INET6");
default:
return xasprintf ("<unknown address family %d>", family);
}
}
+239
View File
@@ -0,0 +1,239 @@
/* Convert struct addrinfo values to a string.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/format_nss.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <support/support.h>
#include <support/xmemstream.h>
static size_t
socket_address_length (int family)
{
switch (family)
{
case AF_INET:
return sizeof (struct sockaddr_in);
case AF_INET6:
return sizeof (struct sockaddr_in6);
default:
return -1;
}
}
static void
format_ai_flags_1 (FILE *out, struct addrinfo *ai, int flag, const char *name,
int * flags_printed)
{
if ((ai->ai_flags & flag) != 0)
fprintf (out, " %s", name);
*flags_printed |= flag;
}
static void
format_ai_flags (FILE *out, struct addrinfo *ai)
{
if (ai == NULL)
return;
if (ai->ai_flags != 0)
{
fprintf (out, "flags:");
int flags_printed = 0;
#define FLAG(flag) format_ai_flags_1 (out, ai, flag, #flag, &flags_printed)
FLAG (AI_PASSIVE);
FLAG (AI_CANONNAME);
FLAG (AI_NUMERICHOST);
FLAG (AI_V4MAPPED);
FLAG (AI_ALL);
FLAG (AI_ADDRCONFIG);
FLAG (AI_IDN);
FLAG (AI_CANONIDN);
FLAG (AI_IDN_ALLOW_UNASSIGNED);
FLAG (AI_IDN_USE_STD3_ASCII_RULES);
FLAG (AI_NUMERICSERV);
#undef FLAG
int remaining = ai->ai_flags & ~flags_printed;
if (remaining != 0)
fprintf (out, " %08x", remaining);
fprintf (out, "\n");
}
/* Report flag mismatches within the list. */
int flags = ai->ai_flags;
int index = 1;
ai = ai->ai_next;
while (ai != NULL)
{
if (ai->ai_flags != flags)
fprintf (out, "error: flags at %d: 0x%x expected, 0x%x actual\n",
index, flags, ai->ai_flags);
ai = ai->ai_next;
++index;
}
}
static void
format_ai_canonname (FILE *out, struct addrinfo *ai)
{
if (ai == NULL)
return;
if (ai->ai_canonname != NULL)
fprintf (out, "canonname: %s\n", ai->ai_canonname);
/* Report incorrectly set ai_canonname fields on subsequent list
entries. */
int index = 1;
ai = ai->ai_next;
while (ai != NULL)
{
if (ai->ai_canonname != NULL)
fprintf (out, "error: canonname set at %d: %s\n",
index, ai->ai_canonname);
ai = ai->ai_next;
++index;
}
}
static void
format_ai_one (FILE *out, struct addrinfo *ai)
{
{
char type_buf[32];
const char *type_str;
char proto_buf[32];
const char *proto_str;
/* ai_socktype */
switch (ai->ai_socktype)
{
case SOCK_RAW:
type_str = "RAW";
break;
case SOCK_DGRAM:
type_str = "DGRAM";
break;
case SOCK_STREAM:
type_str = "STREAM";
break;
default:
snprintf (type_buf, sizeof (type_buf), "%d", ai->ai_socktype);
type_str = type_buf;
}
/* ai_protocol */
switch (ai->ai_protocol)
{
case IPPROTO_IP:
proto_str = "IP";
break;
case IPPROTO_UDP:
proto_str = "UDP";
break;
case IPPROTO_TCP:
proto_str = "TCP";
break;
default:
snprintf (proto_buf, sizeof (proto_buf), "%d", ai->ai_protocol);
proto_str = proto_buf;
}
fprintf (out, "address: %s/%s", type_str, proto_str);
}
/* ai_addrlen */
if (ai->ai_addrlen != socket_address_length (ai->ai_family))
{
char *family = support_format_address_family (ai->ai_family);
fprintf (out, "error: invalid address length %d for %s\n",
ai->ai_addrlen, family);
free (family);
}
/* ai_addr */
{
char buf[128];
uint16_t port;
const char *ret;
switch (ai->ai_family)
{
case AF_INET:
{
struct sockaddr_in *sin = (struct sockaddr_in *) ai->ai_addr;
ret = inet_ntop (AF_INET, &sin->sin_addr, buf, sizeof (buf));
port = sin->sin_port;
}
break;
case AF_INET6:
{
struct sockaddr_in6 *sin = (struct sockaddr_in6 *) ai->ai_addr;
ret = inet_ntop (AF_INET6, &sin->sin6_addr, buf, sizeof (buf));
port = sin->sin6_port;
}
break;
default:
errno = EAFNOSUPPORT;
ret = NULL;
}
if (ret == NULL)
fprintf (out, "error: inet_top failed: %m\n");
else
fprintf (out, " %s %u\n", buf, ntohs (port));
}
}
/* Format all the addresses in one address family. */
static void
format_ai_family (FILE *out, struct addrinfo *ai, int family)
{
while (ai)
{
if (ai->ai_family == family)
format_ai_one (out, ai);
ai = ai->ai_next;
}
}
char *
support_format_addrinfo (struct addrinfo *ai, int ret)
{
int errno_copy = errno;
struct xmemstream mem;
xopen_memstream (&mem);
if (ret != 0)
{
fprintf (mem.out, "error: %s\n", gai_strerror (ret));
if (ret == EAI_SYSTEM)
{
errno = errno_copy;
fprintf (mem.out, "error: %m\n");
}
}
else
{
format_ai_flags (mem.out, ai);
format_ai_canonname (mem.out, ai);
format_ai_family (mem.out, ai, AF_INET);
format_ai_family (mem.out, ai, AF_INET6);
}
xfclose_memstream (&mem);
return mem.buffer;
}
+222
View File
@@ -0,0 +1,222 @@
/* Convert a DNS packet to a human-readable representation.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <support/format_nss.h>
#include <arpa/inet.h>
#include <resolv.h>
#include <support/check.h>
#include <support/support.h>
#include <support/xmemstream.h>
struct in_buffer
{
const unsigned char *data;
size_t size;
};
static inline bool
extract_8 (struct in_buffer *in, unsigned char *value)
{
if (in->size == 0)
return false;
*value = in->data[0];
++in->data;
--in->size;
return true;
}
static inline bool
extract_16 (struct in_buffer *in, unsigned short *value)
{
if (in->size < 2)
return false;
*value = (in->data[0] << 8) | in->data[1];
in->data += 2;
in->size -= 2;
return true;
}
static inline bool
extract_32 (struct in_buffer *in, unsigned *value)
{
if (in->size < 4)
return false;
unsigned a = in->data[0];
unsigned b = in->data[1];
unsigned c = in->data[2];
unsigned d = in->data[3];
*value = (a << 24) | (b << 16) | (c << 8) | d;
in->data += 4;
in->size -= 4;
return true;
}
static inline bool
extract_bytes (struct in_buffer *in, size_t length, struct in_buffer *value)
{
if (in->size < length)
return false;
*value = (struct in_buffer) {in->data, length};
in->data += length;
in->size -= length;
return true;
}
struct dname
{
char name[MAXDNAME + 1];
};
static bool
extract_name (struct in_buffer full, struct in_buffer *in, struct dname *value)
{
const unsigned char *full_end = full.data + full.size;
/* Sanity checks; these indicate buffer misuse. */
TEST_VERIFY_EXIT
(!(in->data < full.data || in->data > full_end
|| in->size > (size_t) (full_end - in->data)));
int ret = dn_expand (full.data, full_end, in->data,
value->name, sizeof (value->name));
if (ret < 0)
return false;
in->data += ret;
in->size -= ret;
return true;
}
char *
support_format_dns_packet (const unsigned char *buffer, size_t length)
{
struct in_buffer full = { buffer, length };
struct in_buffer in = full;
struct xmemstream mem;
xopen_memstream (&mem);
unsigned short txnid;
unsigned short flags;
unsigned short qdcount;
unsigned short ancount;
unsigned short nscount;
unsigned short adcount;
if (!(extract_16 (&in, &txnid)
&& extract_16 (&in, &flags)
&& extract_16 (&in, &qdcount)
&& extract_16 (&in, &ancount)
&& extract_16 (&in, &nscount)
&& extract_16 (&in, &adcount)))
{
fprintf (mem.out, "error: could not parse DNS header\n");
goto out;
}
if (qdcount != 1)
{
fprintf (mem.out, "error: question count is %d, not 1\n", qdcount);
goto out;
}
struct dname qname;
if (!extract_name (full, &in, &qname))
{
fprintf (mem.out, "error: malformed QNAME\n");
goto out;
}
unsigned short qtype;
unsigned short qclass;
if (!(extract_16 (&in, &qtype)
&& extract_16 (&in, &qclass)))
{
fprintf (mem.out, "error: malformed question\n");
goto out;
}
if (qtype != T_A && qtype != T_AAAA && qtype != T_PTR)
{
fprintf (mem.out, "error: unsupported QTYPE %d\n", qtype);
goto out;
}
fprintf (mem.out, "name: %s\n", qname.name);
for (int i = 0; i < ancount; ++i)
{
struct dname rname;
if (!extract_name (full, &in, &rname))
{
fprintf (mem.out, "error: malformed record name\n");
goto out;
}
unsigned short rtype;
unsigned short rclass;
unsigned ttl;
unsigned short rdlen;
struct in_buffer rdata;
if (!(extract_16 (&in, &rtype)
&& extract_16 (&in, &rclass)
&& extract_32 (&in, &ttl)
&& extract_16 (&in, &rdlen)
&& extract_bytes (&in, rdlen, &rdata)))
{
fprintf (mem.out, "error: malformed record header\n");
goto out;
}
/* Skip non-matching record types. */
if ((rtype != qtype && rtype != T_CNAME) || rclass != qclass)
continue;
switch (rtype)
{
case T_A:
if (rdlen == 4)
fprintf (mem.out, "address: %d.%d.%d.%d\n",
rdata.data[0],
rdata.data[1],
rdata.data[2],
rdata.data[3]);
else
fprintf (mem.out, "error: A record of size %d: %s\n",
rdlen, rname.name);
break;
case T_AAAA:
{
if (rdlen == 16)
{
char buf[100];
if (inet_ntop (AF_INET6, rdata.data, buf, sizeof (buf)) == NULL)
fprintf (mem.out, "error: AAAA record decoding failed: %m\n");
else
fprintf (mem.out, "address: %s\n", buf);
}
else
fprintf (mem.out, "error: AAAA record of size %d: %s\n",
rdlen, rname.name);
}
break;
case T_CNAME:
case T_PTR:
{
struct dname name;
if (extract_name (full, &rdata, &name))
fprintf (mem.out, "name: %s\n", name.name);
else
fprintf (mem.out, "error: malformed CNAME/PTR record\n");
}
}
}
out:
xfclose_memstream (&mem);
return mem.buffer;
}

Some files were not shown because too many files have changed in this diff Show More