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
Fixes a typo introduced in commit
be7991c070. 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
The condition for declaration of long double functions in
math-finite.h was #ifdef __MATH_DECLARE_LDOUBLE before the
macroization of this file. After the macroization, it was incorreclty
changed to #if __MATH_DECLARE_LDOUBLE, which broke the build for arm.
* math/math.h: Fix check for __MATH_DECLARE_LDOUBLE.
* math/bits/math-finite.h: Likewise.
This patch fixes some test-errno-linux unexpected returns for the
tested syscalls on some older kernels (I saw it on a Linux 3.8 on
armv7l). Basically:
- inotify_add_watch: Linux v3.8 (676a0675c) removed the test to
check at least one valid bit in flags (to return EINVAL). It
was later added back in v3.9 (04df32fa1).
- quotactl: returns ENOSYS for kernels not configured with
CONFIG_QUOTA.
Checked on x86_64-linux-gnu and armv7l-linux-gnueabihf.
* sysdeps/unix/sysv/linux/test-errno-linux.c (do_test): Handle
non expected inotify_add_watch and quotactl return.
The implementation of __ieee754_rem_pio2l in ldbl-128, ldbl-128ibm,
and ldbl-96 return the type int32_t, whereas math_private.h declares
it as returning int. This patch changes the declaration to match the
declaration in thoses directories, as well as it changes the stub
implementation in math/e_rem_pio2l.c, similarly.
* math/e_rem_pio2l.c (__ieee754_rem_pio2l): Change return type
to int32_t.
* sysdeps/generic/math_private.h: Declare __ieee754_rem_pio2l
as returning int32_t.
This patch macroizes the declarations in math/bits/math-finite.h
similarly to what math/bits/mathcalls.h does. For each floating-point
type, the file is included once in math/math.h. This will reduce the
amount of repetitive boilerplate required when adding float128
versions of these declarations.
Tested for powerpc64le and s390x.
* math/math.h: Include bits/math-finite.h once per
floating-point type.
* math/bits/math-finite.h: Macroize all declarations by
floating-point type.
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.
Fix the incorrect sorting order of a digraph and its geminated variant,
regression introduced by a faulty fix to bug 13547 in commit
b008d4c856.
Fix two inconsistencies in sorting unusual capitalization of digraphs
(bug #18587).
Enable DIACRIT_FORWARD to work around bug #17750.
Sort foreign accents after the Hungarian ones.
Add extensive unittests containing all the examples from The Rules of
Hungarian Orthography and many more, including explanatory comments.
termios.h should define IUCLC for UNIX98 and older XSI standards. The
sysdeps/unix/sysv/linux/alpha version defines it only if __USE_MISC,
so causing some conform/ tests to fail.
Other versions define it unconditionally (I* being a reserved
namespace for this header); the API should be consistent between
architectures in the absence of a clear reason for it to differ (and
given that a symbol is part of the API on two architectures, I don't
see any reason for the feature test macros required ever to differ
between those architectures), so this patch makes the alpha version
define it unconditionally as well. Two non-POSIX macros alongside it,
IMAXBEL and IUTF8, are also defined unconditionally on other
architectures, so this patch makes them consistent by defining them
unconditionally on alpha as well.
Tested (compilation only) with build-many-glibcs.py.
[BZ #21277]
* sysdeps/unix/sysv/linux/alpha/bits/termios.h (IUCLC): Define
unconditionally.
(IMAXBEL): Likewise.
(IUTF8): Likewise.
Since commit 8b9e9c3c0b, security_level replaces
is_secure. There were some old files need to be updated.
2017-03-23 Sunyeop Lee <sunyeop97@gmail.com>
* README.tunables: Updated descriptions.
* elf/dl-tunables.list: Fixed typo: SXID_NONE -> NONE.
* scripts/gen-tunables.awk: Updated the code related to the commit.
of the size and alignment is based on a trace of SPEC2006. Instead of
repeating the same copy over and over again like the existing tests, it times
several thousand different copies to more accurately estimate the overhead of
branch prediction.
* benchtests/Makefile (string-benchset): Add memcpy-random.
* benchtests/bench-memcpy-random.c: New file.
ISO C++ section 8.3.5 [dcl.fct] requires exception specifications
to appear before attribute specifiers in function declarations.
This patch fixes issues reported by stdio-common/check-installed-headers-cxx.
* stdio-common/printf.h (register_printf_modifier): Change the
order of __wur and __THROW.
(register_printf_type): Likewise.
* stdio-common/bug25.c: Include stdlib.h.
* support/tst-support_format_dns_packet.c: Include stdio.h,
stdlib.h, and string.h.
* support/tst-support_record_failure.c: Include string.h.
* support/tst-support_record_failure-2.sh: Adjust line number
expectations and correct a typo in an error message.
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.
The test malloc/tst-interpose-nothread fails on s390x if built
with GCC 7 and glibc commit "Remove the str(n)dup inlines
from string/bits/string2.h. Although inlining"
(ae65d4f3c3) with output:
error: free: 0x3fffdffa010: invalid allocation index: 0 (not less than 0)
The destructor check_for_allocations in malloc/tst-interpose-aux.c is
called twice. One time after the test-child-process has finished successfully
and once after the test-parent-process finishes.
During the latter invocation, allocation_index == 0. GCC 7 is now inlining the
free function and calls unconditionally fail in get_header as
header->allocation_index (type == size_t) is always >= allocation_index (= 0).
Before the mentioned commit above, strdup was replaced by strlen, malloc and
memcpy. The malloc call was also inlined and allocation_index was set to one.
This patch moves the already existing compiler barrier before the invocation
of free.
ChangeLog:
* malloc/tst-interpose-aux.c (check_for_allocations):
Move compiler barrier before free.
POSIX specifies long as the type of elements of struct mq_attr. For
x32, they are __syscall_slong_t (i.e. long long). This patch XFAILs
the corresponding tests for x32 in the conformtest expectations (the
bug should not be closed without an actual fix).
Tested with build-many-glibcs.py.
[BZ #21279]
* sysdeps/unix/sysv/linux/x86_64/x32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): Update comment.
* conform/data/mqueue.h-data (mq_attr.mq_flags): XFAIL for
x86_64-x32-linux.
(mq_attr.mq_maxmsg): Likewise.
(mq_attr.mq_msgsize): Likewise.
(mq_attr.mq_curmsgs): Likewise.
MIPS o32 struct stat has the wrong type of st_rdev. This patch XFAILs
that test in the conformtest expectations for this case (the bug
should not be closed without an actual fix, however).
Tested with build-many-glibcs.py.
[BZ #21278]
* sysdeps/unix/sysv/linux/mips/mips32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): Update comment.
* conform/data/sys/stat.h-data (stat.st_rdev): XFAIL for
mips-o32-linux.
sysdeps/unix/sysv/linux/alpha/bits/termios.h defines NL2 and NL3 for
__USE_MISC || __USE_XOPEN. These should only be defined for
__USE_MISC as they are not part of any standard namespace. This patch
conditions them accordingly, matching the powerpc version of the
header (the only other one in glibc that defines these macros).
Tested (compilation only) with build-many-glibcs.py.
[BZ #21268]
* sysdeps/unix/sysv/linux/alpha/bits/termios.h (NL2): Define only
if [__USE_MISC]
(NL3): Likewise.
The ia64-specific clone2 call expects the base of the stack mapping and
the stack size as sep arguments, not an initial stack value as on other
stack-grows-down architectures. Reuse the stack-grows-up macro so we
pass in the right stack base.
Reported-by: Matt Turner <mattst88@gentoo.org>
If a link (say /proc/self/fd/0) pointing to a device, say /dev/pts/2, in a
parent mount namespace is passed to ttyname, and a /dev/pts/2 exists (in a
different devpts) in the current namespace, then it returns /dev/pts/2.
But /dev/pts/2 is NOT the current tty, it is a different file and device.
Detect this case and return ENODEV. Userspace can choose to take this as a hint
that the fd points to a tty device but to act on the fd rather than the link.
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This patch XFAILs the conformtest tv_nsec tests for x32 so that the
incorrect type does not potentially hide other failures. As this is
not a fix for the bug, it should remain open in Bugzilla.
Tested (compilation only) with build-many-glibcs.py.
[BZ #16437]
* sysdeps/unix/sysv/linux/x86_64/x32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): New variable.
* conform/data/signal.h-data (timespec.tv_nsec): XFAIL for
x86_64-x32-linux.
* conform/data/sys/select.h-data (timespec.tv_nsec): Likewise.
* conform/data/sys/stat.h-data (timespec.tv_nsec): Likewise.
* conform/data/time.h-data (timespec.tv_nsec): Likewise.
sysdeps/unix/sysv/linux/sparc/bits/setjmp.h defines 64-bit __jmp_buf
with a load of identifiers that are not part of any standard
namespace, resulting in conform/ tests failing. This patch fixes this
by moving those identifiers to the implementation namespace, so
enabling the conform/ tests to pass for sparc64.
Tested (compilation only) for sparc64 with build-many-glibcs.py.
[BZ #21261]
* sysdeps/unix/sysv/linux/sparc/bits/setjmp.h
[__WORDSIZE == 64 && !_ASM] (__sparc64_jmp_buf): Use reserved
names for all fields.
* sysdeps/sparc/sparc64/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Update
for jmp_buf field renaming.
(_JMPBUF_UNWINDS_ADJ): Likewise.
This patch fixes the conformtest handling of headers listed in
allow-header to process xfail[cond]- in the expectations for those
headers.
Tested with build-many-glibcs.py.
* conform/conformtest.pl: Handle xfail[cond]- in header mentioned
with allow-header.
Additional check for chunk_size == next->prev->chunk_size in unlink()
2017-03-17 Chris Evans <scarybeasts@gmail.com>
* malloc/malloc.c (unlink): Add consistency check between size and
next->prev->size, to further harden against 1-byte overflows.
sysdeps/unix/sysv/linux/alpha/bits/termios.h defines IXANY only if
__USE_MISC. But it's in the base standard for POSIX.1:2008, and
XSI-shaded in previous standards. This patch makes the header define
it unconditionally, like other versions of this header do (it's always
reserved by standards that don't require it, so defining
unconditionally is OK by the standards).
Tested (compilation only) for alpha with build-many-glibcs.py. Note
that there are still termios.h conformtest failures after this patch
because of other issues with the alpha version of this header.
[BZ #21259]
* sysdeps/unix/sysv/linux/alpha/bits/termios.h (IXANY): Define
unconditionally, not just for [__USE_MISC].
As noted in bug 17786, MIPS o32 struct stat has the wrong type of
st_dev. This patch XFAILs that test in the conformtest expectations
for this case (the test still fails after the patch because there's
also a similar issue for st_rdev that needs reporting and XFAILing
separately, and the bug should not be closed without an actual fix,
not just XFAILing).
Tested for mips with build-many-glibcs.py.
[BZ #17786]
* sysdeps/unix/sysv/linux/mips/mips32/Makefile: New file.
* conform/data/sys/stat.h-data (stat.st_dev): XFAIL for
mips-o32-linux.
As noted in bug 21260, sysdeps/unix/sysv/linux/alpha/bits/netdb.h
defines struct netent with n_net of type unsigned long instead of the
correct uint32_t. This patch XFAILs that test in the conformtest
expectations for alpha. (This is not a fix for the bug, and it should
not be closed without an actual fix.)
Tested for alpha with build-many-glibcs.py.
[BZ #21260]
* sysdeps/unix/sysv/linux/alpha/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): New variable.
This patch makes conformtest skip execution tests when
cross-compiling, as an interim step towards running most of these
tests (presently disabled) in that case. It omits the (obvious)
Makefile change to actually enable the conformtest tests when
cross-compiling, as there are still enough failures seen with
build-many-glibcs.py that I'd like to get the results cleaner before
enabling these tests.
Tested for x86_64, and with the tests actually enabled for
cross-compilation with build-many-glibcs.py.
* conform/conformtest.pl ($cross): New variable.
(--cross): New command-line option.
(runtest): Skip test execution when cross-compiling.
* conform/Makefile (conformtest-cross): New variable.
($(conformtest-header-tests)): Pass $(conformtest-cross) to
conformtest.pl.
conformtest has an internal XFAIL mechanism to allow failures of
individual expectations to be ignored, so that known hard-to-fix
failures (e.g. those affecting ABIs or requiring kernel changes) do
not cause the overall tests to FAIL and so hide other failures from
the same (header, standard) pair.
Various such bugs are system-specific, so this patch adds a mechanism
to allow system-specific XFAILs. A system-independent XFAIL is
achieved by putting "xfail-" at the start of the relevant expectation
in the *-data files. A system-specific XFAIL instead uses
"xfail[cond]-", where "cond" is a condition listed in
conformtest-xfail-conds in a sysdeps makefile (so one for x32 might
set conformtest-xfail-conds = x86_64-x32-linux, for example, and then
an expectation for tv_nsec's type could use
xfail[x86_64-x32-linux]-). The actual names are arbitrary, just
needing to match between the makefiles and the expectations, and if
necessary you can use "xfail[cond1|cond2]-" for a test that is
expected to fail under multiple conditions. As with
system-independent XFAILs, I think system-specific ones should have a
bug filed in Bugzilla and a comment referencing that bug.
Tested for x86_64, including with test expectations and makefiles
changed to use the new facility.
* conform/conformtest.pl ($xfail_str): New variable.
(--xfail=): New command-line option.
(top level): Handle expectations starting xfail[cond]-.
* conform/Makefile (conformtest-xfail): New variable.
($(conformtest-header-tests)): Pass $(conformtest-xfail) to
conformtest.pl.
The conformtest header tests test some things through compilation
tests and others through execution tests. This patch makes more of
the tests into compilation tests, using _Static_assert (note: for
float.h tests on floating-point values this is depending on a GNU
extension, that those assertions are allowed in the absence of
-pedantic although they aren't strictly integer constant expressions).
The remaining execution tests are for values of things listed as
"symbol" (in fact no such things have a value expectation listed) and
for values of macros defined as string constants (three such values
listed in total).
This is intended as preparation for enabling the vast bulk of the
tests to run for cross compilation. (Even the few remaining execution
tests ought in principle to run for cross compilation when a test
wrapper is defined, but that's more complicated. The existing
execution tests for native builds in fact are linked and run with an
existing installed libc that's required to exist to link against,
rather than with the newly built libc; only the new headers are used.)
Tested for x86_64.
* conform/conformtest.pl: Use compilation instead of execution
tests for testing values of constants and usability in #if.
Mark 4 catan and catanh tests as xfail-rounding:ibm128-libgcc.
After this patch all catan and catanh tests pass on ibm128.
Regenerated auto-libm-test-out using gmp 6.1.2, mpfr 3.1.5 and upstream
mpc (9ef8030e50),
Tested on powerpc, powerpc64 and powerpc64le.
* math/auto-libm-test-in: Mark some catan and catanh as
xfail-rounding:ibm128-libgcc.
* math/auto-libm-test-out-catan: Regenerate.
* math/auto-libm-test-out-catanh: Likewise.
glibc headers include some code (not particularly consistent or
systematic) to put various declarations in C++ namespaces std and
__c99, if _GLIBCPP_USE_NAMESPACES is defined.
As noted in <https://gcc.gnu.org/ml/libstdc++/2017-03/msg00025.html>,
this macro was removed from libstdc++ in 2000. I don't expect
compilation with such old versions of libstdc++ to work with current
glibc headers anyway (whereas old *binaries* are expected to stay
working with current glibc); this patch (which should be a no-op with
any libstdc++ version postdating that removal) removes all this code
from the glibc headers.
The begin-end-check.pl test, whose comments say it is about checking
these namespace macro calls, is also removed. The code in that test
would have covered __BEGIN_DECLS / __END_DECLS as well, but if those
weren't properly matched it would show up with the
check-installed-headers-cxx tests, so I don't think there is an actual
use for keeping begin-end-check.pl with the namespace code removed.
Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).
* misc/sys/cdefs.h (__BEGIN_NAMESPACE_STD): Remove macro.
(__END_NAMESPACE_STD): Likewise.
(__USING_NAMESPACE_STD): Likewise.
(__BEGIN_NAMESPACE_C99): Likewise.
(__END_NAMESPACE_C99): Likewise.
(__USING_NAMESPACE_C99): Likewise.
* math/math.h (_Mdouble_BEGIN_NAMESPACE): Do not define and
undefine macro.
(_Mdouble_END_NAMESPACE): Likewise.
* ctype/ctype.h: Do not handle C++ namespaces.
* libio/bits/stdio-ldbl.h: Likewise.
* libio/stdio.h: Likewise.
* locale/locale.h: Likewise.
* math/bits/mathcalls.h: Likewise.
* setjmp/setjmp.h: Likewise.
* signal/signal.h: Likewise.
* stdlib/bits/stdlib-float.h: Likewise.
* stdlib/bits/stdlib-ldbl.h: Likewise.
* stdlib/stdlib.h: Likewise.
* string/string.h: Likewise.
* sysdeps/x86/fpu/bits/mathinline.h: Likewise.
* time/bits/types/clock_t.h: Likewise.
* time/bits/types/struct_tm.h: Likewise.
* time/bits/types/time_t.h: Likewise.
* time/time.h: Likewise.
* wcsmbs/bits/wchar-ldbl.h: Likewise.
* wcsmbs/uchar.h: Likewise.
* wcsmbs/wchar.h: Likewise.
[_GLIBCPP_USE_NAMESPACES] (wint_t): Remove conditional definition.
* wctype/wctype.h: Do not handle C++ namespaces.
* scripts/begin-end-check.pl: Remove.
* Makefile (installed-headers): Likewise.
(tests-special): Do not add $(objpfx)begin-end-check.out.
($(objpfx)begin-end-check.out): Remove.
When glibc is compiled with gcc 6.2 that has been configured with
to default to PIC/PIE, the static version of __mempcpy_chk is not built,
as the test is done on PIC instead of SHARED. Fix the test to check for
SHARED, like it is done for similar functions like __memcpy_chk.
2017-03-12 Mike Frysinger <vapier@gentoo.org>
* sysdeps/x86_64/mempcpy_chk.S (__mempcpy_chk): Check for SHARED
instead of PIC.
Bug 21094 reports 3ulp errors of cosf and tanf for certain arguments
near pi/2 arising from the use of an insufficiently accurate range
reduction. (To be clear, this is a quality-of-implementation issue
relating to the apparent intent of those particular cosf and tanf
implementations; 3ulp is within the general glibc accuracy goals, so
not inherently a bug.)
This patch fixes that error by making a wider range of cases use the
existing more accurate range reduction for arguments close to pi/2.
The wider range of values is still narrow enough for the "z -=
pio2_2;" in the more accurate case to be exact, as the code expects.
Tested for x86_64, x86 and mips64; no ulps updates needed (but at
least on mips64, the larger ulps were seen if the tests were added
without the substantive fix).
[BZ #21094]
* sysdeps/ieee754/flt-32/e_rem_pio2f.c (__ieee754_rem_pio2f): Use
24+24+24-bit pi for wider range of values around pi/2.
* math/auto-libm-test-in: Add more tests of cos and tan.
* math/auto-libm-test-out-cos: Regenerated.
* math/auto-libm-test-out-tan: Likewise.
The test for "-z combreloc" fails when cross-compiling on a machine
that uses BSD grep (e.g. on macos). grep complains about empty
subexpression and exits with non-zero status, which is interpreted
by configure as "not found". As a result, support for "-z combreloc"
(HAVE_Z_COMBRELOC) is not detected, leading to link failure on SPARC.
While there, replace fgrep with 'grep -F', as fgrep is non-POSIX.
* configure.ac: Avoid empty subexpression in grep.
Signed-off-by: Alexey Neyman <stilor@att.net>