]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 years ago__libc_dynarray_emplace_enlarge: Add missing else
Florian Weimer [Wed, 6 Sep 2017 09:25:14 +0000 (11:25 +0200)] 
__libc_dynarray_emplace_enlarge: Add missing else

Before, arrays of small elements received a starting allocation size of
8, not 16.

(cherry picked from commit ab5ac271e6210fa0af11cf3ca525ce573bc47c48)

7 years agodynarray: Set errno on overflow-induced allocation failure
Florian Weimer [Wed, 30 Aug 2017 18:10:56 +0000 (20:10 +0200)] 
dynarray: Set errno on overflow-induced allocation failure

This allows the caller to return directly on such an error, with an
appropriate errno value.

(cherry picked from commit 5898f4548efdcd7c0fd437a74eeb80facc51a117)

7 years agodynarray: Implement begin/end functions in the spirit of C++
Florian Weimer [Tue, 13 Jun 2017 15:03:56 +0000 (17:03 +0200)] 
dynarray: Implement begin/end functions in the spirit of C++

(cherry picked from commit f8bf87face3304f216bcd838081fa33bb4976ac6)

7 years agoAdd internal facility for dynamic array handling
Florian Weimer [Fri, 2 Jun 2017 09:59:28 +0000 (11:59 +0200)] 
Add internal facility for dynamic array handling

This is intended as a type-safe alternative to obstacks and
hand-written realloc constructs.  The implementation avoids
writing function pointers to the heap.

(cherry picked from commit 91b6eb1140eda6bab324821ee3785e5d0ca155b8)

7 years agoAdd check_mul_overflow_size_t
Florian Weimer [Thu, 4 Jan 2018 11:51:48 +0000 (12:51 +0100)] 
Add check_mul_overflow_size_t

Backported from commit 2e0bbbfbf95fc9e22692e93658a6fbdd2d4554da.

7 years agoAdd <libc-pointer-arith.h> to help with backporting
Florian Weimer [Thu, 4 Jan 2018 11:45:41 +0000 (12:45 +0100)] 
Add <libc-pointer-arith.h> to help with backporting

