]> sourceware.org Git - glibc.git/log
glibc.git
8 years agoNEWS: Add 18665 and 19791 to fixed bug list. ibm/2.18/master
Paul E. Murphy [Wed, 20 Apr 2016 14:18:20 +0000 (09:18 -0500)]
NEWS: Add 18665 and 19791 to fixed bug list.

8 years agoCVE-2016-3075: Stack overflow in _nss_dns_getnetbyname_r [BZ #19879]
Florian Weimer [Wed, 20 Apr 2016 14:01:33 +0000 (09:01 -0500)]
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)

8 years agoresolv: Always set *resplen2 out parameter in send_dg [BZ #19791]
Florian Weimer [Tue, 19 Apr 2016 22:38:19 +0000 (17:38 -0500)]
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)

8 years agoCVE-2015-7547: getaddrinfo() stack-based buffer overflow (Bug 18665).
Carlos O'Donell [Tue, 19 Apr 2016 22:38:09 +0000 (17:38 -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 pick from commit e9db92d3acfe1822d56d11abcea5bfc4c41cf6ca)

8 years agoMerge branch 'release/2.18/master' into ibm/2.18/master
Tulio Magno Quites Machado Filho [Thu, 31 Dec 2015 16:55:21 +0000 (14:55 -0200)]
Merge branch 'release/2.18/master' into ibm/2.18/master

Conflicts:
NEWS

