]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
8 years agoIgnore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209) linaro/2.23/master
Siddhesh Poyarekar [Tue, 7 Mar 2017 15:22:04 +0000 (20:52 +0530)] 
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 1c1243b6fc33c029488add276e56570a07803bfd)

8 years agold.so: Reject overly long LD_AUDIT path elements
Florian Weimer [Mon, 19 Jun 2017 20:32:12 +0000 (22:32 +0200)] 
ld.so: Reject overly long LD_AUDIT path elements

Also only process the last LD_AUDIT entry.

(cherry picked from commit 81b82fb966ffbd94353f793ad17116c6088dedd9)

8 years agold.so: Reject overly long LD_PRELOAD path elements
Florian Weimer [Mon, 19 Jun 2017 20:31:04 +0000 (22:31 +0200)] 
ld.so: Reject overly long LD_PRELOAD path elements

(cherry picked from commit 6d0ba622891bed9d8394eef1935add53003b12e8)

8 years agoCVE-2017-1000366: Ignore LD_LIBRARY_PATH for AT_SECURE=1 programs [BZ #21624]
Florian Weimer [Mon, 19 Jun 2017 16:34:53 +0000 (18:34 +0200)] 
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 f6110a8fee2ca36f8e2d2abecf3cba9fa7b8ea7d)

8 years agoCorrect collation rules for Malayalam.
Santhosh Thottingal [Sun, 11 Jun 2017 14:08:37 +0000 (10:08 -0400)] 
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.

8 years agoposix: Add cleanup on the trap list for globtest.sh
Adhemerval Zanella [Tue, 11 Apr 2017 18:08:02 +0000 (15:08 -0300)] 
posix: Add cleanup on the trap list for globtest.sh

This patch prevents lingering files for SIGSEGV failures by adding
a cleanup handler on trap handler.  Checked on x86_64-linux-gnu.

* posix/globtest.sh: Add cleanup routine on trap 0.

Cherry-pick of 4fee33f.

8 years agofts: Fix symbol redirect for fts_set [BZ #21289]
Slava Barinov [Fri, 31 Mar 2017 06:49:25 +0000 (08:49 +0200)] 
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 ce39613205dc47ceaeea76710d49e7a483b503ab)

8 years agoDrop GLIBC_TUNABLES in setxid processes
Siddhesh Poyarekar [Thu, 2 Feb 2017 10:45:45 +0000 (16:15 +0530)] 
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.

8 years agoconfigure: accept __stack_chk_fail_local for ssp support too [BZ #20662]
Denis Kaganovich [Thu, 20 Oct 2016 20:01:39 +0000 (22:01 +0200)] 
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 c7409aded44634411a19b0b7178b7faa237835e6)

