Commit Graph

22686 Commits

Author SHA1 Message Date
H.J. Lu bd4f7903df Add a test for multiple setcontext calls
Check multiple setcontext calls.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>.

	* stdlib/Makefile ((tests): Add tst-setcontext5.
	* stdlib/tst-setcontext5.c: New file.
2018-07-25 05:00:30 -07:00
H.J. Lu 7e28f20345 Add another test for setcontext
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* stdlib/Makefile (tests): Add tst-setcontext4.
	* stdlib/tst-setcontext4.c: New file.
2018-07-25 04:57:21 -07:00
H.J. Lu 8516ad2de3 Add a test for multiple makecontext calls
Check multiple makecontext calls.

	* stdlib/Makefile (tests): Add tst-swapcontext1.
	* stdlib/tst-swapcontext1.c: New test.
2018-07-25 04:54:00 -07:00
H.J. Lu fddcd00377 x86/CET: Add tests with legacy non-CET shared objects
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.
2018-07-25 04:47:05 -07:00
H.J. Lu 9aa3113a42 x86: Rename __glibc_reserved2 to ssp_base in tcbhead_t
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.
2018-07-25 04:39:39 -07:00
Andreas Schwab 9c79cec8cd Fix out of bounds access in findidxwc (bug 23442)
If usrc is a prefix of cp but one character shorter an out of bounds
access to usrc was done.
2018-07-25 10:50:03 +02:00
Adhemerval Zanella 969c335506 Mention ISO C threads addition
* NEWS: Add ISO C threads addition.
2018-07-24 19:35:03 -03:00
Florian Weimer e0f9c462d8 alpha: mlock2, copy_file_range syscalls were introduced in kernel 4.13 2018-07-24 22:38:39 +02:00
H.J. Lu 394df3815e x86/CET: Extend arch_prctl syscall for CET control
CET arch_prctl bits should be defined in <asm/prctl.h> from Linux kernel
header files.  Add x86 <include/asm/prctl.h> for pre-CET kernel header
files.

Note: sysdeps/unix/sysv/linux/x86/include/asm/prctl.h should be removed
if <asm/prctl.h> from the required kernel header files contains CET
arch_prctl bits.

 /* CET features:
    IBT:   GNU_PROPERTY_X86_FEATURE_1_IBT
    SHSTK: GNU_PROPERTY_X86_FEATURE_1_SHSTK
  */

 /* Return CET features in unsigned long long *addr:
      features: addr[0].
      shadow stack base address: addr[1].
      shadow stack size: addr[2].
  */
 # define ARCH_CET_STATUS		0x3001
 /* Disable CET features in unsigned int features.  */
 # define ARCH_CET_DISABLE		0x3002
 /* Lock all CET features.  */
 # define ARCH_CET_LOCK			0x3003
 /* Allocate a new shadow stack with unsigned long long *addr:
      IN: requested shadow stack size: *addr.
      OUT: allocated shadow stack address: *addr.
  */
 # define ARCH_CET_ALLOC_SHSTK		0x3004
 /* Return legacy region bitmap info in unsigned long long *addr:
     address: addr[0].
     size: addr[1].
  */
 # define ARCH_CET_LEGACY_BITMAP	0x3005

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/x86/include/asm/prctl.h: New file.
	* sysdeps/unix/sysv/linux/x86/cpu-features.c: Include
	<sys/prctl.h> and <asm/prctl.h>.
	(get_cet_status): Call arch_prctl with ARCH_CET_STATUS.
	* sysdeps/unix/sysv/linux/x86/dl-cet.h: Include <sys/prctl.h>
	and <asm/prctl.h>.
	(dl_cet_allocate_legacy_bitmap): Call arch_prctl with
	ARCH_CET_LEGACY_BITMAP.
	(dl_cet_disable_cet): Call arch_prctl with ARCH_CET_DISABLE.
	(dl_cet_lock_cet): Call arch_prctl with ARCH_CET_LOCK.
	* sysdeps/x86/libc-start.c: Include <startup.h>.
2018-07-24 12:23:17 -07:00
Florian Weimer 465455306f sh: Do not define __ASSUME_STATX 2018-07-24 21:05:07 +02:00
Rical Jasan 9d0a979e5d Add manual documentation for threads.h
This patch updates the manual and adds a new chapter to the manual,
explaining types macros, constants and functions defined by ISO C11
threads.h standard.

	[BZ# 14092]
	* manual/debug.texi: Update adjacent chapter name.
	* manual/probes.texi: Likewise.
	* manual/threads.texi (ISO C Threads): New section.
	(POSIX Threads): Convert to a section.
2018-07-24 14:07:31 -03:00
Adhemerval Zanella 0a07288b13 nptl: Add test cases for ISO C11 threads
This patch adds to testsuite new test cases to test all new introduced
C11 threads functions, types and macros are tested.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Juan Manuel Torres Palma  <jmtorrespalma@gmail.com>

	[BZ #14092]
	* nptl/Makefile (tests): Add new test files.
	* nptl/tst-call-once.c : New file. Tests C11 functions and types.
	* nptl/tst-cnd-basic.c: Likewise.
	* nptl/tst-cnd-broadcast.c: Likewise.
	* nptl/tst-cnd-timedwait.c: Likewise.
	* nptl/tst-mtx-basic.c: Likewise.
	* nptl/tst-mtx-recursive.c: Likewise.
	* nptl/tst-mtx-timedlock.c: Likewise.
	* nptl/tst-mtx-trylock.c: Likewise.
	* nptl/tst-thrd-basic.c: Likewise.
	* nptl/tst-thrd-detach.c: Likewise.
	* nptl/tst-thrd-sleep.c: Likewise.
	* nptl/tst-tss-basic.c: Likewise.
2018-07-24 14:07:25 -03:00
Adhemerval Zanella c6dd669bed nptl: Add abilist symbols for C11 threads
This patch adds the required abilist symbols for C11 thread support.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
	(thrd_current, thrd_equal, thrd_sleep, thrd_yield): Add C11 thread
	symbols.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist [[GLIBC_2.28]
	(call_once, cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
	cnd_timedwait, cnd_wait, mtx_destroy, mtx_init, mtx_lock,
	mtx_timedlock, mtx_trylock, mtx_unlokc, thrd_create, thrd_detach,
	thrd_exit, thrd_join, tss_create, tss_delete, tss_get, tss_set):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
	ikewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
2018-07-24 14:07:18 -03:00
Adhemerval Zanella 78d401327f nptl: Add C11 threads tss_* functions
This patch adds the tss_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically tss_create, tss_delete, tss_get, tss_set, and required
types.

Mostly of the definitions are composed based on POSIX conterparts, including
tss_t (pthread_key_t).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (thread_local): New macro.
	(TSS_DTOR_ITERATIONS): Likewise.
	(tss_t): New type.
	(tss_dtor_t): Likewise.
	(tss_create): New function.
	(tss_get): Likewise.
	(tss_set): Likewise.
	(tss_delete): Likewise.
	* nptl/Makefile (libpthread-routines): Add tss_create, tss_delete,
	tss_get, and tss_set objects.
	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
	* nptl/tss_create.c: New file.
	* nptl/tss_delete.c: Likewise.
	* nptl/tss_get.c: Likewise.
	* nptl/tss_set.c: Likewise.
	* sysdeps/nptl/threads.h (thread_local): New define.
	(TSS_DTOR_ITERATIONS): Likewise.
	(tss_t): New typedef.
	(tss_dtor_t): Likewise.
	(tss_create): New prototype.
	(tss_get): Likewise.
	(tss_set): Likewise.
	(tss_delete): Likewise.
2018-07-24 14:07:12 -03:00
Adhemerval Zanella 918311a3a3 nptl: Add C11 threads cnd_* functions
This patch adds the cnd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
cnd_timedwait, cnd_wait, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and
cnd_t is also based on internal pthreads fields, but with distinct internal
layout to avoid possible issues with code interchange (such as trying to pass
POSIX structure on C11 functions and to avoid inclusion of pthread.h).  The
idea is to make it possible to share POSIX internal implementation for mostly
of the code making adjust where only required.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (cnd_t): New type.
	(cnd_init): New function.
	(cnd_signal): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
	object.
	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
	* nptl/cnd_broadcast.c: New file.
	* nptl/cnd_destroy.c: Likewise.
	* nptl/cnd_init.c: Likewise.
	* nptl/cnd_signal.c: Likewise.
	* nptl/cnd_timedwait.c: Likewise.
	* nptl/cnd_wait.c: Likewise.
	* sysdeps/nptl/threads.h (cnd_t): New type.
	(cnd_init): New prototype.
	(cnd_signa): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
2018-07-24 14:07:07 -03:00
Adhemerval Zanella 3c20a679b6 nptl: Add C11 threads call_once functions
This patch adds the call_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically call_once and required types.

Mostly of the definitions are composed based on POSIX conterparts,including
once_flag (pthread_once_t).  The idea is to make possible to share POSIX
internal implementations for mostly of the code (and making adjustment only
when required).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.
	(once_flag): New type.
	(call_once): New function.
	* nptl/Makefile (libpthread-routines): Add call_once object.
	* nptl/Versions (libphread) [GLIBC_2.28]: Add call_once symbol.
	* nptl/call_once.c: New file.
	* sysdeps/nptl/threads.h (ONCE_FLAG_INIT): New define.
	(once_flag): New type.
	(call_once): New prototype.
2018-07-24 14:07:01 -03:00
Adhemerval Zanella 18d59c1b36 nptl: Add C11 threads mtx_* functions
This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
mtx_unlock, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
is also based on internal pthread fields, but with a distinct internal layout
to avoid possible issues with code interchange (such as trying to pass POSIX
structure on C11 functions and to avoid inclusion of pthread.h).  The idea
is to make possible to share POSIX internal implementations for mostly of
the code (and making adjustment only when required).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (mtx_plain): New constant.
	(mtx_recursive): Likewise.
	(mtx_timed): Likewise.
	(mtx_t): New type.
	(mtx_init): New function.
	(mtx_lock): Likewise.
	(mtx_timedlock): Likewise.
	(mtx_trylock): Likewise.
	(mtx_unlock): Likewise.
	(mtx_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add mtx_destroy, mtx_init,
	mtx_lock, mtx_timedlock, mtx_trylock, and mtx_unlock object.
	* nptl/Versions (libpthread) [GLIBC_2.28]): Add mtx_init, mtx_lock,
	mtx_timedlock, mtx_trylock, mtx_unlock, and mtx_destroy.
	* nptl/mtx_destroy.c: New file.
	* nptl/mtx_init.c: Likewise.
	* nptl/mtx_lock.c: Likewise.
	* nptl/mtx_timedlock.c: Likewise.
	* nptl/mtx_trylock.c: Likewise.
	* nptl/mtx_unlock.c: Likewise.
	* sysdeps/nptl/threads.h (mtx_plain): New enumeration.
	(mtx_recursive): Likewise.
	(mtx_timed): Likewise.
	(mtx_t): New type.
	(mtx_init): New prototype.
	(mtx_lock): Likewise.
	(mtx_timedlock): Likewise.
	(mtx_trylock): Likewise.
	(mtx_unlock): Likewise.
	(mtx_destroy): Likewise.
2018-07-24 14:06:54 -03:00
Adhemerval Zanella ce7528f637 nptl: Add C11 threads thrd_* functions
This patch adds the thrd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically thrd_create, thrd_curent, rhd_detach, thrd_equal,
thrd_exit, thrd_join, thrd_sleep, thrd_yield, and required types.

Mostly of the definitions are composed based on POSIX conterparts, such as
thrd_t (using pthread_t).  For thrd_* function internally direct
POSIX pthread call are used with the exceptions:

  1. thrd_start uses pthread_create internal implementation, but changes
     how to actually calls the start routine.  This is due the difference
     in signature between POSIX and C11, where former return a 'void *'
     and latter 'int'.
     To avoid calling convention issues due 'void *' to int cast, routines
     from C11 threads are started slight different than default pthread one.
     Explicit cast to expected return are used internally on pthread_create
     and the result is stored back to void also with an explicit cast.

  2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
     errno and to handle expected standard return codes.  It is a
     cancellation entrypoint to be consistent with both thrd_join and
     cnd_{timed}wait.

  3. thrd_yield also uses internal direct syscall to avoid errno clobbering.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/Makefile (conformtest-headers-ISO11): Add threads.h.
	(linknamespace-libs-ISO11): Add libpthread.a.
	* conform/data/threads.h-data: New file: add C11 thrd_* types and
	functions.
	* include/stdc-predef.h (__STDC_NO_THREADS__): Remove definition.
	* nptl/Makefile (headers): Add threads.h.
	(libpthread-routines): Add new C11 thread thrd_create, thrd_current,
	thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, and
	thrd_yield.
	* nptl/Versions (libpthread) [GLIBC_2.28]): Add new C11 thread
	thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit,
	thrd_join, thrd_sleep, and thrd_yield symbols.
	* nptl/descr.h (struct pthread): Add c11 field.
	* nptl/pthreadP.h (ATTR_C11_THREAD): New define.
	* nptl/pthread_create.c (START_THREAD_DEFN): Call C11 thread start
	routine with expected function prototype.
	(__pthread_create_2_1): Add C11 threads check based on attribute
	value.
	* sysdeps/unix/sysdep.h (INTERNAL_SYSCALL_CANCEL): New macro.
	* nptl/thrd_create.c: New file.
	* nptl/thrd_current.c: Likewise.
	* nptl/thrd_detach.c: Likewise.
	* nptl/thrd_equal.c: Likewise.
	* nptl/thrd_exit.c: Likewise.
	* nptl/thrd_join.c: Likewise.
	* nptl/thrd_priv.h: Likewise.
	* nptl/thrd_sleep.c: Likewise.
	* nptl/thrd_yield.c: Likewise.
	* include/threads.h: Likewise.
2018-07-24 14:06:45 -03:00
H.J. Lu e27f41ba2b Add <bits/indirect-return.h>
Add <bits/indirect-return.h> and include it in <ucontext.h>.
__INDIRECT_RETURN defined in <bits/indirect-return.h> indicates if
swapcontext requires special compiler treatment.  The default
__INDIRECT_RETURN is empty.

On x86, when shadow stack is enabled, __INDIRECT_RETURN is defined
with indirect_return attribute, which has been added to GCC 9, to
indicate that swapcontext returns via indirect branch.  Otherwise
__INDIRECT_RETURN is defined with returns_twice attribute.

When shadow stack is enabled, remove always_inline attribute from
prepare_test_buffer in string/tst-xbzero-opt.c to avoid:

tst-xbzero-opt.c: In function ‘prepare_test_buffer’:
tst-xbzero-opt.c:105:1: error: function ‘prepare_test_buffer’ can never be inlined because it uses setjmp
 prepare_test_buffer (unsigned char *buf)

when indirect_return attribute isn't available.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* bits/indirect-return.h: New file.
	* misc/sys/cdefs.h (__glibc_has_attribute): New.
	* sysdeps/x86/bits/indirect-return.h: Likewise.
	* stdlib/Makefile (headers): Add bits/indirect-return.h.
	* stdlib/ucontext.h: Include <bits/indirect-return.h>.
	(swapcontext): Add __INDIRECT_RETURN.
	* string/tst-xbzero-opt.c (ALWAYS_INLINE): New.
	(prepare_test_buffer): Use it.
2018-07-24 07:55:47 -07:00
Andreas Schwab 21526a507d Fix out-of-bounds access in IBM-1390 converter (bug 23448)
The IBM-1390 converter can consume/produce two UCS4 characters in each
loop.
2018-07-24 16:45:46 +02:00
H.J. Lu 3650e1d928 x86: Update vfork to pop shadow stack
The shadow stack prevents us from pushing the saved return PC onto
the stack and returning normally.  Instead we pop the shadow stack
and return directly.  This is the safest way to return and ensures
any stack manipulations done by the vfork'd child doesn't cause the
parent to terminate when CET is enabled.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/i386/vfork.S (SYSCALL_ERROR_HANDLER):
	Redefine if shadow stack is enabled.
	(SYSCALL_ERROR_LABEL): Likewise.
	(__vfork): Pop shadow stack and jump back to to caller directly
	when shadow stack is in use.
	* sysdeps/unix/sysv/linux/x86_64/vfork.S (SYSCALL_ERROR_HANDLER):
	Redefine if shadow stack is enabled.
	(SYSCALL_ERROR_LABEL): Likewise.
	(__vfork): Pop shadow stack and jump back to to caller directly
	when shadow stack is in use.
2018-07-24 05:21:07 -07:00
H.J. Lu ca027e0f62 x86-64: Add endbr64 to tst-quadmod[12].S
Add endbr64 to tst-quadmod1.S and tst-quadmod2.S so that func and foo
can be called indirectly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86_64/tst-quadmod1.S (func): Add endbr64 if IBT is
	enabled.
	(foo): Likewise.
	* sysdeps/x86_64/tst-quadmod2.S (func) : Likewise.
	(foo): Likewise.
2018-07-24 05:12:14 -07:00
Joseph Myers b99f1c957d Use binutils 2.31 branch in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default
	binutils version to 2.31 branch.
2018-07-20 16:11:15 +00:00
Zong Li c8fabb8434 Change URL of gcc's tarball
After 7.1.0 version, there is no .bz2 format of gcc's tarball.

	* scripts/build-many-glibcs.py (Context.checkout_tar): Change the
	URL of gcc's tarball.
2018-07-20 15:30:05 +00:00
Florian Weimer 786658a088 regcomp: Fix off-by-one bug in build_equiv_class [BZ #23396]
This bug is very similar to bug 23036: The existing code assumed that
the length count included the length byte itself.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-20 11:58:51 +02:00
Samuel Thibault 2d5c41ded9 check-execstack: Permit sysdeps to xfail some libs
* scripts/check-execstack.awk: Consider `xfail' variable containing a
	list
	of libraries whose stack executability is expected.
	* elf/Makefile ($(objpfx)check-execstack.out): Pass
	$(check-execstack-xfail) to check-execstack.awk through `xfail'
	variable.
	* sysdeps/mach/hurd/i386/Makefile (check-execstack-xfail): Set to ld.so
	libc.so libpthread.so.
2018-07-20 03:28:14 +02:00
Samuel Thibault 8ba1520e8c hurd: Fix installed-headers tests
* sysdeps/mach/include/mach-shortcuts-hidden.h [!_ISOMAC]: Do not
	declare libc hidden prototypes.
	* sysdeps/mach/include/mach/mach_traps.h [!_ISOMAC]: Likewise.
2018-07-20 03:28:08 +02:00
Thomas Schwinge de195be015 hurd: Implement pipe2
* sysdeps/mach/hurd/pipe2.c: New file, copy from pipe.c.  Evolve it to
	implement __pipe2.
	* sysdeps/mach/hurd/pipe.c (__pipe): Reimplement using __pipe2.
2018-07-20 01:29:55 +02:00
Thomas Schwinge 75d5e4a09e hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socketpair
* sysdeps/mach/hurd/socketpair.c (__socketpair): Handle SOCK_CLOEXEC
	and SOCK_NONBLOCK.
2018-07-20 01:24:41 +02:00
Thomas Schwinge 6008824221 hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socket
* sysdeps/mach/hurd/socket.c (__socket): Handle SOCK_CLOEXEC and
	SOCK_NONBLOCK.
2018-07-20 01:22:12 +02:00
Samuel Thibault 46f2474e93 hurd: Enable thread-safe i386 atomic instructions
* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Set multiple_threads
	to 1.
2018-07-20 01:12:08 +02:00
Leonardo Sandoval 1cf4ae7fe6 benchtests: improve argument parsing through argparse library
The argparse library is used on compare_bench script to improve command line
argument parsing. The 'schema validation file' is now optional, reducing by
one the number of required parameters.

	* benchtests/scripts/compare_bench.py (__main__): use the argparse
	library to improve command line parsing.
	(__main__): make schema file as optional parameter (--schema),
	defaulting to benchtests/scripts/benchout.schema.json.
	(main): move out of the parsing stuff to __main_  and leave it
	only as caller of main comparison functions.
2018-07-19 14:53:37 -05:00
H.J. Lu e84bd8514c INSTALL: Add a note for Intel CET status
* NEWS: Add a note for Intel CET status.
	* manual/install.texi: Likewise.
	* INSTALL: Regenerated.
2018-07-19 12:05:10 -07:00
Quentin PAGÈS df467d229a oc_FR locale: Multiple updates (bug 23140, bug 23422).
Multiple updates for Occitan language including alternative month names,
update abday and abmon, fix typos in day, fix d_fmt, correct LC_NAME,
and use “copy "ca_ES"” as LC_COLLATE.

	[BZ #23140]
	* localedata/locales/oc_FR (mon): Rename to...
	(alt_mon): This, then update October (typo fix).
	(mon): New content (genitive case, month names preceded by
	"de" or "d’").

	[BZ #23422]
	* localedata/locales/oc_FR (abday): Update all items.
	(day): Update Wednesday and Saturday (typo fixes).
	(abmon): Update all items, except May.
	(d_fmt): Update "%d.%m.%Y" -> "%d/%m/%Y".
	(LC_IDENTIFICATION): Bump the revision number and date.
	Keep the "category" entries in alphabetic order.
	(LC_ADDRESS): Remove no longer needed comment.
	(LC_COLLATE): Use “copy "ca_ES"”.
	(LC_NAME): Set the correct values of "name_fmt", "name_mr", and
	"name_mrs".

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-18 23:17:17 +02:00
Joseph Myers 5c112f1b62 Avoid insecure usage of tmpnam in tests.
Various glibc testcases use tmpnam in ways subject to race conditions
(generate a temporary file name, then later open that file without
O_EXCL).

This patch fixes those tests to use mkstemp - generally a minimal
local fix to use mkstemp instead of tmpnam, rather than a larger fix
to use other testsuite infrastructure for temporary files.  The
unchanged use of tmpnam in posix/wordexp-test.c would fail safe in the
event of a race (it's generating a name for use with mkdir rather than
for a file to be opened for writing).

Tested for x86_64.

	* grp/tst_fgetgrent.c: Include <unistd.h>.
	(main): Use mkstemp instead of tmpnam.
	* io/test-utime.c (main): Likewise.
	* posix/annexc.c (macrofile): Change to modifiable array.
	(get_null_defines): Use mkstemp instead of tmpnam.  Do not remove
	macrofile here.
	* posix/bug-getopt1.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt2.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt3.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt4.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt5.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* stdio-common/bug7.c: Include <stdlib.h> and <unistd.h>.
	(main): Use mkstemp instead of tmpnam.
	* stdio-common/tst-fdopen.c: Include <stdlib.h>.
	(main): Use mkstemp instead of tmpnam.
	* stdio-common/tst-ungetc.c: Include <stdlib.h>.
	(main): use mkstemp instead of tmpnam.
	* stdlib/isomac.c (macrofile): Change to modifiable array.
	(get_null_defines): Use mkstemp instead of tmpnam.  Do not remove
	macrofile here.
2018-07-18 21:04:12 +00:00
H.J. Lu 6d90776dff x86/CET: Document glibc.tune.x86_ibt and glibc.tune.x86_shstk
* manual/tunables.texi: Document glibc.tune.x86_ibt and
	glibc.tune.x86_shstk.
2018-07-18 11:35:03 -07:00
H.J. Lu e6c695099b Intel CET: Document --enable-cet
* NEWS: Mention --enable-cet.
	* manual/install.texi: Document --enable-cet.
	* INSTALL: Regenerated.
2018-07-18 09:52:53 -07:00
H.J. Lu e2d40a8822 x86-64: Use _CET_NOTRACK in memcmp-sse4.S
* sysdeps/x86_64/multiarch/memcmp-sse4.S (BRANCH_TO_JMPTBL_ENTRY):
	Add _CET_NOTRACK before indirect jump to jump table.
2018-07-18 08:07:32 -07:00
H.J. Lu 77a8ae0948 i386: Use _CET_NOTRACK in memset-sse2-rep.S
* sysdeps/i386/i686/multiarch/memset-sse2-rep.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:04:12 -07:00
H.J. Lu 90d15dc577 i386: Use _CET_NOTRACK in strcat-sse2.S
* sysdeps/i386/i686/multiarch/strcat-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:03:15 -07:00
H.J. Lu f1574581c7 i386: Use _CET_NOTRACK in strcpy-sse2.S
* sysdeps/i386/i686/multiarch/strcpy-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:02:26 -07:00
H.J. Lu 7fb613361c i386: Use _CET_NOTRACK in memcpy-ssse3.S
* sysdeps/i386/i686/multiarch/memcpy-ssse3.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:01:06 -07:00
H.J. Lu 0a899af097 i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
* sysdeps/i386/i686/multiarch/memcpy-ssse3-rep.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(BRANCH_TO_JMPTBL_ENTRY_TAIL): Likewise.
2018-07-18 08:00:09 -07:00
H.J. Lu 177824e232 i386: Use _CET_NOTRACK in memcmp-sse4.S
* sysdeps/i386/i686/multiarch/memcmp-sse4.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 07:59:04 -07:00
H.J. Lu 00e7b76a8f i386: Use _CET_NOTRACK in memset-sse2.S
* sysdeps/i386/i686/multiarch/memset-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 07:57:59 -07:00
H.J. Lu 7e119cd582 i386: Use _CET_NOTRACK in i686/memcmp.S
* sysdeps/i386/i686/memcmp.S (memcmp): Add _CET_NOTRACK before
	indirect jump to jump table.
2018-07-18 07:56:58 -07:00
H.J. Lu 03aaf49b68 x86-64: Use _CET_NOTRACK in memcpy-ssse3.S
* sysdeps/x86_64/multiarch/memcpy-ssse3.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(MEMCPY): Likewise.
2018-07-18 06:39:46 -07:00
H.J. Lu 811e9e52b2 x86-64: Use _CET_NOTRACK in memcpy-ssse3-back.S
* sysdeps/x86_64/multiarch/memcpy-ssse3-back.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(MEMCPY): Likewise.
2018-07-18 06:38:23 -07:00
H.J. Lu 8817df4265 x86-64: Use _CET_NOTRACK in strcmp-sse42.S
* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
	_CET_NOTRACK before indirect jump to jump table.
2018-07-18 06:37:09 -07:00
H.J. Lu 921595d151 x86-64: Use _CET_NOTRACK in strcpy-sse2-unaligned.S
* sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 06:33:06 -07:00
H.J. Lu 4ef60d9597 x86_64: Use _CET_NOTRACK in strcmp.S
* sysdeps/x86_64/strcmp.S (STRCMP): Add _CET_NOTRACK before
	indirect jump to jump table.
2018-07-18 06:31:53 -07:00
Valery Timiriliyev 61c4aad705 New locale: Yakut (Sakha) for Russia (sah_RU) [BZ #22241]
* localedata/Makefile (test-input): Add sah_RU.UTF-8.
	(LOCALES): Likewise.
	* localedata/SUPPORTED (sah_RU/UTF-8): New entry.
	* localedata/locales/sah_RU: New file.
	* localedata/sah_RU.UTF-8.in: New file.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-18 11:45:44 +02:00
H.J. Lu be9ccd27c0 i386: Add _CET_ENDBR to indirect jump targets in add_n.S/sub_n.S
i386 add_n.S and sub_n.S use a trick to implment jump tables with LEA.
We can't use conditional branches nor normal jump tables since jump
table entries use EFLAGS set by jump table index.  This patch adds
_CET_ENDBR to indirect jump targets and adjust destination for
_CET_ENDBR.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/add_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
	* sysdeps/i386/i686/add_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
	* sysdeps/i386/sub_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_sub_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
2018-07-17 16:11:44 -07:00
H.J. Lu 5efc6777ad x86-64: Add _CET_ENDBR to STRCMP_SSE42
Add _CET_ENDBR to STRCMP_SSE42, which is called indirectly, to support
IBT.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
	_CET_ENDBR.
2018-07-17 16:08:47 -07:00
H.J. Lu 562837c002 x86: Add _CET_ENDBR to functions in dl-tlsdesc.S
Add _CET_ENDBR to functions in dl-tlsdesc.S, which are called indirectly,
to support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_return): Add
	_CET_ENDBR.
	(_dl_tlsdesc_undefweak): Likewise.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_resolve_abs_plus_addend): Likewise.
	(_dl_tlsdesc_resolve_rel): Likewise.
	(_dl_tlsdesc_resolve_rela): Likewise.
	(_dl_tlsdesc_resolve_hold): Likewise.
	* sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_return): Likewise.
	(_dl_tlsdesc_undefweak): Likewise.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_resolve_rela): Likewise.
	(_dl_tlsdesc_resolve_hold): Likewise.
2018-07-17 16:07:17 -07:00
H.J. Lu 124bcde683 x86: Add _CET_ENDBR to functions in crti.S
Add _CET_ENDBR to functions in crti.S, which are called indirectly, to
support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
	(_fini): Likewise.
	* sysdeps/x86_64/crti.S (_init): Likewise.
	(_fini): Likewise.
2018-07-17 16:05:18 -07:00
Rafal Luzynski 9145f0333d os_RU: Add alternative month names (bug 23140).
[BZ #23140]
	* localedata/locales/os_RU (mon): Rename to...
	(alt_mon): This.
	(mon): Import from CLDR (genitive case).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-17 23:58:56 +02:00
H.J. Lu ba2ea23d05 x86: Always include <dl-cet.h>/cet-tunables.h> for --enable-cet
Always include <dl-cet.h> and cet-tunables.h> when CET is enabled.
Otherwise, configure glibc with --enable-cet --disable-tunables will
fail to build.

	* sysdeps/x86/cpu-features.c: Always include <dl-cet.h> and
	cet-tunables.h> when CET is enabled.
2018-07-17 04:16:35 -07:00
H.J. Lu f753fa7dea x86: Support IBT and SHSTK in Intel CET [BZ #21598]
Intel Control-flow Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-en
forcement-technology-preview.pdf

includes Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK).

GNU_PROPERTY_X86_FEATURE_1_IBT is added to GNU program property to
indicate that all executable sections are compatible with IBT when
ENDBR instruction starts each valid target where an indirect branch
instruction can land.  Linker sets GNU_PROPERTY_X86_FEATURE_1_IBT on
output only if it is set on all relocatable inputs.

On an IBT capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable IBT and
lock IBT if GNU_PROPERTY_X86_FEATURE_1_IBT is set on the executable.
2. When loading an executable with an interpreter, enable IBT if
GNU_PROPERTY_X86_FEATURE_1_IBT is set on the interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_IBT isn't set on the executable,
     disable IBT.
  b. Lock IBT.
3. If IBT is enabled, when loading a shared object without
GNU_PROPERTY_X86_FEATURE_1_IBT:
  a. If legacy interwork is allowed, then mark all pages in executable
     PT_LOAD segments in legacy code page bitmap.  Failure of legacy code
     page bitmap allocation causes an error.
  b. If legacy interwork isn't allowed, it causes an error.

GNU_PROPERTY_X86_FEATURE_1_SHSTK is added to GNU program property to
indicate that all executable sections are compatible with SHSTK where
return address popped from shadow stack always matches return address
popped from normal stack.  Linker sets GNU_PROPERTY_X86_FEATURE_1_SHSTK
on output only if it is set on all relocatable inputs.

On a SHSTK capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on the executable.
2. When loading an executable with an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_SHSTK isn't set on the executable
     or any shared objects loaded via the DT_NEEDED tag, disable SHSTK.
  b. Otherwise lock SHSTK.
3. After SHSTK is enabled, it is an error to load a shared object
without GNU_PROPERTY_X86_FEATURE_1_SHSTK.

To enable CET support in glibc, --enable-cet is required to configure
glibc.  When CET is enabled, both compiler and assembler must support
CET.  Otherwise, it is a configure-time error.

To support CET run-time control,

1. _dl_x86_feature_1 is added to the writable ld.so namespace to indicate
if IBT or SHSTK are enabled at run-time.  It should be initialized by
init_cpu_features.
2. For dynamic executables:
   a. A l_cet field is added to struct link_map to indicate if IBT or
      SHSTK is enabled in an ELF module.  _dl_process_pt_note or
      _rtld_process_pt_note is called to process PT_NOTE segment for
      GNU program property and set l_cet.
   b. _dl_open_check is added to check IBT and SHSTK compatibilty when
      dlopening a shared object.
3. Replace i386 _dl_runtime_resolve and _dl_runtime_profile with
_dl_runtime_resolve_shstk and _dl_runtime_profile_shstk, respectively if
SHSTK is enabled.

CET run-time control can be changed via GLIBC_TUNABLES with

$ export GLIBC_TUNABLES=glibc.tune.x86_shstk=[permissive|on|off]
$ export GLIBC_TUNABLES=glibc.tune.x86_ibt=[permissive|on|off]

1. permissive: SHSTK is disabled when dlopening a legacy ELF module.
2. on: IBT or SHSTK are always enabled, regardless if there are IBT or
SHSTK bits in GNU program property.
3. off: IBT or SHSTK are always disabled, regardless if there are IBT or
SHSTK bits in GNU program property.

<cet.h> from CET-enabled GCC is automatically included by assembly codes
to add GNU_PROPERTY_X86_FEATURE_1_IBT and GNU_PROPERTY_X86_FEATURE_1_SHSTK
to GNU program property.  _CET_ENDBR is added at the entrance of all
assembly functions whose address may be taken.  _CET_NOTRACK is used to
insert NOTRACK prefix with indirect jump table to support IBT.  It is
defined as notrack when _CET_NOTRACK is defined in <cet.h>.

	 [BZ #21598]
	* configure.ac: Add --enable-cet.
	* configure: Regenerated.
	* elf/Makefille (all-built-dso): Add a comment.
	* elf/dl-load.c (filebuf): Moved before "dynamic-link.h".
	Include <dl-prop.h>.
	(_dl_map_object_from_fd): Call _dl_process_pt_note on PT_NOTE
	segment.
	* elf/dl-open.c: Include <dl-prop.h>.
	(dl_open_worker): Call _dl_open_check.
	* elf/rtld.c: Include <dl-prop.h>.
	(dl_main): Call _rtld_process_pt_note on PT_NOTE segment.  Call
	_rtld_main_check.
	* sysdeps/generic/dl-prop.h: New file.
	* sysdeps/i386/dl-cet.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/cpu-features.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/dl-cet.h: Likewise.
	* sysdeps/x86/cet-tunables.h: Likewise.
	* sysdeps/x86/check-cet.awk: Likewise.
	* sysdeps/x86/configure: Likewise.
	* sysdeps/x86/configure.ac: Likewise.
	* sysdeps/x86/dl-cet.c: Likewise.
	* sysdeps/x86/dl-procruntime.c: Likewise.
	* sysdeps/x86/dl-prop.h: Likewise.
	* sysdeps/x86/libc-start.h: Likewise.
	* sysdeps/x86/link_map.h: Likewise.
	* sysdeps/i386/dl-trampoline.S (_dl_runtime_resolve): Add
	_CET_ENDBR.
	(_dl_runtime_profile): Likewise.
	(_dl_runtime_resolve_shstk): New.
	(_dl_runtime_profile_shstk): Likewise.
	* sysdeps/linux/x86/Makefile (sysdep-dl-routines): Add dl-cet
	if CET is enabled.
	(CFLAGS-.o): Add -fcf-protection if CET is enabled.
	(CFLAGS-.os): Likewise.
	(CFLAGS-.op): Likewise.
	(CFLAGS-.oS): Likewise.
	(asm-CPPFLAGS): Add -fcf-protection -include cet.h if CET
	is enabled.
	(tests-special): Add $(objpfx)check-cet.out.
	(cet-built-dso): New.
	(+$(cet-built-dso:=.note)): Likewise.
	(common-generated): Add $(cet-built-dso:$(common-objpfx)%=%.note).
	($(objpfx)check-cet.out): New.
	(generated): Add check-cet.out.
	* sysdeps/x86/cpu-features.c: Include <dl-cet.h> and
	<cet-tunables.h>.
	(TUNABLE_CALLBACK (set_x86_ibt)): New prototype.
	(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
	(init_cpu_features): Call get_cet_status to check CET status
	and update dl_x86_feature_1 with CET status.  Call
	TUNABLE_CALLBACK (set_x86_ibt) and TUNABLE_CALLBACK
	(set_x86_shstk).  Disable and lock CET in libc.a.
	* sysdeps/x86/cpu-tunables.c: Include <cet-tunables.h>.
	(TUNABLE_CALLBACK (set_x86_ibt)): New function.
	(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
	* sysdeps/x86/sysdep.h (_CET_NOTRACK): New.
	(_CET_ENDBR): Define if not defined.
	(ENTRY): Add _CET_ENDBR.
	* sysdeps/x86/dl-tunables.list (glibc.tune): Add x86_ibt and
	x86_shstk.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Add
	_CET_ENDBR.
	(_dl_runtime_profile): Likewise.
2018-07-16 14:08:27 -07:00
Rogerio Alves 52b2a80fae powerpc64: Always restore TOC on longjmp [BZ #21895]
This patch changes longjmp to always restore the TOC pointer (r2 register)
to the caller frame on powerpc64 and powerpc64le.  This is related to bug
21895 that reports a situation where you have a static longjmp to a
shared object file.

	[BZ #21895]
	* sysdeps/powerpc/powerpc64/__longjmp-common.S: Remove condition code for
	restoring r2 in longjmp.
	* sysdeps/powerpc/powerpc64/Makefile: Added tst-setjmp-bug21895-static to
	test list.
	Added rules to build test tst-setjmp-bug21895-static.
	Added module setjmp-bug21895 and rules to build a shared object from it.
	* sysdeps/powerpc/powerpc64/setjmp-bug21895.c: New test file.
	* sysdeps/powerpc/powerpc64/tst-setjmp-bug21895-static.c: New test file.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-07-16 16:08:41 -03:00
Wilco Dijkstra 3ae725dfb6 Improve strstr performance
Improve strstr performance.  Strstr tends to be slow because it uses
many calls to memchr and a slow byte loop to scan for the next match.
Performance is significantly improved by using strnlen on larger blocks
and using strchr to search for the next matching character.  strcasestr
can also use strnlen to scan ahead, and memmem can use memchr to check
for the next match.

On the GLIBC bench tests the performance gains on Cortex-A72 are:
strstr: +25%
strcasestr: +4.3%
memmem: +18%

On a 256KB dataset strstr performance improves by 67%, strcasestr by 47%.

    Reviewd-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-07-16 17:51:52 +01:00
H.J. Lu 31e422ca96 x86_64: Undef SHADOW_STACK_POINTER_OFFSET last
Since SHADOW_STACK_POINTER_OFFSET is defined in jmp_buf-ssp.h, we must
undef SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.

	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Undef
	SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.
2018-07-15 08:48:54 -07:00
H.J. Lu faaee1f07e x86: Support shadow stack pointer in setjmp/longjmp
Save and restore shadow stack pointer in setjmp and longjmp to support
shadow stack in Intel CET.  Use feature_1 in tcbhead_t to check if
shadow stack is enabled before saving and restoring shadow stack pointer.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/__longjmp.S: Include <jmp_buf-ssp.h>.
	(__longjmp): Restore shadow stack pointer if shadow stack is
	enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
	isn't defined for __longjmp_cancel.
	* sysdeps/i386/bsd-_setjmp.S: Include <jmp_buf-ssp.h>.
	(_setjmp): Save shadow stack pointer if shadow stack is enabled
	and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/i386/bsd-setjmp.S: Include <jmp_buf-ssp.h>.
	(setjmp): Save shadow stack pointer if shadow stack is enabled
	and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/i386/setjmp.S: Include <jmp_buf-ssp.h>.
	(__sigsetjmp): Save shadow stack pointer if shadow stack is
	enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Include
	<jmp_buf-ssp.h>.
	(____longjmp_chk): Restore shadow stack pointer if shadow stack
	is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/unix/sysv/linux/x86/Makefile (gen-as-const-headers):
	Remove jmp_buf-ssp.sym.
	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Include
	<jmp_buf-ssp.h>.
	(____longjmp_chk): Restore shadow stack pointer if shadow stack
	is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/x86/Makefile (gen-as-const-headers): Add
	jmp_buf-ssp.sym.
	* sysdeps/x86/jmp_buf-ssp.sym: New dummy file.
	* sysdeps/x86_64/__longjmp.S: Include <jmp_buf-ssp.h>.
	(__longjmp): Restore shadow stack pointer if shadow stack is
	enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
	isn't defined for __longjmp_cancel.
	* sysdeps/x86_64/setjmp.S: Include <jmp_buf-ssp.h>.
	(__sigsetjmp): Save shadow stack pointer if shadow stack is
	enabled and SHADOW_STACK_POINTER_OFFSET is defined.
2018-07-14 05:59:53 -07:00
H.J. Lu ebff9c5cfa x86: Rename __glibc_reserved1 to feature_1 in tcbhead_t [BZ #22563]
feature_1 has X86_FEATURE_1_IBT and X86_FEATURE_1_SHSTK bits for CET
run-time control.

CET_ENABLED, IBT_ENABLED and SHSTK_ENABLED are defined to 1 or 0 to
indicate that if CET, IBT and SHSTK are enabled.

<tls-setup.h> is added to set up thread-local data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #22563]
	* nptl/pthread_create.c: Include <tls-setup.h>.
	(__pthread_create_2_1): Call tls_setup_tcbhead.
	* sysdeps/generic/tls-setup.h: New file.
	* sysdeps/x86/nptl/tls-setup.h: Likewise.
	* sysdeps/i386/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (FEATURE_1_OFFSET):
	Likewise.
	* sysdeps/i386/nptl/tls.h (tcbhead_t): Rename __glibc_reserved1
	to feature_1.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Likewise.
	* sysdeps/x86/sysdep.h (X86_FEATURE_1_IBT): New.
	(X86_FEATURE_1_SHSTK): Likewise.
	(CET_ENABLED): Likewise.
	(IBT_ENABLED): Likewise.
	(SHSTK_ENABLED): Likewise.
2018-07-14 05:56:46 -07:00
Rafal Luzynski 0a83bad2aa dsb_DE locale: Fix syntax error and add tests (bug 23208).
Fixed syntax error in the collation rules of Lower Sorbian language.
Collation test added in order to test the bugs like this early.

Reported-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

	[BZ #23208]
	* localedata/Makefile (test-input): Add dsb_DE.UTF-8.
	(LOCALES): Likewise.
	* localedata/dsb_DE.UTF-8.in: New file.
	* localedata/locales/dsb_DE (LC_COLLATE): Fix syntax error.
2018-07-13 23:06:32 +02:00
Florian Weimer 046bfed9de nptl: Use __mprotect consistently for _STACK_GROWS_UP 2018-07-12 15:01:43 +02:00
Florian Weimer 93304f5f7a Install <bits/statx.h> header 2018-07-11 08:59:51 +02:00
Mike FABIAN 4beefeeb8e Put the correct Unicode version number 11.0.0 into the generated files
In some places there was still the old Unicode version 10.0.0 in the files.

	* localedata/charmaps/UTF-8: Use correct Unicode version 11.0.0 in comment.
	* localedata/locales/i18n_ctype: Use correct Unicode version in comments
	and headers.
	* localedata/unicode-gen/utf8_gen.py: Add option to specify Unicode version
	* localedata/unicode-gen/Makefile: Use option to specify Unicode version
	for utf8_gen.py
2018-07-10 17:30:31 +02:00
Florian Weimer fd70af4552 Add the statx function 2018-07-10 16:14:45 +02:00
Adhemerval Zanella b444e8f7cc Comment tst-ofdlocks-compat expected failure in some Linux releases
As pointed out in a libc-alpha thread [1], the misc/tst-ofdlocks-compat
may fail in some specific Linux releases.  This patch adds a comment
along with a link to discussion in the test source code.

No changes are expected.

	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Add a comment about
	a kernel issue which lead to test failure in some cases.

[1] https://sourceware.org/ml/libc-alpha/2018-07/msg00243.html
2018-07-10 10:28:39 -03:00
Florian Weimer 7b2f4cedf0 regexec: Fix off-by-one bug in weight comparison [BZ #23036]
Each weight is prefixed by its length, and the length does not include
itself in the count.  This can be seen clearly from the find_idx
function in string/strxfrm_l.c, for example.  The old code behaved as if
the length itself counted, thus comparing an additional byte after the
weight, leading to spurious comparison failures and incorrect further
partitioning of character equivalence classes.
2018-07-10 11:18:26 +02:00
Florian Weimer 4fa34da679 Fix copyright years in recent commits 2018-07-10 11:03:08 +02:00
Florian Weimer 916124ed84 nss_files: Fix re-reading of long lines [BZ #18991]
Use the new __libc_readline_unlocked function to pick up
reading at the same line in case the buffer needs to be enlarged.
2018-07-06 17:52:54 +02:00
Florian Weimer 3f5e3f5d06 libio: Implement internal function __libc_readline_unlocked
This is a variant of fgets which fails with ERANGE if the
buffer is too small, and the buffer length is given as an
argument of type size_t.

This function will be useful for implementing NSS file reading
operations.  Compared to a direct implementation using the public API,
it avoids an lseek system call in case the line terminator can be
found in the internal read buffer.
2018-07-06 17:52:54 +02:00
Szabolcs Nagy 397c54c1af aarch64: add HWCAP_ATOMICS to HWCAP_IMPORTANT
This enables searching shared libraries in atomics/ when the hardware
supports LSE atomics of armv8.1 so one can provide optimized variants
of libraries in a portable way.

LSE atomics does not affect library abi, the new instructions can
interoperate with old ones.

I considered the earlier comments on the patch

https://sourceware.org/ml/libc-alpha/2018-04/msg00400.html
https://sourceware.org/ml/libc-alpha/2018-04/msg00625.html

It turns out that the way glibc dynamic linker decides on the search
path is not very flexible: it wants to use hwcap bits and associated
strings.  So some targets reuse hwcap bits for glibc internal purposes
to affect the search logic.  But hwcap is an interface with the kernel,
glibc should not allocate bits in it for its internal logic as that
limits future hwcap extensions and confusing to users who expect to see
hwcap bits in ifunc resolvers.  Instead of rewriting the dynamic linker
path logic (which affects all targets) this patch just uses the existing
mechanism, however this means that the path name has to be the hwcap
name "atomics" and cannot be changed to something more meaningful to
users.

It is hard to tell how much performance benefit this can give, in
principle armv8.1 atomics can be better optimized in the hardware, so it
can make a difference for synchronization heavy code.  On some systems
such multilib setup may be the only viable way to get optimized
libraries used.

	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT): Add
	HWCAP_ATOMICS.
2018-07-06 15:58:16 +01:00
Szabolcs Nagy d0cd798071 aarch64: Remove HWCAP_CPUID from HWCAP_IMPORTANT
This partially reverts

commit f82e9672ad
Author:     Siddhesh Poyarekar <siddhesh@sourceware.org>

    aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK

The idea was to make it possible to disable cpuid based ifunc resolution
in glibc by changing the hwcap mask which the user could already control.

However the hwcap mask has an orthogonal role: it specifies additional
library search paths for the dynamic linker.  So "cpuid" got added to
the search paths when it was set in the default mask (HWCAP_IMPORTANT),
which is not useful behaviour, the hwcap masking should not be reused
in the cpu features code.

Meanwhile there is a tunable to set the cpu explicitly so it is possible
to disable the cpuid based dispatch without using a hwcap mask:

  GLIBC_TUNABLES=glibc.tune.cpu=generic

	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features):
	Use dl_hwcap without masking.
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT):
	Remove HWCAP_CPUID.
2018-07-06 15:57:18 +01:00
Florian Weimer ddb3c626b0 conform/conformtest.pl: Escape literal braces in regular expressions
This suppresses Perl warnings like these:

Unescaped left brace in regex is deprecated here (and will be fatal in
Perl 5.32), passed through in regex; marked by <-- HERE in m/^element
*({ <-- HERE ([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*)
*(.*)/ at conformtest.pl line 370.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-06 16:31:55 +02:00
Amit Pawar bce5911b67 Use AVX_Fast_Unaligned_Load from Zen onwards.
From Zen onwards this will be enabled. It was disabled for the
Excavator case and will remain disabled.

Reviewd-by: Carlos O'Donell <carlos@redhat.com>
2018-07-06 09:55:36 -04:00
Florian Weimer 3a885c1f51 Build csu/elf-init.c and csu/static-reloc.c with stack protector
This does not change generated code (with -fstack-protector-strong), but
is important for formal compiler flags compliance.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-05 22:57:45 +02:00
Florian Weimer 38cade0c46 Compile debug/stack_chk_fail_local.c with stack protector
The resulting object file is statically linked into applications, so
it is desirable to have (formal) stack protector coverage there.
2018-07-05 19:28:35 +02:00
Maciej W. Rozycki 9449a295ad libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
where correct absolute (SHN_ABS) symbol run-time load semantics is
required.  This way it can be ensured at static link time that a program
or DSO will not suffer from previous semantics where absolute symbols
were relocated by the base address, or symbols whose `st_value' is zero
silently ignored leading to a confusing "undefined symbol" error message
at load time, and instead "ELF file ABI version invalid" is printed with
old dynamic loaders, making it clear that there is an ABI version
incompatibility.

	[BZ #19818]
	[BZ #23307]
	* libc-abis (ABSOLUTE): New ABI.
	* sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
	* NEWS: Mention the new ABI.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-05 18:06:43 +01:00
Florian Weimer d6da5cb6a8 Add renameat2 function [BZ #17662]
The implementation falls back to renameat if renameat2 is not available
in the kernel (or in the kernel headers) and the flags argument is zero.
Without kernel support, a non-zero argument returns EINVAL, not ENOSYS.
This mirrors what the kernel does for invalid renameat2 flags.
2018-07-05 19:00:10 +02:00
Adhemerval Zanella 1002d70823 posix: Fix bug-regex33 after regex sync
On some platforms the inclusion of regex-internal.h in bug-regex33
testcase show a MAX redefinition if test-skeleton.c is include later.
This patch fixes by removing regex-internal.h inclusion and using
SBC_MAX value directly.

Checked on aarch64-linux-gnu.

	* posix/bug-regex33.c: Fix build after regex sync.
2018-07-04 17:29:49 -03:00
Carlos O'Donell 34fdb893e0 locale: XFAIL newlocale usage in static binary (Bug 23164)
There is a glibc optimization which allows for locale categories
to be removed during static compilation. There have been various
bugs for this support over the years, with bug 16915 being the
most recent. The solution there was to emit a reference to all the
categories to avoid any being removed. This fix, although it's in
the generic __nl_langinfo_l function, doesn't appear to be enough
to fix the case for a statically linked program that uses newlocale
and nl_langinfo_l. This commit doesn't fix the problem, but it does
add a XFAIL'd test case such that a fix can be applied against this
and the XFAIL removed. It's not entirely clear that the problem is
the same as that which was seen in bug 16915.
2018-07-04 15:23:50 -04:00
Florian Weimer f2873d2da0 testrun.sh: Implement --tool=strace, --tool=valgrind
$(file …) appears to be the only convenient way to create files
with newlines and make substitution variables.  This needs make 4.0
(released in 2013), so update the requirement to match.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-04 15:30:45 +02:00
Adhemerval Zanella eb04c21373 posix: Sync gnulib regex implementation
This patch syncs the regex implementation with gnulib (commit 0ee5212).
Only two changes in GLIBC regex testing are required:

  1. posix/bug-regex28.c: as previously discussed [1] the change of
     expected results on the pattern should be safe.

  2. posix/PCRE.tests: the ERE (a)|\1 is malformed (in the sense that
     the \1 doesn't mean anything) and although current GLIBC accepts
     it has undefined behavior.  This patch removes the specific test.

This sync contains some patches from thread 'Regex: Make libc regex
more usable outside GLIBC.' [2] which have been pushed upstream in
gnulib.  This patches also fixes some regex issues (BZ #23233,
BZ #21163, BZ #18986, BZ #13762) and I did not add testcases for
both #23233 and #13762 because I couldn't think a simple way to
trigger the expected failure path to trigger them.

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

	[BZ #23233]
	[BZ #21163]
	[BZ #18986]
	[BZ #13762]
	* posix/Makefile (tests): Add bug-regex37 and bug-regex38.
	* posix/PCRE.tests: Remove invalid test.
	* posix/bug-regex28.c: Fix expected values for used syntax.
	* posix/bug-regex37.c: New file.
	* posix/bug-regex38.c: Likewise.
	* posix/regcomp.c: Sync with gnulib.
	* posix/regex.c: Likewise.
	* posix/regex.h: Likewise.
	* posix/regex_internal.c: Likewise.
	* posix/regex_internal.h: Likewise.
	* posix/regexec.c: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00807.html
[2] https://sourceware.org/ml/libc-alpha/2017-12/msg00237.html
2018-07-04 09:54:45 -03:00
Mike FABIAN b11643c21c Bug 23308: Update to Unicode 11.0.0
Unicode 11.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 11.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Some info about the number of characters added:

Total added characters in newly generated CHARMAP: 684
Total added characters in newly generated WIDTH: 119
alpha: Added 380 characters in new ctype which were not in old ctype
combining: Added 56 characters in new ctype which were not in old ctype
combining_level3: Added 37 characters in new ctype which were not in old ctype
graph: Added 684 characters in new ctype which were not in old ctype
lower: Added 82 characters in new ctype which were not in old ctype
print: Added 684 characters in new ctype which were not in old ctype
punct: Added 304 characters in new ctype which were not in old ctype
tolower: Added 79 characters in new ctype which were not in old ctype
totitle: Added 33 characters in new ctype which were not in old ctype
toupper: Added 79 characters in new ctype which were not in old ctype
upper: Added 79 characters in new ctype which were not in old ctype

No characters were removed.

	[BZ #23308]
	* unicode-gen/Makefile (UNICODE_VERSION): Set to 11.0.0.
	* localedata/unicode-gen/DerivedCoreProperties.txt: Update to Unicode 11.0.0.
	* localedata/unicode-gen/EastAsianWidth.txt: likewise.
	* localedata/unicode-gen/PropList.txt: likewise.
	* localedata/unicode-gen/UnicodeData.txt: likewise.
	* localedata/charmaps/UTF-8: Regenerate.
	* localedata/locales/i18n_ctype: likewise.
	* localedata/locales/tr_TR: likewise.
	* localedata/locales/translit_circle: likewise.
	* localedata/locales/translit_cjk_compat: likewise.
	* localedata/locales/translit_combining: likewise.
	* localedata/locales/translit_compat: likewise.
	* localedata/locales/translit_font: likewise.
	* localedata/locales/translit_fraction: likewise.
2018-07-04 12:03:33 +02:00
Florian Weimer 5a35750665 stdio-common/tst-printf.c: Remove part under a non-free license [BZ #23363]
The license does not allow modification.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-03 18:29:16 +02:00
Adhemerval Zanella 7279af007c Fix hurd expected fcntl version
Different than Linux, hurd does not need the OFD locks fix from
06ab719d30 (since OFD locks are current Linux specific). This in
turn allows hurd to not provide a fcntl compat symbol.

Checked on a i686-gnu with check-abi.

	* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl): Remove
	symbol.
2018-07-03 10:02:06 -03:00
Gabriel F. T. Gomes b7b88cea41 ldbl-128ibm-compat: Add printf_size
Since the addition of the _Float128 API, strfromf128 and printf_size use
__printf_fp to print _Float128 values.  This is achieved by setting the
'is_binary128' member of the 'printf_info' structure to one.  Now that
the format of long double on powerpc64le is getting a third option, this
mechanism is reused for long double values that have binary128 format
(i.e.: when -mabi=ieeelongdouble).

This patch adds __printf_sizeieee128 as an exported symbol, but doesn't
provide redirections from printf_size, yet.  All redirections will be
installed in a future commit, once all other functions that print or
read long double values with binary128 format are ready.  In
__printf_fp, when 'is_binary128' is one, the floating-point argument is
treated as if it was of _Float128 type, regardless of the value of
'is_long_double', thus __printf_sizeieee128 sets 'is_binary128' to the
same value of 'is_long_double'.  Otherwise, double values would not be
printed correctly.

Tested for powerpc64le.
2018-07-02 10:51:01 -03:00
Szabolcs Nagy 2b445206a1 Use uint32_t sign in single precision math error handling functions
Ideally sign should be bool, but sometimes (e.g. in powf) it's more
efficient to pass a non-zero value than 1 to indicate that the sign
should be set.  The fixed size int is less ambigous than unsigned
long.

	* sysdeps/ieee754/flt-32/e_powf.c (__powf): Use uint32_t.
	(exp2f_inline): Likewise.
	* sysdeps/ieee754/flt-32/math_config.h (__math_oflowf): Likewise.
	(__math_uflowf): Likewise.
	(__math_may_uflowf): Likewise.
	(__math_divzerof): Likewise.
	(__math_invalidf): Likewise.
	* sysdeps/ieee754/flt-32/math_errf.c (xflowf): Likewise.
	(__math_oflowf): Likewise.
	(__math_uflowf): Likewise.
	(__math_may_uflowf): Likewise.
	(__math_divzerof): Likewise.
	(__math_invalidf): Likewise.
2018-07-02 09:29:04 +01:00
Carlos O'Donell 2827ab990a libc: Extend __libc_freeres framework (Bug 23329).
The __libc_freeres framework does not extend to non-libc.so objects.
This causes problems in general for valgrind and mtrace detecting
unfreed objects in both libdl.so and libpthread.so.  This change is
a pre-requisite to properly moving the malloc hooks out of malloc
since such a move now requires precise accounting of all allocated
data before destructors are run.

This commit adds a proper hook in libc.so.6 for both libdl.so and
for libpthread.so, this ensures that shm-directory.c which uses
freeit () to free memory is called properly.  We also remove the
nptl_freeres hook and fall back to using weak-ref-and-check idiom
for a loaded libpthread.so, thus making this process similar for
all DSOs.

Lastly we follow best practice and use explicit free calls for
both libdl.so and libpthread.so instead of the generic hook process
which has undefined order.

Tested on x86_64 with no regressions.

Signed-off-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-06-29 22:39:06 -04:00
Rajalakshmi Srinivasaraghavan 37d3d244e1 Add long double input for strfmon test
This patch adds long double type inputs in strfmon_l test
which will help in long double migration.

Tested for powerpc64le.
2018-06-30 06:54:34 +05:30
Michael Wolf a1e0c5fa88 New locale: Lower Sorbian (dsb_DE) [BZ #23208]
[BZ #23208]
	* localedata/SUPPORTED (dsb_DE/UTF-8): New entry.
	* localedata/locales/dsb_DE: New file.
2018-06-29 23:03:06 +02:00
Rafal Luzynski 2e0c5de622 hy_AM: Add alternative month names (bug 23140).
This locale already contained correct data in mon array.  Updated from
CLDR to start the month names with the lowercase letters.

alt_mon is a new import from CLDR.  The change has been consulted
off-list with a native speaker.

	[BZ #23140]
	* localedata/locales/hy_AM (mon): Synchronize with CLDR (lowercase,
	genitive case).
	(alt_mon): New entry, import from CLDR (nominative case).
2018-06-29 22:18:24 +02:00
Sylvain Lesage cdb52c7182 es_BO locale: Change LC_PAPER to en_US (bug 22996).
[BZ #22996]
	* localedata/locales/es_BO (LC_PAPER): Change to “copy "en_US"”.
2018-06-29 21:45:16 +02:00
Siddhesh Poyarekar 0aec4c1d18 aarch64,falkor: Use vector registers for memcpy
Vector registers perform better than scalar register pairs for copying
data so prefer them instead.  This results in a time reduction of over
50% (i.e. 2x speed improvemnet) for some smaller sizes for memcpy-walk.
Larger sizes show improvements of around 1% to 2%.  memcpy-random shows
a very small improvement, in the range of 1-2%.

	* sysdeps/aarch64/multiarch/memcpy_falkor.S (__memcpy_falkor):
	Use vector registers.
2018-06-29 22:45:59 +05:30
Siddhesh Poyarekar ce76a5cb8d aarch64,falkor: Use vector registers for memmove
Vector registers perform much better for moves compared to pairs of
registers on falkor, so use them instead.  This results in a time
reduction of up to 50% (i.e. 2x improvement) for a lot of the smaller
sizes, i.e. up to 1K in memmove-walk.  Improvements for larger sizes are
smaller, at about 1%-2%.

	* sysdeps/aarch64/multiarch/memmove_falkor.S
	(__memcpy_falkor): Use vector registers.
2018-06-29 22:45:07 +05:30
Martin Sebor 7e8989d03b Document interaction with GCC built-ins in the Customizing Printf
section of the manual.
2018-06-29 10:45:19 -06:00
Maciej W. Rozycki bac15a72fc elf: Accept absolute (SHN_ABS) symbols whose value is zero [BZ #23307]
We have this condition in `check_match' (in elf/dl-lookup.c):

  if (__glibc_unlikely ((sym->st_value == 0 /* No value.  */
                         && stt != STT_TLS)
                        || ELF_MACHINE_SYM_NO_MATCH (sym)
                        || (type_class & (sym->st_shndx == SHN_UNDEF))))
    return NULL;

which causes all !STT_TLS symbols whose value is zero to be silently
ignored in lookup.  This may make sense for regular symbols, however not
for absolute (SHN_ABS) ones, where zero is like any value, there's no
special meaning attached to it.

Consequently legitimate programs fail, for example taking the
`elf/tst-absolute-sym' test case, substituting 0 for 0x55aa in
`elf/tst-absolute-sym-lib.lds' and then trying to run the resulting
program we get this:

$ .../elf/tst-absolute-sym
.../elf/tst-absolute-sym: symbol lookup error: .../elf/tst-absolute-sym-lib.so: undefined symbol: absolute
$

even though the symbol clearly is there:

$ readelf --dyn-syms .../elf/tst-absolute-sym-lib.so | grep '\babsolute\b'
     7: 00000000     0 NOTYPE  GLOBAL DEFAULT  ABS absolute
$

The check for the zero value has been there since forever or commit
d66e34cd4234/08162fa88891 ("Implemented runtime dynamic linker to
support ELF shared libraries.") dating back to May 2nd 1995, and the
problem triggers regardless of commit e7feec374c ("elf: Correct
absolute (SHN_ABS) symbol run-time calculation [BZ #19818]") being
present or not.

Fix the issue then, by permitting `sym->st_value' to be 0 for SHN_ABS
symbols in lookup.

	[BZ #23307]
	* elf/dl-lookup.c (check_match): Do not reject a symbol whose
	`st_value' is 0 if `st_shndx' is SHN_ABS.
	* elf/tst-absolute-zero.c: New file.
	* elf/tst-absolute-zero-lib.c: New file.
	* elf/tst-absolute-zero-lib.lds: New file.
	* elf/Makefile (tests): Add `tst-absolute-zero'.
	(modules-names): Add `tst-absolute-zero-lib'.
	(LDLIBS-tst-absolute-zero-lib.so): New variable.
	($(objpfx)tst-absolute-zero-lib.so): New dependency.
	($(objpfx)tst-absolute-zero: New dependency.
2018-06-29 17:10:43 +01:00