8 years agoFix memory handling in strxfrm_l [BZ #16009]
Leonhard Holz [Tue, 13 Jan 2015 06:03:56 +0000 (11:33 +0530)]
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

8 years agoFix BZ #17269 -- _IO_wstr_overflow integer overflow
Paul Pluzhnikov [Sun, 22 Feb 2015 20:01:47 +0000 (12:01 -0800)]
Fix BZ #17269 -- _IO_wstr_overflow integer overflow

(cherry picked from commit bdf1ff052a8e23d637f2c838fa5642d78fcedc33)

Conflicts:
NEWS

8 years agoFix read past end of pattern in fnmatch (bug 18032)
Andreas Schwab [Thu, 26 Feb 2015 13:55:24 +0000 (14:55 +0100)]
Fix read past end of pattern in fnmatch (bug 18032)

(cherry picked from commit 4a28f4d55a6cc33474c0792fe93b5942d81bf185)

Conflicts:
NEWS
posix/tst-fnmatch3.c

8 years agoHarden tls_dtor_list with pointer mangling [BZ #19018]
Florian Weimer [Tue, 6 Oct 2015 11:12:36 +0000 (13:12 +0200)]
Harden tls_dtor_list with pointer mangling [BZ #19018]

(cherry picked from commit f586e1328681b400078c995a0bb6ad301ef73549)

Conflicts:
NEWS
stdlib/cxa_thread_atexit_impl.c

8 years agoAlways enable pointer guard [BZ #18928]
Florian Weimer [Thu, 15 Oct 2015 07:23:07 +0000 (09:23 +0200)]
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

9 years agoSeparate internal state between getXXent and getXXbyYY NSS calls (bug 18007)
Andreas Schwab [Wed, 25 Mar 2015 15:35:46 +0000 (16:35 +0100)]
Separate internal state between getXXent and getXXbyYY NSS calls (bug 18007)

Conflicts:
NEWS
nss/nss_files/files-hosts.c

9 years agoCVE-2014-8121: Do not close NSS files database during iteration [BZ #18007]
Florian Weimer [Wed, 29 Apr 2015 12:41:25 +0000 (14:41 +0200)]
CVE-2014-8121: Do not close NSS files database during iteration [BZ #18007]

Robin Hack discovered Samba would enter an infinite loop processing
certain quota-related requests.  We eventually tracked this down to a
glibc issue.

Running a (simplified) test case under strace shows that /etc/passwd
is continuously opened and closed:


open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
lseek(3, 0, SEEK_CUR)                   = 0
read(3, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 2717
lseek(3, 2717, SEEK_SET)                = 2717
close(3)                                = 0
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_SET)                   = 0
read(3, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 2717
lseek(3, 2717, SEEK_SET)                = 2717
close(3)                                = 0
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
lseek(3, 0, SEEK_CUR)                   = 0


The lookup function implementation in
nss/nss_files/files-XXX.c:DB_LOOKUP has code to prevent that.  It is
supposed skip closing the input file if it was already open.

  /* Reset file pointer to beginning or open file.  */       \
  status = internal_setent (keep_stream);       \
      \
  if (status == NSS_STATUS_SUCCESS)       \
    {       \
      /* Tell getent function that we have repositioned the file pointer.  */ \
      last_use = getby;       \
      \
      while ((status = internal_getent (result, buffer, buflen, errnop       \
H_ERRNO_ARG EXTRA_ARGS_VALUE))       \
     == NSS_STATUS_SUCCESS)       \
{ break_if_match }       \
      \
      if (! keep_stream)       \
internal_endent ();       \
    }       \

keep_stream is initialized from the stayopen flag in internal_setent.
internal_setent is called from the set*ent implementation as:

  status = internal_setent (stayopen);

However, for non-host database, this flag is always 0, per the
STAYOPEN magic in nss/getXXent_r.c.

Thus, the fix is this:

-  status = internal_setent (stayopen);
+  status = internal_setent (1);

This is not a behavioral change even for the hosts database (where the
application can specify the stayopen flag) because with a call to
sethostent(0), the file handle is still not closed in the
implementation of gethostent.

Conflicts:
NEWS

9 years agoCVE-2015-1781: resolv/nss_dns/dns-host.c buffer overflow [BZ#18287]
Arjun Shankar [Tue, 21 Apr 2015 12:06:31 +0000 (14:06 +0200)]
CVE-2015-1781: resolv/nss_dns/dns-host.c buffer overflow [BZ#18287]

Conflicts:
NEWS

9 years agoMerge branch release/2.18/master into ibm/2.18/master
Tulio Magno Quites Machado Filho [Tue, 7 Apr 2015 13:13:59 +0000 (10:13 -0300)]
Merge branch release/2.18/master into ibm/2.18/master

Conflicts:
NEWS

9 years agoFix invalid file descriptor reuse while sending DNS query (BZ #15946)
Andreas Schwab [Mon, 26 May 2014 16:01:31 +0000 (18:01 +0200)]
Fix invalid file descriptor reuse while sending DNS query (BZ #15946)

Conflicts:
NEWS

9 years agopowerpc: Fix incorrect results for pow when using FMA
Adhemerval Zanella [Tue, 10 Mar 2015 13:38:54 +0000 (09:38 -0400)]
powerpc: Fix incorrect results for pow when using FMA

This patch adds no FMA generation for e_pow to avoid precision issues
for powerpc.  This fixes BZ#18104.

9 years agoCVE-2015-1472: wscanf allocates too little memory
Paul Pluzhnikov [Fri, 6 Feb 2015 05:30:42 +0000 (00:30 -0500)]
CVE-2015-1472: wscanf allocates too little memory

BZ #16618

Under certain conditions wscanf can allocate too little memory for the
to-be-scanned arguments and overflow the allocated buffer.  The
implementation now correctly computes the required buffer size when
using malloc.

A regression test was added to tst-sscanf.

Conflicts:
ChangeLog
NEWS

9 years agoPowerPC: Remove 64 bits instructions in PPC32 code
Adhemerval Zanella [Thu, 22 May 2014 19:48:38 +0000 (14:48 -0500)]
PowerPC: Remove 64 bits instructions in PPC32 code

This patch replaces the insrdi by insrwi in powerpc32 assembly.

It is a backport of d298c41635ce7f2dc7c3eccc842fe3aa754c0c8e.

Conflicts:
ChangeLog

9 years agoCVE-2014-7817: wordexp fails to honour WRDE_NOCMD.
Carlos O'Donell [Wed, 19 Nov 2014 16:44:12 +0000 (11:44 -0500)]
CVE-2014-7817: wordexp fails to honour WRDE_NOCMD.

The function wordexp() fails to properly handle the WRDE_NOCMD
flag when processing arithmetic inputs in the form of "$((... ``))"
where "..." can be anything valid. The backticks in the arithmetic
epxression are evaluated by in a shell even if WRDE_NOCMD forbade
command substitution. This allows an attacker to attempt to pass
dangerous commands via constructs of the above form, and bypass
the WRDE_NOCMD flag. This patch fixes this by checking for WRDE_NOCMD
in exec_comm(), the only place that can execute a shell. All other
checks for WRDE_NOCMD are superfluous and removed.

We expand the testsuite and add 3 new regression tests of roughly
the same form but with a couple of nested levels.

On top of the 3 new tests we add fork validation to the WRDE_NOCMD
testing. If any forks are detected during the execution of a wordexp()
call with WRDE_NOCMD, the test is marked as failed. This is slightly
heuristic since vfork might be used in the future, but it provides a
higher level of assurance that no shells were executed as part of
command substitution with WRDE_NOCMD in effect. In addition it doesn't
require libpthread or libdl, instead we use the public implementation
namespace function __register_atfork (already part of the public ABI
for libpthread).

Tested on x86_64 with no regressions.

9 years agoLabel CVE-2014-9402 in NEWS
Allan McRae [Thu, 18 Dec 2014 01:01:43 +0000 (11:01 +1000)]
Label CVE-2014-9402 in NEWS

9 years agoAvoid infinite loop in nss_dns getnetbyname [BZ #17630]
Florian Weimer [Mon, 15 Dec 2014 16:41:13 +0000 (17:41 +0100)]
Avoid infinite loop in nss_dns getnetbyname [BZ #17630]

9 years agoCVE-2012-3406: Stack overflow in vfprintf [BZ #16617]
Jeff Law [Mon, 15 Dec 2014 09:09:32 +0000 (10:09 +0100)]
CVE-2012-3406: Stack overflow in vfprintf [BZ #16617]

A larger number of format specifiers coudld cause a stack overflow,
potentially allowing to bypass _FORTIFY_SOURCE format string
protection.

9 years agoMention CVE-2014-4043 in NEWS
Allan McRae [Sat, 21 Jun 2014 07:23:55 +0000 (17:23 +1000)]
Mention CVE-2014-4043 in NEWS

9 years agoposix_spawn_file_actions_addopen needs to copy the path argument (BZ 17048)
Florian Weimer [Wed, 11 Jun 2014 21:12:52 +0000 (23:12 +0200)]
posix_spawn_file_actions_addopen needs to copy the path argument (BZ 17048)

POSIX requires that we make a copy, so we allocate a new string
and free it in posix_spawn_file_actions_destroy.

Reported by David Reid, Alex Gaynor, and Glyph Lefkowitz.  This bug
may have security implications.

9 years ago_nl_find_locale: Improve handling of crafted locale names [BZ #17137]
Florian Weimer [Mon, 12 May 2014 13:24:12 +0000 (15:24 +0200)]
_nl_find_locale: Improve handling of crafted locale names [BZ #17137]

Prevent directory traversal in locale-related environment variables
(CVE-2014-0475).

9 years ago__gconv_translit_find: Disable function [BZ #17187]
Florian Weimer [Tue, 26 Aug 2014 17:38:59 +0000 (19:38 +0200)]
__gconv_translit_find: Disable function [BZ #17187]

This functionality has never worked correctly, and the implementation
contained a security vulnerability (CVE-2014-5119).

9 years agoCVE-2014-6040: Crashes on invalid input in IBM gconv modules [BZ #17325]
Florian Weimer [Wed, 3 Sep 2014 17:45:43 +0000 (19:45 +0200)]
CVE-2014-6040: Crashes on invalid input in IBM gconv modules [BZ #17325]

These changes are based on the fix for BZ #14134 in commit
6e230d11837f3ae7b375ea69d7905f0d18eb79e5.

9 years agoAdd CVE-2013-4332 to NEWS.
Will Newton [Fri, 13 Sep 2013 08:26:02 +0000 (09:26 +0100)]
Add CVE-2013-4332 to NEWS.

9 years agomalloc: Check for integer overflow in memalign.
Will Newton [Fri, 16 Aug 2013 11:54:29 +0000 (12:54 +0100)]
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.

9 years agomalloc: Check for integer overflow in valloc.
Will Newton [Fri, 16 Aug 2013 10:59:37 +0000 (11:59 +0100)]
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.

10 years agoFixed pthread_spin_lock on sparc32/64 (bug 16882)
Guo Yixuan [Tue, 3 Jun 2014 23:19:11 +0000 (16:19 -0700)]
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.

10 years agoFix sparc memcpy data corruption when using niagara2 optimized routines.
Jose E. Marchesi [Sat, 17 May 2014 18:20:27 +0000 (11:20 -0700)]
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.

10 years agoSPARC: add prlimit and prlimit64 in <bits/resource.h> (BZ #16943)
Aurelien Jarno [Thu, 15 May 2014 22:04:41 +0000 (00:04 +0200)]
SPARC: add prlimit and prlimit64 in <bits/resource.h> (BZ #16943)

prlimit and prlimit64 have been added in the main <bits/resource.h>, but
not in the SPARC specific version. Fix that.

Note: this is Debian bug#703559, reported by Emilio Pozuelo Monfort
<pochu@debian.org>

(cherry picked from commit d16e6ec7ca2c861ba681e3a2fbd431725774292e)

10 years agoSPARC: add EFD_SEMAPHORE in <bits/eventfd.h> (BZ #16916)
Aurelien Jarno [Tue, 6 May 2014 21:31:44 +0000 (23:31 +0200)]
SPARC: add EFD_SEMAPHORE in <bits/eventfd.h> (BZ #16916)

EFD_SEMAPHORE has been added in the main <bits/eventfd.h>, but not in
the SPARC specific version. Fix that.

(cherry picked from commit 83df9ad0cc861ef24f08a88c5a4c055e2516d33c)

10 years agoNEWS: Add 16885 to fixed bug list.
David S. Miller [Thu, 1 May 2014 20:44:25 +0000 (16:44 -0400)]
NEWS: Add 16885 to fixed bug list.

10 years agoFix v9/64-bit strcmp when string ends in multiple zero bytes.
David S. Miller [Wed, 30 Apr 2014 19:57:51 +0000 (12:57 -0700)]
Fix v9/64-bit strcmp when string ends in multiple zero bytes.

[BZ #16885]
* sysdeps/sparc/sparc64/strcmp.S: Fix end comparison handling when
multiple zero bytes exist at the end of a string.
Reported by Aurelien Jarno <aurelien@aurel32.net>

* string/test-strcmp.c (check): Add explicit test for situations where
there are multiple zero bytes after the first.

10 years agoFix erroneous (and circular) implied pattern rule for linkobj/libc.so.
Brooks Moses [Tue, 18 Feb 2014 17:18:44 +0000 (11:18 -0600)]
Fix erroneous (and circular) implied pattern rule for linkobj/libc.so.

[BZ #15915] As described in the bug, the pattern rule for lib%.so files
in Makerules includes linkobj/libc.so as a dependency.  However, the
explicit rule for linkobj/libc.so is in the top-level Makefile.

Thus, the subdirectory makefiles that include Makerules end up with an
erroneous makefile pattern rule for linkobj/libc.so that includes
itself as a dependency.  The result is make warnings whenever rules
for other .so files are resolved -- and, on occasion, actual makefile
failures when a race condition causes the implicit rule to actually be
used.

This patch moves the explicit rules for linkobj/libc.so into Makerules
to clear up this problem.  It also elaborates a couple of comments
that I'd initially found confusing.

Backport of 5f855e3598a576c35e54623a13b256f3e87fcd4d

10 years agoPowerPC: Remove inexistent paths in sysdeps dirs
Adhemerval Zanella [Thu, 6 Feb 2014 18:10:25 +0000 (12:10 -0600)]
PowerPC: Remove inexistent paths in sysdeps dirs

This patch removes inexistent paths when building with --with-cpu=power5
or newer.

10 years agoFix assert() remove for DT_RUNPATH and DT_RPATH
Adhemerval Zanella [Thu, 6 Feb 2014 18:10:00 +0000 (12:10 -0600)]
Fix assert() remove for DT_RUNPATH and DT_RPATH

This patch fixes a wrong merge of d19762a5fd946ef86fb2922eb5710aac8000ab25

10 years agoFix wrong ChangeLog merge
Adhemerval Zanella [Wed, 5 Feb 2014 21:29:39 +0000 (15:29 -0600)]
Fix wrong ChangeLog merge

10 years agoAdd GLIBC_2.3 to libm in Versions.def
Adhemerval Zanella [Wed, 5 Feb 2014 21:28:57 +0000 (15:28 -0600)]
Add GLIBC_2.3 to libm in Versions.def

This patch adds GLIBC_2.3 mark on libm so it is always
define in abi-versions.h. This fixes a build issue with
fe_nomask.c in PPC64 LE where GLIBC_2_3 are no defined
for SHLIB_COMPAT, resulting in a wrong evaluation in the macro.

10 years agoPowerPC: powerpc64le abilist for 2.17
Adhemerval Zanella [Tue, 4 Feb 2014 16:18:26 +0000 (10:18 -0600)]
PowerPC: powerpc64le abilist for 2.17

This patch is the abifiles for powerpc64le based on GLIBC 2.17.

10 years agoPowerPC: Change powerpc64le start ABI to 2.17.
Adhemerval Zanella [Tue, 4 Feb 2014 16:07:36 +0000 (10:07 -0600)]
PowerPC: Change powerpc64le start ABI to 2.17.

Backport of 0ff8246327401ae8779e2697d5c7348611cdbf8a.

10 years agoabilist-pattern configurability
Adhemerval Zanella [Tue, 4 Feb 2014 16:06:41 +0000 (10:06 -0600)]
abilist-pattern configurability

This patch creates implicit rules to match the abifiles if
abilist-pattern is defined in the architecture Makefile. This allows
machine specific Makefiles to define different abifiles names
(for instance *-le.abilist for powerpc64le).

10 years agoDisable x87 inline functions for SSE2 math
H.J. Lu [Wed, 29 Jan 2014 15:51:41 +0000 (07:51 -0800)]
Disable x87 inline functions for SSE2 math

When i386 and x86-64 mathinline.h was merged into a single mathinline.h,
"gcc -m32" enables x87 inline functions on x86-64 even when -mfpmath=sse
and SSE2 is enabled.  It is a regression on x86-64.  We should check
__SSE2_MATH__ instead of __x86_64__ when disabling x87 inline functions.

(cherry picked from commit 409e00bd69b8d8dd74d7327085351d26769ea6fc)

Conflicts:
ChangeLog
NEWS

10 years agoPowerPC: Fix gettimeofday ifunc selection
Adhemerval Zanella [Thu, 23 Jan 2014 17:07:47 +0000 (11:07 -0600)]
PowerPC: Fix gettimeofday ifunc selection

The IFUNC selector for gettimeofday runs before _libc_vdso_platform_setup where
__vdso_gettimeofday is set. The selector then sets __gettimeofday (the internal
version used within GLIBC) to use the system call version instead of the vDSO one.
This patch changes the check if vDSO is available to get its value directly
instead of rely on __vdso_gettimeofday.

This patch changes it by getting the vDSO value directly.

It fixes BZ#16431.

10 years agoPowerPC: remove wrong truncl implementation for PowerPC64
Adhemerval Zanella [Thu, 23 Jan 2014 17:06:58 +0000 (11:06 -0600)]
PowerPC: remove wrong truncl implementation for PowerPC64

The truncl assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_truncl.S)
returns wrong results for some inputs where first double is a exact integer
and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d401698a58cf7da150d9cce769fa6679ba5f that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_truncl.c instead it fixes tgammal
issues regarding wrong result sign.

10 years agoPowerPC: Fix __fe_mask_env export
Adhemerval Zanella [Thu, 23 Jan 2014 17:04:51 +0000 (11:04 -0600)]
PowerPC: Fix __fe_mask_env export

This patch does not export __fe_mask_env anymore, only providing a
compatibility symbol. It fixes BZ#14143.

10 years ago[AArch64] BZ #16169 Add CFI directives to clone.S
Tom Tromey [Mon, 20 Jan 2014 12:58:03 +0000 (12:58 +0000)]
[AArch64] BZ #16169 Add CFI directives to clone.S

[BZ #16169] Add CFI directives to the AArch64 clone.S implementation
and ensure that the FP in the child is zero'd in order to comply with
AAPCS.
(cherry picked from commit 3a3acb6afc753475675b5724f206e619d0c9590d)

Conflicts:

NEWS

10 years agoInclude generic symbol-hacks.h for x32
H.J. Lu [Mon, 20 Jan 2014 19:05:22 +0000 (11:05 -0800)]
Include generic symbol-hacks.h for x32

In BZ #15605 fix with addding memset/memmove alias in symbol-hacks.h,
x32 symbol-hacks.h change was missing.  Fixed by including
<sysdeps/generic/symbol-hacks.h> in x32 symbol-hacks.h.

10 years agoPowerPC: Fix ftime gettimeofday internal call returning bogus data
Adhemerval Zanella [Thu, 16 Jan 2014 19:01:55 +0000 (13:01 -0600)]
PowerPC: Fix ftime gettimeofday internal call returning bogus data

This patches fixes BZ#16430 by setting a different symbol for internal
GLIBC calls that points to ifunc resolvers. For PPC32, if the symbol
is defined as hidden (which is the case for gettimeofday and time) the
compiler will create local branches (symbol@local) and linker will not
create PLT calls (required for IFUNC). This will leads to internal symbol
calling the IFUNC resolver instead of the resolved symbol.
For PPC64 this behavior does not occur because a call to a function in
another translation unit might use a different toc pointer thus requiring
a PLT call.

10 years ago[AArch64] Fix FP_ROUNDMODE.
Marcus Shawcroft [Tue, 7 Jan 2014 16:16:35 +0000 (16:16 +0000)]
[AArch64] Fix FP_ROUNDMODE.

[BZ #16387] Fix FP_ROUNDMODE to extract the correct bits from FPCR.

Conflicts:
NEWS

10 years ago[AArch64] Fix CFA adjustment on dynamic linker entry.
Marcus Shawcroft [Tue, 7 Jan 2014 10:12:35 +0000 (10:12 +0000)]
[AArch64] Fix CFA adjustment on dynamic linker entry.

10 years agoFix race in free() of fastbin chunk: BZ #15073
Maxim Kuvyrkov [Mon, 23 Dec 2013 20:44:50 +0000 (09:44 +1300)]
Fix race in free() of fastbin chunk: BZ #15073

Perform sanity check only if we have_lock.  Due to lockless nature of fastbins
we need to be careful derefencing pointers to fastbin entries (chunksize(old)
in this case) in multithreaded environments.

The fix is to add have_lock to the if-condition checks.  The rest of the patch
only makes code more readable.

* malloc/malloc.c (_int_free): Perform sanity check only if we
have_lock.

Conflicts:

ChangeLog
NEWS

10 years ago[AArch64] Save and restore q0-q7 on entry to dynamic linker.
Marcus Shawcroft [Wed, 18 Dec 2013 10:00:07 +0000 (10:00 +0000)]
[AArch64] Save and restore q0-q7 on entry to dynamic linker.

[BZ #15128] Ensure all argument passing registers are saved and
restored on entry to dynamic linker.

(cherry picked from commit 9dbebe1a67bbedfcb39c6b739f15bc639e8d40a2)

Conflicts:
NEWS

10 years agoMerge the changes to add little endian support on PowerPC
Tulio Magno Quites Machado Filho [Thu, 21 Nov 2013 17:02:35 +0000 (15:02 -0200)]
Merge the changes to add little endian support on PowerPC

Discard all the previous changes from ibm/2.18/master in order to keep a
clean branch.

10 years agoalpha: Fix signal thunk unwind info
Richard Henderson [Fri, 15 Nov 2013 20:34:39 +0000 (06:34 +1000)]
alpha: Fix signal thunk unwind info

10 years agoMention powerpc64le support in NEWS and README, plus bugs fixed.
Alan Modra [Fri, 15 Nov 2013 23:48:28 +0000 (10:18 +1030)]
Mention powerpc64le support in NEWS and README, plus bugs fixed.

* NEWS: Mention powerpc64le support and bugs fixed.
* README: Both big-endian and little-endian powerpc64 supported.

10 years agoPowerPC64le has ifunc too.
Alan Modra [Fri, 15 Nov 2013 23:39:06 +0000 (10:09 +1030)]
PowerPC64le has ifunc too.

I believe this is really just a "documentation" fix.
See https://sourceware.org/ml/binutils/2013-10/msg00059.html

10 years agoSet arch_minimum_kernel for powerpc*le.
Alan Modra [Sat, 5 Oct 2013 07:35:54 +0000 (17:05 +0930)]
Set arch_minimum_kernel for powerpc*le.

10 years agoA little more precise %Lf for IBM long double
Alan Modra [Sat, 17 Aug 2013 09:41:11 +0000 (19:11 +0930)]
A little more precise %Lf for IBM long double
http://sourceware.org/ml/libc-alpha/2013-08/msg00106.html

IBM long double has variable precision and we often have values with
107 bits during the normal course of calculations.  It's possible to
have an IBM long double with 2k bits of precision, and while some might
argue we ought to print to the full precision, I'm not inclined to try
to implement that.

So this patch gives the mpn values returned from ldbl2mpn() an extra
11 bits of precision.  To do that it's necessary to inform the caller
of __mpn_extract_long_double() exactly how many bits are returned
rather than assuming a fixed LDBL_MANT_DIG bits.  I did that
indirectly by returning the number of zero bits in the last mp_limb,
which turns out to be convenient both in __mpn_extract_long_double(),
and it's caller.  Given the extra parameter it then becomes possible
to omit shifting in __mpn_extract_long_double(), since the caller does
that anyway.

In the following, note that 1 - IEEE854_LONG_DOUBLE_BIAS is equal to
LDBL_MIN_EXP - 1.  I prefer the former since we already use
IEEE854_LONG_DOUBLE_BIAS in the exponent calculation for normalised
values, and it reinforces the fact that denormals are treated as if
their unbiased exponent was 1.

[BZ #5268]
* include/gmp.h (__mpn_extract_double, __mpn_extract_long_double):
Update prototypes.
* stdio-common/printf_fp.c: Likewise.
(__printf_fp): Use returned zero_bits.
* stdlib/dbl2mpn.c (__mpn_extract_double): Update funtion arguments.
* sysdeps/i386/ldbl2mpn.c (__mpn_extract_long_double): Don't perform
shifts for denormals here.  Instead return leading zero bit count
and adjust return value of function.
* sysdeps/ieee754/dbl-64/dbl2mpn.c (__mpn_extract_long_double): Likewise.
* sysdeps/ieee754/ldbl-128/ldbl2mpn.c (__mpn_extract_long_double):
Likewise.
* sysdeps/ieee754/ldbl-96/ldbl2mpn.c (__mpn_extract_long_double):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c (__mpn_extract_long_double):
Likewise.  Return an extra 11 bits of precision.

10 years agoPowerPC LE ABI tests
Alan Modra [Thu, 3 Oct 2013 04:39:27 +0000 (14:09 +0930)]
PowerPC LE ABI tests
http://sourceware.org/ml/libc-alpha/2013-08/msg00096.html

This adds ABI tests for powerpc64le.

* Makerules (abilist): Define and use var in abilist rules.
* sysdeps/unix/sysv/linux/powerpc/Makefile (abilist): Define.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/ld-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libBrokenLocale-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libanl-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libc-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libcrypt-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libdl-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libm-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libnsl-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libpthread-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libresolv-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/librt-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libthread_db-le.abilist,
* sysdeps/unix/sysv/linux/powerpc/powerpc64/nptl/libutil-le.abilist:
New files.

10 years agoUpdate powerpc-fpu ULPs.
Adhemerval Zanella [Fri, 15 Nov 2013 21:10:10 +0000 (15:10 -0600)]
Update powerpc-fpu ULPs.

10 years agoPowerPC64 ELFv2 ABI 6/6: Bump ld.so soname version number
Ulrich Weigand [Fri, 15 Nov 2013 18:04:30 +0000 (12:04 -0600)]
PowerPC64 ELFv2 ABI 6/6: Bump ld.so soname version number

To avoid having a ELFv2 binary accidentally picking up an old ABI ld.so,
this patch bumps the soname to ld64.so.2.

In theory (or for testing purposes) this will also allow co-installing
ld.so versions for both ABIs on the same system.  Note that the kernel
will already be able to load executables of both ABIs.  However, there
is currently no plan to use that theoretical possibility in a any
supported distribution environment ...

Note that in order to check which ABI to use, we need to invoke the
compiler to check the _CALL_ELF macro; this is done in a new configure
check in sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac,
replacing the hard-coded value of default-abi in the Makefile.

10 years agoPowerPC64 ELFv2 ABI 5/6: LD_AUDIT interface changes
Ulrich Weigand [Fri, 15 Nov 2013 18:01:33 +0000 (12:01 -0600)]
PowerPC64 ELFv2 ABI 5/6: LD_AUDIT interface changes

The ELFv2 ABI changes the calling convention by passing and returning
structures in registers in more cases than the old ABI:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01145.html
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01147.html

For the most part, this does not affect glibc, since glibc assembler
files do not use structure parameters / return values.  However, one
place is affected: the LD_AUDIT interface provides a structure to
the audit routine that contains all registers holding function
argument and return values for the intercepted PLT call.

Since the new ABI now sometimes uses registers to return values
that were never used for this purpose in the old ABI, this structure
has to be extended.  To force audit routines to be modified for the
new ABI if necessary, the patch defines v2 variants of the la_ppc64
types and routines.

In addition, the patch contains two unrelated changes to the
PLT trampoline routines: it fixes a bug where FPR return values
were stored in the wrong place, and it removes the unnecessary
save/restore of CR.

10 years agoPowerPC64 ELFv2 ABI 4/6: Stack frame layout changes
Ulrich Weigand [Fri, 15 Nov 2013 17:59:39 +0000 (11:59 -0600)]
PowerPC64 ELFv2 ABI 4/6: Stack frame layout changes

This updates glibc for the changes in the ELFv2 relating to the
stack frame layout.  These are described in more detail here:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01149.html
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01146.html

Specifically, the "compiler and linker doublewords" were removed,
which has the effect that the save slot for the TOC register is
now at offset 24 rather than 40 to the stack pointer.

In addition, a function may now no longer necessarily assume that
its caller has set up a 64-byte register save area its use.

To address the first change, the patch goes through all assembler
files and replaces immediate offsets in instructions accessing the
ABI-defined stack slots by symbolic offsets.  Those already were
defined in ucontext_i.sym and used in some of the context routines,
but that doesn't really seem like the right place for those defines.

The patch instead defines those symbolic offsets in sysdeps.h,
in two variants for the old and new ABI, and uses them systematically
in all assembler files, not just the context routines.

The second change only affected a few assembler files that used
the save area to temporarily store some registers.  In those
cases where this happens within a leaf function, this patch
changes the code to store those registers to the "red zone"
below the stack pointer.  Otherwise, the functions already allocate
a stack frame, and the patch changes them to add extra space in
these frames as temporary space for the ELFv2 ABI.

10 years agoPowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization
Ulrich Weigand [Fri, 15 Nov 2013 17:56:31 +0000 (11:56 -0600)]
PowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization

This is a follow-on to the previous patch to support the ELFv2 ABI in the
dynamic loader, split off into its own patch since it is just an optional
optimization.

In the ELFv2 ABI, most functions define both a global and a local entry
point; the local entry requires r2 to be already set up by the caller
to point to the callee's TOC; while the global entry does not require
the caller to know about the callee's TOC, but it needs to set up r12
to the callee's entry point address.

Now, when setting up a PLT slot, the dynamic linker will usually need
to enter the target function's global entry point.  However, if the
linker can prove that the target function is in the same DSO as the
PLT slot itself, and the whole DSO only uses a single TOC (which the
linker will let ld.so know via a DT_PPC64_OPT entry), then it is
possible to actually enter the local entry point address into the
PLT slot, for a slight improvement in performance.

Note that this uncovered a problem on the first call via _dl_runtime_resolve,
because that routine neglected to restore the caller's TOC before calling
the target function for the first time, since it assumed that function
would always reload its own TOC anyway ...

10 years agoPowerPC64 ELFv2 ABI 2/6: Remove function descriptors
Ulrich Weigand [Fri, 15 Nov 2013 17:54:51 +0000 (11:54 -0600)]
PowerPC64 ELFv2 ABI 2/6: Remove function descriptors

This patch adds support for the ELFv2 ABI feature to remove function
descriptors.  See this GCC patch for in-depth discussion:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01141.html

This mostly involves two types of changes: updating assembler source
files to the new logic, and updating the dynamic loader.

After the refactoring in the previous patch, most of the assembler source
changes can be handled simply by providing ELFv2 versions of the
macros in sysdep.h.   One somewhat non-obvious change is in __GI__setjmp:
this used to "fall through" to the immediately following __setjmp ENTRY
point.  This is no longer safe in the ELFv2 since ENTRY defines both
a global and a local entry point, and you cannot simply fall through
to a global entry point as it requires r12 to be set up.

Also, makecontext needs to be updated to set up registers according to
the new ABI for calling into the context's start routine.

The dynamic linker changes mostly consist of removing special code
to handle function descriptors.  We also need to support the new PLT
and glink format used by the the ELFv2 linker, see:
https://sourceware.org/ml/binutils/2013-10/msg00376.html

In addition, the dynamic linker now verifies that the dynamic libraries
it loads match its own ABI.

The hack in VDSO_IFUNC_RET to "synthesize" a function descriptor
for vDSO routines is also no longer necessary for ELFv2.

10 years agoPowerPC64 ELFv2 ABI 1/6: Code refactoring
Ulrich Weigand [Fri, 15 Nov 2013 17:52:37 +0000 (11:52 -0600)]
PowerPC64 ELFv2 ABI 1/6: Code refactoring

This is the first patch to support the new ELFv2 ABI in glibc.

As preparation, this patch simply refactors some of the powerpc64 assembler
code to move all code related to creating function descriptors (.opd section)
or using function descriptors (function pointer call) into a central place
in sysdep.h.

Note that most locations creating .opd entries were already using macros
in sysdep.h, this patch simply extends this to the remaining places.

No relevant change in generated code expected.

10 years agoPowerPC64: Report overflow on @h and @ha relocations
Alan Modra [Fri, 15 Nov 2013 17:51:18 +0000 (11:51 -0600)]
PowerPC64: Report overflow on @h and @ha relocations

This patch updates glibc in accordance with the binutils patch checked
in here:
https://sourceware.org/ml/binutils/2013-10/msg00372.html

This changes the various R_PPC64_..._HI and _HA relocations to report
32-bit overflows.  The motivation is that existing uses of @h / @ha
are to build up 32-bit offsets (for the "medium model" TOC access
that GCC now defaults to), and we'd really like to see failures at
link / load time rather than silent truncations.

For those rare cases where a modifier is needed to build up a 64-bit
constant, new relocations _HIGH / _HIGHA are supported.

The patch also fixes a bug in overflow checking for the R_PPC64_ADDR30
and R_PPC64_ADDR32 relocations.

10 years agoPowerPC64: Fix incorrect CFI in *context routines
Ulrich Weigand [Fri, 15 Nov 2013 17:49:21 +0000 (11:49 -0600)]
PowerPC64: Fix incorrect CFI in *context routines

The context established by "makecontext" has a link register pointing
back to an error path within the makecontext routine.  This is currently
covered by the CFI FDE for makecontext itself, which is simply wrong
for the stack frame *inside* the context.  When trying to unwind (e.g.
doing a backtrace) in a routine inside a context created by makecontext,
this can lead to uninitialized stack slots being accessed, causing the
unwinder to crash in the worst case.

Similarly, during parts of the "setcontext" routine, when the stack
pointer has already been switched to point to the new context, the
address range is still covered by the CFI FDE for setcontext.  When
trying to unwind in that situation (e.g. backtrace from an async
signal handler for profiling), it is again possible that the unwinder
crashes.

Theses are all problems in existing code, but the changes in stack
frame layout appear to make the "worst case" much more likely in
the ELFv2 ABI context.  This causes regressions e.g. in the libgo
testsuite on ELFv2.

This patch fixes this by ending the makecontext/setcontext FDEs
before those problematic parts of the assembler, similar to what
is already done on other platforms.   This fixes the libgo
regression on ELFv2.

10 years agoPowerPC64: Add __private_ss field to TCB header
Ulrich Weigand [Fri, 15 Nov 2013 17:47:44 +0000 (11:47 -0600)]
PowerPC64: Add __private_ss field to TCB header

the TCB header on Intel contains a field __private_ss that is used
to efficiently implement the -fsplit-stack GCC feature.

In order to prepare for a possible future implementation of that
feature on powerpc64, we'd like to reserve a similar field in
the TCB header as well.  (It would be good if this went in with
or before the ELFv2 patches to ensure that this field will be
available always in the ELFv2 environment.)

The field needs to be added at the front of tcbhead_t structure
to avoid changing the ABI; see the recent discussion when adding
the EBB fields.

10 years agoPowerPC: Fix vDSO missing ODP entries
Adhemerval Zanella [Thu, 7 Nov 2013 11:34:22 +0000 (05:34 -0600)]
PowerPC: Fix vDSO missing ODP entries

This patch fixes the vDSO symbol used directed in IFUNC resolver where
they do not have an associated ODP entry leading to undefined behavior
in some cases. It adds an artificial OPD static entry to such cases
and set its TOC to non 0 to avoid triggering lazy resolutions.

10 years agoPowerPC: Fix POINTER_CHK_GUARD thread register for PPC64
Adhemerval Zanella [Wed, 25 Sep 2013 18:43:04 +0000 (13:43 -0500)]
PowerPC: Fix POINTER_CHK_GUARD thread register for PPC64

10 years agoAdd CVE-2013-4332 to NEWS.
Will Newton [Fri, 13 Sep 2013 08:26:02 +0000 (09:26 +0100)]
Add CVE-2013-4332 to NEWS.

10 years agomalloc: Check for integer overflow in memalign.
Will Newton [Fri, 16 Aug 2013 11:54:29 +0000 (12:54 +0100)]
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.

10 years agomalloc: Check for integer overflow in valloc.
Will Newton [Fri, 16 Aug 2013 10:59:37 +0000 (11:59 +0100)]
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.

10 years agomalloc: Check for integer overflow in pvalloc.
Will Newton [Mon, 12 Aug 2013 14:08:02 +0000 (15:08 +0100)]
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.

10 years agoBZ #15754: CVE-2013-4788
Carlos O'Donell [Mon, 23 Sep 2013 04:52:09 +0000 (00:52 -0400)]
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.

10 years agoCheck for integer overflow in cache size computation in strcoll
Siddhesh Poyarekar [Mon, 23 Sep 2013 05:54:30 +0000 (11:24 +0530)]
Check for integer overflow in cache size computation in strcoll

strcoll is implemented using a cache for indices and weights of
collation sequences in the strings so that subsequent passes do not
have to search through collation data again.  For very large string
inputs, the cache size computation could overflow.  In such a case,
use the fallback function that does not cache indices and weights of
collation sequences.

Fixes CVE-2012-4412.

10 years agoFall back to non-cached sequence traversal and comparison on malloc fail
Siddhesh Poyarekar [Mon, 23 Sep 2013 05:50:02 +0000 (11:20 +0530)]
Fall back to non-cached sequence traversal and comparison on malloc fail

strcoll currently falls back to alloca if malloc fails, resulting in a
possible stack overflow.  This patch implements sequence traversal and
comparison without caching indices and rules.

Fixes CVE-2012-4424.

10 years agoSimplify strcoll implementation
Siddhesh Poyarekar [Tue, 20 Aug 2013 03:10:05 +0000 (08:40 +0530)]
Simplify strcoll implementation

Break up strcoll into simpler functions so that the logic is easier to
follow and maintain.

10 years agoFix parsing of 0e+0 as float
Andreas Schwab [Thu, 31 Oct 2013 11:51:03 +0000 (12:51 +0100)]
Fix parsing of 0e+0 as float

10 years agoPowerPC: strcpy/stpcpy optimization for PPC64/POWER7
Adhemerval Zanella [Thu, 26 Sep 2013 14:29:19 +0000 (09:29 -0500)]
PowerPC: strcpy/stpcpy optimization for PPC64/POWER7

This patch intends to unify both strcpy and stpcpy implementationsi
for PPC64 and PPC64/POWER7. The idead default powerpc64 implementation
is to provide both doubleword and word aligned memory access.

For PPC64/POWER7 is also provide doubleword and word memory access,
remove the branch hints, use the cmpb instruction for compare
doubleword/words, and add an optimization for inputs of same alignment.

10 years agoFix stack overflow due to large AF_INET6 requests
Siddhesh Poyarekar [Fri, 25 Oct 2013 04:52:12 +0000 (10:22 +0530)]
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.

10 years agoAvoid ordered comparisons of NaNs in ldbl-128ibm acosl and asinl.
Joseph Myers [Thu, 10 Oct 2013 19:11:30 +0000 (19:11 +0000)]
Avoid ordered comparisons of NaNs in ldbl-128ibm acosl and asinl.

10 years agoUse stdint.h types in union unaligned.
Alan Modra [Fri, 4 Oct 2013 03:18:51 +0000 (12:48 +0930)]
Use stdint.h types in union unaligned.

* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
Use stdint types in rather than __attribute__((mode())).
* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.

10 years agoCorrect little-endian relocation of UADDR64,32,16.
Alan Modra [Thu, 3 Oct 2013 04:21:52 +0000 (13:51 +0930)]
Correct little-endian relocation of UADDR64,32,16.

* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
Correct handling of unaligned relocs for little-endian.
* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.

10 years agoPowerPC LE configury
Alan Modra [Thu, 3 Oct 2013 04:33:03 +0000 (14:03 +0930)]
PowerPC LE configury
http://sourceware.org/ml/libc-alpha/2013-08/msg00096.html

This adds the basic configury bits for powerpc64le and powerpcle.

* configure.in: Map powerpc64le and powerpcle to base_machine/machine.
* configure: Regenerate.
* nptl/shlib-versions: Powerpc*le starts at 2.18.
* shlib-versions: Likewise.

10 years agostring/tester memrchr test
Alan Modra [Sat, 17 Aug 2013 09:08:26 +0000 (18:38 +0930)]
string/tester memrchr test
http://sourceware.org/ml/libc-alpha/2013-08/msg00095.html

I found this useful at one stage when I was seeing a huge number of
memrchr failures all of test number 10.

* string/tester.c (test_memrchr): Increment reported test cycle.

10 years agostring/test-memcpy error reporting
Alan Modra [Sat, 17 Aug 2013 09:07:58 +0000 (18:37 +0930)]
string/test-memcpy error reporting
http://sourceware.org/ml/libc-alpha/2013-08/msg00094.html

Using plain %s here runs the risk of segfaulting when displaying the
string.  src and dst aren't zero terminated strings.

* string/test-memcpy.c (do_one_test): When reporting errors, print
string address and don't overrun end of string.

10 years agoPowerPC LE memchr and memrchr
Alan Modra [Sat, 17 Aug 2013 09:18:36 +0000 (18:48 +0930)]
PowerPC LE memchr and memrchr
http://sourceware.org/ml/libc-alpha/2013-08/msg00105.html

Like strnlen, memchr and memrchr had a number of defects fixed by this
patch as well as adding little-endian support.  The first one I
noticed was that the entry to the main loop needlessly checked for
"are we done yet?" when we know the size is large enough that we can't
be done.  The second defect I noticed was that the main loop count was
wrong, which in turn meant that the small loop needed to handle an
extra word.  Thirdly, there is nothing to say that the string can't
wrap around zero, except of course that we'd normally hit a segfault
on trying to read from address zero.  Fixing that simplified a number
of places:

- /* Are we done already?  */
- addi    r9,r8,8
- cmpld r9,r7
- bge L(null)

becomes

+ cmpld r8,r7
+ beqlr

However, the exit gets an extra test because I test for being on the
last word then if so whether the byte offset is less than the end.
Overall, the change is a win.

Lastly, memrchr used the wrong cache hint.

* sysdeps/powerpc/powerpc64/power7/memchr.S: Replace rlwimi with
insrdi.  Make better use of reg selection to speed exit slightly.
Schedule entry path a little better.  Remove useless "are we done"
checks on entry to main loop.  Handle wrapping around zero address.
Correct main loop count.  Handle single left-over word from main
loop inline rather than by using loop_small.  Remove extra word
case in loop_small caused by wrong loop count.  Add little-endian
support.
* sysdeps/powerpc/powerpc32/power7/memchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.  Use proper
cache hint.
* sysdeps/powerpc/powerpc32/power7/memrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Add little-endian
support.  Avoid rlwimi.
* sysdeps/powerpc/powerpc32/power7/rawmemchr.S: Likewise.

10 years agoPowerPC LE memset
Alan Modra [Sat, 17 Aug 2013 09:17:59 +0000 (18:47 +0930)]
PowerPC LE memset
http://sourceware.org/ml/libc-alpha/2013-08/msg00104.html

One of the things I noticed when looking at power7 timing is that rlwimi
is cracked and the two resulting insns have a register dependency.
That makes it a little slower than the equivalent rldimi.

* sysdeps/powerpc/powerpc64/memset.S: Replace rlwimi with
        insrdi.  Formatting.
* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/memset.S: Likewise.
* sysdeps/powerpc/powerpc32/power6/memset.S: Likewise.
* sysdeps/powerpc/powerpc32/power7/memset.S: Likewise.

10 years agoPowerPC LE memcpy
Alan Modra [Sat, 17 Aug 2013 09:17:22 +0000 (18:47 +0930)]
PowerPC LE memcpy
http://sourceware.org/ml/libc-alpha/2013-08/msg00103.html

LIttle-endian support for memcpy.  I spent some time cleaning up the
64-bit power7 memcpy, in order to avoid the extra alignment traps
power7 takes for little-endian.  It probably would have been better
to copy the linux kernel version of memcpy.

* sysdeps/powerpc/powerpc32/power4/memcpy.S: Add little endian support.
* sysdeps/powerpc/powerpc32/power6/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc32/power7/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc32/power7/mempcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.  Make better
use of regs.  Use power7 mtocrf.  Tidy function tails.

10 years agoPowerPC LE memcmp
Alan Modra [Sat, 17 Aug 2013 09:16:47 +0000 (18:46 +0930)]
PowerPC LE memcmp
http://sourceware.org/ml/libc-alpha/2013-08/msg00102.html

This is a rather large patch due to formatting and renaming.  The
formatting changes were to make it possible to compare power7 and
power4 versions of memcmp.  Using different register defines came
about while I was wrestling with the code, trying to find spare
registers at one stage.  I found it much simpler if we refer to a reg
by the same name throughout a function, so it's better if short-term
multiple use regs like rTMP are referred to using their register
number.  I made the cr field usage changes when attempting to reload
rWORDn regs in the exit path to byte swap before comparing when
little-endian.  That proved a bad idea due to the pipelining involved
in the main loop;  Offsets to reload the regs were different first
time around the loop..  Anyway, I left the cr field usage changes in
place for consistency.

Aside from these more-or-less cosmetic changes, I fixed a number of
places where an early exit path restores regs unnecessarily, removed
some dead code, and optimised one or two exits.

* sysdeps/powerpc/powerpc64/power7/memcmp.S: Add little-endian support.
Formatting.  Consistently use rXXX register defines or rN defines.
Use early exit labels that avoid restoring unused non-volatile regs.
Make cr field use more consistent with rWORDn compares.  Rename
regs used as shift registers for unaligned loop, using rN defines
for short lifetime/multiple use regs.
* sysdeps/powerpc/powerpc64/power4/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc32/power7/memcmp.S: Likewise.  Exit with
addi 1,1,64 to pop stack frame.  Simplify return value code.
* sysdeps/powerpc/powerpc32/power4/memcmp.S: Likewise.

10 years agoPowerPC LE strchr
Alan Modra [Sat, 17 Aug 2013 09:16:05 +0000 (18:46 +0930)]
PowerPC LE strchr
http://sourceware.org/ml/libc-alpha/2013-08/msg00101.html

Adds little-endian support to optimised strchr assembly.  I've also
tweaked the big-endian code a little.  In power7/strchr.S there's a
check in the tail of the function that we didn't match 0 before
finding a c match, done by comparing leading zero counts.  It's just
as valid, and quicker, to compare the raw output from cmpb.

Another little tweak is to use rldimi/insrdi in place of rlwimi for
the power7 strchr functions.  Since rlwimi is cracked, it is a few
cycles slower.  rldimi can be used on the 32-bit power7 functions
too.

* sysdeps/powerpc/powerpc64/power7/strchr.S (strchr): Add little-endian
support.  Correct typos, formatting.  Optimize tail.  Use insrdi
rather than rlwimi.
* sysdeps/powerpc/powerpc32/power7/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strchrnul.S (__strchrnul): Add
little-endian support.  Correct typos.
* sysdeps/powerpc/powerpc32/power7/strchrnul.S: Likewise.  Use insrdi
rather than rlwimi.
* sysdeps/powerpc/powerpc64/strchr.S (rTMP4, rTMP5): Define.  Use
in loop and entry code to keep "and." results.
(strchr): Add little-endian support.  Comment.  Move cntlzd
earlier in tail.
* sysdeps/powerpc/powerpc32/strchr.S: Likewise.

10 years agoPowerPC LE strcpy
Alan Modra [Sat, 17 Aug 2013 09:15:31 +0000 (18:45 +0930)]
PowerPC LE strcpy
http://sourceware.org/ml/libc-alpha/2013-08/msg00100.html

The strcpy changes for little-endian are quite straight-forward, just
a matter of rotating the last word differently.

I'll note that the powerpc64 version of stpcpy is just begging to be
converted to use 64-bit loads and stores..

* sysdeps/powerpc/powerpc64/strcpy.S: Add little-endian support:
* sysdeps/powerpc/powerpc32/strcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/stpcpy.S: Likewise.
* sysdeps/powerpc/powerpc32/stpcpy.S: Likewise.

10 years agoPowerPC LE strcmp and strncmp
Alan Modra [Sat, 17 Aug 2013 09:11:17 +0000 (18:41 +0930)]
PowerPC LE strcmp and strncmp
http://sourceware.org/ml/libc-alpha/2013-08/msg00099.html

More little-endian support.  I leave the main strcmp loops unchanged,
(well, except for renumbering rTMP to something other than r0 since
it's needed in an addi insn) and modify the tail for little-endian.

I noticed some of the big-endian tail code was a little untidy so have
cleaned that up too.

* sysdeps/powerpc/powerpc64/strcmp.S (rTMP2): Define as r0.
(rTMP): Define as r11.
(strcmp): Add little-endian support.  Optimise tail.
* sysdeps/powerpc/powerpc32/strcmp.S: Similarly.
* sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc32/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc32/power7/strncmp.S: Likewise.

10 years agoPowerPC LE strnlen
Alan Modra [Sat, 17 Aug 2013 09:10:48 +0000 (18:40 +0930)]
PowerPC LE strnlen
http://sourceware.org/ml/libc-alpha/2013-08/msg00098.html

The existing strnlen code has a number of defects, so this patch is more
than just adding little-endian support.  The changes here are similar to
those for memchr.

* sysdeps/powerpc/powerpc64/power7/strnlen.S (strnlen): Add
little-endian support.  Remove unnecessary "are we done" tests.
Handle "s" wrapping around zero and extremely large "size".
Correct main loop count.  Handle single left-over word from main
loop inline rather than by using small_loop.  Correct comments.
Delete "zero" tail, use "end_max" instead.
* sysdeps/powerpc/powerpc32/power7/strnlen.S: Likewise.

10 years agoPowerPC LE strlen
Alan Modra [Sat, 17 Aug 2013 09:10:11 +0000 (18:40 +0930)]
PowerPC LE strlen
http://sourceware.org/ml/libc-alpha/2013-08/msg00097.html

This is the first of nine patches adding little-endian support to the
existing optimised string and memory functions.  I did spend some
time with a power7 simulator looking at cycle by cycle behaviour for
memchr, but most of these patches have not been run on cpu simulators
to check that we are going as fast as possible.  I'm sure PowerPC can
do better.  However, the little-endian support mostly leaves main
loops unchanged, so I'm banking on previous authors having done a
good job on big-endian..  As with most code you stare at long enough,
I found some improvements for big-endian too.

Little-endian support for strlen.  Like most of the string functions,
I leave the main word or multiple-word loops substantially unchanged,
just needing to modify the tail.

Removing the branch in the power7 functions is just a tidy.  .align
produces a branch anyway.  Modifying regs in the non-power7 functions
is to suit the new little-endian tail.

* sysdeps/powerpc/powerpc64/power7/strlen.S (strlen): Add little-endian
support.  Don't branch over align.
* sysdeps/powerpc/powerpc32/power7/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/strlen.S (strlen): Add little-endian support.
Rearrange tmp reg use to suit.  Comment.
* sysdeps/powerpc/powerpc32/strlen.S: Likewise.

This page took 0.092793 seconds and 5 git commands to generate.