ptrace.h: add __ prefix to ptrace_peeksiginfo_args

All the other ptrace structures in this file have a __ prefix except this
new one.  This in turn causes build problems for most packages that try to
use ptrace such as strace:

gcc -DHAVE_CONFIG_H -I. -I../..  -I../../linux/x86_64 -I../../linux \
	-I./linux  -Wall -Wwrite-strings -g -O2 -MT process.o -MD -MP \
	-MF .deps/process.Tpo -c -o process.o ../../process.c
In file included from ../../process.c:63:0:
/usr/include/linux/ptrace.h:58:8: error: redefinition of 'struct ptrace_peeksiginfo_args'
 struct ptrace_peeksiginfo_args {
        ^
In file included from ../../defs.h:159:0,
                 from ../../process.c:37:
/usr/include/sys/ptrace.h:191:8: note: originally defined here
 struct ptrace_peeksiginfo_args
        ^

Since this struct was introduced in glibc-2.18, there shouldn't be any
real regressions with adding the __ prefix.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
ia64: add __ prefix to pt_all_user_regs/ia64_fpreg [BZ #762]

This addresses a long standing collision between userspace headers and
kernel headers only on ia64 systems.  All other types have a __ prefix
in the ptrace headers except these two.  Let's finally namespace these.

Verified that at least strace still builds after this change, as well
as after deleting all the struct hacks it has specifically for ia64.

URL: https://sourceware.org/bugzilla/show_bug.cgi?id=762
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
ARM: Fix clone code when built for Thumb.

The mov lr, pc instruction will lose the Thumb bit from the return address
so use blx lr instead.

ports/ChangeLog.arm:

2013-08-30  Will Newton  <will.newton@linaro.org>

	[BZ #15909]
	* sysdeps/unix/sysv/linux/arm/clone.S (__clone): Use blx
	instead of mov lr, pc.

(cherry picked from commit 6b06ac56cdfc9293908724e51e827534e97819aa)
(cherry picked from commit 4f2bcda964d4fff56855e0c66198c9bcb682ea1e)
Fix PI mutex check in pthread_cond_broadcast and pthread_cond_signal

Fixes BZ #15996.

The check had a typo - it checked for PTHREAD_MUTEX_ROBUST_NP instead
of PTHREAD_MUTEX_ROBUST_NORMAL_NP.  It has now been replaced by the
already existing convenience macro USE_REQUEUE_PI.

(cherry picked from commit 2770d15e7e880821fc586619c59eb45180628e16)
CVE-2013-4237, BZ #14699: Buffer overflow in readdir_r

* sysdeps/posix/dirstream.h (struct __dirstream): Add errcode
member.
* sysdeps/posix/opendir.c (__alloc_dir): Initialize errcode
member.
* sysdeps/posix/rewinddir.c (rewinddir): Reset errcode member.
* sysdeps/posix/readdir_r.c (__READDIR_R): Enforce NAME_MAX limit.
Return delayed error code.  Remove GETDENTS_64BIT_ALIGNED
conditional.
* sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c: Do not define
GETDENTS_64BIT_ALIGNED.
* sysdeps/unix/sysv/linux/i386/readdir64_r.c: Likewise.
* manual/filesys.texi (Reading/Closing Directory): Document
ENAMETOOLONG return value of readdir_r.  Recommend readdir more
strongly.
* manual/conf.texi (Limits for Files): Add portability note to
NAME_MAX, PATH_MAX.
(Pathconf): Add portability note for _PC_NAME_MAX, _PC_PATH_MAX.

backport of 91ce40854d0b7f865cf5024ef95a8026b76096f3

(cherry picked from commit f166b9c6e90d631115c59b4357357bc168d8e51a)
* elf/setup-vdso.h (setup_vdso): Fix missing string termination.

backport of f315524e034cfc644157cb4af5ecc99f645dd067

(cherry picked from commit f8a004f1fa412e3aae77faa30b4dfb654d721510)
PowerPC: fix POWER7 memrchr for some large inputs

(cherry picked from commit b51679672648410c6627a4bd169e076c5b36f47b)

Conflicts:
	ChangeLog
Fix memory leaks in libio on allocation failure

(cherry picked from commit 8e395175c4786ad9679851e3ed3c0c54a6f4e1f0)
Fix memory leak in stdlib/isomac.c

(cherry picked from commit 3f71830d35d7bf4ac11664f0c48c3c68d250618b)
Fix stack overflow due to large AF_INET6 requests

Resolves #16072 (CVE-2013-4458).

This patch fixes another stack overflow in getaddrinfo when it is
called with AF_INET6.  The AF_UNSPEC case was fixed as CVE-2013-1914,
but the AF_INET6 case went undetected back then.

(cherry picked from commit 6f95434fd488e9b72117f9b93ec2e2dbf397a4d3)
BZ #15754: CVE-2013-4788

The pointer guard used for pointer mangling was not initialized for
static applications resulting in the security feature being disabled.
The pointer guard is now correctly initialized to a random value for
static applications. Existing static applications need to be
recompiled to take advantage of the fix.

The test tst-ptrguard1-static and tst-ptrguard1 add regression
coverage to ensure the pointer guards are sufficiently random
and initialized to a default value.

(cherry picked from commit c779e9df75256f19c7be8d12b2d163e2016a63f4)
malloc: Check for integer overflow in pvalloc.

A large bytes parameter to pvalloc could cause an integer overflow
and corrupt allocator internals. Check the overflow does not occur
before continuing with the allocation.

ChangeLog:

2013-09-11  Will Newton  <will.newton@linaro.org>

	[BZ #15855]
	* malloc/malloc.c (__libc_pvalloc): Check the value of bytes
	does not overflow.

(cherry picked from commit 7e0e64ead52591b968df582b0ddc247ba5c4eab4)
malloc: Check for integer overflow in valloc.

A large bytes parameter to valloc could cause an integer overflow
and corrupt allocator internals. Check the overflow does not occur
before continuing with the allocation.

ChangeLog:

2013-09-11  Will Newton  <will.newton@linaro.org>

	[BZ #15856]
	* malloc/malloc.c (__libc_valloc): Check the value of bytes
	does not overflow.

(cherry picked from commit 6a6a386a3040726053a5fb8582ff26dc85d84741)
malloc: Check for integer overflow in memalign.

A large bytes parameter to memalign could cause an integer overflow
and corrupt allocator internals. Check the overflow does not occur
before continuing with the allocation.

ChangeLog:

2013-09-11  Will Newton  <will.newton@linaro.org>

	[BZ #15857]
	* malloc/malloc.c (__libc_memalign): Check the value of bytes
	does not overflow.

(cherry picked from commit c51d675c459aefef8d84d5a0b114010f916ea278)
PowerPC: Fix POINTER_CHK_GUARD thread register for PPC64

(cherry picked from commit dc3a1f98dc4c86cb454474f4912ae325573655cb)
Fix build on pre-v9 32-bit Sparc.

We cannot use fnegd in this code, as fnegd was added in v9.
Only fnegs exists in v8 and earlier.

	[BZ #15985]
	* sysdeps/sparc/sparc32/fpu/s_fdim.S (__fdim): Do not use fnegd
	on pre-v9 cpus, use a fnegs+fmovs sequence instead.

(cherry picked from commit 2216e48645dbd297cdc0f4050fdfc0b52e2a4ab8)
Fix sparc 64-bit GMP ifunc resolution in static builds.

	[BZ #16150]
	* sysdeps/sparc/sparc64/multiarch/add_n.S: Resolve to the correct generic
	symbol in the non-vis3 case in static builds.
	* sysdeps/sparc/sparc64/multiarch/addmul_1.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/mul_1.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/sub_n.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/submul_1.S: Likewise.

(cherry picked from commit 2293d2b10a583486cd22ce578796848f4c3a8b6d)