]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 years agoMerge branch 'release/2.22/master' into ibm/2.22/master ibm/2.22/master
Tulio Magno Quites Machado Filho [Thu, 19 Apr 2018 18:21:54 +0000 (15:21 -0300)] 
Merge branch 'release/2.22/master' into ibm/2.22/master

7 years agoglob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332] release/2.22/master
Paul Eggert [Sun, 22 Oct 2017 08:00:57 +0000 (10:00 +0200)] 
glob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]

(cherry picked from commit a159b53fa059947cc2548e3b0d5bdcf7b9630ba8)

7 years agoglob: Add new test tst-glob-tilde
Florian Weimer [Sat, 21 Oct 2017 16:03:30 +0000 (18:03 +0200)] 
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 e80fc1fc98bf614eb01cf8325503df3a1451a99c)

7 years agoCVE-2017-15670: glob: Fix one-byte overflow [BZ #22320]
Paul Eggert [Fri, 20 Oct 2017 16:41:14 +0000 (18:41 +0200)] 
CVE-2017-15670: glob: Fix one-byte overflow [BZ #22320]

(cherry picked from commit c369d66e5426a30e4725b100d5cd28e372754f90)

7 years agoposix: Sync glob with gnulib [BZ #1062]
Adhemerval Zanella [Mon, 4 Sep 2017 17:53:38 +0000 (14:53 -0300)] 
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 c66c908230169c1bab1f83b071eb585baa214b9f)

7 years agoMerge branch 'release/2.22/master' into ibm/2.22/master
Tulio Magno Quites Machado Filho [Fri, 6 Apr 2018 20:17:24 +0000 (17:17 -0300)] 
Merge branch 'release/2.22/master' into ibm/2.22/master

7 years agoRecord CVE-2018-6551 in NEWS and ChangeLog [BZ #22774]
Florian Weimer [Tue, 6 Feb 2018 08:19:03 +0000 (09:19 +0100)] 
Record CVE-2018-6551 in NEWS and ChangeLog [BZ #22774]

(cherry picked from commit 71aa429b029fdb6f9e65d44050388b51eca460d6)

7 years agoRecord CVE-2018-6485 in ChangeLog and NEWS [BZ #22343]
Florian Weimer [Thu, 1 Feb 2018 14:00:44 +0000 (15:00 +0100)] 
Record CVE-2018-6485 in ChangeLog and NEWS [BZ #22343]

(cherry picked from commit 4590634fd65162568b9f52fb4beb60aa25da37f2)

7 years agoAdd ChangeLog reference to bug 16750/CVE-2009-5064
Florian Weimer [Wed, 16 Aug 2017 14:47:20 +0000 (16:47 +0200)] 
Add ChangeLog reference to bug 16750/CVE-2009-5064

(cherry picked from commit 403143e1df85dadd374f304bd891be0cd7573e3b)

7 years agoFix integer overflows in internal memalign and malloc functions [BZ #22343]
Arjun Shankar [Thu, 18 Jan 2018 16:47:06 +0000 (16:47 +0000)] 
Fix integer overflows in internal memalign and malloc functions [BZ #22343]

When posix_memalign is called with an alignment less than MALLOC_ALIGNMENT
and a requested size close to SIZE_MAX, it falls back to malloc code
(because the alignment of a block returned by malloc is sufficient to
satisfy the call).  In this case, an integer overflow in _int_malloc leads
to posix_memalign incorrectly returning successfully.

Upon fixing this and writing a somewhat thorough regression test, it was
discovered that when posix_memalign is called with an alignment larger than
MALLOC_ALIGNMENT (so it uses _int_memalign instead) and a requested size
close to SIZE_MAX, a different integer overflow in _int_memalign leads to
posix_memalign incorrectly returning successfully.

Both integer overflows affect other memory allocation functions that use
_int_malloc (one affected malloc in x86) or _int_memalign as well.

This commit fixes both integer overflows.  In addition to this, it adds a
regression test to guard against false successful allocations by the
following memory allocation functions when called with too-large allocation
sizes and, where relevant, various valid alignments:
malloc, realloc, calloc, reallocarray, memalign, posix_memalign,
aligned_alloc, valloc, and pvalloc.

(cherry picked from commit 8e448310d74b283c5cd02b9ed7fb997b47bf9b22)

7 years agoelf: Compute correct array size in _dl_init_paths [BZ #22606]
Florian Weimer [Thu, 14 Dec 2017 14:18:38 +0000 (15:18 +0100)] 
elf: Compute correct array size in _dl_init_paths [BZ #22606]

(cherry picked from commit 8a0b17e48b83e933960dfeb8fa08b259f03f310e)

7 years ago<array_length.h>: New array_length and array_end macros
Florian Weimer [Thu, 2 Nov 2017 11:14:01 +0000 (12:14 +0100)] 
<array_length.h>: New array_length and array_end macros

(cherry picked from commit c94a5688fb1228a862b2d4a3f1239cdc0e3349e5)

7 years agoelf: Count components of the expanded path in _dl_init_path [BZ #22607]
Florian Weimer [Thu, 14 Dec 2017 14:05:57 +0000 (15:05 +0100)] 
elf: Count components of the expanded path in _dl_init_path [BZ #22607]

(cherry picked from commit 3ff3dfa5af313a6ea33f3393916f30eece4f0171)

7 years agoelf: Check for empty tokens before dynamic string token expansion [BZ #22625]
Aurelien Jarno [Sat, 30 Dec 2017 09:54:23 +0000 (10:54 +0100)] 
elf: Check for empty tokens before dynamic string token expansion [BZ #22625]

The fillin_rpath function in elf/dl-load.c loops over each RPATH or
RUNPATH tokens and interprets empty tokens as the current directory
("./"). In practice the check for empty token is done *after* the
dynamic string token expansion. The expansion process can return an
empty string for the $ORIGIN token if __libc_enable_secure is set
or if the path of the binary can not be determined (/proc not mounted).

Fix that by moving the check for empty tokens before the dynamic string
token expansion. In addition, check for NULL pointer or empty strings
return by expand_dynamic_string_token.

The above changes highlighted a bug in decompose_rpath, an empty array
is represented by the first element being NULL at the fillin_rpath
level, but by using a -1 pointer in decompose_rpath and other functions.

Changelog:
[BZ #22625]
* elf/dl-load.c (fillin_rpath): Check for empty tokens before dynamic
string token expansion. Check for NULL pointer or empty string possibly
returned by expand_dynamic_string_token.
(decompose_rpath): Check for empty path after dynamic string
token expansion.

(cherry picked from commit 3e3c904daef69b8bf7d5cc07f793c9f07c3553ef)

7 years agosunrpc: Avoid use-after-free read access in clntudp_call [BZ #21115]
Florian Weimer [Thu, 13 Apr 2017 11:09:38 +0000 (13:09 +0200)] 
sunrpc: Avoid use-after-free read access in clntudp_call [BZ #21115]

After commit bc779a1a5b3035133024b21e2f339fe4219fb11c
(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 d42eed4a044e5e10dfb885cf9891c2518a72a491)

7 years agoldd: never run file directly
Andreas Schwab [Wed, 16 Aug 2017 13:59:55 +0000 (15:59 +0200)] 
ldd: never run file directly

(cherry picked from commit eedca9772e99c72ab4c3c34e43cc764250aa3e3c)

7 years agoSynchronize support/ infrastructure with master
Arjun Shankar [Wed, 7 Jun 2017 09:46:24 +0000 (11:46 +0200)] 
Synchronize support/ infrastructure with master

This commit updates the support/ subdirectory to
commit 2714c5f3c95f90977167c1d21326d907fb76b419
on the master branch and modifies Makeconfig,
Rules, and extra-lib.mk accordingly.

(cherry picked from commit 4c5785aa129a5d195fc1cd5c7fcd6f62c2b0ff0c)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
8 years agoMerge branch release/2.22/master into ibm/2.22/master
Tulio Magno Quites Machado Filho [Fri, 14 Oct 2016 20:01:21 +0000 (17:01 -0300)] 
Merge branch release/2.22/master into ibm/2.22/master

8 years agopowerpc: Sync hwcap.h with kernel
Carlos Eduardo Seo [Fri, 14 Oct 2016 19:57:32 +0000 (16:57 -0300)] 
powerpc: Sync hwcap.h with kernel

Linux commit b4b56f9ecab40f3b4ef53e130c9f6663be491894 introduced
a new HWCAP2 bit to indicate that the kernel now aborts a memory
transaction when a syscall is made.  This patch adds that bit to
sysdeps/powerpc/bits/hwcap.h.

* sysdeps/powerpc/bits/hwcap.h: Add PPC_FEATURE2_HTM_NOSC.
* sysdeps/powerpc/dl-procinfo.c:
(_dl_powerpc_cap_flags): Added descriptor for this hwcap
feature so it shows when LD_SHOW_AUXV=1.

(cherry picked from commit 3c13f28c8eac1e5a883d1b3801314430a094fc99)

8 years agopowerpc: Add missing hwcap strings.
Carlos Eduardo Seo [Fri, 14 Oct 2016 19:57:32 +0000 (16:57 -0300)] 
powerpc: Add missing hwcap strings.

Some features in hwcap.h do not have matching string descriptors
to be displayed when LD_SHOW_AUXV=1.  This patch fixes the problem.

* sysdeps/powerpc/dl-procinfo.c:
(_dl_powerpc_cap_flags): Added missing strings for some
hwcap features.
* sysdeps/powerpc/dl-procinfo.h: Updated hwcap bit count.

(cherry picked from commit 94ec7e007f4845de284d4f7569721b225ba77572)

8 years agoDon't compile do_test with -mavx/-mavx2/-mavx512.
Andrew Senkevich [Fri, 14 Oct 2016 18:10:50 +0000 (21:10 +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 agopowerpc: Add a POWER8-optimized version of sinf()
Anton Blanchard [Tue, 28 Jun 2016 11:59:40 +0000 (21:59 +1000)] 
powerpc: Add a POWER8-optimized version of sinf()

This uses the implementation of sinf() in sysdeps/x86_64/fpu/s_sinf.S
as inspiration.

(cherry picked from commit aa95fc13f5b02044eadc3af3d9e1c025f2e1edda)

8 years agopowerpc: Add a POWER8-optimized version of expf()
Tulio Magno Quites Machado Filho [Mon, 27 Jun 2016 19:03:10 +0000 (16:03 -0300)] 
powerpc: Add a POWER8-optimized version of expf()

This implementation is based on the one already used at
sysdeps/x86_64/fpu/e_expf.S.

This implementation improves the performance by ~14% on average in synthetic
benchmarks at the cost of decreasing accuracy to 1 ULP.

(cherry picked from commit 35da2541c382d1d4b7c9a15049a3cd1c7a6863a3)

8 years agoMerge branch release/2.22/master into ibm/2.22/master
Tulio Magno Quites Machado Filho [Fri, 14 Oct 2016 17:29:35 +0000 (14:29 -0300)] 
Merge branch release/2.22/master into ibm/2.22/master

8 years agoFixed x86_64 vector sincos/sincosf ABI.
Andrew Senkevich [Fri, 14 Oct 2016 15:55:59 +0000 (18: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 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: 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)

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 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 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 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)

9 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)

9 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)

9 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)

9 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 agoS390: Fix build failure in test string/tst-endian.c with gcc 6.
Stefan Liebler [Mon, 25 Jan 2016 11:44:46 +0000 (12:44 +0100)] 
S390: Fix build failure in test string/tst-endian.c with gcc 6.

Building string/tst-endian.c with gcc 6 produces an build warning/error on s390 (big endian machine):
gcc tst-endian.c -c -std=gnu11 -fgnu89-inline  -O2 or -O3 ...
tst-endian.c: In function ‘do_test’:
tst-endian.c:16:30: error: self-comparison always evaluates to false [-Werror=tautological-compare]
    if (htobe16 (be16toh (i)) != i)
                              ^~
...

See definitions of htobexx, bexxtoh in string/endian.h:
...

This patch silences these warnings with DIAG_* macros if build with gcc 6
and newer.

The same warnings occur on little endian machines with the
"htoleXX (leXXtoh (i)) != i" if-statements.

ChangeLog:

* string/tst-endian.c: Include <libc-internal.h>.
(do_test): Ignore tautological-compare warnings around
"htobeXX (beXXtoh (i)) != i" and
"htoleXX (leXXtoh (i)) != i" if-statements.

(cherry picked from commit f69f887092914f6e1abcc2d622e4f5e56a6e1645)

9 years agoRemove unused variable in math/atest-exp2.c.
Torvald Riegel [Thu, 17 Dec 2015 22:30:03 +0000 (23:30 +0100)] 
Remove unused variable in math/atest-exp2.c.

(cherry picked from commit 794950ed1d29853158d783d57f72260f5665afe5)

9 years agosysdeps/unix/sysv/linux/dl-openat64.c: Convert to ISO definition
Florian Weimer [Thu, 2 Jun 2016 11:21:30 +0000 (13:21 +0200)] 
sysdeps/unix/sysv/linux/dl-openat64.c: Convert to ISO definition

Partial backport of commit 9dd346ff431fc761f1b748bd4da8bb59f7652094.

9 years agoFix indentation.
Steve Ellcey [Fri, 11 Dec 2015 17:19:37 +0000 (09:19 -0800)] 
Fix indentation.

* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
Fix indentation.

(cherry picked from commit 976ef870542580cf5fed896c2c652b3e1a95f9da)

9 years agoFix several build failures with GCC6 due to unused static variables.
Wilco Dijkstra [Fri, 18 Sep 2015 19:27:20 +0000 (20:27 +0100)] 
Fix several build failures with GCC6 due to unused static variables.

2015-09-18  Wilco Dijkstra  <wdijkstr@arm.com>

        * resolv/base64.c (rcsid): Remove unused static.
        * sysdeps/ieee754/dbl-64/atnat2.h (qpi1): Remove unused
        static.  (tqpi1): Likewise.
        * sysdeps/ieee754/dbl-64/uexp.h (one): Likewise.
        * sysdeps/ieee754/dbl-64/upow.h (sqrt_2): Likewise.
        * sysdeps/ieee754/flt-32/e_log10f.c (one): Likewise.
        * sysdeps/ieee754/flt-32/s_cosf.c (one): Likewise.
        * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (zero): Likewise.
        * sysdeps/ieee754/ldbl-128/s_erfl.c (half): Likewise.
        * sysdeps/ieee754/ldbl-128/s_log1pl.c (maxlog): Likewise.
        * timezone/private.h (time_t_min): Likewise.  (time_t_max):
        Likewise.

(cherry picked from commit 6565fcb6e189d67b5a3f321453daebb805056d73)

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 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 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 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 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 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 agomalloc: Update comment for list_lock
Florian Weimer [Wed, 13 Apr 2016 19:11:42 +0000 (14:11 -0500)] 
malloc: Update comment for list_lock

(cherry picked from commit 7962541a32eff5597bc4207e781cfac8d1bb0d87)

9 years agotst-malloc-thread-exit: Use fewer system resources
Florian Weimer [Wed, 13 Apr 2016 19:11:27 +0000 (14:11 -0500)] 
tst-malloc-thread-exit: Use fewer system resources

(cherry picked from commit 2a38688932243b5b16fb12d84c7ac1138ce50363)

9 years agomalloc: Fix list_lock/arena lock deadlock [BZ #19182]
Florian Weimer [Wed, 13 Apr 2016 19:10:49 +0000 (14:10 -0500)] 
malloc: Fix list_lock/arena lock deadlock [BZ #19182]

* malloc/arena.c (list_lock): Document lock ordering requirements.
(free_list_lock): New lock.
(ptmalloc_lock_all): Comment on free_list_lock.
(ptmalloc_unlock_all2): Reinitialize free_list_lock.
(detach_arena): Update comment.  free_list_lock is now needed.
(_int_new_arena): Use free_list_lock around detach_arena call.
Acquire arena lock after list_lock.  Add comment, including FIXME
about incorrect synchronization.
(get_free_list): Switch to free_list_lock.
(reused_arena): Acquire free_list_lock around detach_arena call
and attached threads counter update.  Add two FIXMEs about
incorrect synchronization.
(arena_thread_freeres): Switch to free_list_lock.
* malloc/malloc.c (struct malloc_state): Update comments to
mention free_list_lock.

(cherry picked from commit 90c400bd4904b0240a148f0b357a5cbc36179239)

9 years agomalloc: Fix attached thread reference count handling [BZ #19243]
Florian Weimer [Wed, 13 Apr 2016 19:08:24 +0000 (14:08 -0500)] 
malloc: Fix attached thread reference count handling [BZ #19243]

reused_arena can increase the attached thread count of arenas on the
free list.  This means that the assertion that the reference count is
zero is incorrect.  In this case, the reference count initialization
is incorrect as well and could cause arenas to be put on the free
list too early (while they still have attached threads).

* malloc/arena.c (get_free_list): Remove assert and adjust
reference count handling.  Add comment about reused_arena
interaction.
(reused_arena): Add comments abount get_free_list interaction.
* malloc/tst-malloc-thread-exit.c: New file.
* malloc/Makefile (tests): Add tst-malloc-thread-exit.
(tst-malloc-thread-exit): Link against libpthread.

(cherry picked from commit 3da825ce483903e3a881a016113b3e59fd4041de)

9 years agomalloc: Prevent arena free_list from turning cyclic [BZ #19048]
Florian Weimer [Wed, 13 Apr 2016 19:07:58 +0000 (14:07 -0500)] 
malloc: Prevent arena free_list from turning cyclic [BZ #19048]

[BZ# 19048]
* malloc/malloc.c (struct malloc_state): Update comment.  Add
attached_threads member.
(main_arena): Initialize attached_threads.
* malloc/arena.c (list_lock): Update comment.
(ptmalloc_lock_all, ptmalloc_unlock_all): Likewise.
(ptmalloc_unlock_all2): Reinitialize arena reference counts.
(deattach_arena): New function.
(_int_new_arena): Initialize arena reference count and deattach
replaced arena.
(get_free_list, reused_arena): Update reference count and deattach
replaced arena.
(arena_thread_freeres): Update arena reference count and only put
unreferenced arenas on the free list.

(cherry picked from commit a62719ba90e2fa1728890ae7dc8df9e32a622e7b)

9 years agoFix i386 build for lll_unlock_elision change.
Joseph Myers [Tue, 12 Apr 2016 22:03:00 +0000 (17:03 -0500)] 
Fix i386 build for lll_unlock_elision change.

Tested for i386.

* sysdeps/unix/sysv/linux/i386/lowlevellock.h
(lll_unlock_elision): Add adapt_count parameter.

(cherry picked from commit 5ef193391bb0916ec03f0f06a9b1fe0b00591ad8)

9 years agopowerpc: Optimize lock elision for pthread_mutex_t
Paul Murphy [Tue, 12 Apr 2016 21:58:54 +0000 (16:58 -0500)] 
powerpc: Optimize lock elision for pthread_mutex_t

With TLE enabled, the adapt count variable update incurs
an 8% overhead before entering the critical section of an
elided mutex.

Instead, if it is done right after leaving the critical
section, this serialization can be avoided.

This alters the existing behavior of __lll_trylock_elision
as it will only decrement the adapt_count if it successfully
acquires the lock.

* sysdeps/unix/sysv/linux/powerpc/elision-lock.c
(__lll_lock_elision): Remove adapt_count decrement...
* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
(__lll_trylock_elision): Likewise.
* sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
(__lll_unlock_elision): ... to here. And utilize
new adapt_count parameter.
* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
(__lll_unlock_elision): Update to include adapt_count
parameter.
(lll_unlock_elision): Pass pointer to adapt_count
variable.

(cherry picked from commit fadd2ad9cc36115440d50b0eae9299e65988917d)

9 years agonptl: Add adapt_count parameter to lll_unlock_elision
Paul Murphy [Tue, 12 Apr 2016 21:59:03 +0000 (16:59 -0500)] 
nptl: Add adapt_count parameter to lll_unlock_elision

Adding this parameter will give architectures more freedom in
how they choose to update this variable.  This change has no
effect on architectures which choose not to use it.

* nptl/pthread_mutex_unlock.c(lll_unlock_elision):
Add elision adapt_count parameter to list of arguments.
* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
(lll_unlock_elision): Update with new parameter list
* sysdeps/unix/sysv/linux/s390/lowlevellock.h
(lll_unlock_elision): Likewise
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
(lll_unlock_elision): Likewise

(cherry picked from commit e5e6bea22a2939fe7c415a375992f3ca19f9ff2e)

9 years agoMerge branch 'release/2.22/master' into ibm/2.22/master
Paul E. Murphy [Tue, 12 Apr 2016 18:51:00 +0000 (13:51 -0500)] 
Merge branch 'release/2.22/master' into ibm/2.22/master

9 years agoIncrease internal precision of ldbl-128ibm decimal printf [BZ #19853]
Paul E. Murphy [Tue, 12 Apr 2016 18:29:53 +0000 (13:29 -0500)] 
Increase internal precision of ldbl-128ibm decimal printf [BZ #19853]

When the signs differ, the precision of the conversion sometimes
drops below 106 bits.  This strategy is identical to the
hexadecimal variant.

I've refactored tst-sprintf3 to enable testing a value with more
than 30 significant digits in order to demonstrate this failure
and its solution.

Additionally, this implicitly fixes a typo in the shift
quantities when subtracting from the high mantissa to compute
the difference.

(cherry picked from commit 37a4c70bd4c5c74ac562072e450dc02e8cb4c150)

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 agopowerpc: Fix tabort usage in syscalls
Paul E. Murphy [Fri, 21 Aug 2015 19:39:01 +0000 (14:39 -0500)] 
powerpc: Fix tabort usage in syscalls

Fix usage of tabort in generated syscalls.  r0 has special meaning
when used with this instruction, thus it will not generate
persistent errors, nor return an error code.  This mitigates poor
CPU usage when performing elided critical sections.

Additionally, transactions should be aborted when entering a user
invoked syscall.  Otherwise the results of the transaction may be
undefined.

2015-08-25  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>

* sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION): Use
register other than r0 for tabort, it has special meaning.
* sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION): Likewise
* sysdeps/unix.sysv/linux/powerpc/syscall.S (syscall): Abort
transaction before starting syscall.

(cherry picked from commit 18173559a23e28055640b152e623d9f0d40ecca8)

9 years agoS390: Extend structs La_s390_regs / La_s390_retval with vector-registers.
Stefan Liebler [Mon, 4 Apr 2016 10:54:23 +0000 (12:54 +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.

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.

(cherry picked from commit 5cdd1989d1d2f135d02e66250f37ba8e767f9772)

9 years agoS390: Save and restore fprs/vrs while resolving symbols.
Stefan Liebler [Mon, 4 Apr 2016 10:54:23 +0000 (12:54 +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.

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.

(cherry picked from commit 4603c51ef7989d7eb800cdd6f42aab206f891077
and commit d8a012c5c9e4bfc1b8db2bc6deacb85b44a2e1eb)

9 years agoS390: configure check for vector instruction support in assembler.
Stefan Liebler [Mon, 4 Apr 2016 10:54:22 +0000 (12:54 +0200)] 
S390: configure check for vector instruction support in assembler.

The S390 specific test checks if the assembler has support for the new z13
vector instructions by compiling a vector instruction. The .machine and
.machinemode directives are needed to compile the vector instruction without
-march=z13 option on 31/64 bit.
On success the macro HAVE_S390_VX_ASM_SUPPORT is defined. This macro is used
to determine if the optimized functions can be build without compile errors.
If the used assembler lacks vector support, then a warning is dumped while
configuring and only the common code functions are build.

The z13 instruction support was introduced in
"[Committed] S/390: Add support for IBM z13."
(https://sourceware.org/ml/binutils/2015-01/msg00197.html)

ChangeLog:

* config.h.in (HAVE_S390_VX_ASM_SUPPORT): New macro undefine.
* sysdeps/s390/configure.ac: Add test for S390 vector instruction
assembler support.
* sysdeps/s390/configure: Regenerated.

(cherry picked from commit 4f0a1cea34c05fb2acc16f1a2d291f53230eb4fb)

9 years agoS390: Add new s390 platform.
Stefan Liebler [Mon, 4 Apr 2016 10:54:22 +0000 (12:54 +0200)] 
S390: Add new s390 platform.

The new IBM z13 is added to platform string array.
The macro _DL_PLATFORMS_COUNT is incremented to 8,
because it was not incremented by commit
"S/390: Sync AUXV capabilities and archs with kernel".

ChangeLog:

* sysdeps/s390/dl-procinfo.c (_dl_s390_cap_flags): Add z13.
* sysdeps/s390/dl-procinfo.h (_DL_PLATFORMS_COUNT): Increased.

(cherry picked from commit a1b0488fc9df3d895a2e5eefbcd348d3f7fe0e52)

9 years agoS390: Add hwcaps value for vector facility.
Stefan Liebler [Mon, 4 Apr 2016 10:54:22 +0000 (12:54 +0200)] 
S390: Add hwcaps value for vector facility.

The HWCAP_S390_VX flag in hwcap field of auxiliary vector indicates
if the vector facility is available and the kernel is aware of it.
This can be tested with LD_SHOW_AUXV=1 <prog>.
Currently it does not show te, because it was not incremented
by commit "S/390: Add hwcap value for transactional execution.".
Thus _DL_HWCAP_COUNT is incremented by two.

ChangeLog:

* sysdeps/s390/dl-procinfo.c (_dl_s390_platforms): Add vector flag.
* sysdeps/s390/dl-procinfo.h: Add vector capability.
* sysdeps/unix/sysv/linux/s390/bits/hwcap.h (HWCAP_S390_VX): Define.

(cherry picked from commit 4e28fa80886c71e6aaf85016b82ce981c0f12e6d)

9 years agoMerge branch 'release/2.22/master' into ibm/2.22/master
Tulio Magno Quites Machado Filho [Fri, 1 Apr 2016 19:15:39 +0000 (16:15 -0300)] 
Merge branch 'release/2.22/master' into ibm/2.22/master

9 years agoNEWS: update from previous commit
Tulio Magno Quites Machado Filho [Fri, 1 Apr 2016 18:58:16 +0000 (15:58 -0300)] 
NEWS: update from previous commit

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)

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 agoUse PIC relocation in ALIAS_IMPL
Andrew Senkevich [Wed, 17 Feb 2016 22:23:32 +0000 (14:23 -0800)] 
Use PIC relocation in ALIAS_IMPL

Since libmvec_nonshared.a may be linked into shared objects, ALIAS_IMPL
should use PIC relocation.

[BZ #19590]
* sysdeps/x86_64/fpu/svml_finite_alias.S (ALIAS_IMPL): Use PIC
relocation.

(cherry picked from commit a5df3210a641c175138052037fcdad34298bfa4d)

9 years agoFix x86_64 fma4 pow inappropriate contraction (bug 19003).
Joseph Myers [Thu, 24 Sep 2015 16:48:32 +0000 (16:48 +0000)] 
Fix x86_64 fma4 pow inappropriate contraction (bug 19003).

The x86_64 fma4 version of pow fails to disable contraction of
operations other than those explicitly intended to use fma
instructions, so resulting in large ulps errors on processors with
fma4 instructions, as in bug 18104 (165ulp for the test added for that
bug; error originally reported by "blaaa" on #glibc).  This patch adds
$(config-cflags-nofma) for e_pow-fma4.c, corresponding to the use for
e_pow.c in sysdeps/ieee754/dbl-64/Makefile.

Tested for x86_64 on a processor with fma4.

[BZ #19003]
* sysdeps/x86_64/fpu/multiarch/Makefile (CFLAGS-e_pow-fma4.c): Add
$(config-cflags-nofma).

(cherry picked from commit 51df2605064a2bfd44fa0655ef9815812347de80)

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 agoS390: Do not use direct socket syscalls if build on kernels >= 4.3. [BZ #19682]
Stefan Liebler [Thu, 3 Mar 2016 07:17:09 +0000 (08:17 +0100)] 
S390: Do not use direct socket syscalls if build on kernels >= 4.3. [BZ #19682]

Beginning with Linux 4.3, the kernel headers contain direct
system call numbers __NR_socket etc. on s390x. On older kernels,
the socket-multiplexer syscall __NR_socketcall was used.

To enable these new syscalls, the patch
"S390: Call direct system calls for socket operations."
(https://sourceware.org/git/?p=glibc.git;a=commit;h=016495b818cb61df7d0d10e6db54074271b3e3a5)
was applied upstream.

If glibc 2.23 is configured with --enable-kernel=4.3 and newer,
the direct socket syscalls are used.
For older kernels, the socket-multiplexer syscall is used instead.

In glibc 2.22 and earlier, this patch is not applied.
If you build glibc on a kernel < 4.3, the socket-multiplexer
syscall is used. But if you build glibc on kernel >= 4.3, the
direct socket-syscalls are used. If you install this glibc on a
kernel < 4.3, all socket operations will fail.
See "Bug 19682 - s390x: Incorrect syscall definitions cause
breakage with Linux 4.3 headers"
(https://sourceware.org/bugzilla/show_bug.cgi?id=19682)
The configure switch --enable-kernel does not influence this
behaviour on older glibc-releases.

The solution is to remove the direct socket-syscalls in
sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
(this patch) on older glibc-releases as it was done by the
upstream patch, too. These entries were never used on s390x,
but the c-files in sysdeps/unix/sysv/linux/.
After this removal, the behaviour of the socket functions are
not changed compared to the original glibc release version
and the socket-multiplexer-syscall is always used.

9 years agoRegenerate Alpha ULPs
Aurelien Jarno [Tue, 1 Mar 2016 08:22:26 +0000 (09:22 +0100)] 
Regenerate Alpha ULPs

* sysdeps/alpha/fpu/libm-test-ulps: Update ULPs.

9 years agopowerpc: More elision improvements
Paul Murphy [Wed, 28 Oct 2015 22:34:31 +0000 (17:34 -0500)] 
powerpc: More elision improvements

__lll_trylock_elision sets the adapt_count variable too
aggressively, and incorrectly on persistent aborts.  Taking
a cue from s390, adapt_count is only updated if the lock
is locked, or a persistent failure occurs.

In addition, the abort codes have been renumbered and
refactored for clarity.  As it stands, glibc only cares
if the abort is persistent or not.

All aborts are now persistent, excepting a busy lock.  This
includes changing _ABORT_NESTED_TRYLOCK into a persistent
abort.

* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
(__lll_trylock_elision): Fix setting of adapt_count.
* sysdeps/unix/sysv/linux/powerpc/htm.h
(_ABORT_PERSISTENT): Define to clarify persistent aborts.
(_ABORT_NESTED_TRYLOCK): Renumber, and make persistent.
(_ABORT_SYSCALL): Renumber, and clarify definition.
(_ABORT_LOCK_BUSY): Renumber, make non-persistent.

(cherry picked from commit 86b4939846caf2bb072bba6057e1dc3ad187c2c2)

Conflicts:
sysdeps/unix/sysv/linux/powerpc/elision-trylock.c

9 years agoMerge branch 'release/2.22/master' into ibm/2.22/master
Tulio Magno Quites Machado Filho [Mon, 22 Feb 2016 19:20:34 +0000 (16:20 -0300)] 
Merge branch 'release/2.22/master' into ibm/2.22/master

9 years agopowerpc: Fix macro usage of htm builtins
Paul E. Murphy [Wed, 20 Jan 2016 16:33:19 +0000 (10:33 -0600)] 
powerpc: Fix macro usage of htm builtins

Some extraneous semicolons were included in a
recent patch which causes a build failure with
newer compilers.

(cherry picked from commit af8ea0f449af7d3847351a4a5bafcd435a22ac31)

9 years agopowerpc: Enforce compiler barriers on hardware transactions
Tulio Magno Quites Machado Filho [Mon, 28 Dec 2015 14:24:43 +0000 (12:24 -0200)] 
powerpc: Enforce compiler barriers on hardware transactions

Work around a GCC behavior with hardware transactional memory built-ins.
GCC doesn't treat the PowerPC transactional built-ins as compiler
barriers, moving instructions past the transaction boundaries and
altering their atomicity.

(cherry picked from commit 42bf1c897170ff951c7fd0ee9da25f97ff787396)

Conflicts:
sysdeps/unix/sysv/linux/powerpc/elision-trylock.c

9 years agoCVE-2015-7547: getaddrinfo() stack-based buffer overflow (Bug 18665).
Carlos O'Donell [Wed, 17 Feb 2016 02:26:37 +0000 (21:26 -0500)] 
CVE-2015-7547: getaddrinfo() stack-based buffer overflow (Bug 18665).

* A stack-based buffer overflow was found in libresolv when invoked from
  libnss_dns, allowing specially crafted DNS responses to seize control
  of execution flow in the DNS client.  The buffer overflow occurs in
  the functions send_dg (send datagram) and send_vc (send TCP) for the
  NSS module libnss_dns.so.2 when calling getaddrinfo with AF_UNSPEC
  family.  The use of AF_UNSPEC triggers the low-level resolver code to
  send out two parallel queries for A and AAAA.  A mismanagement of the
  buffers used for those queries could result in the response of a query
  writing beyond the alloca allocated buffer created by
  _nss_dns_gethostbyname4_r.  Buffer management is simplified to remove
  the overflow.  Thanks to the Google Security Team and Red Hat for
  reporting the security impact of this issue, and Robert Holiday of
  Ciena for reporting the related bug 18665. (CVE-2015-7547)

See also:
https://sourceware.org/ml/libc-alpha/2016-02/msg00416.html
https://sourceware.org/ml/libc-alpha/2016-02/msg00418.html

(cherry picked from commit e9db92d3acfe1822d56d11abcea5bfc4c41cf6ca)

9 years agohsearch_r: Apply VM size limit in test case
Florian Weimer [Fri, 12 Feb 2016 11:57:40 +0000 (12:57 +0100)] 
hsearch_r: Apply VM size limit in test case

(cherry picked from commit f34f146e682d8d529dcf64b3c2781bf3f2f05f6c)

9 years agoImprove check against integer wraparound in hcreate_r [BZ #18240]
Florian Weimer [Thu, 28 Jan 2016 12:59:11 +0000 (13:59 +0100)] 
Improve check against integer wraparound in hcreate_r [BZ #18240]

(cherry picked from commit bae7c7c764413b23e61cb099ce33be4c4ee259bb)

9 years agoHandle overflow in __hcreate_r
Ondřej Bílka [Sat, 11 Jul 2015 15:44:10 +0000 (17:44 +0200)] 
Handle overflow in __hcreate_r

Hi,

As in bugzilla entry there is overflow in hsearch when looking for prime
number as SIZE_MAX - 1 is divisible by 5. We fix that by rejecting large
inputs before looking for prime.

* misc/hsearch_r.c (__hcreate_r): Handle overflow.

(cherry picked from commit 2f5c1750558fe64bac361f52d6827ab1bcfe52bc)

9 years agoGracefully handle incompatible locale data
Ludovic Courtès [Tue, 27 Oct 2015 12:33:26 +0000 (13:33 +0100)] 
Gracefully handle incompatible locale data

* locale/loadlocale.c (_nl_intern_locale_data): Change assertion
on CNT to a conditional jump to 'puntdata'.

(cherry picked from commit 0062ace2292effc4135c15ea99b1931fea5e0203)

9 years agohppa: start.S: rework references to fix PIE TEXTRELs [BZ #18421]
Alan Modra [Sat, 15 Aug 2015 02:15:49 +0000 (22:15 -0400)] 
hppa: start.S: rework references to fix PIE TEXTRELs [BZ #18421]

The startup code was not using PIC friendly references leading to TEXTRELs
in every PIE ELF.

(cherry picked from commit cf4253777412e9c8d5bfbc1c8b975f472e1e7d43)

9 years agohppa: Fix miscompilation of sched_setaffinity() [BZ #18480]
John David Anglin [Fri, 7 Aug 2015 15:54:19 +0000 (11:54 -0400)] 
hppa: Fix miscompilation of sched_setaffinity() [BZ #18480]

The attached change fixes the miscompilation of sched_setaffinity() on
hppa.  This is an old problem that was fixed on other architectures using
a similar approach to the attached change.  See:
https://sourceware.org/ml/libc-hacker/2004-04/msg00016.html

Build tested on trunk.  Patch has been applied to debian glibc for some time.

(cherry picked from commit 04ece7d2dec91fe870c5f1a38032875915f44633)

9 years agoFix BZ #18985 -- out of range data to strftime() causes a segfault
Paul Pluzhnikov [Sat, 26 Sep 2015 20:27:48 +0000 (13:27 -0700)] 
Fix BZ #18985 -- out of range data to strftime() causes a segfault

(cherry picked from commit d36c75fc0d44deec29635dd239b0fbd206ca49b7)

9 years agoFix trailing space.
Paul Pluzhnikov [Sat, 8 Aug 2015 22:54:40 +0000 (15:54 -0700)] 
Fix trailing space.

(cherry picked from commit 7565d2a862683a3c26ffb1f32351b8c5ab9f7b31)

9 years agoFix BZ #17905
Paul Pluzhnikov [Sat, 8 Aug 2015 22:53:03 +0000 (15:53 -0700)] 
Fix BZ #17905

(cherry picked from commit 0f58539030e436449f79189b6edab17d7479796e)

9 years agoalpha/hppa: fix libc.abilist sorting wrt fmemopen
Aurelien Jarno [Mon, 7 Dec 2015 14:40:01 +0000 (15:40 +0100)] 
alpha/hppa: fix libc.abilist sorting wrt fmemopen

Commit fdb7d390 introduced the fmemopen symbol at the wrong location
in alpha/libc.abilist and hppa/libc.abilist. The file needs to keep
sorted, fix that.

Note: this is for 2.22 only, for master the format has been changed in
commit 8c77b6ad.

* sysdeps/unix/sysv/linux/alpha/libc.abilist [GLIBC_2.22]: Move
to keep the file sorted.
* sysdeps/unix/sysv/linux/hppa/libc.abilist [GLIBC_2.22]: Likewise.

9 years agoMerge branch 'release/2.22/master' into ibm/2.22/master
Tulio Magno Quites Machado Filho [Thu, 17 Dec 2015 19:31:21 +0000 (17:31 -0200)] 
Merge branch 'release/2.22/master' into ibm/2.22/master

9 years agopowerpc: Fix usage of elision transient failure adapt param
Paul Murphy [Thu, 27 Aug 2015 14:48:04 +0000 (09:48 -0500)] 
powerpc: Fix usage of elision transient failure adapt param

The skip_lock_out_of_tbegin_retries adaptive parameter was
not being used correctly, nor as described.  This prevents
a fallback for all users of the lock if a transient abort
occurs within the accepted number of retries.

[BZ #19174]
* sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of
.skip_lock_out_of_tbegin_retries.
* sysdeps/unix/sysv/linux/powerpc/elision-lock.c
(__lll_lock_elision): Likewise, and respect a value of
try_tbegin <= 0.

(cherry picked from commit 72f1463df85a522bfd1568e47bd81371522ee358)

Conflicts:
NEWS

9 years agoCorrected path to installed libmvec_nonshared.a
Andrew Senkevich [Thu, 3 Dec 2015 17:54:52 +0000 (20:54 +0300)] 
Corrected path to installed libmvec_nonshared.a

    * math/Makefile ($(inst_libdir)/libm.so): Corrected path to
    libmvec_nonshared.a

9 years agoBetter workaround for aliases of *_finite symbols in vector math library.
Andrew Senkevich [Fri, 27 Nov 2015 14:30:04 +0000 (17:30 +0300)] 
Better workaround for aliases of *_finite symbols in vector math library.

Old workaround based on assembly aliases can lead to link fail (bug 19058).
This patch makes workaround in another way to avoid it.

    [BZ #19058]
    * math/Makefile ($(inst_libdir)/libm.so): Added libmvec_nonshared.a
    to AS_NEEDED.
    * sysdeps/x86/fpu/bits/math-vector.h: Removed code with old workaround.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support,
    libmvec-static-only-routines): Added new file.
    * sysdeps/x86_64/fpu/svml_finite_alias.S: New file.
    * NEWS: Mention this fix.

9 years agoNaCl: Use allocate_code_data after dyncode_create
Roland McGrath [Sat, 21 Nov 2015 00:16:35 +0000 (16:16 -0800)] 
NaCl: Use allocate_code_data after dyncode_create

(cherry picked from commit f549f0bcba7196a2afc51657c536bbc131a7c544)

9 years agoRun tst-prelink test for GLOB_DAT reloc
H.J. Lu [Sat, 14 Nov 2015 20:00:16 +0000 (12:00 -0800)] 
Run tst-prelink test for GLOB_DAT reloc

Run tst-prelink test on targets with GLOB_DAT relocaton.

* config.make.in (have-glob-dat-reloc): New.
* configure.ac (libc_cv_has_glob_dat): New.  Set to yes if
target supports GLOB_DAT relocaton. AC_SUBST.
* configure: Regenerated.
* elf/Makefile (tests): Add tst-prelink.
(tests-special): Add $(objpfx)tst-prelink-cmp.out.
(tst-prelink-ENV): New.
($(objpfx)tst-prelink-conflict.out): Likewise.
($(objpfx)tst-prelink-cmp.out): Likewise.
* sysdeps/x86/tst-prelink.c: Moved to ...
* elf/tst-prelink.c: Here.
* sysdeps/x86/tst-prelink.exp: Moved to ...
* elf/tst-prelink.exp: Here.
* sysdeps/x86/Makefile (tests): Don't add tst-prelink.
(tst-prelink-ENV): Removed.
($(objpfx)tst-prelink-conflict.out): Likewise.
($(objpfx)tst-prelink-cmp.out): Likewise.
(tests-special): Don't add $(objpfx)tst-prelink-cmp.out.

(cherry picked from commit 89569c8bb6b386db4881af0e96514d2ec5c35478)