8 years agomalloc: Simplify static malloc interposition [BZ #20432]
Florian Weimer [Fri, 26 Aug 2016 20:40:27 +0000 (22:40 +0200)] 
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.

8 years agonptl/tst-tls3-malloc: Force freeing of thread stacks
Florian Weimer [Tue, 16 Aug 2016 09:06:13 +0000 (11:06 +0200)] 
nptl/tst-tls3-malloc: Force freeing of thread stacks

It turns out that due to the reduced stack size in tst-tls3 and the
(fixed) default stack cache size, allocated TLS variables are never
freed, so the test coverage for tst-tls3-malloc is less than complete.
This change increases the thread stack size for tst-tls3-malloc only,
to make sure thread stacks and TLS variables are freed.

8 years agomalloc: Run tests without calling mallopt [BZ #19469]
Florian Weimer [Tue, 2 Aug 2016 15:01:02 +0000 (17:01 +0200)] 
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.)

8 years agoelf: Do not use memalign for TCB/TLS blocks allocation [BZ #17730]
Florian Weimer [Wed, 3 Aug 2016 14:16:57 +0000 (16:16 +0200)] 
elf: Do not use memalign for TCB/TLS blocks allocation [BZ #17730]

Instead, call malloc and explicitly align the pointer.

There is no external location to store the original (unaligned)
pointer, and this commit increases the allocation size to store
the pointer at a fixed location relative to the TCB pointer.

The manual alignment means that some space goes unused which
was previously made available for subsequent allocations.
However, in the TLS_DTV_AT_TP case, the manual alignment code
avoids aligning the pre-TCB to the TLS block alignment.  (Even
while using memalign, the allocation had some unused padding
in front.)

This concludes the removal of memalign calls from the TLS code,
and the new tst-tls3-malloc test verifies that only core malloc
routines are used.

8 years agoelf: Avoid using memalign for TLS allocations [BZ #17730]
Florian Weimer [Wed, 3 Aug 2016 14:15:38 +0000 (16:15 +0200)] 
elf: Avoid using memalign for TLS allocations [BZ #17730]

Instead of a flag which indicates the pointer can be freed, dtv_t
now includes the pointer which should be freed.  Due to padding,
the size of dtv_t does not increase.

To avoid using memalign, the new allocate_dtv_entry function
allocates a sufficiently large buffer so that a sub-buffer
can be found in it which starts with an aligned pointer.  Both
the aligned and original pointers are kept, the latter for calling
free later.

8 years agoelf: Consolidate machine-agnostic DTV definitions in <dl-dtv.h>
Florian Weimer [Mon, 20 Jun 2016 12:31:40 +0000 (14:31 +0200)] 
elf: Consolidate machine-agnostic DTV definitions in <dl-dtv.h>

Identical definitions of dtv_t and TLS_DTV_UNALLOCATED were
repeated for all architectures using DTVs.

8 years agolocaledata: bs_BA: fix yesexpr/noexpr [BZ #20974]
Mike Frysinger [Thu, 15 Dec 2016 23:34:05 +0000 (18:34 -0500)] 
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 a035eb6928bc63fb798dcc1421529f933122d74f)

8 years agoFix cos computation for multiple precision fallback (bz #20357)
Siddhesh Poyarekar [Mon, 18 Jul 2016 17:03:09 +0000 (22:33 +0530)] 
Fix cos computation for multiple precision fallback (bz #20357)

During the sincos consolidation I made two mistakes, one was a logical
error due to which cos(0x1.8475e5afd4481p+0) returned
sin(0x1.8475e5afd4481p+0) instead.

The second issue was an error in negating inputs for the correct
quadrants for sine.  I could not find a suitable test case for this
despite running a program to search for such an input for a couple of
hours.

Following patch fixes both issues.  Tested on x86_64.  Thanks to Matt
Clay for identifying the issue.

[BZ #20357]
* sysdeps/ieee754/dbl-64/s_sin.c (sloww): Fix up condition
to call __mpsin/__mpcos and to negate values.
* math/auto-libm-test-in: Add test.
* math/auto-libm-test-out: Regenerate.

(cherry picked from commit cbf88869edced4b23d792d95a8626e35b831df35)

8 years agoDon't compile do_test with -mavx/-mavx2/-mavx512.
Andrew Senkevich [Mon, 17 Oct 2016 16:01:32 +0000 (19:01 +0300)] 
Don't compile do_test with -mavx/-mavx2/-mavx512.

Don't compile do_test (in sincos ABI tests) with -mavx, -mavx2
nor -mavx512 since they won't run on non-AVX machines.

(cherry-picked from commit fe0cf8614836e2b08b802eb1f55abca75d558545)

8 years agoFixed x86_64 vector sincos/sincosf ABI.
Andrew Senkevich [Mon, 17 Oct 2016 14:55:28 +0000 (17:55 +0300)] 
Fixed x86_64 vector sincos/sincosf ABI.

Fixed wrong vector sincos/sincosf ABI to have it compatible with
current vector function declaration "#pragma omp declare simd notinbranch",
according to which vector sincos should have vector of pointers for second and
third parameters. It is fixed with implementation as wrapper to version
having second and third parameters as pointers.

(cherry-picked from commit ee2196bb6766ca7e63a1ba22ebb7619a3266776a)

8 years agopowerpc: Fix POWER9 implies
Tulio Magno Quites Machado Filho [Fri, 16 Sep 2016 20:31:58 +0000 (17:31 -0300)] 
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 1850ce5a2ea3b908b26165e7e951cd4334129f07)

8 years agonptl/tst-once5: Reduce time to expected failure
Florian Weimer [Wed, 17 Aug 2016 14:14:02 +0000 (16:14 +0200)] 
nptl/tst-once5: Reduce time to expected failure

(cherry picked from commit 1f645571d2db9008b3cd3d5acb9ff93357864283)

8 years agoargp: Do not override GCC keywords with macros [BZ #16907]
Florian Weimer [Thu, 18 Aug 2016 09:15:42 +0000 (11:15 +0200)] 
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 2c820533c61fed175390bc6058afbbe42d2edc37)

8 years agofopencookie: Mangle function pointers stored on the heap [BZ #20222]
Florian Weimer [Sat, 11 Jun 2016 10:07:14 +0000 (12:07 +0200)] 
fopencookie: Mangle function pointers stored on the heap [BZ #20222]

(cherry picked from commit 983fd5c41ab7e5a5c33922259ca1ac99b3b413f8)

8 years agonss_db: Fix initialization of iteration position [BZ #20237]
Florian Weimer [Sat, 11 Jun 2016 10:12:56 +0000 (12:12 +0200)] 
nss_db: Fix initialization of iteration position [BZ #20237]

When get*ent is called without a preceding set*ent, we need
to set the initial iteration position in get*ent.

Reproducer: Add “services: db files” to /etc/nsswitch.conf, then run
“perl -e getservent”.  It will segfault before this change, and exit
silently after it.

(cherry picked from commit 31d0a4fa646db8b8c97ce24e0ec0a7b73de4fca1)

8 years agoReturn proper status from _nss_nis_initgroups_dyn (bug 20262)
Andreas Schwab [Thu, 16 Jun 2016 10:44:29 +0000 (12:44 +0200)] 
Return proper status from _nss_nis_initgroups_dyn (bug 20262)

(cherry picked from commit 73fb56a4d51fd4437e4cde6dd3c8077a610f88a8)

8 years agomalloc: Avoid premature fallback to mmap [BZ #20284]
Florian Weimer [Tue, 21 Jun 2016 19:29:21 +0000 (21:29 +0200)] 
malloc: Avoid premature fallback to mmap [BZ #20284]

Before this change, the while loop in reused_arena which avoids
returning a corrupt arena would never execute its body if the selected
arena were not corrupt.  As a result, result == begin after the loop,
and the function returns NULL, triggering fallback to mmap.

(cherry picked from commit a3b473373ee43a292f5ec68a7fda6b9cfb26a9b0)

8 years agoarm: mark __startcontext as .cantunwind (bug 20435)
Andreas Schwab [Thu, 18 Aug 2016 09:38:28 +0000 (11:38 +0200)] 
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 9e2ff6c9cc54c0b4402b8d49e4abe7000fde7617)

Also includes the NEWS update, cherry-picked from commits
056dd72af83f5459ce6d545a49dea6dba7d635dc and
4d047efdbc55b0d68947cde682e5363d16a66294.

8 years agoDo not override objects in libc.a in other static libraries [BZ #20452]
Florian Weimer [Wed, 17 Aug 2016 12:57:00 +0000 (14:57 +0200)] 
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 d9067fca40b8aac156d73cfa44d6875813555a6c)

8 years agomalloc: Preserve arena free list/thread count invariant [BZ #20370]
Florian Weimer [Tue, 2 Aug 2016 10:24:50 +0000 (12:24 +0200)] 
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 f88aab5d508c13ae4a88124e65773d7d827cd47b)

8 years agox86: Use sysdep.o from libc.a in static libraries
Florian Weimer [Thu, 4 Aug 2016 09:10:57 +0000 (11:10 +0200)] 
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 e67330ab57bfd0f964539576ae7dcc658c456724)

8 years agoSPARC64: update localplt.data
Aurelien Jarno [Thu, 30 Jun 2016 14:06:10 +0000 (16:06 +0200)] 
SPARC64: update localplt.data

Commits d81f90cc and 89faa0340 replaced called to __isnan and __isinf
by the corresponding GCC builtins. In turns GCC emits calls to _Qp_cmp.
We should therefore add _Qp_cmp to localplt.data as otherwise the
elf/check-localplt test fails with:

   Extra PLT reference: libc.so: _Qp_cmp

A similar change has already been done for SPARC32 in commit 6ef1cb95.

Changelog:
* sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data: Add _Qp_cmp.

(cherry picked from commit fd1cf1dc3b2d90c2a61332363feb1043f6916564)

8 years agohppa: fix loading of global pointer in _start [BZ #20277]
John David Anglin [Tue, 21 Jun 2016 22:35:22 +0000 (18:35 -0400)] 
hppa: fix loading of global pointer in _start [BZ #20277]

The patched change fixes a regression for executables compiled with the
-p option and linked with gcrt1.o.  The executables crash on startup.

This regression was introduced in 2.22 and was noticed in the gcc testsuite.

(cherry picked from commit 9765ffa71030efd8bb4f2ea4ed6e020fcb4bb714)

8 years agoi686/multiarch: Regenerate ulps
Aurelien Jarno [Wed, 29 Jun 2016 22:31:11 +0000 (00:31 +0200)] 
i686/multiarch: Regenerate ulps

This comes from running “make regen-ulps” on AMD Opteron 6272 CPUs.

Changelog:
* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Regenerated.

(cherry picked from commit 6a40d8df0c269a953726a432c50702372b86c500)

8 years agoFix tst-cancel17/tst-cancelx17, which sometimes segfaults while exiting.
Stefan Liebler [Tue, 17 May 2016 08:45:48 +0000 (10:45 +0200)] 
Fix tst-cancel17/tst-cancelx17, which sometimes segfaults while exiting.

The testcase tst-cancel[x]17 ends sometimes with a segmentation fault.
This happens in one of 10000 cases. Then the real testcase has already
exited with success and returned from do_test(). The segmentation fault
occurs after returning from main in _dl_fini().

In those cases, the aio_read(&a) was not canceled because the read
request was already in progress. In the meanwhile aio_write(ap) wrote
something to the pipe and the read request is able to read the
requested byte.
The read request hasn't finished before returning from do_test().
After it finishes, it writes the return value and error code from the
read syscall to the struct aiocb a, which lies on the stack of do_test.
The stack of the subsequent function call of _dl_fini or _dl_sort_fini,
which is inlined in _dl_fini is corrupted.

In case of S390, it reads a zero and decrements it by 1:
unsigned int k = nmaps - 1;
struct link_map **runp = maps[k]->l_initfini;
The load from unmapped memory leads to the segmentation fault.
The stack corruption also happens on other architectures.
I saw them e.g. on x86 and ppc, too.

This patch adds an aio_suspend call to ensure, that the read request
is finished before returning from do_test().

ChangeLog:

* nptl/tst-cancel17.c (do_test): Wait for finishing aio_read(&a).

(cherry picked from commit b3a810d0d3d5c6ce7ddfb61321cd7971808ca703)

8 years agoMIPS: run tst-mode-switch-{1,2,3}.c using test-skeleton.c
Aurelien Jarno [Mon, 27 Jun 2016 14:45:45 +0000 (16:45 +0200)] 
MIPS: run tst-mode-switch-{1,2,3}.c using test-skeleton.c

For some reasons I have not investigated yet, tst-mode-switch-1 hangs on
a MIPS UTM-8 machine running an o32 userland and a 3.6.1 kernel.

This patch changes the test so that it runs under the test-skeleton
framework, causing the test to fail after a timeout instead of hanging
the whole testsuite. At the same time, also change the tst-mode-switch-2
and tst-mode-switch-3 tests.

Changelog:
* sysdeps/mips/tst-mode-switch-1.c (main): Converted to ...
(do_test): ... this.
(TEST_FUNCTION): New macro.
 Include test-skeleton.c.
* sysdeps/mips/tst-mode-switch-2.c (main): Likewise.
* sysdeps/mips/tst-mode-switch-3.c (main): Likewise.

(cherry picked from commit 0cdaef4dac5a885af9848e158e77cc347ee781bb)

8 years agoMIPS, SPARC: more fixes to the vfork aliases in libpthread.so
Aurelien Jarno [Tue, 21 Jun 2016 21:59:37 +0000 (23:59 +0200)] 
MIPS, SPARC: more fixes to the vfork aliases in libpthread.so

Commit 43c29487 tried to fix the vfork aliases in libpthread.so on MIPS
and SPARC, but failed to do it correctly, introducing an ABI change.

This patch does the remaining changes needed to align the MIPS and SPARC
vfork implementations with the other architectures. That way the the
alpha version of pt-vfork.S works correctly for MIPS and SPARC. The
changes for alpha were done in 82aab97c.

Changelog:
* sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Rename into
__libc_vfork.
(__vfork) [IS_IN (libc)]: Remove alias.
(__libc_vfork) [IS_IN (libc)]: Define as an alias.
* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.

(cherry picked from commit b87c1ec3fa398646f042a68f0ce0f7d09c1348c7)

8 years agoMIPS, SPARC: fix wrong vfork aliases in libpthread.so
Aurelien Jarno [Sat, 18 Jun 2016 17:11:23 +0000 (19:11 +0200)] 
MIPS, SPARC: fix wrong vfork aliases in libpthread.so

With recent binutils versions the GNU libc fails to build on at least
MISP and SPARC, with this kind of error:

  /home/aurel32/glibc/glibc-build/nptl/libpthread.so:(*IND*+0x0): multiple definition of `vfork@GLIBC_2.0'
  /home/aurel32/glibc/glibc-build/nptl/libpthread.so::(.text+0xee50): first defined here

It appears that on these architectures pt-vfork.S includes vfork.S
(through the alpha version of pt-vfork.S) and that the __vfork aliases
are not conditionalized on IS_IN (libc) like on other architectures.
Therefore the aliases are also wrongly included in libpthread.so.

Fix this by properly conditionalizing the aliases like on other
architectures.

Changelog:
* sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Conditionalize
hidden_def, weak_alias and strong_alias on [IS_IN (libc)].
* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.

(cherry picked from commit 43c2948756bb6e144c7b871e827bba37d61ad3a3)

9 years agoAdd runtime check for __ASSUME_REQUEUE_PI (BZ# 18463)
Adhemerval Zanella [Tue, 17 May 2016 13:16:39 +0000 (10:16 -0300)] 
Add runtime check for __ASSUME_REQUEUE_PI (BZ# 18463)

This patch adds a runtime check for requeue priority futexes
(FUTEX_{WAIT,CMP}_REQUEUE_PI) for configurations that do not define
__ASSUME_REQUEUE_PI.

It uses the same check uses for priority lock/unlock support, where
issuing a futex operation with FUTEX_UNLOCK_PI returns if kernel has
or not internal 'futex_cmpxchg_enabled' support (which is also used
on requeue priority futexes operations).

For architectures that already have __ASSUME_REQUEUE_PI the code
flow does not change, 'use_requeue_pi' returns the previous chec
logic.  Also, if 'futex_cmpxchg_enabled' is not supported by the
kernel, the previous logic will be used (by issuing a default futex
operation).

Tested on ARM (v3.8 kernel) and x86_64.

* nptl/pthreadP.h (prio_inherit_missing): Change name to
__prio_inherit_missing.
(USE_REQUEUE_PI): Remove define.
(use_requeue_pi): New function.
* nptl/pthread_cond_broadcast.c [__ASSUME_REQUEUE_PI]
(__pthread_cond_broadcast): Remove ifdef.
(USE_REQUEUE_PI): Change to use_requeue_pi.
* nptl/pthread_cond_signal.c [__ASSUME_REQUEUE_PI]
(__pthread_cond_signal): Remove ifdef.
(USE_REQUEUE_PI): Change to use_requeue_pi.
* nptl/pthread_cond_timedwait.c [__ASSUME_REQUEUE_PI]
(__pthread_cond_timedwait): Remove ifdef.
(USE_REQUEUE_PI): Change to use_requeue_pi.
( nptl/pthread_cond_wait.c [__ASSUME_REQUEUE_PI]
(__pthread_cond_wait): Remove ifdef.
(USE_REQUEUE_PI): Change to use_requeue_pi.
* nptl/pthread_mutex_init.c (prio_inherit_missing): Remove 'static'
qualifier and change name to __prio_inherit_missing.

9 years agoRemove __ASSUME_SET_ROBUST_LIST
Adhemerval Zanella [Mon, 16 May 2016 22:01:10 +0000 (19:01 -0300)] 
Remove __ASSUME_SET_ROBUST_LIST

This patch removes __ASSUME_SET_ROBUST_LIST usage and assumes that
kernel will correctly return if it supports or not
futex_atomic_cmpxchg_inatomic.

On minimum supported kernel (v3.2 and v2.6.32 for x86) kernel has:

2418 SYSCALL_DEFINE2(set_robust_list, struct robust_list_head __user *, head,
2419                 size_t, len)
2420 {
2421         if (!futex_cmpxchg_enabled)
2422                 return -ENOSYS;

The patch also adds the __set_robust_list_avail runtime check for all
architectures, since for some the syscall may still return ENOSYS if
futex_atomic_cmpxchg_inatomic is not supported (for instance ARM).

Tested on armhf (with 3.8 kernel) and x86_64.

* nptl/nptl-init.c [__ASSUME_SET_ROBUST_LIST]
(__set_robust_list_avail): Remove define.
[__NR_set_robust_list] (__pthread_initialize_minimal_internal):
Likewise.
* nptl/pthreadP.h [__ASSUME_SET_ROBUST_LIST]
(__set_robust_list_avail): Likewise.
* nptl/pthread_create.c
[__NR_set_robust_list && !__ASSUME_SET_ROBUST_LIST]
(START_THREAD_DEFN): Likewise.
* nptl/pthread_mutex_init.c [!__ASSUME_SET_ROBUST_LIST]
(__pthread_mutex_init): Likewise.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h:
(__ASSUME_SET_ROBUST_LIST): Likewise.

9 years agoRemove __ASSUME_FUTEX_LOCK_PI
Adhemerval Zanella [Mon, 16 May 2016 13:35:25 +0000 (10:35 -0300)] 
Remove __ASSUME_FUTEX_LOCK_PI

This patch removes __ASSUME_FUTEX_LOCK_PI usage and assumes that
kernel will correctly return if it supports or not
futex_atomic_cmpxchg_inatomic.

Current PI mutex code already has runtime support by calling
prio_inherit_missing and returns ENOTSUP if the futex operation fails
at initialization (it issues a FUTEX_UNLOCK_PI futex operation).

Also, current minimum supported kernel (v3.2) will return ENOSYS if
futex_atomic_cmpxchg_inatomic is not supported in the system:

kernel/futex.c:

2628 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
2629                 u32 __user *uaddr2, u32 val2, u32 val3)
2630 {
2631         int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK;
[...]
2667         case FUTEX_UNLOCK_PI:
2668                 if (futex_cmpxchg_enabled)
2669                         ret = futex_unlock_pi(uaddr, flags);
[...]
2686         return ret;
2687 }

The futex_cmpxchg_enabled is initialized by calling cmpxchg_futex_value_locked,
which calls futex_atomic_cmpxchg_inatomic.

For ARM futex_atomic_cmpxchg_inatomic will be either defined (if both
CONFIG_CPU_USE_DOMAINS and CONFIG_SMP are not defined) or use the
default generic implementation that returns ENOSYS.

For m68k is uses the default generic implementation.

For mips futex_atomic_cmpxchg_inatomic will return ENOSYS if cpu has no
'cpu_has_llsc' support (defined by each chip supporte inside kernel).

For sparc, 32-bit kernel will just use default generic implementation,
while 64-bit kernel has support.

Tested on ARM (v3.8 kernel) and x86_64.

* nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
(prio_inherit_missing): Remove define.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FUTEX_LOCK_PI):
Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.

9 years agolibio: Fix fmemopen append mode failure (BZ# 20012)
Adhemerval Zanella [Wed, 27 Apr 2016 14:51:01 +0000 (11:51 -0300)] 
libio: Fix fmemopen append mode failure (BZ# 20012)

The fmemopen implementation does not account the file position correctly in
append mode. The following example shows the failure:

===
int main ()
{
  char buf[10] = "test";
  FILE *fp = fmemopen (buf, 10, "a+");
  fseek (fp, 0, SEEK_SET);

  int gr;
  if ((gr = getc (fp)) != 't' ||
      (gr = getc (fp)) != 'e' ||
      (gr = getc (fp)) != 's' ||
      (gr = getc (fp)) != 't' ||
      (gr = getc (fp)) != EOF)
    {
      printf ("%s: getc failed returned %i\n", __FUNCTION__, gr);
      return 1;
    }

  return 0;
}
===

This is due both how read and write operation update the buffer position,
taking in consideration buffer lenght instead of maximum position defined
by the open mode.  This patch fixes it and also fixes fseek not returning
EINVAL for invalid whence modes.

Tested on x86_64 and i686.

This is a backport of b65b205fbcabbb02463e31df17f5cabf7556f892.

[BZ #20012]
* libio/fmemopen.c (fmemopen_read): Use buffer maximum position, not
length to calculate the buffer to read.
(fmemopen_write): Set the buffer position based on bytes written.
(fmemopen_seek): Return EINVAL for invalid whence modes.

9 years agolibio: Update internal fmemopen position after write (BZ #20005)
Adhemerval Zanella [Tue, 26 Apr 2016 20:40:25 +0000 (17:40 -0300)] 
libio: Update internal fmemopen position after write (BZ #20005)

Current GLIBC fmemopen fails with a simple testcase:

  char buffer[500] = "x";
  FILE *stream;
  stream = fmemopen(buffer, 500, "r+");
  fwrite("fish",sizeof(char),5,stream);
  printf("pos-1:%ld\n",ftell(stream));
  fflush(stream);
  printf("pos-2:%ld\n",ftell(stream));

It returns:

  pos-1:5
  pos-2:0

Where it should return:

  pos-1:5
  pos-2:5

This is due the internal write function does not correctly update the internal
object position state and then the seek operation returns a wrong value.  This
patch fixes it.

It fixes both BZ #20005 and BZ #19230 (marked as duplicated). A new test is
added to check for such case.

Tested on x86_64 and i686.

This is a backport of f9123b5003e62b6e54996076e860f23aee9a0593.

* libio/fmemopen.c (fmemopen_write): Update internal position after
write.
* stdio-common/Makefile (tests): Add tst-fmemopen4.c.
* stdio-common/tst-fmemopen4.c: New file..

9 years agofork in libpthread cannot use IFUNC resolver [BZ #19861]
Florian Weimer [Wed, 1 Jun 2016 05:14:42 +0000 (07:14 +0200)] 
fork in libpthread cannot use IFUNC resolver [BZ #19861]

This commit only addresses the fork case, the vfork case has to be a
tail call, which is why the generic code needs an IFUNC resolver
there.

(cherry picked from commit f06f3f05b48c72e2c9b0fa78671f94fd22d67da8)

9 years agotest-skeleton.c: Do not set RLIMIT_DATA [BZ #19648]
Florian Weimer [Mon, 7 Mar 2016 12:48:47 +0000 (13:48 +0100)] 
test-skeleton.c: Do not set RLIMIT_DATA [BZ #19648]

With older kernels, it is mostly ineffective because it causes malloc
to switch from sbrk to mmap (potentially invalidating malloc testing
compared to what real appliations do).  With newer kernels which
have switched to enforcing RLIMIT_DATA for mmap as well, some test
cases will fail in an unintended fashion because the limit which was
set previously does not include room for all mmap mappings.

(cherry picked from commit 900056024b75eae8b550d7fee1dec9e71f28344e)

9 years agoMake padding in struct sockaddr_storage explicit [BZ #20111]
Florian Weimer [Mon, 23 May 2016 17:43:09 +0000 (19:43 +0200)] 
Make padding in struct sockaddr_storage explicit [BZ #20111]

This avoids aliasing issues with GCC 6 in -fno-strict-aliasing
mode.  (With implicit padding, not all data is copied.)

This change makes it explicit that struct sockaddr_storage is
only 126 bytes large on m68k (unlike elsewhere, where we end up
with the requested 128 bytes).  The new test case makes sure that
this does not happen on other architectures.

(cherry picked from commit 3375cfafa7961c6ae0e509c31c3b3cef9ad1f03d)

9 years agoCVE-2016-4429: sunrpc: Do not use alloca in clntudp_call [BZ #20112]
Florian Weimer [Mon, 23 May 2016 18:18:34 +0000 (20:18 +0200)] 
CVE-2016-4429: sunrpc: Do not use alloca in clntudp_call [BZ #20112]

The call is technically in a loop, and under certain circumstances
(which are quite difficult to reproduce in a test case), alloca
can be invoked repeatedly during a single call to clntudp_call.
As a result, the available stack space can be exhausted (even
though individual alloca sizes are bounded implicitly by what
can fit into a UDP packet, as a side effect of the earlier
successful send operation).

(cherry picked from commit bc779a1a5b3035133024b21e2f339fe4219fb11c)

9 years agotst-mallocfork2: Fix race condition, use fewer resources
Florian Weimer [Fri, 13 May 2016 14:55:01 +0000 (16:55 +0200)] 
tst-mallocfork2: Fix race condition, use fewer resources

The first SIGUSR1 signal could arrive when sigusr1_sender_pid
was still 0.  As a result, kill would send SIGSTOP to the
entire process group.  This would cause the test to hang before
printing any output.

This commit also adds a sched_yield to the signal source, so that
it does not flood the parent process with signals it has never a
chance to handle.

Even with these changes, tst-mallocfork2 still fails reliably
after the fix in commit commit 56290d6e762c1194547e73ff0b948cd79d3a1e03
(Increase fork signal safety for single-threaded processes) is
backed out.

(cherry picked from commit e2cd73a2ccabe8acae28719a0c3c1c03f2b5f9fb)

The backport increases the timeout to 20 seconds, in line with
the default on master.  (The branch default of 2 seconds is too
tight.)

9 years agoIncrease fork signal safety for single-threaded processes [BZ #19703]
Florian Weimer [Thu, 12 May 2016 06:54:17 +0000 (08:54 +0200)] 
Increase fork signal safety for single-threaded processes [BZ #19703]

This provides a band-aid and addresses the scenario where fork is
called from a signal handler while the process is in the malloc
subsystem (or has acquired the libio list lock).  It does not
address the general issue of async-signal-safety of fork;
multi-threaded processes are not covered, and some glibc
subsystems have fork handlers which are not async-signal-safe.

(cherry picked from commit 56290d6e762c1194547e73ff0b948cd79d3a1e03)

9 years agoFix strfmon_l: Use specified locale for number formatting [BZ #19633]
Stefan Liebler [Thu, 14 Apr 2016 10:21:53 +0000 (12:21 +0200)] 
Fix strfmon_l: Use specified locale for number formatting [BZ #19633]

The commit 985fc132f23dbb83de76c5af9e783ef1b5900148
"strfmon_l: Use specified locale for number formatting [BZ #19633]"
introduced an elf/check-abi-libc testfailure due to __printf_fp_l
on architectures which use sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h.

This patch uses libc_hidden_def instead of ldbl_hidden_def.
The ldbl_strong_alias is removed due to the rename of ___printf_fp_l
to __printf_fp_l.

ChangeLog:

* stdio-common/printf_fp.c (__printf_fp_l):
Rename ___printf_fp_l to __printf_fp_l and
remove strong alias. Use libc_hidden_def instead
of ldbl_hidden_def macro.

(cherry picked from commit b1b8f5d89d06a994773e22ad4b7fe1036b37f8ab)

9 years agoCVE-2016-3706: getaddrinfo: stack overflow in hostent conversion [BZ #20010]
Florian Weimer [Fri, 29 Apr 2016 08:35:34 +0000 (10:35 +0200)] 
CVE-2016-3706: getaddrinfo: stack overflow in hostent conversion [BZ #20010]

When converting a struct hostent response to struct gaih_addrtuple, the
gethosts macro (which is called from gaih_inet) used alloca, without
malloc fallback for large responses.  This commit changes this code to
use calloc unconditionally.

This commit also consolidated a second hostent-to-gaih_addrtuple
conversion loop (in gaih_inet) to use the new conversion function.

(cherry picked from commit 4ab2ab03d4351914ee53248dc5aef4a8c88ff8b9)

9 years agoRevert "Report dlsym, dlvsym lookup errors using dlerror [BZ #19509]"
Florian Weimer [Wed, 11 May 2016 09:40:44 +0000 (11:40 +0200)] 
Revert "Report dlsym, dlvsym lookup errors using dlerror [BZ #19509]"

This reverts commits 80f87443eed17838fe453f1f5406ccf5d3698c25
and a824d609581d5ee7544aabcbbc70e8da44b2b5b6.

See bug 20069.  We can revisit this change once there has been a GCC
release with a fix for Address Sanitizer.

9 years agoRemove trailing newline from date_fmt in Serbian locales [BZ #19581]
Florian Weimer [Fri, 19 Feb 2016 13:21:34 +0000 (14:21 +0100)] 
Remove trailing newline from date_fmt in Serbian locales [BZ #19581]

(cherry picked from commit ff889b196575c2fbf6aa7130abb1ec862714ea4e)

9 years agoFix tst-dlsym-error build
Adhemerval Zanella [Thu, 31 Mar 2016 13:51:51 +0000 (10:51 -0300)] 
Fix tst-dlsym-error build

This patch fixes the new test tst-dlsym-error build on aarch64
(and possible other architectures as well) due missing strchrnul
definition.

* elf/tst-dlsym-error.c: Include <string.h> for strchrnul.

(cherry picked from commit e91bd7465816f474617dcb4bbfe72f3594c5783c)

9 years agoReport dlsym, dlvsym lookup errors using dlerror [BZ #19509]
Florian Weimer [Thu, 31 Mar 2016 09:26:55 +0000 (11:26 +0200)] 
Report dlsym, dlvsym lookup errors using dlerror [BZ #19509]

* elf/dl-lookup.c (_dl_lookup_symbol_x): Report error even if
skip_map != NULL.
* elf/tst-dlsym-error.c: New file.
* elf/Makefile (tests): Add tst-dlsym-error.
(tst-dlsym-error): Link against libdl.

(cherry picked from commit 7d45c163d00c88d5875a112343c4ea3e61349e6b)

9 years agoldconfig: Do not remove stale symbolic links with -X [BZ #19610]
Florian Weimer [Mon, 7 Mar 2016 21:06:18 +0000 (22:06 +0100)] 
ldconfig: Do not remove stale symbolic links with -X [BZ #19610]

(cherry picked from commit 920b35c92ed8f41796c090c2819434e56701da5b)

9 years agoCVE-2016-1234: glob: Do not copy d_name field of struct dirent [BZ #19779]
Florian Weimer [Wed, 4 May 2016 10:09:35 +0000 (12:09 +0200)] 
CVE-2016-1234: glob: Do not copy d_name field of struct dirent [BZ #19779]

Instead, we store the data we need from the return value of
readdir in an object of the new type struct readdir_result.
This type is independent of the layout of struct dirent.

(cherry picked from commit 5171f3079f2cc53e0548fc4967361f4d1ce9d7ea)

9 years agoglob: Simplify the interface for the GLOB_ALTDIRFUNC callback gl_readdir
Florian Weimer [Fri, 29 Apr 2016 07:33:07 +0000 (09:33 +0200)] 
glob: Simplify the interface for the GLOB_ALTDIRFUNC callback gl_readdir

Previously, application code had to set up the d_namlen member if
the target supported it, involving conditional compilation.  After
this change, glob will use the length of the string in d_name instead
of d_namlen to determine the file name length.  All glibc targets
provide the d_type and d_ino members, and setting them as needed for
gl_readdir is straightforward.

Changing the behavior with regards to d_ino is left to a future
cleanup.

(cherry picked from commit 137fe72eca6923a00381a3ca9f0e7672c1f85e3f)

9 years agostrfmon_l: Use specified locale for number formatting [BZ #19633]
Florian Weimer [Mon, 4 Apr 2016 13:18:13 +0000 (15:18 +0200)] 
strfmon_l: Use specified locale for number formatting [BZ #19633]

(cherry picked from commit 985fc132f23dbb83de76c5af9e783ef1b5900148)

9 years agotst-audit10: Fix compilation on compilers without bit_AVX512F [BZ #19860]
Florian Weimer [Fri, 25 Mar 2016 10:11:42 +0000 (11:11 +0100)] 
tst-audit10: Fix compilation on compilers without bit_AVX512F [BZ #19860]

[BZ# 19860]
* sysdeps/x86_64/tst-audit10.c (avx512_enabled): Always return
zero if the compiler does not provide the AVX512F bit.

(cherry picked from commit f327f5b47be57bc05a4077344b381016c1bb2c11)

9 years agoFix tst-audit10 build when -mavx512f is not supported.
Roland McGrath [Tue, 8 Mar 2016 20:31:13 +0000 (12:31 -0800)] 
Fix tst-audit10 build when -mavx512f is not supported.

(cherry picked from commit 3bd80c0de2f8e7ca8020d37739339636d169957e)

9 years agotst-audit4, tst-audit10: Compile AVX/AVX-512 code separately [BZ #19269]
Florian Weimer [Mon, 7 Mar 2016 15:00:25 +0000 (16:00 +0100)] 
tst-audit4, tst-audit10: Compile AVX/AVX-512 code separately [BZ #19269]

This ensures that GCC will not use unsupported instructions before
the run-time check to ensure support.

(cherry picked from commit 3c0f7407eedb524c9114bb675cd55b903c71daaa)

9 years agoresolv: Always set *resplen2 out parameter in send_vc [BZ #19825]
Florian Weimer [Wed, 27 Apr 2016 12:26:47 +0000 (14:26 +0200)] 
resolv: Always set *resplen2 out parameter in send_vc [BZ #19825]

In various error scenarios (for example, if the server closes the
TCP connection before sending the full response), send_vc can return
without resetting the *resplen2 value.  This can pass uninitialized
or unexpected data to the caller.

(cherry picked from commit b9bdfa7c8fa22c944bb5f21a673dfd1f91b71c56)

9 years agonss_dns: Skip over non-PTR records in the netent code [BZ #19868]
Florian Weimer [Wed, 27 Apr 2016 15:15:57 +0000 (17:15 +0200)] 
nss_dns: Skip over non-PTR records in the netent code [BZ #19868]

This requires additional checks for the RDATA length and the
availability of record metadata.

(cherry picked from commit a12f9431b3808e78b9ed397e4fce7de69410d94d)

9 years agonss_dns: Check address length before creating addrinfo result [BZ #19831]
Florian Weimer [Wed, 27 Apr 2016 14:39:12 +0000 (16:39 +0200)] 
nss_dns: Check address length before creating addrinfo result [BZ #19831]

Previously, we allocated room in the result space before the check,
leaving uninitialized data there in case the check failed.

This also consolidates the behavior between single (A or AAAA) and
dual (A and AAAA in parallel) queries.  Single queries checked
the record length against the QTYPE, not the RRTYPE.

(cherry picked from commit 5e0c421cc07e2d06945b863ed3bb92395472705d)

9 years agoresolv, nss_dns: Remove remaining syslog logging [BZ #19862]
Florian Weimer [Wed, 27 Apr 2016 14:12:32 +0000 (16:12 +0200)] 
resolv, nss_dns: Remove remaining syslog logging [BZ #19862]

The fix for bug 14841 only removed part of the logging.

(cherry picked from commit b9b026c9c00db1a1b5b4a3caa28162655a04a882)

9 years agonss_dns: Validate RDATA length against packet length [BZ #19830]
Florian Weimer [Wed, 27 Apr 2016 13:11:41 +0000 (15:11 +0200)] 
nss_dns: Validate RDATA length against packet length [BZ #19830]

In _nss_dns_getcanonname_r, a check for the availability of RR metadata
was missing as well.

(cherry picked from commit f749498fa53df9ead81e291cd9378d67483c2452)

9 years agonss_dns: Fix assertion failure in _nss_dns_getcanonname_r [BZ #19865]
Florian Weimer [Mon, 11 Apr 2016 08:55:43 +0000 (10:55 +0200)] 
nss_dns: Fix assertion failure in _nss_dns_getcanonname_r [BZ #19865]

(cherry picked from commit d29fb41f4431ca35ea360498ef9d37558ce90d76)

9 years agomalloc: Add missing internal_function attributes on function definitions
Florian Weimer [Thu, 14 Apr 2016 10:53:03 +0000 (12:53 +0200)] 
malloc: Add missing internal_function attributes on function definitions

Fixes build on i386 after commit 29d794863cd6e03115d3670707cc873a9965ba92.

(cherry picked from commit 186fe877f3df0b84d57dfbf0386f6332c6aa69bc)

9 years agomalloc: Remove malloc hooks from fork handler
Florian Weimer [Thu, 14 Apr 2016 07:18:30 +0000 (09:18 +0200)] 
malloc: Remove malloc hooks from fork handler

The fork handler now runs so late that there is no risk anymore that
other fork handlers in the same thread use malloc, so it is no
longer necessary to install malloc hooks which made a subset
of malloc functionality available to the thread that called fork.

(cherry picked from commit 8a727af925be63aa6ea0f5f90e16751fd541626b)

9 years agomalloc: Run fork handler as late as possible [BZ #19431]
Florian Weimer [Thu, 14 Apr 2016 07:17:02 +0000 (09:17 +0200)] 
malloc: Run fork handler as late as possible [BZ #19431]

Previously, a thread M invoking fork would acquire locks in this order:

  (M1) malloc arena locks (in the registered fork handler)
  (M2) libio list lock

A thread F invoking flush (NULL) would acquire locks in this order:

  (F1) libio list lock
  (F2) individual _IO_FILE locks

A thread G running getdelim would use this order:

  (G1) _IO_FILE lock
  (G2) malloc arena lock

After executing (M1), (F1), (G1), none of the threads can make progress.

This commit changes the fork lock order to:

  (M'1) libio list lock
  (M'2) malloc arena locks

It explicitly encodes the lock order in the implementations of fork,
and does not rely on the registration order, thus avoiding the deadlock.

(cherry picked from commit 29d794863cd6e03115d3670707cc873a9965ba92)

9 years agoFix malloc threaded tests link on non-Linux
Samuel Thibault [Tue, 22 Mar 2016 08:58:48 +0000 (09:58 +0100)] 
Fix malloc threaded tests link on non-Linux

* malloc/Makefile ($(objpfx)tst-malloc-backtrace,
$(objpfx)tst-malloc-thread-exit, $(objpfx)tst-malloc-thread-fail): Use
$(shared-thread-library) instead of hardcoding the path to libpthread.

(cherry picked from commit b87e41378beca3c98ec3464d64835e66cc788497)

9 years agomalloc: Remove NO_THREADS
Florian Weimer [Fri, 19 Feb 2016 16:07:45 +0000 (17:07 +0100)] 
malloc: Remove NO_THREADS

No functional change.  It was not possible to build without
threading support before.

(cherry picked from commit 59eda029a8a35e5f4e5cd7be0f84c6629e48ec6e)

9 years agohesiod: Avoid heap overflow in get_txt_records [BZ #20031]
Florian Weimer [Mon, 2 May 2016 14:04:32 +0000 (16:04 +0200)] 
hesiod: Avoid heap overflow in get_txt_records [BZ #20031]

(cherry picked from commit 8a03ccbb77f52ec4b55062eeedddb8daec1a33e4)

9 years agohesiod: Always use thread-local resolver state [BZ #19573]
Florian Weimer [Mon, 2 May 2016 13:25:20 +0000 (15:25 +0200)] 
hesiod: Always use thread-local resolver state [BZ #19573]

The Hesiod implementation imported into glibc was enhanced
to support caller-supplied resolver states.  But its only
consumer is nss_hesiod, and it supplies the thread-local
resolver state.  Therefore, this commit changes the Hesiod
implementation to use the thread-local resolver state (_res)
directly.  This fixes bug 19573 because the Hesiod
implementation no longer has to initialize and free any
resolver state.

To avoid any risk of interposition of ABI-incompatible Hesiod
function implementations, this commit marks the Hesiod functions
as hidden.  (They were already hidden using a linker version
script.)

(cherry picked from commit 5018f16c6205404ba3aa7298dc8a3d45fbd46bfc)

9 years agohesiod: Remove RCS keywords
Florian Weimer [Mon, 2 May 2016 10:07:09 +0000 (12:07 +0200)] 
hesiod: Remove RCS keywords

(cherry picked from commit dbdc657dc0b962ef3ac61585c81e0828d8da42ee)

9 years agogetnameinfo: Return EAI_OVERFLOW in more cases [BZ #19787]
Florian Weimer [Wed, 4 May 2016 12:45:17 +0000 (14:45 +0200)] 
getnameinfo: Return EAI_OVERFLOW in more cases [BZ #19787]

The AF_LOCAL and AF_INET/AF_INET6 non-numerci service conversion
did not return EAI_OVERFLOW if the supplied buffer was too small,
silently returning truncated data.  In the AF_INET/AF_INET6
numeric cases, the snprintf return value checking was incorrect.

(cherry picked from commit 066746783d6c6c0f61b39c741177e24a9b398a20)

9 years agogetnameinfo: Avoid calling strnlen on uninitialized buffer
Florian Weimer [Wed, 4 May 2016 12:35:23 +0000 (14:35 +0200)] 
getnameinfo: Avoid calling strnlen on uninitialized buffer

In the numeric AF_INET/AF_INET6 case, if inet_ntop fails
as the result of a short host buffer, we used to call strnlen
on the uninitialized host buffer.

(cherry picked from commit 1c3490d4b29fc5b3f30dd6b13082046aee94443d)

9 years agogetnameinfo: Reduce line length and add missing comments
Florian Weimer [Wed, 4 May 2016 12:35:12 +0000 (14:35 +0200)] 
getnameinfo: Reduce line length and add missing comments

(cherry picked from commit c9b0e6a432e827b61f12eb52c2aaeadc77b64461)

9 years agogetnameinfo: Refactor and fix memory leak [BZ #19642]
Florian Weimer [Fri, 29 Apr 2016 15:08:06 +0000 (17:08 +0200)] 
getnameinfo: Refactor and fix memory leak [BZ #19642]

Split getnameinfo into separate functions for host and service
lookups, and for different address families.

(cherry picked from commit 2dce81a319601e1ee110f7316f705b48c5686e72)

9 years agogetnameinfo: Do not preserve errno
Florian Weimer [Thu, 28 Apr 2016 15:41:49 +0000 (17:41 +0200)] 
getnameinfo: Do not preserve errno

POSIX does not require it, the companion getaddrinfo implementation
does not do it, and this behavior is not documented in the manual
page, either.

(cherry picked from commit 2b54cbce2c363ab6ae89d10657d7465858116d7a)

9 years agonss_db: Propagate ERANGE error if parse_line fails [BZ #19837]
Florian Weimer [Tue, 29 Mar 2016 09:27:32 +0000 (11:27 +0200)] 
nss_db: Propagate ERANGE error if parse_line fails [BZ #19837]

Reproducer (needs to run as root):

perl -e \
  'print "large:x:999:" . join(",", map {"user$_"} (1 .. 135))."\n"' \
  >> /etc/group
cd /var/db
make
getent -s db group

After the fix, the last command should list the "large" group.

The magic number 135 has been chosen so that the line is shorter than
1024 bytes, but the pointers required to encode the member array will
cross the threshold, triggering the bug.

(cherry picked from commit a6033052d08027f745867e5e346852da1959226c)

9 years agoSuppress GCC 6 warning about ambiguous 'else' with -Wparentheses
Yvan Roux [Fri, 15 Apr 2016 11:29:26 +0000 (13:29 +0200)] 
Suppress GCC 6 warning about ambiguous 'else' with -Wparentheses

(cherry picked from commit df1cf48777fe4cd81ad7fb09ecbe5b31432b7c1c)

9 years agoconfigure: fix `test ==` usage
Mike Frysinger [Sun, 10 Apr 2016 00:02:48 +0000 (20:02 -0400)] 
configure: fix `test ==` usage

POSIX defines the = operator, but not ==.  Fix the few places where we
incorrectly used ==.

(cherry picked from commit b2d4456b333970ab4cb01ed8045b9a8d2c4832f3)

9 years agoCVE-2016-3075: Stack overflow in _nss_dns_getnetbyname_r [BZ #19879]
Florian Weimer [Tue, 29 Mar 2016 10:57:56 +0000 (12:57 +0200)] 
CVE-2016-3075: Stack overflow in _nss_dns_getnetbyname_r [BZ #19879]

The defensive copy is not needed because the name may not alias the
output buffer.

(cherry picked from commit 317b199b4aff8cfa27f2302ab404d2bb5032b9a4)
(cherry picked from commit 883dceebc8f11921a9890211a4e202e5be17562f)

9 years agoS390: Extend structs La_s390_regs / La_s390_retval with vector-registers.
Stefan Liebler [Fri, 1 Apr 2016 12:11:10 +0000 (14:11 +0200)] 
S390: Extend structs La_s390_regs / La_s390_retval with vector-registers.

Starting with z13, vector registers can also occur as argument registers.
Thus the passed input/output register structs for
la_s390_[32|64]_gnu_plt[enter|exit] functions should reflect those new
registers. This patch extends these structs La_s390_regs and La_s390_retval
and adjusts _dl_runtime_profile() to handle those fields in case of
running on a z13 machine.

(picked from upstream commit 5cdd1989d1d2f135d02e66250f37ba8e767f9772)

ChangeLog:

* sysdeps/s390/bits/link.h: (La_s390_vr) New typedef.
(La_s390_32_regs): Append vector register lr_v24-lr_v31.
(La_s390_64_regs): Likewise.
(La_s390_32_retval): Append vector register lrv_v24.
(La_s390_64_retval): Likeweise.
* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
Handle extended structs La_s390_32_regs and La_s390_32_retval.
* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
Handle extended structs La_s390_64_regs and La_s390_64_retval.

9 years agoS390: Save and restore fprs/vrs while resolving symbols.
Stefan Liebler [Fri, 1 Apr 2016 12:11:10 +0000 (14:11 +0200)] 
S390: Save and restore fprs/vrs while resolving symbols.

On s390, no fpr/vrs were saved while resolving a symbol
via _dl_runtime_resolve/_dl_runtime_profile.

According to the abi, the fpr-arguments are defined as call clobbered.
In leaf-functions, gcc 4.9 and newer can use fprs for saving/restoring gprs
instead of saving them to the stack.
If gcc do this in one of the resolver-functions, then the floating point
arguments of a library-function are invalid for the first library-function-call.
Thus, this patch saves/restores the fprs around the resolving code.

The same could occur for vector registers. Furthermore an ifunc-resolver
could also clobber the vector/floating point argument registers.
Thus this patch provides the further variants _dl_runtime_resolve_vx/
_dl_runtime_profile_vx, which are used if the kernel claims, that
we run on a machine with vector registers.

Furthermore, if _dl_runtime_profile calls _dl_call_pltexit,
the pointers to inregs-/outregs-structs were setup invalid.
Now they point to the correct location in the stack-frame.
Before branching back to the caller, the return values are now
restored instead of containing the return values of the
_dl_call_pltexit() call.
On s390-32, an endless loop occurs if _dl_call_pltexit() should be called.
Now, this code-path branches to this function instead of just after the
preceding basr-instruction.

(Picked from upstream commits 4603c51ef7989d7eb800cdd6f42aab206f891077
and d8a012c5c9e4bfc1b8db2bc6deacb85b44a2e1eb)

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.S: Include dl-trampoline.h twice
to create a non-vector/vector version for _dl_runtime_resolve and
_dl_runtime_profile. Move implementation to ...
* sysdeps/s390/s390-32/dl-trampoline.h: ... here.
(_dl_runtime_resolve) Save and restore fpr/vrs.
(_dl_runtime_profile) Save and restore vrs and fix some issues
if _dl_call_pltexit is called.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Choose the correct resolver function if running on a machine with vx.
* sysdeps/s390/s390-64/dl-trampoline.S: Include dl-trampoline.h twice
to create a non-vector/vector version for _dl_runtime_resolve and
_dl_runtime_profile. Move implementation to ...
* sysdeps/s390/s390-64/dl-trampoline.h: ... here.
(_dl_runtime_resolve) Save and restore fpr/vrs.
(_dl_runtime_profile) Save and restore vrs and fix some issues
* sysdeps/s390/s390-64/dl-machine.h: (elf_machine_runtime_setup):
Choose the correct resolver function if running on a machine with vx.

9 years agoresolv: Always set *resplen2 out parameter in send_dg [BZ #19791]
Florian Weimer [Fri, 25 Mar 2016 10:49:51 +0000 (11:49 +0100)] 
resolv: Always set *resplen2 out parameter in send_dg [BZ #19791]

Since commit 44d20bca52ace85850012b0ead37b360e3ecd96e (Implement
second fallback mode for DNS requests), there is a code path which
returns early, before *resplen2 is initialized.  This happens if the
name server address is immediately recognized as invalid (because of
lack of protocol support, or if it is a broadcast address such
255.255.255.255, or another invalid address).

If this happens and *resplen2 was non-zero (which is the case if a
previous query resulted in a failure), __libc_res_nquery would reuse
an existing second answer buffer.  This answer has been previously
identified as unusable (for example, it could be an NXDOMAIN
response).  Due to the presence of a second answer, no name server
switching will occur.  The result is a name resolution failure,
although a successful resolution would have been possible if name
servers have been switched and queries had proceeded along the search
path.

The above paragraph still simplifies the situation.  Before glibc
2.23, if the second answer needed malloc, the stub resolver would
still attempt to reuse the second answer, but this is not possible
because __libc_res_nsearch has freed it, after the unsuccessful call
to __libc_res_nquerydomain, and set the buffer pointer to NULL.  This
eventually leads to an assertion failure in __libc_res_nquery:

/* Make sure both hp and hp2 are defined */
assert((hp != NULL) && (hp2 != NULL));

If assertions are disabled, the consequence is a NULL pointer
dereference on the next line.

Starting with glibc 2.23, as a result of commit
e9db92d3acfe1822d56d11abcea5bfc4c41cf6ca (CVE-2015-7547: getaddrinfo()
stack-based buffer overflow (Bug 18665)), the second answer is always
allocated with malloc.  This means that the assertion failure happens
with small responses as well because there is no buffer to reuse, as
soon as there is a name resolution failure which triggers a search for
an answer along the search path.

This commit addresses the issue by ensuring that *resplen2 is
initialized before the send_dg function returns.

This commit also addresses a bug where an invalid second reply is
incorrectly returned as a valid to the caller.

(cherry picked from commit b66d837bb5398795c6b0f651bd5a5d66091d8577)

9 years agomath: don't clobber old libm.so on install [BZ #19822]
Dylan Alex Simon [Tue, 15 Mar 2016 17:20:01 +0000 (13:20 -0400)] 
math: don't clobber old libm.so on install [BZ #19822]

When installing glibc (w/mathvec enabled) in-place on a system with
a glibc w/out mathvec enabled, the install will clobber the existing
libm.so (e.g., /lib64/libm-2.21.so) with a linker script.  This is
because libm.so is a symlink to libm.so.6 which is a symlink to the
final libm-2.21.so file.  When the makefile writes the linker script
directly to libm.so, it gets clobbered.

The simple patch below to math/Makefile fixes this.  It is based on
the nptl Makefile, which does exactly the same thing in a safer way.

(cherry picked from commit f9378ac3773ffe998a2b3406568778ee9f77f759)

9 years agoFix resource leak in resolver (bug 19257)
Andreas Schwab [Wed, 18 Nov 2015 14:45:59 +0000 (15:45 +0100)] 
Fix resource leak in resolver (bug 19257)

The number of currently defined nameservers is stored in ->nscount,
whereas ->_u._ext.nscount is set by __libc_res_nsend only after local
initializations.

(cherry picked from commit 5e7fdabd7df1fc6c56d104e61390bf5a6b526c38)

9 years agoOr bit_Prefer_MAP_32BIT_EXEC in EXTRA_LD_ENVVARS
H.J. Lu [Thu, 3 Mar 2016 22:51:40 +0000 (14:51 -0800)] 
Or bit_Prefer_MAP_32BIT_EXEC in EXTRA_LD_ENVVARS

We should turn on bit_Prefer_MAP_32BIT_EXEC in EXTRA_LD_ENVVARS without
overriding other bits.

[BZ #19758]
* sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
(EXTRA_LD_ENVVARS): Or bit_Prefer_MAP_32BIT_EXEC.

9 years agoDefine _HAVE_STRING_ARCH_mempcpy to 1 for x86
H.J. Lu [Tue, 8 Mar 2016 18:57:31 +0000 (10:57 -0800)] 
Define _HAVE_STRING_ARCH_mempcpy to 1 for x86

Since x86 has an optimized mempcpy and GCC can inline mempcpy on x86,
define _HAVE_STRING_ARCH_mempcpy to 1 for x86.

[BZ #19759]
* sysdeps/x86/bits/string.h (_HAVE_STRING_ARCH_mempcpy): New.

(cherry picked from commit 2b35e48c0c547b3f6f81996ce7ad7d67e24c7329)

9 years agoMention BZ #19762 in NEWS
H.J. Lu [Fri, 11 Mar 2016 01:08:23 +0000 (17:08 -0800)] 
Mention BZ #19762 in NEWS

9 years agoUse HAS_ARCH_FEATURE with Fast_Rep_String
H.J. Lu [Sun, 6 Mar 2016 16:23:24 +0000 (08:23 -0800)] 
Use HAS_ARCH_FEATURE with Fast_Rep_String

HAS_ARCH_FEATURE, not HAS_CPU_FEATURE, should be used with
Fast_Rep_String.

[BZ #19762]
* sysdeps/i386/i686/multiarch/bcopy.S (bcopy): Use
HAS_ARCH_FEATURE with Fast_Rep_String.
* sysdeps/i386/i686/multiarch/bzero.S (__bzero): Likewise.
* sysdeps/i386/i686/multiarch/memcpy.S (memcpy): Likewise.
* sysdeps/i386/i686/multiarch/memcpy_chk.S (__memcpy_chk):
Likewise.
* sysdeps/i386/i686/multiarch/memmove_chk.S (__memmove_chk):
Likewise.
* sysdeps/i386/i686/multiarch/mempcpy.S (__mempcpy): Likewise.
* sysdeps/i386/i686/multiarch/mempcpy_chk.S (__mempcpy_chk):
Likewise.
* sysdeps/i386/i686/multiarch/memset.S (memset): Likewise.
* sysdeps/i386/i686/multiarch/memset_chk.S (__memset_chk):
Likewise.

(cherry picked from commit 4e940b2f4b577f3a530e0580373f7c2d569f4d63)

9 years agomips: terminate the FDE before the return trampoline in makecontext
Aurelien Jarno [Tue, 8 Mar 2016 23:25:00 +0000 (00:25 +0100)] 
mips: terminate the FDE before the return trampoline in makecontext

In makecontext the FDE needs to be terminated before the return
trampoline otherwise backtrace called within a context created by
makecontext yields infinite backtrace.

This bug has been present for a long time, stdlib/tst-makecontext did
not fail until recent commit e535ce25. Tested on mips-linux-gnu and
mips64el-linux-gnuabi64 and mips-linux-gnu, no regression.

This fixes stdlib/tst-makecontext on MIPS.

Changelog:
[BZ #19792]
* sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext):
Terminate FDE before return label.

(cherry picked from commit f8e9c4d30c28b8815e65a391416e8b15d2e7cbb8)

9 years agoAdd sys/auxv.h wrapper to include/sys/
Aurelien Jarno [Tue, 8 Mar 2016 14:16:40 +0000 (15:16 +0100)] 
Add sys/auxv.h wrapper to include/sys/

The GNU libc testsuite fails to build on powerpc/ppc64/ppc64le with the
following error:

    ../sysdeps/powerpc/test-get_hwcap.c:26:22: fatal error: sys/auxv.h: No such file or director

This is because test-get_hwcap.c includes <sys/auxv.h>, but we don't
provide a wrapper in include/sys. This patch adds one.

Changelog:
* include/sys/auxv.h: New file.

(cherry picked from commit 0b8dedd38f304d796b6b9b349428bea7f1f7065f)

9 years agosln: use stat64
Hongjiu Zhang [Mon, 7 Mar 2016 01:18:21 +0000 (20:18 -0500)] 
sln: use stat64

When using sln on some filesystems which return 64-bit inodes,
the stat call might fail during install like so:
.../elf/sln .../elf/symlink.list
/lib32/libc.so.6: invalid destination: Value too large for defined data type
/lib32/ld-linux.so.2: invalid destination: Value too large for defined data type
Makefile:104: recipe for target 'install-symbolic-link' failed

Switch to using stat64 all the time to avoid this.

URL: https://bugs.gentoo.org/576396
(cherry picked from commit f5e753c8c3a18a1e3c715dd11bf4dc341b5c481f)

9 years agoUpdate NEWS.
Carlos O'Donell [Fri, 26 Feb 2016 07:09:11 +0000 (02:09 -0500)] 
Update NEWS.

9 years agoNEWS (2.23): Fix typo in bug 19048 text.
Carlos O'Donell [Thu, 25 Feb 2016 03:04:13 +0000 (22:04 -0500)] 
NEWS (2.23): Fix typo in bug 19048 text.

9 years agoDon't use long double math functions if NO_LONG_DOUBLE
Andreas Schwab [Tue, 23 Feb 2016 15:27:56 +0000 (16:27 +0100)] 
Don't use long double math functions if NO_LONG_DOUBLE

9 years agoAdd fts64_* to sysdeps/arm/nacl/libc.abilist
Roland McGrath [Mon, 22 Feb 2016 23:19:56 +0000 (15:19 -0800)] 
Add fts64_* to sysdeps/arm/nacl/libc.abilist

(cherry picked from commit b2e722855b4599cdcc5dfc98e9d28e3825ecbe33)