about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename the glibc.tune namespace to glibc.cpuSiddhesh Poyarekar2018-08-0217-45/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The glibc.tune namespace is vaguely named since it is a 'tunable', so give it a more specific name that describes what it refers to. Rename the tunable namespace to 'cpu' to more accurately reflect what it encompasses. Also rename glibc.tune.cpu to glibc.cpu.name since glibc.cpu.cpu is weird. * NEWS: Mention the change. * elf/dl-tunables.list: Rename tune namespace to cpu. * sysdeps/powerpc/dl-tunables.list: Likewise. * sysdeps/x86/dl-tunables.list: Likewise. * sysdeps/aarch64/dl-tunables.list: Rename tune.cpu to cpu.name. * elf/dl-hwcaps.c (_dl_important_hwcaps): Adjust. * elf/dl-hwcaps.h (GET_HWCAP_MASK): Likewise. * manual/README.tunables: Likewise. * manual/tunables.texi: Likewise. * sysdeps/powerpc/cpu-features.c: Likewise. * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features): Likewise. * sysdeps/x86/cpu-features.c: Likewise. * sysdeps/x86/cpu-features.h: Likewise. * sysdeps/x86/cpu-tunables.c: Likewise. * sysdeps/x86_64/Makefile: Likewise. * sysdeps/x86/dl-cet.c: Likewise. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Do not define various fenv.h macros for MIPS soft-float (bug 23479).Joseph Myers2018-08-025-16/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MIPS soft-float glibc does not support floating-point exceptions and rounding modes, and uses a different ABI from hard-float so a soft-float compilation cannot use a glibc that does support floating-point exceptions and rounding modes. Thus, bits/fenv.h should not, when compiling for soft-float, define macros for the unsupported features. This patch changes it accordingly to define those macros only for hard-float. None of the exception macros are defined for soft-float, with FE_ALL_EXCEPT defined to 0 in that case, and only FE_TONEAREST is defined of the rounding-mode macros, and FE_NOMASK_ENV is not defined; this is consistent with how architectures lacking exception and rounding mode support generally define things in this header. As well as making the header more correct for this case, this also means the generic math_private.h optimizations for this case automatically apply (inlining libm-internal fenv.h function calls that are trivial when exceptions and rounding modes are not supported). The mips64 sfp-machine.h then needs similar changes to disable more of the exception and rounding mode handling for soft-float. (The mips32 sfp-machine.h is already used only for soft-float, has no integration with hardware exceptions or rounding modes and so needs no changes.) Existing binaries might use the old FE_NOMASK_ENV value as an argument to fesetenv / feupdateenv and expect an error for it (given that it was defined in a header that also defined FE_ALL_EXCEPT to a nonzero value). To preserve that error, wrappers for the fallback fesetenv and feupdateenv are created in sysdeps/mips/nofpu/. Tested for mips64 (hard-float and soft-float, all three ABIs). [BZ #23479] * sysdeps/mips/bits/fenv.h (FE_INEXACT): Define only if [__mips_hard_float]. (FE_UNDERFLOW): Likewise. (FE_OVERFLOW): Likewise. (FE_DIVBYZERO): Likewise. (FE_INVALID): Likewise. (FE_ALL_EXCEPT): Define to 0 if [!__mips_hard_float]. (FE_TOWARDZERO): Define only if [__mips_hard_float]. (FE_UPWARD): Likewise. (FE_DOWNWARD): Likewise. (__FE_UNDEFINED): Define if [!__mips_hard_float] (FE_NOMASK_ENV): Define only if [__mips_hard_float]. * sysdeps/mips/mips64/sfp-machine.h (_FP_DECL_EX): Define only if [__mips_hard_float]. (FP_ROUNDMODE): Likewise. (FP_RND_NEAREST): Likewise. (FP_RND_ZERO): Likewise. (FP_RND_PINF): Likewise. (FP_RND_MINF): Likewise. (FP_EX_INVALID): Likewise. (FP_EX_OVERFLOW): Likewise. (FP_EX_UNDERFLOW): Likewise. (FP_EX_DIVZERO): Likewise. (FP_EX_INEXACT): Likewise. (FP_INIT_ROUNDMODE): Likewise. * sysdeps/mips/nofpu/fesetenv.c: New file. * sysdeps/mips/nofpu/feupdateenv.c: Likewise.
* Fix math/test-misc.c for undefined fenv.h macros.Joseph Myers2018-08-012-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | math/test-misc.c contains some code that uses fenv.h macros FE_UNDERFLOW, FE_OVERFLOW and FE_UPWARD without being conditional on those macros being defined. That would normally break the build for configurations (typically soft-float) not defining those macros. However, the code in question is inside LDBL_MANT_DIG > DBL_MANT_DIG conditionals. And, while we have configurations lacking rounding mode and exception support where LDBL_MANT_DIG > DBL_MANT_DIG (soft-float MIPS64 and RISC-V), those configurations currently define the fenv.h macros in question even for soft-float. There may be some case for defining those macros in cases where a soft-float compilation could use a hard-float libm (where both soft-float and hard-float can use the same ABI, as on ARM and RISC-V, for example). But MIPS is not such a case - the hard-float and soft-float ABIs are incompatible - and thus I am testing a patch to stop defining those macros for soft-float MIPS (motivated by reducing the extent to which architectures need their own definitions of math-tests.h macros - if lack of rounding mode / exception support can be determined by the lack of macros in fenv.h, that avoids the need for math-tests.h to declare that lack as well). Introducing a case of LDBL_MANT_DIG > DBL_MANT_DIG without these macros defined shows up the problem with math/test-misc.c. This patch then fixes that problem by adding appropriate conditionals. Tested for MIPS64 in conjunction with changes to stop defining the macros in question in bits/fenv.h for soft-float. * math/test-misc.c (do_test) [LDBL_MANT_DIG > DBL_MANT_DIG]: Make code using FE_UNDERFLOW conditional on [FE_UNDERFLOW], code using FE_OVERFLOW conditional on [FE_OVERFLOW] and code using FE_UPWARD conditional on [FE_UPWARD].
* regex: fix memory leak in GnulibPaul Eggert2018-08-012-1/+10
| | | | | | | | Problem and fix reported by Assaf Gordon in: https://lists.gnu.org/r/bug-gnulib/2018-07/txtqLKNwBdefE.txt * posix/regcomp.c (free_charset) [!_LIBC]: Free range_starts and range_ends members too, as they are defined in 'struct re_charset_t' even if not _LIBC. This affects only Gnulib.
* x86: Rename get_common_indeces to get_common_indicesH.J. Lu2018-08-012-4/+11
| | | | | | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> * sysdeps/x86/cpu-features.c (get_common_indeces): Renamed to ... (get_common_indices): This. (init_cpu_features): Updated.
* Move SNAN_TESTS_PRESERVE_PAYLOAD out of math-tests.h.Joseph Myers2018-08-018-19/+103
| | | | | | | | | | | | | | | | | | | | | Continuing moving macros out of math-tests.h to smaller headers following typo-proof conventions instead of using #ifndef, this patch moves SNAN_TESTS_PRESERVE_PAYLOAD out to its own sysdeps header. Tested with build-many-glibcs.py. * sysdeps/generic/math-tests-snan-payload.h: New file. * sysdeps/hppa/math-tests-snan-payload.h: Likewise. * sysdeps/mips/math-tests-snan-payload.h: Likewise. * sysdeps/riscv/math-tests-snan-payload.h: Likewise. * sysdeps/generic/math-tests.h: Include <math-tests-snan-payload.h>. (SNAN_TESTS_PRESERVE_PAYLOAD): Do not define macro here. * sysdeps/hppa/math-tests.h: Remove file. * sysdeps/mips/math-tests.h [!__mips_nan2008] (SNAN_TESTS_PRESERVE_PAYLOAD): Do not define macro here. * sysdeps/riscv/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): Likewise.
* Move SNAN_TESTS_TYPE_CAST out of math-tests.h.Joseph Myers2018-08-015-14/+66
| | | | | | | | | | | | | | | | | | | | | | The math-tests.h header has many different macros and groups of macros, defined using #ifndef in the generic version which is included by architecture versions with #include_next after possibly defining non-default versions of some of those macros. This use of #ifndef is contrary to our normal typo-proof conventions for macro definitions. This patch moves one of the macros, SNAN_TESTS_TYPE_CAST, out to its own sysdeps header, to follow those typo-proof conventions more closely. Tested with build-many-glibcs.py. 2018-08-01 Joseph Myers <joseph@codesourcery.com> * sysdeps/generic/math-tests-snan-cast.h: New file. * sysdeps/powerpc/math-tests-snan-cast.h: Likewise. * sysdeps/generic/math-tests.h: Include <math-tests-snan-cast.h>. (SNAN_TESTS_TYPE_CAST): Do not define macro here. * sysdeps/powerpc/math-tests.h (SNAN_TESTS_TYPE_CAST): Likewise.
* Add version.h, and NEWS update to ChangeLog.Carlos O'Donell2018-08-011-0/+4
|
* Open master branch for glibc 2.29 development glibc-2.28.9000Carlos O'Donell2018-08-012-2/+26
|
* Update NEWS, version.h, and features.h for glibc 2.28. glibc-2.28Carlos O'Donell2018-08-014-5/+188
|
* Synchronize translation project PO files.Carlos O'Donell2018-08-0125-46025/+62196
|
* hurd: Fix exec usage of mach_setup_threadSamuel Thibault2018-08-018-11/+41
| | | | | | | | | | | | | | | | Exec needs that mach_setup_thread does *not* set up TLS since it works on another task, so we have to split this into mach_setup_tls. * mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes. * mach/setup-thread.c (__mach_setup_thread): Move TLS setup to... (__mach_setup_tls): ... new function. (mach_setup_tls): New alias. * hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after __mach_setup_thread. * sysdeps/mach/hurd/profil.c (update_waiter): Likewise. * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise. * mach/Versions [libc] (mach_setup_tls): Add symbol. * sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
* hurd: Add missing ChangeLog entrySamuel Thibault2018-08-011-0/+6
|
* hurd: Fix startup of static binaries linked against libpthreadSamuel Thibault2018-07-311-33/+35
| | | | | | * sysdeps/mach/hurd/i386/init-first.c (init1): Move ELF hdr and TLS initialization... (init): ... before initializing libpthread.
* Update tooling versions verified to work with glibc.Carlos O'Donell2018-07-313-20/+47
|
* Update contrib.texi contributions.Carlos O'Donell2018-07-312-12/+33
|
* Update translation for be.Carlos O'Donell2018-07-312-1214/+1052
|
* Update SH libm-tests-ulpsAdhemerval Zanella2018-07-312-4/+16
| | | | * sysdeps/sh/libm-test-ulps: Update.
* Update translations for bg, de, hr, pt_BR, sv, and vi.Carlos O'Donell2018-07-317-4699/+5221
|
* x86/CET: Fix property note parser [BZ #23467]H.J. Lu2018-07-306-9/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | GNU_PROPERTY_X86_FEATURE_1_AND may not be the first property item. We need to check each property item until we reach the end of the property or find GNU_PROPERTY_X86_FEATURE_1_AND. This patch adds 2 tests. The first test checks if IBT is enabled and the second test reads the output from the first test to check if IBT is is enabled. The second second test fails if IBT isn't enabled properly. Reviewed-by: Carlos O'Donell <carlos@redhat.com> [BZ #23467] * sysdeps/unix/sysv/linux/x86/Makefile (tests): Add tst-cet-property-1 and tst-cet-property-2 if CET is enabled. (CFLAGS-tst-cet-property-1.o): New. (ASFLAGS-tst-cet-property-dep-2.o): Likewise. ($(objpfx)tst-cet-property-2): Likewise. ($(objpfx)tst-cet-property-2.out): Likewise. * sysdeps/unix/sysv/linux/x86/tst-cet-property-1.c: New file. * sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c: Likewise. * sysdeps/unix/sysv/linux/x86/tst-cet-property-dep-2.S: Likewise. * sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Parse each property item until GNU_PROPERTY_X86_FEATURE_1_AND is found.
* x86: Add tst-get-cpu-features-static to $(tests) [BZ #23458]H.J. Lu2018-07-302-1/+6
| | | | | | | | | All tests should be added to $(tests). Reviewed-by: Carlos O'Donell <carlos@redhat.com> [BZ #23458] * sysdeps/x86/Makefile (tests): Add tst-get-cpu-features-static.
* hurd: Fix some ld.so symbol override from libcSamuel Thibault2018-07-283-1/+23
| | | | | | | | ld.so symbols to be overriden by libc need to be extern to really get overriden. * sysdeps/mach/hurd/not-errno.h: New file. * sysdeps/mach/hurd/i386/localplt.data: Update accordingly.
* hurd: Fix some ld.so symbol override from libcSamuel Thibault2018-07-284-12/+15
| | | | | | | | | | ld.so symbols to be overriden by libc need to be extern to really get overriden. * sysdeps/mach/hurd/dl-unistd.h (__access, __brk, __lseek, __read, __sbrk): Do not set attribute_hidden. * sysdeps/mach/hurd/i386/ld.abilist: Update accordingly. * sysdeps/mach/hurd/i386/localplt.data: Update accordingly.
* Update translations for cs, pl, and uk.Carlos O'Donell2018-07-274-1140/+1242
|
* x86/CET: Don't parse beyond the note endH.J. Lu2018-07-272-1/+6
| | | | | | | | | Simply check if "ptr < ptr_end" since "ptr" is always incremented by 8. Reviewed-by: Carlos O'Donell <carlos@redhat.com> * sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Don't parse beyond the note end.
* Update NEWS with ISO 14651 update information.Carlos O'Donell2018-07-271-0/+12
|
* NEWS: Avoid the words "nominative" and "genitive".Rafal Luzynski2018-07-271-3/+4
| | | | | | | | | Glibc supports two grammatical forms of month names and we keep adding the locale data which actually use this feature but those two forms are not necessarily nominative and genitive. It is better to use a more generic term. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Fix Linux fcntl OFD locks on unsupported kernelsAdhemerval Zanella2018-07-273-2/+18
| | | | | | | | | | | This patch make the OFD tests return unsupported if kernel does not support OFD locks (it was added on 3.15). Checked on a ia64-linux-gnu with Linux 3.14. * sysdeps/unix/sysv/linux/tst-ofdlocks.c: Return unsupported if kernel does not support OFD locks. * sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
* Add the missing ChangeLog entry for commit be525a69a66H.J. Lu2018-07-271-0/+10
|
* hurd: Fix some ld.so symbol override from libcSamuel Thibault2018-07-276-8/+34
| | | | | | | | | | | | | | ld.so symbols to be overriden by libc need to be extern to really get overriden. More fixes are needed to avoid the hidden attribute. * sysdeps/mach/hurd/Versions (libc): Make __access and __access_noerrno external so they can override the ld symbols. (ld): Make __access, __read, __sbrk, __strtoul_internal, __write, __writev, __open64, __access_noerrno extern so they can be overrided. * sysdeps/mach/hurd/i386/libc.abilist: Update accordingly. * sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.
* Update libc.pot.Carlos O'Donell2018-07-262-353/+375
|
* Update powerpc-nofpu ulps.Joseph Myers2018-07-262-0/+39
| | | | * sysdeps/powerpc/nofpu/libm-test-ulps: Update.
* x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]H.J. Lu2018-07-262-10/+19
| | | | | | | | | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> [BZ #23459] * sysdeps/x86/cpu-features.c (get_extended_indices): New function. (init_cpu_features): Call get_extended_indices for both Intel and AMD CPUs. * sysdeps/x86/cpu-features.h (COMMON_CPUID_INDEX_80000001): Remove "for AMD" comment.
* x86: Correct index_cpu_LZCNT [BZ # 23456]H.J. Lu2018-07-262-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | cpu-features.h has #define bit_cpu_LZCNT (1 << 5) #define index_cpu_LZCNT COMMON_CPUID_INDEX_1 #define reg_LZCNT But the LZCNT feature bit is in COMMON_CPUID_INDEX_80000001: Initial EAX Value: 80000001H ECX Extended Processor Signature and Feature Bits: Bit 05: LZCNT available index_cpu_LZCNT should be COMMON_CPUID_INDEX_80000001, not COMMON_CPUID_INDEX_1. The VMX feature bit is in COMMON_CPUID_INDEX_1: Initial EAX Value: 01H Feature Information Returned in the ECX Register: 5 VMX Reviewed-by: Carlos O'Donell <carlos@redhat.com> [BZ # 23456] * sysdeps/x86/cpu-features.h (index_cpu_LZCNT): Set to COMMON_CPUID_INDEX_80000001.
* Fix string/tst-xbzero-opt if build with gcc head.Stefan Liebler2018-07-262-0/+20
| | | | | | | | | | | | | | | | | | | | | | On s390x, the test string/tst-xbzero-opt is failing if build with gcc head: FAIL: no clear/prepare: expected 32 got 0 FAIL: no clear/test: expected some got 0 FAIL: ordinary clear/prepare: expected 32 got 0 INFO: ordinary clear/test: found 0 patterns (memset not eliminated) PASS: explicit clear/prepare: expected 32 got 32 PASS: explicit clear/test: expected 0 got 0 In setup_no_clear / setup_ordinary_clear, GCC is omitting the memcpy loop in prepare_test_buffer. Thus count_test_patterns does not find any of the test_pattern. This patch calls use_test_buffer in order to force the compiler to really copy the pattern to buf. ChangeLog: * string/tst-xbzero-opt.c (use_test_buffer): New function. (prepare_test_buffer): Call use_test_buffer as compiler barrier.
* htl: Use weak aliases for public symbolsFlorian Weimer2018-07-262-3/+8
| | | | | Strong definitions of flockfile, funlockfile, ftrylockfile can conflict with application symbols when linking statically.
* Add missing localedata/en_US.UTF-8.in (Bug 23393).Carlos O'Donell2018-07-251-0/+2159
| | | | | Commit 7cd7d36f1feb3ccacf476e909b115b45cdd46e77 failed to include the new testing file en_US.UTF-8.in.
* Keep expected behaviour for [a-z] and [A-z] (Bug 23393).Carlos O'Donell2018-07-255-1008/+1065
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In commit 9479b6d5e08eacce06c6ab60abc9b2f4eb8b71e4 we updated all of the collation data to harmonize with the new version of ISO 14651 which is derived from Unicode 9.0.0. This collation update brought with it some changes to locales which were not desirable by some users, in particular it altered the meaning of the locale-dependent-range regular expression, namely [a-z] and [A-Z], and for en_US it caused uppercase letters to be matched by [a-z] for the first time. The matching of uppercase letters by [a-z] is something which is already known to users of other locales which have this property, but this change could cause significant problems to en_US and other similar locales that had never had this change before. Whether this behaviour is desirable or not is contentious and GNU Awk has this to say on the topic: https://www.gnu.org/software/gawk/manual/html_node/Ranges-and-Locales.html While the POSIX standard also has this further to say: "RE Bracket Expression": http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html "The current standard leaves unspecified the behavior of a range expression outside the POSIX locale. ... As noted above, efforts were made to resolve the differences, but no solution has been found that would be specific enough to allow for portable software while not invalidating existing implementations." In glibc we implement the requirement of ISO POSIX-2:1993 and use collation element order (CEO) to construct the range expression, the API internally is __collseq_table_lookup(). The fact that we use CEO and also have 4-level weights on each collation rule means that we can in practice reorder the collation rules in iso14651_t1_common (the new data) to provide consistent range expression resolution *and* the weights should maintain the expected total order. Therefore this patch does three things: * Reorder the collation rules for the LATIN script in iso14651_t1_common to deinterlace uppercase and lowercase letters in the collation element orders. * Adds new test data en_US.UTF-8.in for sort-test.sh which exercises strcoll* and strxfrm* and ensures the ISO 14651 collation remains. * Add back tests to tst-fnmatch.input and tst-regexloc.c which exercise that [a-z] does not match A or Z. The reordering of the ISO 14651 data is done in an entirely mechanical fashion using the following program attached to the bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23393#c28 It is up for discussion if the iso14651_t1_common data should be refined further to have 3 very tight collation element ranges that include only a-z, A-Z, and 0-9, which would implement the solution sought after in: https://sourceware.org/bugzilla/show_bug.cgi?id=23393#c12 and implemented here: https://www.sourceware.org/ml/libc-alpha/2018-07/msg00854.html No regressions on x86_64. Verified that removal of the iso14651_t1_common change causes tst-fnmatch to regress with: 422: fnmatch ("[a-z]", "A", 0) = 0 (FAIL, expected FNM_NOMATCH) *** ... 425: fnmatch ("[A-Z]", "z", 0) = 0 (FAIL, expected FNM_NOMATCH) ***
* ia64: Work around incorrect type of IA64 uc_sigmaskH.J. Lu2018-07-252-0/+30
| | | | | | | | Work around: https://sourceware.org/bugzilla/show_bug.cgi?id=21634 * sysdeps/unix/sysv/linux/ia64/tst-setcontext4.c: New file.
* Fix ISO C threads installed header and HURD assumptionAdhemerval Zanella2018-07-254-208/+276
| | | | | | | | | | | | | Set installed NPTL header as the expected one (instead of an internal one for glibc testsuite) and add a hurd specific stdc-predef with __STDC_NO_THREADS__. Checked on both i686-linux-gnu and i686-gnu that both threads.h and stdc-predef.h are the expected ones. * nptl/threads.h: Move to ... * sysdeps/nptl/threads.h: ... here. * sysdeps/hurd/stdc-predef.h: New file.
* x86/CET: Add a setcontext test for CETH.J. Lu2018-07-253-0/+141
| | | | | | | | | | Verify that setcontext works with gaps above and below the newly allocated shadow stack. * sysdeps/unix/sysv/linux/x86/Makefile (tests): Add tst-cet-setcontext-1 if CET is enabled. (CFLAGS-tst-cet-setcontext-1.c): Add -mshstk. * sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c: New file.
* Fix C11 conformance issuesAdhemerval Zanella2018-07-254-3/+12
| | | | | | | | | | | | | | | | | | | | | | | Remove conformace assumption of NPTL implementation for ISO C threads and revert wrong libcrypt addition on linknamespace-libs-XPG4. The i686-gnu target now shows two new conformance failures: FAIL: conform/ISO11/threads.h/conform FAIL: conform/ISO11/threads.h/linknamespace It is expected due missing HTL ISO C threads support and both conformance .out files indicates the reason ("#error "HTL does not implement ISO C threads"). Checked on i686-linux-gnu and i686-gnu. * include/threads.h: Move to ... * sysdeps/nptl/threads.h: ... here. * sysdeps/htl/threads.h: New file. * conform/Makefile (linknamespace-libs-ISO11): Use static-thread-library instead of linking libpthread. (linknamespace-libs-XPG4): Revert wrong libcrypt.a addition.
* C11 threads: Fix timeout and locking issuesFlorian Weimer2018-07-255-2/+61
|
* x86-64/CET: Extend ucontext_t to save shadow stackH.J. Lu2018-07-259-1/+421
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a field to ucontext_t to save shadow stack: 1. getcontext and swapcontext are updated to save the caller's shadow stack pointer and return addresses. 2. setcontext and swapcontext are updated to restore shadow stack and jump to new context directly. 3. makecontext is updated to allocate a new shadow stack and set the caller's return address to __start_context. Since makecontext allocates a new shadow stack when making a new context and kernel allocates a new shadow stack for clone/fork/vfork syscalls, we track the current shadow stack base. In setcontext and swapcontext, if the target shadow stack base is the same as the current shadow stack base, we unwind the shadow stack. Otherwise it is a stack switch and we look for a restore token. We enable shadow stack at run-time only if program and all used shared objects, including dlopened ones, are shadow stack enabled, which means that they must be compiled with GCC 8 or above and glibc 2.28 or above. We need to save and restore shadow stack only if shadow stack is enabled. When caller of getcontext, setcontext, swapcontext and makecontext is compiled with smaller ucontext_t, shadow stack won't be enabled at run-time. We check if shadow stack is enabled before accessing the extended field in ucontext_t. Reviewed-by: Carlos O'Donell <carlos@redhat.com> * sysdeps/unix/sysv/linux/x86/sys/ucontext.h (ucontext_t): Add __ssp. * sysdeps/unix/sysv/linux/x86_64/__start_context.S: Include <asm/prctl.h> and "ucontext_i.h" when shadow stack is enabled. (__push___start_context): New. * sysdeps/unix/sysv/linux/x86_64/getcontext.S: Include <asm/prctl.h>. (__getcontext): Record the current shadow stack base. Save the caller's shadow stack pointer and base. * sysdeps/unix/sysv/linux/x86_64/makecontext.c: Include <pthread.h>, <libc-pointer-arith.h> and <sys/prctl.h>. (__push___start_context): New prototype. (__makecontext): Call __push___start_context to allocate a new shadow stack, push __start_context onto the new stack as well as the new shadow stack. * sysdeps/unix/sysv/linux/x86_64/setcontext.S: Include <asm/prctl.h>. (__setcontext): Restore the target shadow stack. * sysdeps/unix/sysv/linux/x86_64/swapcontext.S: Include <asm/prctl.h>. (__swapcontext): Record the current shadow stack base. Save the caller's shadow stack pointer and base. Restore the target shadow stack. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT): New. * sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym (oSSP): New.
* Add tests for setcontext on the context from makecontextH.J. Lu2018-07-256-1/+369
| | | | | | | | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> * stdlib/Makefile ((tests): Add tst-setcontext6, tst-setcontext7, tst-setcontext8 and tst-setcontext9. * stdlib/tst-setcontext6.c: New file. * stdlib/tst-setcontext7.c: Likewise. * stdlib/tst-setcontext8.c: Likewise. * stdlib/tst-setcontext9.c: Likewise.
* Add a test for multiple setcontext callsH.J. Lu2018-07-253-1/+94
| | | | | | | | | Check multiple setcontext calls. Reviewed-by: Carlos O'Donell <carlos@redhat.com>. * stdlib/Makefile ((tests): Add tst-setcontext5. * stdlib/tst-setcontext5.c: New file.
* Add another test for setcontextH.J. Lu2018-07-253-1/+223
| | | | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> * stdlib/Makefile (tests): Add tst-setcontext4. * stdlib/tst-setcontext4.c: New file.
* Add a test for multiple makecontext callsH.J. Lu2018-07-253-1/+115
| | | | | | | Check multiple makecontext calls. * stdlib/Makefile (tests): Add tst-swapcontext1. * stdlib/tst-swapcontext1.c: New test.
* x86/CET: Add tests with legacy non-CET shared objectsH.J. Lu2018-07-2513-0/+335
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check binary compatibility of CET-enabled executables: 1. When CET-enabled executable is used with legacy non-CET shared object at run-time, ld.so should disable SHSTK and put legacy non-CET shared objects in legacy bitmap. 2. When IBT-enabled executable dlopens legacy non-CET shared object, ld.so should put legacy shared object in legacy bitmap. 3. Use GLIBC_TUNABLES=glibc.tune.x86_shstk=[on|off|permissive] to control how SHSTK is enabled. * sysdeps/x86/Makefile (tests): Add tst-cet-legacy-1, tst-cet-legacy-2, tst-cet-legacy-2a, tst-cet-legacy-3, tst-cet-legacy-4, tst-cet-legacy-4a, tst-cet-legacy-4b and tst-cet-legacy-4c. (modules-names): Add tst-cet-legacy-mod-1, tst-cet-legacy-mod-2 and tst-cet-legacy-mod-4. (CFLAGS-tst-cet-legacy-2.c): New. (CFLAGS-tst-cet-legacy-mod-1.c): Likewise. (CFLAGS-tst-cet-legacy-mod-2.c): Likewise. (CFLAGS-tst-cet-legacy-3.c): Likewise. (CFLAGS-tst-cet-legacy-4.c): Likewise. (CFLAGS-tst-cet-legacy-mod-4.c): Likewise. ($(objpfx)tst-cet-legacy-1): Likewise. ($(objpfx)tst-cet-legacy-2): Likewise. ($(objpfx)tst-cet-legacy-2.out): Likewise. ($(objpfx)tst-cet-legacy-2a): Likewise. ($(objpfx)tst-cet-legacy-2a.out): Likewise. ($(objpfx)tst-cet-legacy-4): Likewise. ($(objpfx)tst-cet-legacy-4.out): Likewise. ($(objpfx)tst-cet-legacy-4a): Likewise. ($(objpfx)tst-cet-legacy-4a.out): Likewise. (tst-cet-legacy-4a-ENV): Likewise. ($(objpfx)tst-cet-legacy-4b): Likewise. ($(objpfx)tst-cet-legacy-4b.out): Likewise. (tst-cet-legacy-4b-ENV): Likewise. ($(objpfx)tst-cet-legacy-4c): Likewise. ($(objpfx)tst-cet-legacy-4c.out): Likewise. (tst-cet-legacy-4c-ENV): Likewise. * sysdeps/x86/tst-cet-legacy-1.c: New file. * sysdeps/x86/tst-cet-legacy-2.c: Likewise. * sysdeps/x86/tst-cet-legacy-2a.c: Likewise. * sysdeps/x86/tst-cet-legacy-3.c: Likewise. * sysdeps/x86/tst-cet-legacy-4.c: Likewise. * sysdeps/x86/tst-cet-legacy-4a.c: Likewise. * sysdeps/x86/tst-cet-legacy-4b.c: Likewise. * sysdeps/x86/tst-cet-legacy-4c.c: Likewise. * sysdeps/x86/tst-cet-legacy-mod-1.c: Likewise. * sysdeps/x86/tst-cet-legacy-mod-2.c: Likewise. * sysdeps/x86/tst-cet-legacy-mod-4.c: Likewise.
* x86: Rename __glibc_reserved2 to ssp_base in tcbhead_tH.J. Lu2018-07-255-2/+22
| | | | | | | | | | | | | | | This will be used to record the current shadow stack base for shadow stack switching by getcontext, makecontext, setcontext and swapcontext. If the target shadow stack base is the same as the current shadow stack base, we unwind the shadow stack. Otherwise it is a stack switch and we look for a restore token to restore the target shadow stack. * sysdeps/i386/nptl/tcb-offsets.sym (SSP_BASE_OFFSET): New. * sysdeps/i386/nptl/tls.h (tcbhead_t): Replace __glibc_reserved2 with ssp_base. * sysdeps/x86_64/nptl/tcb-offsets.sym (SSP_BASE_OFFSET): New. * sysdeps/x86_64/nptl/tls.h (tcbhead_t): Replace __glibc_reserved2 with ssp_base.