glibc:release/2.18/master

Last commit made on 2016-04-22
Get this branch:
git clone -b release/2.18/master https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
release/2.18/master
Repository:
lp:glibc

Recent commits

715e7fe... by Florian Weimer

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)

04130e5... by Andreas Schwab <email address hidden>

Fix invalid file descriptor reuse while sending DNS query (BZ #15946)

(cherry picked from commit 45af2f6fe19b8a776373cac5a2691460179aa1a3)

c5ae7f9... by Carlos O'Donell <email address hidden>

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)

b057b48... by Leonhard Holz <email address hidden>

Fix memory handling in strxfrm_l [BZ #16009]

[Modified from the original email by Siddhesh Poyarekar]

This patch solves bug #16009 by implementing an additional path in
strxfrm that does not depend on caching the weight and rule indices.

In detail the following changed:

* The old main loop was factored out of strxfrm_l into the function
do_xfrm_cached to be able to alternativly use the non-caching version
do_xfrm.

* strxfrm_l allocates a a fixed size array on the stack. If this is not
sufficiant to store the weight and rule indices, the non-caching path is
taken. As the cache size is not dependent on the input there can be no
problems with integer overflows or stack allocations greater than
__MAX_ALLOCA_CUTOFF. Note that malloc-ing is not possible because the
definition of strxfrm does not allow an oom errorhandling.

* The uncached path determines the weight and rule index for every char
and for every pass again.

* Passing all the locale data array by array resulted in very long
parameter lists, so I introduced a structure that holds them.

* Checking for zero src string has been moved a bit upwards, it is
before the locale data initialization now.

* To verify that the non-caching path works correct I added a test run
to localedata/sort-test.sh & localedata/xfrm-test.c where all strings
are patched up with spaces so that they are too large for the caching path.

(cherry picked from commit 0f9e585480edcdf1e30dc3d79e24b84aeee516fa)

Conflicts:
 NEWS
 string/strxfrm_l.c

3252416... by Ppluzhnikov-google

Fix BZ #17269 -- _IO_wstr_overflow integer overflow

(cherry picked from commit bdf1ff052a8e23d637f2c838fa5642d78fcedc33)

Conflicts:
 NEWS

161a7ef... by Andreas Schwab <email address hidden>

Fix read past end of pattern in fnmatch (bug 18032)

(cherry picked from commit 4a28f4d55a6cc33474c0792fe93b5942d81bf185)

Conflicts:
 NEWS
 posix/tst-fnmatch3.c

f0cb70a... by Florian Weimer

Harden tls_dtor_list with pointer mangling [BZ #19018]

(cherry picked from commit f586e1328681b400078c995a0bb6ad301ef73549)

Conflicts:
 NEWS
 stdlib/cxa_thread_atexit_impl.c

80e44fa... by Florian Weimer

Always enable pointer guard [BZ #18928]

Honoring the LD_POINTER_GUARD environment variable in AT_SECURE mode
has security implications. This commit enables pointer guard
unconditionally, and the environment variable is now ignored.

        [BZ #18928]
        * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
        _dl_pointer_guard member.
        * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
        initializer.
        (security_init): Always set up pointer guard.
        (process_envvars): Do not process LD_POINTER_GUARD.

(cherry picked from commit a014cecd82b71b70a6a843e250e06b541ad524f7)

Conflicts:
 NEWS

d4deb63... by Guo Yixuan

Fixed pthread_spin_lock on sparc32/64 (bug 16882)

 [BZ #16882]
 * nptl/sysdeps/sparc/sparc32/pthread_spin_lock.S
 (pthread_spin_lock): Branch out of spin loop to proper location.
 * nptl/sysdeps/sparc/sparc64/pthread_spin_lock.S
 (pthread_spin_lock): Likewise.

 * nptl/tst-spin4.c: New test.
 * nptl/Makefile (tests): Add tst-spin4.

f2b605e... by "Jose E. Marchesi" <email address hidden>

Fix sparc memcpy data corruption when using niagara2 optimized routines.

 * sysdeps/sparc/sparc64/multiarch/memcpy-niagara2.S: Add missing
 membar to avoid block loads/stores to overlap previous stores.