7 years agogetaddrinfo: Fix error handling in gethosts [BZ #21915] [BZ #21922]
Florian Weimer [Thu, 4 Jan 2018 11:32:36 +0000 (12:32 +0100)] 
getaddrinfo: Fix error handling in gethosts [BZ #21915] [BZ #21922]

The old code uses errno as the primary indicator for success or
failure.  This is wrong because errno is only set for specific
combinations of the status return value and the h_errno variable.

(cherry picked from commit f4a6be2582b8dfe8adfa68da3dd8decf566b3983)

7 years agogetaddrinfo: Return EAI_NODATA if gethostbyname2_r reports NO_DATA [BZ #21922]
Florian Weimer [Mon, 4 Sep 2017 09:25:34 +0000 (11:25 +0200)] 
getaddrinfo: Return EAI_NODATA if gethostbyname2_r reports NO_DATA [BZ #21922]

(cherry picked from commit 5f8340f583fe3d4f5734bd2371c5a45ecff2db0d)

7 years agogetaddrinfo: In gaih_inet, use h_errno for certain status values only
Florian Weimer [Fri, 1 Sep 2017 06:57:52 +0000 (08:57 +0200)] 
getaddrinfo: In gaih_inet, use h_errno for certain status values only

h_errno is not set for NSS_STATUS_SUCCESS, so its value might not be
accurate at this point.

(cherry picked from commit a2881ef01450295782b065f2f850f340d5c12c14)

7 years agogetaddrinfo: Properly set errno for NSS function lookup failure
Florian Weimer [Fri, 1 Sep 2017 06:57:28 +0000 (08:57 +0200)] 
getaddrinfo: Properly set errno for NSS function lookup failure

(cherry picked from commit ad816a5e00ce891a2cea8187638fa0e00f83aaf6)

7 years agogetaddrinfo: Use &h_errno has the h_errno pointer
Florian Weimer [Fri, 1 Sep 2017 06:57:07 +0000 (08:57 +0200)] 
getaddrinfo: Use &h_errno has the h_errno pointer

This simplifies the code because it is not necessary to propagate the
temporary h_errno value to the thread-local variable.  It also increases
compatibility with NSS modules which update only one of the two places.

(cherry picked from commit 53250a21b81474ef4e78090a4a9a63d8471e1091)

7 years agogetaddrinfo: Use &errno has the errno pointer
Florian Weimer [Fri, 1 Sep 2017 06:56:46 +0000 (08:56 +0200)] 
getaddrinfo: Use &errno has the errno pointer

Similar code in nss/getXXbyYY_r.c is already using &errno as the
argument.

(cherry picked from commit 924b121c5978689001ae28cf1c8497371dad4f71)

7 years agogetaddrinfo: Remove unreachable return statement from gaih_inet
Florian Weimer [Tue, 8 Aug 2017 16:48:05 +0000 (18:48 +0200)] 
getaddrinfo: Remove unreachable return statement from gaih_inet

(cherry picked from commit 0df595b23a829c9169ec418a19eef9006b4ae801)

7 years agoresolv/tst-resolv-basic: Add test cases for bug 21295
Florian Weimer [Sat, 24 Jun 2017 14:51:31 +0000 (16:51 +0200)] 
resolv/tst-resolv-basic: Add test cases for bug 21295

(cherry picked from commit 513a71a420e74270a6a9702ec916e807be51350a)

7 years agogetaddrinfo: Merge IPv6 addresses and IPv4 addresses [BZ #21295]
Dmitry Bilunov [Thu, 4 Jan 2018 10:33:53 +0000 (11:33 +0100)] 
getaddrinfo: Merge IPv6 addresses and IPv4 addresses [BZ #21295]

(cherry picked from commit 5cf88a83f27b0cd2d5a83511930e40d716c939eb)

7 years agosupport_format_addrinfo: Fix flags and canonname formatting
Florian Weimer [Thu, 11 May 2017 09:32:16 +0000 (11:32 +0200)] 
support_format_addrinfo: Fix flags and canonname formatting

The address family splitting via format_ai_family made unpredictable
the place where the canonname field was printed.  This commit adjusts
the implementation so that the ai_flags is checked for consistency
across the list, and ai_canonname must only be present on the first
list element.

Tests for AI_CANONNAME are added to resolv/tst-resolv-basic.

(cherry picked from commit 8ec69bb7ecf3ca5edde5b7d9d7d5d3a5f8b6c405)

7 years agoresolv: Support an exactly sized buffer in ns_name_pack [BZ #21359]
Florian Weimer [Thu, 4 Jan 2018 10:45:20 +0000 (11:45 +0100)] 
resolv: Support an exactly sized buffer in ns_name_pack [BZ #21359]

This bug did not affect name resolution because those functions
indirectly call ns_name_pack with a buffer which is always larger
than the generated query packet, even in the case of the
longest-possible domain name.

(cherry picked from commit c803cb9b24c6cea15698768e4301e963b98e742c)

7 years agoresolv: Add test coverage for ns_name_unpack, ns_name_ntop
Florian Weimer [Tue, 4 Apr 2017 12:09:56 +0000 (14:09 +0200)] 
resolv: Add test coverage for ns_name_unpack, ns_name_ntop

(cherry picked from commit 07d6f1a3ca990e0e4f93b010605d4d87a3abdf24)

7 years agogetaddrinfo: Avoid stack copy of IPv6 address
Florian Weimer [Wed, 21 Jun 2017 11:35:37 +0000 (13:35 +0200)] 
getaddrinfo: Avoid stack copy of IPv6 address

(cherry picked from commit 76b8266f990a2912f42d1b7050840e8c7f14f2c2)

7 years ago__inet_pton_length: Implement new internal helper function
Florian Weimer [Wed, 21 Jun 2017 11:09:08 +0000 (13:09 +0200)] 
__inet_pton_length: Implement new internal helper function

(cherry picked from commit 60149b28590be28051f99d0a343d7fbe002f2a8c)

7 years agoinet_pton: Reformat in GNU style
Florian Weimer [Thu, 11 May 2017 12:48:51 +0000 (14:48 +0200)] 
inet_pton: Reformat in GNU style

Generated machine code is identical on x86-64.

(cherry picked from commit d53b8652880ba42913f66e7eee0567ce4cfe7791)

7 years agogetaddrinfo: Eliminate another strdup call
Florian Weimer [Sat, 3 Jun 2017 06:37:13 +0000 (08:37 +0200)] 
getaddrinfo: Eliminate another strdup call

(cherry picked from commit 363911ce1313a246b7d33f0983a09e7ab2525b3a)

7 years agogetaddrinfo: Fix localplt failure involving strdup
Florian Weimer [Fri, 2 Jun 2017 14:35:13 +0000 (16:35 +0200)] 
getaddrinfo: Fix localplt failure involving strdup

(cherry picked from commit 6257fcfd58479f6b7ae0fdde045b9ff144d543da)

7 years agogetaddrinfo: Always allocate canonical name on the heap
Florian Weimer [Fri, 2 Jun 2017 12:54:56 +0000 (14:54 +0200)] 
getaddrinfo: Always allocate canonical name on the heap

A further simplification could eliminate the canon variable in
gaih_inet and replace it with canonbuf.  However, canonbuf is
used as a flag in the nscd code, which makes this somewhat
non-straightforward.

(cherry picked from commit 673cb072a4710bd4bf6029a062d2867cca929c43)

7 years agogetaddrinfo: Unconditionally use malloc for address list
Florian Weimer [Thu, 11 May 2017 08:01:49 +0000 (10:01 +0200)] 
getaddrinfo: Unconditionally use malloc for address list

getaddrinfo has to call malloc eventually anyway, so the complexity
of avoiding malloc calls is not worth potential savings.

(cherry picked from commit 46ce8881ade788db56079622f47f648d4aaa003b)

7 years agox86-64: Regenerate libm-test-ulps for AVX512 mathvec tests
H.J. Lu [Wed, 23 Aug 2017 16:11:41 +0000 (09:11 -0700)] 
x86-64: Regenerate libm-test-ulps for AVX512 mathvec tests

Update libm-test-ulps for AVX512 mathvec tests by running
“make regen-ulps” on Intel Xeon processor with AVX512.

* sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.

(cherry picked from commit fcaaca412fecb6097c902acd1260f585819b8b7e)

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 agoelf: do not substitute dst in $LD_LIBRARY_PATH twice [BZ #22627]
Dmitry V. Levin [Sun, 17 Dec 2017 23:49:46 +0000 (23:49 +0000)] 
elf: do not substitute dst in $LD_LIBRARY_PATH twice [BZ #22627]

Starting with commit
glibc-2.18.90-470-g2a939a7e6d81f109d49306bc2e10b4ac9ceed8f9 that
introduced substitution of dynamic string tokens in fillin_rpath,
_dl_init_paths invokes _dl_dst_substitute for $LD_LIBRARY_PATH twice:
the first time it's called directly, the second time the result
is passed on to fillin_rpath which calls expand_dynamic_string_token
which in turn calls _dl_dst_substitute, leading to the following
behaviour:

$ mkdir -p /tmp/'$ORIGIN' && cd /tmp/'$ORIGIN' &&
  echo 'int main(){}' |gcc -xc - &&
  strace -qq -E LD_LIBRARY_PATH='$ORIGIN' -e /open ./a.out
open("/tmp//tmp/$ORIGIN/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/tmp//tmp/$ORIGIN/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/tmp//tmp/$ORIGIN/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/tmp//tmp/$ORIGIN/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

Fix this by removing the direct _dl_dst_substitute invocation.

* elf/dl-load.c (_dl_init_paths): Remove _dl_dst_substitute preparatory
code and invocation.

(cherry picked from commit bb195224acc14724e9fc2dbaa8d0b20b72ace79b)

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: 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 agoNEWS: merge two sections about security related changes in 2.25.1
Dmitry V. Levin [Fri, 15 Dec 2017 00:30:45 +0000 (00:30 +0000)] 
NEWS: merge two sections about security related changes in 2.25.1

Commit glibc-2.25-70-g717743bb07471f95bef6ea63d9b12848ad91aaf6
introduced a second "Security related changes" section for 2.25.1.
Merge them back into a single section.

7 years agoia64: Add ipc_priv.h header to set __IPC_64 to zero
James Clarke [Tue, 12 Dec 2017 14:17:10 +0000 (12:17 -0200)] 
ia64: Add ipc_priv.h header to set __IPC_64 to zero

When running strace, IPC_64 was set in the command, but ia64 is
an architecture where CONFIG_ARCH_WANT_IPC_PARSE_VERSION *isn't* set
in the kernel, so ipc_parse_version just returns IPC_64 without
clearing the IPC_64 bit in the command.

* sysdeps/unix/sysv/linux/ia64/ipc_priv.h: New file defining
__IPC_64 to 0 to avoid IPC_64 being set.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
(cherry picked from commit 89bd8016b30e504829bea48c4cd556769abfcf3a)

7 years agoUpdate NEWS to add CVE-2017-15804 entry
Aurelien Jarno [Fri, 1 Dec 2017 20:53:51 +0000 (21:53 +0100)] 
Update NEWS to add CVE-2017-15804 entry

(cherry picked from commit 15e84c63c05e0652047ba5e738c54d79d62ba74b)

7 years agoposix/tst-glob-tilde.c: Add test for bug 22332
Florian Weimer [Thu, 2 Nov 2017 10:06:45 +0000 (11:06 +0100)] 
posix/tst-glob-tilde.c: Add test for bug 22332

(cherry picked from commit 2fac6a6cd50c22ac28c97d0864306594807ade3e)

7 years agoglob: Fix buffer overflow during GLOB_TILDE unescaping [BZ #22332]
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 agoUpdate NEWS and ChangeLog for CVE-2017-15671
Florian Weimer [Sun, 22 Oct 2017 07:29:52 +0000 (09:29 +0200)] 
Update NEWS and ChangeLog for CVE-2017-15671

(cherry picked from commit 914c9994d27b80bc3b71c483e801a4f04e269ba6)

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 agoi386: Hide __old_glob64 [BZ #18822]
H.J. Lu [Sun, 20 Aug 2017 17:46:47 +0000 (10:46 -0700)] 
i386: Hide __old_glob64 [BZ #18822]

Hide internal __old_glob64 function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

[BZ #18822]
* sysdeps/unix/sysv/linux/i386/glob64.c (__old_glob64): Add
libc_hidden_proto and libc_hidden_def.

(cherry picked from commit 2585d7b839559e665d5723734862fbe62264b25d)

7 years agoFix missing posix_fadvise64 mips64 static build (BZ #21232)
Adhemerval Zanella [Tue, 14 Mar 2017 19:42:08 +0000 (16:42 -0300)] 
Fix missing posix_fadvise64 mips64 static build (BZ #21232)

This patch fixes the missing posix_fadvise64 symbol for static build
required for _FILE_OFFSET_BITS=64 on mips64 build.

Checked on a mips64-linux-gnu build with run-built-tests=no.

[BZ #21232]
* sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fadvise64.c: Add
posix_fadvise64 weak_alias for static build.

(cherry picked from commit ed7d6072f25f75b808b40c206371361f1313f342)

7 years agoposix: Do not use WNOHANG in waitpid call for Linux posix_spawn
Adhemerval Zanella [Sat, 21 Oct 2017 13:33:27 +0000 (11:33 -0200)] 
posix: Do not use WNOHANG in waitpid call for Linux posix_spawn

As shown in some buildbot issues on aarch64 and powerpc, calling
clone (VFORK) and waitpid (WNOHANG) does not guarantee the child
is ready to be collected.  This patch changes the call back to 0
as before fe05e1cb6d64 fix.

This change can lead to the scenario 4.3 described in the commit,
where the waitpid call can hang undefinitely on the call.  However
this is also a very unlikely and also undefinied situation where
both the caller is trying to terminate a pid before posix_spawn
returns and the race pid reuse is triggered.  I don't see how to
correct handle this specific situation within posix_spawn.

Checked on x86_64-linux-gnu, aarch64-linux-gnu and
powerpc64-linux-gnu.

* sysdeps/unix/sysv/linux/spawni.c (__spawnix): Use 0 instead of
WNOHANG in waitpid call.

(cherry picked from commit aa95a2414e4f664ca740ad5f4a72d9145abbd426)

7 years agoposix: Fix improper assert in Linux posix_spawn (BZ#22273)
Adhemerval Zanella [Thu, 12 Oct 2017 18:20:57 +0000 (15:20 -0300)] 
posix: Fix improper assert in Linux posix_spawn (BZ#22273)

As noted by Florian Weimer, current Linux posix_spawn implementation
can trigger an assert if the auxiliary process is terminated before
actually setting the err member:

    340   /* Child must set args.err to something non-negative - we rely on
    341      the parent and child sharing VM.  */
    342   args.err = -1;
    [...]
    362   new_pid = CLONE (__spawni_child, STACK (stack, stack_size), stack_size,
    363                    CLONE_VM | CLONE_VFORK | SIGCHLD, &args);
    364
    365   if (new_pid > 0)
    366     {
    367       ec = args.err;
    368       assert (ec >= 0);

Another possible issue is killing the child between setting the err and
actually calling execve.  In this case the process will not ran, but
posix_spawn also will not report any error:

    269
    270   args->err = 0;
    271   args->exec (args->file, args->argv, args->envp);

As suggested by Andreas Schwab, this patch removes the faulty assert
and also handles any signal that happens before fork and execve as the
spawn was successful (and thus relaying the handling to the caller to
figure this out).  Different than Florian, I can not see why using
atomics to set err would help here, essentially the code runs
sequentially (due CLONE_VFORK) and I think it would not be legal the
compiler evaluate ec without checking for new_pid result (thus there
is no need to compiler barrier).

Summarizing the possible scenarios on posix_spawn execution, we
have:

  1. For default case with a success execution, args.err will be 0, pid
     will not be collected and it will be reported to caller.

  2. For default failure case, args.err will be positive and the it will
     be collected by the waitpid.  An error will be reported to the
     caller.

  3. For the unlikely case where the process was terminated and not
     collected by a caller signal handler, it will be reported as succeful
     execution and not be collected by posix_spawn (since args.err will
     be 0). The caller will need to actually handle this case.

  4. For the unlikely case where the process was terminated and collected
     by caller we have 3 other possible scenarios:

     4.1. The auxiliary process was terminated with args.err equal to 0:
  it will handled as 1. (so it does not matter if we hit the pid
          reuse race since we won't possible collect an unexpected
          process).

     4.2. The auxiliary process was terminated after execve (due a failure
          in calling it) and before setting args.err to -1: it will also
          be handle as 1. but with the issue of not be able to report the
          caller a possible execve failures.

     4.3. The auxiliary process was terminated after args.err is set to -1:
          this is the case where it will be possible to hit the pid reuse
          case where we will need to collected the auxiliary pid but we
          can not be sure if it will be expected one.  I think for this
          case we need to actually change waitpid to use WNOHANG to avoid
          hanging indefinitely on the call and report an error to caller
          since we can't differentiate between a default failure as 2.
          and a possible pid reuse race issue.

Checked on x86_64-linux-gnu.

* sysdeps/unix/sysv/linux/spawni.c (__spawnix): Handle the case where
the auxiliary process is terminated by a signal before calling _exit
or execve.

(cherry picked from commit fe05e1cb6d64dba6172249c79526f1e9af8f2bfd)

7 years agoAdd test for bug 21041
Andreas Schwab [Tue, 8 Aug 2017 15:44:32 +0000 (17:44 +0200)] 
Add test for bug 21041

(cherry picked from commit 40c06a3d0450365e9675fe26f34fc56ce8497325)

7 years agoFix s390 version of pt-longjmp.c
Andreas Schwab [Wed, 9 Aug 2017 08:36:08 +0000 (10:36 +0200)] 
Fix s390 version of pt-longjmp.c

(cherry picked from commit 5797b410a87f6f6f6d3661d730fac320cbd5f270)

7 years agoDon't use IFUNC resolver for longjmp or system in libpthread (bug 21041)
Andreas Schwab [Tue, 8 Aug 2017 14:21:58 +0000 (16:21 +0200)] 
Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041)

Unlike the vfork forwarder and like the fork forwarder as in bug 19861,
there won't be a problem when the compiler does not turn this into a tail
call.

(cherry picked from commit fc5ad7024c620cdfe9b76e94638aac83b99c5bf8)

7 years agoFix TLS relocations against local symbols on powerpc32, sparc32 and sparc64
James Clarke [Fri, 13 Oct 2017 18:44:39 +0000 (15:44 -0300)] 
Fix TLS relocations against local symbols on powerpc32, sparc32 and sparc64

Normally, TLS relocations against local symbols are optimised by the linker
to be absolute.  However, gold does not do this, and so it is possible to
end up with, for example, R_SPARC_TLS_DTPMOD64 referring to a local symbol.
Since sym_map is left as null in elf_machine_rela for the special local
symbol case, the relocation handling thinks it has nothing to do, and so
the module gets left as 0.  Havoc then ensues when the variable in question
is accessed.

Before this fix, the main_local_gold program would receive a SIGBUS on
sparc64, and SIGSEGV on powerpc32.  With this fix applied, that test now
passes like the rest of them.

* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela):
Assign sym_map to be map for local symbols, as TLS relocations
use sym_map to determine whether the symbol is defined and to
extract the TLS information.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Likewise.

7 years agoInstall correct bits/long-double.h for MIPS64 (bug 22322).
Joseph Myers [Thu, 19 Oct 2017 17:32:20 +0000 (17:32 +0000)] 
Install correct bits/long-double.h for MIPS64 (bug 22322).

Similar to bug 21987 for SPARC, MIPS64 wrongly installs the ldbl-128
version of bits/long-double.h, meaning incorrect results when using
headers installed from a 64-bit installation for a 32-bit build.  (I
haven't actually seen this cause build failures before its interaction
with bits/floatn.h did so - installed headers wrongly expecting
_Float128 to be available in a 32-bit configuration.)

This patch fixes the bug by moving the MIPS header to
sysdeps/mips/ieee754, which comes before sysdeps/ieee754/ldbl-128 in
the sysdeps directory ordering.  (bits/floatn.h will need a similar
fix - duplicating the ldbl-128 version for MIPS will suffice - for
headers from a 32-bit installation to be correct for 64-bit builds.)

Tested with build-many-glibcs.py (compilers build for
mips64-linux-gnu, where there was previously a libstdc++ build failure
as at
<https://sourceware.org/ml/libc-testresults/2017-q4/msg00130.html>).

[BZ #22322]
* sysdeps/mips/bits/long-double.h: Move to ....
* sysdeps/mips/ieee754/bits/long-double.h: ... here.

(cherry picked from commit 37bb78cb8c1fb6b5813407c8856b1557359e6343)

7 years agox86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve [BZ #21265]
H.J. Lu [Sun, 22 Oct 2017 15:20:38 +0000 (08:20 -0700)] 
x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve [BZ #21265]

In _dl_runtime_resolve, use fxsave/xsave/xsavec to preserve all vector,
mask and bound registers.  It simplifies _dl_runtime_resolve and supports
different calling conventions.  ld.so code size is reduced by more than
1 KB.  However, use fxsave/xsave/xsavec takes a little bit more cycles
than saving and restoring vector and bound registers individually.

Latency for _dl_runtime_resolve to lookup the function, foo, from one
shared library plus libc.so:

                             Before    After     Change

Westmere (SSE)/fxsave         345      866       151%
IvyBridge (AVX)/xsave         420      643       53%
Haswell (AVX)/xsave           713      1252      75%
Skylake (AVX+MPX)/xsavec      559      719       28%
Skylake (AVX512+MPX)/xsavec   145      272       87%
Ryzen (AVX)/xsavec            280      553       97%

This is the worst case where portion of time spent for saving and
restoring registers is bigger than majority of cases.  With smaller
_dl_runtime_resolve code size, overall performance impact is negligible.

On IvyBridge, differences in build and test time of binutils with lazy
binding GCC and binutils are noises.  On Westmere, differences in
bootstrap and "makc check" time of GCC 7 with lazy binding GCC and
binutils are also noises.

[BZ #21265]
* sysdeps/x86/cpu-features-offsets.sym (XSAVE_STATE_SIZE_OFFSET):
New.
* sysdeps/x86/cpu-features.c: Include <libc-internal.h>.
(get_common_indeces): Set xsave_state_size and
bit_arch_XSAVEC_Usable if needed.
(init_cpu_features): Remove bit_arch_Use_dl_runtime_resolve_slow
and bit_arch_Use_dl_runtime_resolve_opt.
* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
Removed.
(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
(bit_arch_Prefer_No_AVX512): Updated.
(bit_arch_MathVec_Prefer_No_AVX512): Likewise.
(bit_arch_XSAVEC_Usable): New.
(STATE_SAVE_OFFSET): Likewise.
(STATE_SAVE_MASK): Likewise.
[__ASSEMBLER__]: Include <cpu-features-offsets.h>.
(cpu_features): Add xsave_state_size.
(index_arch_Use_dl_runtime_resolve_opt): Removed.
(index_arch_Use_dl_runtime_resolve_slow): Likewise.
(index_arch_XSAVEC_Usable): New.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Replace _dl_runtime_resolve_sse, _dl_runtime_resolve_avx,
_dl_runtime_resolve_avx_slow, _dl_runtime_resolve_avx_opt,
_dl_runtime_resolve_avx512 and _dl_runtime_resolve_avx512_opt
with _dl_runtime_resolve_fxsave, _dl_runtime_resolve_xsave and
_dl_runtime_resolve_xsavec.
* sysdeps/x86_64/dl-trampoline.S (DL_RUNTIME_UNALIGNED_VEC_SIZE):
Removed.
(DL_RUNTIME_RESOLVE_REALIGN_STACK): Check STATE_SAVE_ALIGNMENT
instead of VEC_SIZE.
(REGISTER_SAVE_BND0): Removed.
(REGISTER_SAVE_BND1): Likewise.
(REGISTER_SAVE_BND3): Likewise.
(REGISTER_SAVE_RAX): Always defined to 0.
(VMOV): Removed.
(_dl_runtime_resolve_avx): Likewise.
(_dl_runtime_resolve_avx_slow): Likewise.
(_dl_runtime_resolve_avx_opt): Likewise.
(_dl_runtime_resolve_avx512): Likewise.
(_dl_runtime_resolve_avx512_opt): Likewise.
(_dl_runtime_resolve_sse): Likewise.
(_dl_runtime_resolve_sse_vex): Likewise.
(USE_FXSAVE): New.
(_dl_runtime_resolve_fxsave): Likewise.
(USE_XSAVE): Likewise.
(_dl_runtime_resolve_xsave): Likewise.
(USE_XSAVEC): Likewise.
(_dl_runtime_resolve_xsavec): Likewise.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx512):
Removed.
(_dl_runtime_resolve_avx512_opt): Likewise.
(_dl_runtime_resolve_avx): Likewise.
(_dl_runtime_resolve_avx_opt): Likewise.
(_dl_runtime_resolve_sse): Likewise.
(_dl_runtime_resolve_sse_vex): Likewise.
(_dl_runtime_resolve_fxsave): New.
(_dl_runtime_resolve_xsave): Likewise.
(_dl_runtime_resolve_xsavec): Likewise.

(cherry picked from commit b52b0d793dcb226ecb0ecca1e672ca265973233c)

7 years agox86-64: Verify that _dl_runtime_resolve preserves vector registers
H.J. Lu [Thu, 19 Oct 2017 15:47:38 +0000 (08:47 -0700)] 
x86-64: Verify that _dl_runtime_resolve preserves vector registers

On x86-64, _dl_runtime_resolve must preserve the first 8 vector
registers.  Add 3 _dl_runtime_resolve tests to verify that SSE,
AVX and AVX512 registers are preserved.

* sysdeps/x86_64/Makefile (tests): Add tst-sse, tst-avx and
tst-avx512.
(test-extras): Add tst-avx-aux and tst-avx512-aux.
(extra-test-objs): Add tst-avx-aux.o and tst-avx512-aux.o.
(modules-names): Add tst-ssemod, tst-avxmod and tst-avx512mod.
($(objpfx)tst-sse): New rule.
($(objpfx)tst-avx): Likewise.
($(objpfx)tst-avx512): Likewise.
(CFLAGS-tst-avx-aux.c): New.
(CFLAGS-tst-avxmod.c): Likewise.
(CFLAGS-tst-avx512-aux.c): Likewise.
(CFLAGS-tst-avx512mod.c): Likewise.
* sysdeps/x86_64/tst-avx-aux.c: New file.
* sysdeps/x86_64/tst-avx.c: Likewise.
* sysdeps/x86_64/tst-avx512-aux.c: Likewise.
* sysdeps/x86_64/tst-avx512.c: Likewise.
* sysdeps/x86_64/tst-avx512mod.c: Likewise.
* sysdeps/x86_64/tst-avxmod.c: Likewise.
* sysdeps/x86_64/tst-sse.c: Likewise.
* sysdeps/x86_64/tst-ssemod.c: Likewise.

(cherry picked from commit 3403a17fea8ccef7dc5f99553a13231acf838744)

7 years agoSynchronize support/ infrastructure with master
Florian Weimer [Wed, 11 Oct 2017 11:09:11 +0000 (13:09 +0200)] 
Synchronize support/ infrastructure with master

This commit updates the support/ subdirectory to
commit 84d0e6f05212cabe786cdf00bf3ba5d166d077c0
on the master branch.

7 years agoFix cast-after-dereference
DJ Delorie [Sat, 7 Oct 2017 11:28:16 +0000 (13:28 +0200)] 
Fix cast-after-dereference

Original code was dereferencing a char*, then casting the value
to size_t.  Should cast the pointer to size_t* then deference.

(cherry picked from commit f8cef4d07d9641e27629bd3ce2d13f5d702fb251)

7 years agoFix BZ #21654 - grp-merge.c alignment
DJ Delorie [Sat, 15 Jul 2017 01:46:42 +0000 (21:46 -0400)] 
Fix BZ #21654 - grp-merge.c alignment

* grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
alignment not char alignment.
(__merge_grp): Likewise.

(cherry picked from commit 4fa8ae49aa169fb8d97882938e8bee3ed9ce5410)

7 years agoFix sparc32 bits/long-double.h (bug 21987).
Joseph Myers [Tue, 22 Aug 2017 00:59:43 +0000 (00:59 +0000)] 
Fix sparc32 bits/long-double.h (bug 21987).

My refactoring of long double information

commit 0acb8a2a855395c25b1feef2470f4d7ca4bed589
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Dec 14 18:27:56 2016 +0000

    Refactor long double information into bits/long-double.h.

resulted in sparc32 configurations installing the ldbl-opt version of
bits/long-double.h instead of the intended
sysdeps/unix/sysv/linux/sparc version.

For sparc32 by itself, this is not a problem, since the ldbl-opt
version is correct for sparc32.  However, both sparc32 and sparc64 are
supposed to install sets of headers that work for both of them, so
that a single sysroot, whichever order the libraries are built and
installed in, works for both.  The effect of having the wrong version
installed is that you end up with a miscompiled sparc64 libstdc++
which fails glibc's configure tests for the C++ compiler.

This patch moves the header from sysdeps/unix/sysv/linux/sparc to
separate copies of the same file for sparc32 and sparc64, to ensure it
comes before ldbl-opt in the sysdeps directory ordering.

Tested with build-many-glibcs.py for sparc64-linux-gnu and
sparcv9-linux-gnu.

[BZ #21987]
* sysdeps/unix/sysv/linux/sparc/bits/long-double.h: Remove file
and copy to ...
* sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h:
... here.
* sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h:
... and here.

(cherry picked from commit 80f91666fed71fa3dd5eb5618739147cc731bc89)

7 years agoMake copy of <bits/std_abs.h> from GCC 7 [BZ #21573]
H.J. Lu [Mon, 11 Sep 2017 16:04:57 +0000 (09:04 -0700)] 
Make copy of <bits/std_abs.h> from GCC 7 [BZ #21573]

<bits/std_abs.h> from GCC 7 will include /usr/include/stdlib.h from
"#include_next" (instead of stdlib/stdlib.h in the glibc source
directory), and this turns up as a make dependency.  Also make a copy
of <bits/std_abs.h> to prevent it from including /usr/include/stdlib.h.

* configure.ac (find_cxx_header): Suppress compiler error message.
* configure: Regenerated.

[BZ #21573]
* Makerules [$(c++-bits-std_abs-h) != ""] (before-compile): Add
$(common-objpfx)bits/std_abs.h.
[$(c++-bits-std_abs-h) != ""] ($(common-objpfx)bits/std_abs.h):
New target.
* config.make.in (c++-bits-std_abs-h): New.
* configure.ac (find_cxx_header): Use "\,$1," with sed.
(CXX_BITS_STD_ABS_H): New.
(AC_SUBST(CXX_BITS_STD_ABS_H)): Likewise.
* configure: Regenerated.

(cherry picked from commit a65ea28d1833d3502c5070472e43bda04410e6b5 and
 commit c2528fef3b05bcffb1ac27c6c09cc3ff24b7f03f)

7 years agostring/stratcliff.c: Replace int with size_t [BZ #21982]
H.J. Lu [Mon, 11 Sep 2017 15:51:52 +0000 (08:51 -0700)] 
string/stratcliff.c: Replace int with size_t [BZ #21982]

Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:

stratcliff.c: In function ‘do_test’:
cc1: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]

[BZ #21982]
* string/stratcliff.c (do_test): Declare size, nchars, inner,
middle and outer with size_t instead of int.  Repleace %d and
%Zd with %zu in printf.  Update "MAX (0, nchars - 128)" and
"MAX (outer, nchars - 64)" to support unsigned outer and
nchars.  Also exit loop when outer == 0.

(cherry picked from commit 376b40a27a6783ea7f73ae577be320df66aeb36d)

7 years agoUse "static const char domain[] ="
H.J. Lu [Thu, 7 Sep 2017 20:56:58 +0000 (13:56 -0700)] 
Use "static const char domain[] ="

* resolv/tst-resolv-qtypes.c (domain): Changed to
"const char domain[] =".

(cherry picked from commit 78bfa877b36e8f33c99cbe9a16eb73f5a2adc0c8)

7 years agoPlace $(elf-objpfx)sofini.os last [BZ #22051]
H.J. Lu [Thu, 31 Aug 2017 13:28:31 +0000 (06:28 -0700)] 
Place $(elf-objpfx)sofini.os last [BZ #22051]

Since sofini.os terminates .eh_frame section, it should be placed last.

[BZ #22051]
* Makerules (build-module-helper-objlist): Filter out
$(elf-objpfx)sofini.os.
(build-shlib-objlist): Append $(elf-objpfx)sofini.os if it is
needed.

(cherry picked from commit ecd0747df388f3925d4839740b0abcf43d0a9fb2)

7 years agomutex: Fix robust mutex lock acquire (Bug 21778)
Carlos O'Donell [Sat, 29 Jul 2017 04:02:03 +0000 (00:02 -0400)] 
mutex: Fix robust mutex lock acquire (Bug 21778)

65810f0ef05e8c9e333f17a44e77808b163ca298 fixed a robust mutex bug but
introduced BZ 21778: if the CAS used to try to acquire a lock fails, the
expected value is not updated, which breaks other cases in the loce
acquisition loop.  The fix is to simply update the expected value with
the value returned by the CAS, which ensures that behavior is as if the
first case with the CAS never happened (if the CAS fails).

This is a regression introduced in the last release.

Tested on x86_64, i686, ppc64, ppc64le, s390x, aarch64, armv7hl.

(cherry picked from commit 5920a4a624b1f4db310d1c44997b640e2a4653e5)

7 years agorwlock: Fix explicit hand-over (bug 21298)
Carlos O'Donell [Mon, 28 Aug 2017 13:04:39 +0000 (15:04 +0200)] 
rwlock: Fix explicit hand-over (bug 21298)

Without this fix, the rwlock can fail to execute the explicit hand-over
in certain cases (e.g., empty critical sections that switch quickly between
read and write phases).  This can then lead to errors in how __wrphase_futex
is accessed, which in turn can lead to deadlocks.

(cherry picked from commit faf8c066df0d6bccb54bd74dd696eeb65e1b3bbc)

7 years agoSynchronize support/ infrastructure with master
Florian Weimer [Mon, 28 Aug 2017 12:38:52 +0000 (14:38 +0200)] 
Synchronize support/ infrastructure with master

This commit updates the support/ subdirectory to
commit faf8c066df0d6bccb54bd74dd696eeb65e1b3bbc
on the master branch.

7 years agoassert: Support types without operator== (int) [BZ #21972]
Florian Weimer [Mon, 21 Aug 2017 14:15:47 +0000 (16:15 +0200)] 
assert: Support types without operator== (int) [BZ #21972]

(cherry picked from commit b5889d25e9bf944a89fdd7bcabf3b6c6f6bb6f7c)

7 years agoresolv: Reduce EDNS payload size to 1200 bytes [BZ #21361]
Florian Weimer [Thu, 13 Apr 2017 11:09:38 +0000 (13:09 +0200)] 
resolv: Reduce EDNS payload size to 1200 bytes [BZ #21361]

This hardens the stub resolver against fragmentation-based attacks.

(cherry picked from commit e14a27723cc3a154d67f3f26e719d08c0ba9ad25)

7 years agoReturn to caller if dl_fixup fails to resolve callee on hppa.
John David Anglin [Sat, 12 Aug 2017 21:54:26 +0000 (17:54 -0400)] 
Return to caller if dl_fixup fails to resolve callee on hppa.

[BZ 19170]
* sysdeps/hppa/dl-trampoline.S (_dl_runtime_resolve): Return to caller
if _dl_fixup fails.

7 years agoCall exit directly in clone (BZ #21512)
John David Anglin [Sat, 12 Aug 2017 21:37:14 +0000 (17:37 -0400)] 
Call exit directly in clone (BZ #21512)

[BZ #21512]
* sysdeps/unix/sysv/linux/aarch64/clone.S (__clone): Call exit
syscall instead of jump to _exit.
* sysdeps/unix/sysv/linux/hppa/localplt.data: Remove _exit entry.

7 years ago hppa: set __IPC_64 as zero for SysV IPC calls
John David Anglin [Sat, 12 Aug 2017 21:19:59 +0000 (17:19 -0400)] 
hppa: set __IPC_64 as zero for SysV IPC calls

    In 1e5834c38a22 ("Refactor Linux ipc_priv header") a different
    approach to passing __IPC_64 as zero was created.  Hppa kernel ABI
    requires to oass __IPC_64 as zero since it does not set
    CONFIG_ARCH_WANT_IPC_PARSE_VERSION in the kernel.

    Checked on hppa-linux-gnu with some adjustments to avoid BZ#21016
    (basically by removing hppa compat implementations and adjusting
    required headers).

            * sysdeps/unix/sysv/linux/hppa/ipc_priv.h: New file.

7 years agoAdd CFI annotation.
John David Anglin [Sat, 12 Aug 2017 20:59:50 +0000 (16:59 -0400)] 
Add CFI annotation.

* sysdeps/unix/sysv/linux/hppa/clone.S (__clone): Add .cfi annotation.
* sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Likewise.
* sysdeps/unix/sysv/linux/hppa/pt-vfork.S (__vfork): Likewise.
* sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext): Likewise.

7 years agoFix stack offset for r19 load in __getcontext.
John David Anglin [Sat, 12 Aug 2017 20:46:35 +0000 (16:46 -0400)] 
Fix stack offset for r19 load in __getcontext.

* sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Fix stack
offset for r19 load.

7 years agoFix __setcontext return value on hppa.
John David Anglin [Sat, 12 Aug 2017 20:28:32 +0000 (16:28 -0400)] 
Fix __setcontext return value on hppa.

* sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext): Return 0.

7 years agoFix syscall cancellation on hppa.
John David Anglin [Sat, 12 Aug 2017 20:11:36 +0000 (16:11 -0400)] 
Fix syscall cancellation on hppa.

* sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (PSEUDO): Fix CFA offset.
Use .cfi_def_cfa_offset instead of .cfi_offset.  Don't record stack
pointer offset.  Correct PIC register offset.  Don't mention frame
related instructions in epilogue.
(PUSHARGS_1): Correct offset.
(PUSHARGS_2): Likewise.
(PUSHARGS_3): Likewise.
(PUSHARGS_4): Likewise.
(PUSHARGS_5): Likewise.
(PUSHARGS_6): Likewise.
(POPARGS_1): Don't mention register restore.
(POPARGS_2): Likewise.
(POPARGS_3): Likewise.
(POPARGS_4): Likewise.
(POPARGS_5): Likewise.
(POPARGS_6): Likewise.
* sysdeps/unix/sysv/linux/hppa/sysdep.h (SAVE_PIC): Don't mention
copy of PIC register.
(LOAD_PIC): Likewise don't mention restore.
(DO_CALL): Fix CFA offset.  Use .cfi_def_cfa_offset instead of
.cfi_offset.  Don't record stack pointer offset.  Correct PIC register
offset.  Don't mention frame related instructions in epilogue.

7 years agoFix [BZ 20098].
John David Anglin [Sat, 12 Aug 2017 19:45:28 +0000 (15:45 -0400)] 
Fix [BZ 20098].

[BZ 20098]
* sysdeps/hppa/dl-fptr.c (_dl_read_access_allowed): New.
(_dl_lookup_address): Return address if it is not consistent with
being a linker defined function pointer.  Likewise, return address
if address and function descriptor addresses are not accessible.

7 years agoFix [BZ locale/19838].
John David Anglin [Sat, 12 Aug 2017 19:09:25 +0000 (15:09 -0400)] 
Fix [BZ locale/19838].

[BZ locale/19838]
* sysdeps/unix/sysv/linux/hppa/bits/shm.h (SHMLBA): Set to page size.

7 years agoFix guard alignment in allocate_stack when stack grows up.
John David Anglin [Sat, 12 Aug 2017 18:39:53 +0000 (14:39 -0400)] 
Fix guard alignment in allocate_stack when stack grows up.

* nptl/allocatestack.c (allocate_stack): Align old and new guard
addresses to page boundaries when the stack grows up.

7 years agoFix failing sNaN tests on hppa.
John David Anglin [Sat, 12 Aug 2017 17:43:57 +0000 (13:43 -0400)] 
Fix failing sNaN tests on hppa.

* sysdeps/hppa/math-tests.h: New.

7 years agoUse generic pthread support on hppa.
John David Anglin [Sat, 12 Aug 2017 17:02:52 +0000 (13:02 -0400)] 
Use generic pthread support on hppa.

        [BZ #21016]
        * sysdeps/hppa/nptl/bits/pthreadtypes.h: Update pthread_cond_t typedef.
        * sysdeps/unix/sysv/linux/hppa/pthread.h: Include
        bits/types/struct_timespec.h.
        (PTHREAD_MUTEX_INITIALIZER): Revise define.
        (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Likewise.
        (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise.
        (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP): Likewise.
        (PTHREAD_RWLOCK_INITIALIZER): Likewise.
        (PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP): Likewise.
        (PTHREAD_COND_INITIALIZER): Likewise.
        Remove old definitions.
        * sysdeps/unix/sysv/linux/hppa/internaltypes.h: Delete.
        * sysdeps/unix/sysv/linux/hppa/pthread_cond_broadcast.c: Delete.
        * sysdeps/unix/sysv/linux/hppa/pthread_cond_destroy.c: Delete.
        * sysdeps/unix/sysv/linux/hppa/pthread_cond_init.c: Delete.
        * sysdeps/unix/sysv/linux/hppa/pthread_cond_signal.c: Delete.
        * sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c: Delete.

7 years agoassert: Suppress pedantic warning caused by statement expression [BZ #21242]
Florian Weimer [Fri, 11 Aug 2017 14:02:55 +0000 (16:02 +0200)] 
assert: Suppress pedantic warning caused by statement expression [BZ #21242]

(cherry picked from commit 8b2c63e4e2ad1fd161f80004ed30624f2a37b57b)

7 years agohppa: Fix register corruption in __longjmp.
John David Anglin [Wed, 9 Aug 2017 01:29:21 +0000 (21:29 -0400)] 
hppa: Fix register corruption in __longjmp.

[BZ #21049]
        * sysdeps/hppa/__longjmp.c (__longjmp): Move call to CHECK_SP up
        to avoid clobbering r26.

7 years agox86-64: Use _dl_runtime_resolve_opt only with AVX512F [BZ #21871]
H.J. Lu [Sun, 6 Aug 2017 17:44:30 +0000 (10:44 -0700)] 
x86-64: Use _dl_runtime_resolve_opt only with AVX512F [BZ #21871]

On AVX machines with XGETBV (ECX == 1) like Skylake processors,

(gdb) disass _dl_runtime_resolve_avx_opt
Dump of assembler code for function _dl_runtime_resolve_avx_opt:
   0x0000000000015890 <+0>: push   %rax
   0x0000000000015891 <+1>: push   %rcx
   0x0000000000015892 <+2>: push   %rdx
   0x0000000000015893 <+3>: mov    $0x1,%ecx
   0x0000000000015898 <+8>: xgetbv
   0x000000000001589b <+11>: mov    %eax,%r11d
   0x000000000001589e <+14>: pop    %rdx
   0x000000000001589f <+15>: pop    %rcx
   0x00000000000158a0 <+16>: pop    %rax
   0x00000000000158a1 <+17>: and    $0x4,%r11d
   0x00000000000158a5 <+21>: bnd je 0x16200 <_dl_runtime_resolve_sse_vex>
End of assembler dump.

is slower than:

(gdb) disass _dl_runtime_resolve_avx_slow
Dump of assembler code for function _dl_runtime_resolve_avx_slow:
   0x0000000000015850 <+0>: vorpd  %ymm0,%ymm1,%ymm8
   0x0000000000015854 <+4>: vorpd  %ymm2,%ymm3,%ymm9
   0x0000000000015858 <+8>: vorpd  %ymm4,%ymm5,%ymm10
   0x000000000001585c <+12>: vorpd  %ymm6,%ymm7,%ymm11
   0x0000000000015860 <+16>: vorpd  %ymm8,%ymm9,%ymm9
   0x0000000000015865 <+21>: vorpd  %ymm10,%ymm11,%ymm10
   0x000000000001586a <+26>: vpcmpeqd %xmm8,%xmm8,%xmm8
   0x000000000001586f <+31>: vorpd  %ymm9,%ymm10,%ymm10
   0x0000000000015874 <+36>: vptest %ymm10,%ymm8
   0x0000000000015879 <+41>: bnd jae 0x158b0 <_dl_runtime_resolve_avx>
   0x000000000001587c <+44>: vzeroupper
   0x000000000001587f <+47>: bnd jmpq 0x16200 <_dl_runtime_resolve_sse_vex>
End of assembler dump.
(gdb)

since xgetbv takes much more cycles than single cycle operations like
vpord/vvpcmpeq/ptest.  _dl_runtime_resolve_opt should be used only with
AVX512 where AVX512 instructions lead to lower CPU frequency on Skylake
server.

[BZ #21871]
* sysdeps/x86/cpu-features.c (init_cpu_features): Set
bit_arch_Use_dl_runtime_resolve_opt only with AVX512F.

(cherry picked from commit d2cf37c0a2a375cf2fde69f1afbcc49e45368fc4)

7 years agoi686/multiarch: Regenerate ulps
Aurelien Jarno [Fri, 4 Aug 2017 01:07:39 +0000 (03:07 +0200)] 
i686/multiarch: Regenerate ulps

This comes from running “make regen-ulps” on an AMD Opteron 2378 CPU.

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

7 years agoFix the return type of the getentropy stub
Aurelien Jarno [Thu, 3 Aug 2017 22:35:48 +0000 (22:35 +0000)] 
Fix the return type of the getentropy stub

The return type of the getentropy stub is wrongly defined as ssize_t,
while both the <sys/random.h> header and the Linux implementation
define it as int. This patch fixes that.

Changelog:
* stdlib/getentropy.c (getentropy): Change return type to int.
(cherry picked from commit 2b34e2716f1e84b2c3457ffc868c3dc775b55845)

7 years agopowerpc: Fix logbl on power7 [BZ# 21280]
Tulio Magno Quites Machado Filho [Fri, 28 Apr 2017 22:45:52 +0000 (19:45 -0300)] 
powerpc: Fix logbl on power7 [BZ# 21280]

 1. Fix the results for negative subnormals by ignoring the signal when
    normalizing the value.
 2. Fix the output when the high part is a power of 2 and the low part
    is a nonzero number with opposite sign.  This fix is based on commit
    380bd0fd2418f8988217de950f8b8ff18af0cb2b.

After applying this patch, logbl() tests pass cleanly on POWER >= 7.

Tested on powerpc, powerpc64 and powerpc64le

[BZ #21280]
* sysdeps/powerpc/power7/fpu/s_logbl.c (__logbl): Ignore the
signal of subnormals and adjust the exponent of power of 2 down
when low part has opposite sign.

(cherry picked from commit c064f6a613844181f411aabb2662384a6aefb69e)

8 years agoAvoid .symver on common symbols [BZ #21666]
H.J. Lu [Wed, 26 Jul 2017 17:08:46 +0000 (10:08 -0700)] 
Avoid .symver on common symbols [BZ #21666]

The .symver directive on common symbol just creates a new common symbol,
not an alias and the newer assembler with the bug fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21661

will issue an error.  Before the fix, we got

$ readelf -sW libc.so | grep "loc[12s]"
  5109: 00000000003a0608     8 OBJECT  LOCAL  DEFAULT   36 loc1
  5188: 00000000003a0610     8 OBJECT  LOCAL  DEFAULT   36 loc2
  5455: 00000000003a0618     8 OBJECT  LOCAL  DEFAULT   36 locs
  6575: 00000000003a05f0     8 OBJECT  GLOBAL DEFAULT   36 locs@GLIBC_2.2.5
  7156: 00000000003a05f8     8 OBJECT  GLOBAL DEFAULT   36 loc1@GLIBC_2.2.5
  7312: 00000000003a0600     8 OBJECT  GLOBAL DEFAULT   36 loc2@GLIBC_2.2.5

in libc.so.  The versioned loc1, loc2 and locs have the wrong addresses.
After the fix, we got

$ readelf -sW libc.so | grep "loc[12s]"
  6570: 000000000039e3b8     8 OBJECT  GLOBAL DEFAULT   34 locs@GLIBC_2.2.5
  7151: 000000000039e3c8     8 OBJECT  GLOBAL DEFAULT   34 loc1@GLIBC_2.2.5
  7307: 000000000039e3c0     8 OBJECT  GLOBAL DEFAULT   34 loc2@GLIBC_2.2.5

[BZ #21666]
* misc/regexp.c (loc1): Add __attribute__ ((nocommon));
(loc2): Likewise.
(locs): Likewise.

(cherry picked from commit 388b4f1a02f3a801965028bbfcd48d905638b797)

8 years ago[AArch64] Use hidden __GI__dl_argv in rtld startup code
Szabolcs Nagy [Wed, 21 Jun 2017 12:47:07 +0000 (13:47 +0100)] 
[AArch64] Use hidden __GI__dl_argv in rtld startup code

We rely on the symbol being locally defined so using extern symbol
is not correct and the linker may complain about the relocations.

8 years agox86-64: Align the stack in __tls_get_addr [BZ #21609]
H.J. Lu [Thu, 6 Jul 2017 11:43:06 +0000 (04:43 -0700)] 
x86-64: Align the stack in __tls_get_addr [BZ #21609]

This change forces realignment of the stack pointer in __tls_get_addr, so
that binaries compiled by GCCs older than GCC 4.9:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066

continue to work even if vector instructions are used in glibc which
require the ABI stack realignment.

__tls_get_addr_slow is added to handle the slow paths in the default
implementation of__tls_get_addr in elf/dl-tls.c.  The new __tls_get_addr
calls __tls_get_addr_slow after realigning the stack.  Internal calls
within ld.so go directly to the default implementation of __tls_get_addr
because they do not need stack realignment.

[BZ #21609]
* sysdeps/x86_64/Makefile (sysdep-dl-routines): Add tls_get_addr.
(gen-as-const-headers): Add rtld-offsets.sym.
* sysdeps/x86_64/dl-tls.c: New file.
* sysdeps/x86_64/rtld-offsets.sym: Likwise.
* sysdeps/x86_64/tls_get_addr.S: Likewise.
* sysdeps/x86_64/dl-tls.h: Add multiple inclusion guards.
* sysdeps/x86_64/tlsdesc.sym (TI_MODULE_OFFSET): New.
(TI_OFFSET_OFFSET): Likwise.

(cherry picked from commit 031e519c95c069abe4e4c7c59e2b4b67efccdee5)

8 years agoi686: Add missing IS_IN (libc) guards to vectorized strcspn
Florian Weimer [Wed, 14 Jun 2017 06:11:22 +0000 (08:11 +0200)] 
i686: Add missing IS_IN (libc) guards to vectorized strcspn

Since commit d957c4d3fa48d685ff2726c605c988127ef99395 (i386: Compile
rtld-*.os with -mno-sse -mno-mmx -mfpmath=387), vector intrinsics can
no longer be used in ld.so, even if the compiled code never makes it
into the final ld.so link.  This commit adds the missing IS_IN (libc)
guard to the SSE 4.2 strcspn implementation, so that it can be used from
ld.so in the future.

(cherry picked from commit 69052a3a95da37169a08f9e59b2cc1808312753c)

8 years agoIgnore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209)
Siddhesh Poyarekar [Tue, 20 Jun 2017 03:59:17 +0000 (05:59 +0200)] 
Ignore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209)

The LD_HWCAP_MASK environment variable may alter the selection of
function variants for some architectures.  For AT_SECURE process it
means that if an outdated routine has a bug that would otherwise not
affect newer platforms by default, LD_HWCAP_MASK will allow that bug
to be exploited.

To be on the safe side, ignore and disable LD_HWCAP_MASK for setuid
binaries.

[BZ #21209]
* elf/rtld.c (process_envvars): Ignore LD_HWCAP_MASK for
AT_SECURE processes.
* sysdeps/generic/unsecvars.h: Add LD_HWCAP_MASK.
* elf/tst-env-setuid.c (test_parent): Test LD_HWCAP_MASK.
(test_child): Likewise.
* elf/Makefile (tst-env-setuid-ENV): Add LD_HWCAP_MASK.

(cherry picked from commit 1c1243b6fc33c029488add276e56570a07803bfd)

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

Also only process the last LD_AUDIT entry.

(cherry picked from commit 81b82fb966ffbd94353f793ad17116c6088dedd9)

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

(cherry picked from commit 6d0ba622891bed9d8394eef1935add53003b12e8)

8 years agoCVE-2017-1000366: Ignore LD_LIBRARY_PATH for AT_SECURE=1 programs [BZ #21624]
Florian Weimer [Mon, 19 Jun 2017 16:31:27 +0000 (18:31 +0200)] 
CVE-2017-1000366: Ignore LD_LIBRARY_PATH for AT_SECURE=1 programs [BZ #21624]

LD_LIBRARY_PATH can only be used to reorder system search paths, which
is not useful functionality.

This makes an exploitable unbounded alloca in _dl_init_paths unreachable
for AT_SECURE=1 programs.

(cherry picked from commit f6110a8fee2ca36f8e2d2abecf3cba9fa7b8ea7d)

8 years agoCorrect collation rules for Malayalam.
Santhosh Thottingal [Sun, 11 Jun 2017 14:08:37 +0000 (10:08 -0400)] 
Correct collation rules for Malayalam.

[BZ #19922]
* locales/iso14651_t1_common: Add collation rules for U+07DA to U+07DF.

[BZ #19919]
* locales/iso14651_t1_common: Correct collation of U+0D36 and U+0D37.

8 years agofork: Remove bogus parent PID assertions [BZ #21386]
Florian Weimer [Fri, 9 Jun 2017 11:21:43 +0000 (13:21 +0200)] 
fork: Remove bogus parent PID assertions [BZ #21386]

(cherry picked from commit 1d2bc2eae969543b89850e35e532f3144122d80a)

8 years agoFix test-math-vector-sincos.h aliasing.
Joseph Myers [Wed, 15 Mar 2017 17:32:46 +0000 (17:32 +0000)] 
Fix test-math-vector-sincos.h aliasing.

x86_64 libmvec tests have been failing to build lately with GCC
mainline with -Wuninitialized errors, and Markus Trippelsdorf traced
this to an aliasing issue
<https://sourceware.org/ml/libc-alpha/2017-03/msg00169.html>.

This patch fixes the aliasing issue, so that the vectors-of-pointers
are initialized using a union instead of pointer casts.  This also
fixes the testsuite build failures with GCC mainline.

Tested for x86_64 (full testsuite with GCC 6; testsuite build with GCC
mainline with build-many-glibcs.py).

* sysdeps/x86/fpu/test-math-vector-sincos.h (INIT_VEC_PTRS_LOOP):
Use a union when storing pointers.
(VECTOR_WRAPPER_fFF_2): Do not take address of integer vector and
cast result when passing to INIT_VEC_PTRS_LOOP.
(VECTOR_WRAPPER_fFF_3): Likewise.
(VECTOR_WRAPPER_fFF_4): Likewise.

(cherry picked from commit ffe308e4fcf2f276c87fd405596569ba52ad0a29)

8 years agoFix i686 memchr overflow calculation (BZ#21182)
Adhemerval Zanella [Tue, 14 Mar 2017 17:16:13 +0000 (14:16 -0300)] 
Fix i686 memchr overflow calculation (BZ#21182)

This patch fixes the regression added by 23d2770 for final address
overflow calculation.  The subtraction of the considered size (16)
at line 120 is at wrong place, for sizes less than 16 subsequent
overflow check will not take in consideration an invalid size (since
the subtraction will be negative).  Also, the lea instruction also
does not raise the carry flag (CF) that is used in subsequent jbe
to check for overflow.

The fix is to follow x86_64 logic from 3daef2c where the overflow
is first check and a sub instruction is issued.  In case of resulting
negative size, CF will be set by the sub instruction and a NULL
result will be returned.  The patch also add similar tests reported
in bug report.

Checked on i686-linux-gnu and x86_64-linux-gnu.

* string/test-memchr.c (do_test): Add BZ#21182 checks for address
near end of a page.
* sysdeps/i386/i686/multiarch/memchr-sse2.S (__memchr): Fix
overflow calculation.

Cherry-pick of 3abeeec5f46ff036bd9df60bb096e20314ccd078.

8 years agox86: Use AVX2 memcpy/memset on Skylake server [BZ #21396]
H.J. Lu [Fri, 28 Apr 2017 17:04:15 +0000 (10:04 -0700)] 
x86: Use AVX2 memcpy/memset on Skylake server [BZ #21396]

On Skylake server, AVX512 load/store instructions in memcpy/memset may
lead to lower CPU turbo frequency in certain situations.  Use of AVX2
in memcpy/memset has been observed to have improved overall performance
in many workloads due to the higher frequency.

Since AVX512ER is unique to Xeon Phi, this patch sets Prefer_No_AVX512
if AVX512ER isn't available so that AVX2 versions of memcpy/memset are
used on Skylake server.

[BZ #21396]
* sysdeps/x86/cpu-features.c (init_cpu_features): Set
Prefer_No_AVX512 if AVX512ER isn't available.
* sysdeps/x86/cpu-features.h (bit_arch_Prefer_No_AVX512): New.
(index_arch_Prefer_No_AVX512): Likewise.
* sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Don't use
AVX512 version if Prefer_No_AVX512 is set.
* sysdeps/x86_64/multiarch/memcpy_chk.S (__memcpy_chk):
Likewise.
* sysdeps/x86_64/multiarch/memmove.S (__libc_memmove): Likewise.
* sysdeps/x86_64/multiarch/memmove_chk.S (__memmove_chk):
Likewise.
* sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Likewise.
* sysdeps/x86_64/multiarch/mempcpy_chk.S (__mempcpy_chk):
Likewise.
* sysdeps/x86_64/multiarch/memset.S (memset): Likewise.
* sysdeps/x86_64/multiarch/memset_chk.S (__memset_chk):
Likewise.

(cherry picked from commit 4cb334c4d6249686653137ec273d081371b3672d)

8 years agox86: Set Prefer_No_VZEROUPPER if AVX512ER is available
H.J. Lu [Fri, 28 Apr 2017 17:03:09 +0000 (10:03 -0700)] 
x86: Set Prefer_No_VZEROUPPER if AVX512ER is available

AVX512ER won't be implemented in any Xeon processors and will be in
all Xeon Phi processors.  Don't check CPU model number when setting
Prefer_No_VZEROUPPER for Xeon Phi.  Instead, set Prefer_No_VZEROUPPER
if AVX512ER is available.  It works with current and future Xeon Phi
and non-Xeon Phi processors.

* sysdeps/x86/cpu-features.c (init_cpu_features): Set
Prefer_No_VZEROUPPER if AVX512ER is available.
* sysdeps/x86/cpu-features.h
(bit_cpu_AVX512PF): New.
(bit_cpu_AVX512ER): Likewise.
(bit_cpu_AVX512CD): Likewise.
(bit_cpu_AVX512BW): Likewise.
(bit_cpu_AVX512VL): Likewise.
(index_cpu_AVX512PF): Likewise.
(index_cpu_AVX512ER): Likewise.
(index_cpu_AVX512CD): Likewise.
(index_cpu_AVX512BW): Likewise.
(index_cpu_AVX512VL): Likewise.
(reg_AVX512PF): Likewise.
(reg_AVX512ER): Likewise.
(reg_AVX512CD): Likewise.
(reg_AVX512BW): Likewise.
(reg_AVX512VL): Likewise.

(cherry picked from commit 1c53cb49de6d82d9469ccbd5aa0c55924502bd8b)

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

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

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

Cherry-pick of 4fee33f.

8 years agox86-64: Improve branch predication in _dl_runtime_resolve_avx512_opt [BZ #21258]
H.J. Lu [Tue, 21 Mar 2017 17:59:31 +0000 (10:59 -0700)] 
x86-64: Improve branch predication in _dl_runtime_resolve_avx512_opt [BZ #21258]

On Skylake server, _dl_runtime_resolve_avx512_opt is used to preserve
the first 8 vector registers.  The code layout is

  if only %xmm0 - %xmm7 registers are used
     preserve %xmm0 - %xmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %zmm0 - %zmm7 registers

Branch predication always executes the fallthrough code path to preserve
%zmm0 - %zmm7 registers speculatively, even though only %xmm0 - %xmm7
registers are used.  This leads to lower CPU frequency on Skylake
server.  This patch changes the fallthrough code path to preserve
%xmm0 - %xmm7 registers instead:

  if whole %zmm0 - %zmm7 registers are used
    preserve %zmm0 - %zmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %xmm0 - %xmm7 registers

Tested on Skylake server.

[BZ #21258]
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve_opt):
Define only if _dl_runtime_resolve is defined to
_dl_runtime_resolve_sse_vex.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_opt):
Fallthrough to _dl_runtime_resolve_sse_vex.

(cherry picked from commit c15f8eb50cea7ad1a4ccece6e0982bf426d52c00)

8 years agoposix_spawn: use a larger min stack for -fstack-check [BZ #21253]
Mike Frysinger [Thu, 16 Mar 2017 06:59:31 +0000 (23:59 -0700)] 
posix_spawn: use a larger min stack for -fstack-check [BZ #21253]

When glibc is built with -fstack-check, trying to use posix_spawn can
lead to segfaults due to gcc internally probing stack memory too far.
The new spawn API will allocate a minimum of 1 page, but the stack
checking logic might probe a couple of pages.  When it tries to walk
them, everything falls apart.

The gcc internal docs [1] state the default interval checking is one
page.  Which means we need two pages (the current one, and the next
probed).  No target currently defines it larger.

Further, it mentions that the default minimum stack size needed to
recover from an overflow is 4/8KiB for sjlj or 8/12KiB for others.
But some Linux targets (like mips and ppc) go up to 16KiB (and some
non-Linux targets go up to 24KiB).

Let's create each child with a minimum of 32KiB slack space to support
them all, and give us future breathing room.

No test is added as existing ones crash.  Even a simple call is
enough to trigger the problem:
char *argv[] = { "/bin/ls", NULL };
posix_spawn(NULL, "/bin/ls", NULL, NULL, argv, NULL);

[1] https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gccint/Stack-Checking.html

(cherry picked from commit 21f042c804835d1f7a4a8e06f2c93ca35a182042)

8 years agoCall the right helper function when setting mallopt M_ARENA_MAX (BZ #21338)
Wladimir J. van der Laan [Sat, 1 Apr 2017 07:09:09 +0000 (12:39 +0530)] 
Call the right helper function when setting mallopt M_ARENA_MAX (BZ #21338)

Fixes a typo introduced in commit
be7991c0705e35b4d70a419d117addcd6c627319. This caused
mallopt(M_ARENA_MAX) as well as the environment variable
MALLOC_ARENA_MAX to not work as intended because it set the
wrong internal parameter.

  [BZ #21338]
* malloc/malloc.c: Call do_set_arena_max for M_ARENA_MAX
instead of incorrect do_set_arena_test