2015-08-13 10:37:47 +00:00
|
|
|
ifeq ($(subdir),csu)
|
2016-05-11 12:49:09 +00:00
|
|
|
gen-as-const-headers += cpu-features-offsets.sym
|
2015-08-13 10:37:47 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(subdir),elf)
|
2020-12-25 15:30:46 +00:00
|
|
|
sysdep_routines += get-cpuid-feature-leaf
|
2015-08-13 10:37:47 +00:00
|
|
|
sysdep-dl-routines += dl-get-cpu-features
|
2021-06-05 13:42:20 +00:00
|
|
|
sysdep_headers += sys/platform/x86.h bits/platform/x86.h
|
2015-08-13 10:37:47 +00:00
|
|
|
|
2022-01-14 19:16:05 +00:00
|
|
|
CFLAGS-dl-get-cpu-features.os += $(rtld-early-cflags)
|
2021-03-15 14:54:45 +00:00
|
|
|
CFLAGS-get-cpuid-feature-leaf.o += $(no-stack-protector)
|
|
|
|
|
x86: Install <sys/platform/x86.h> [BZ #26124]
Install <sys/platform/x86.h> so that programmers can do
#if __has_include(<sys/platform/x86.h>)
#include <sys/platform/x86.h>
#endif
...
if (CPU_FEATURE_USABLE (SSE2))
...
if (CPU_FEATURE_USABLE (AVX2))
...
<sys/platform/x86.h> exports only:
enum
{
COMMON_CPUID_INDEX_1 = 0,
COMMON_CPUID_INDEX_7,
COMMON_CPUID_INDEX_80000001,
COMMON_CPUID_INDEX_D_ECX_1,
COMMON_CPUID_INDEX_80000007,
COMMON_CPUID_INDEX_80000008,
COMMON_CPUID_INDEX_7_ECX_1,
/* Keep the following line at the end. */
COMMON_CPUID_INDEX_MAX
};
struct cpuid_features
{
struct cpuid_registers cpuid;
struct cpuid_registers usable;
};
struct cpu_features
{
struct cpu_features_basic basic;
struct cpuid_features features[COMMON_CPUID_INDEX_MAX];
};
/* Get a pointer to the CPU features structure. */
extern const struct cpu_features *__x86_get_cpu_features
(unsigned int max) __attribute__ ((const));
Since all feature checks are done through macros, programs compiled with
a newer <sys/platform/x86.h> are compatible with the older glibc binaries
as long as the layout of struct cpu_features is identical. The features
array can be expanded with backward binary compatibility for both .o and
.so files. When COMMON_CPUID_INDEX_MAX is increased to support new
processor features, __x86_get_cpu_features in the older glibc binaries
returns NULL and HAS_CPU_FEATURE/CPU_FEATURE_USABLE return false on the
new processor feature. No new symbol version is neeeded.
Both CPU_FEATURE_USABLE and HAS_CPU_FEATURE are provided. HAS_CPU_FEATURE
can be used to identify processor features.
Note: Although GCC has __builtin_cpu_supports, it only supports a subset
of <sys/platform/x86.h> and it is equivalent to CPU_FEATURE_USABLE. It
doesn't support HAS_CPU_FEATURE.
2020-06-30 01:30:54 +00:00
|
|
|
tests += tst-get-cpu-features tst-get-cpu-features-static \
|
2021-02-04 18:39:34 +00:00
|
|
|
tst-cpu-features-cpuinfo tst-cpu-features-cpuinfo-static \
|
|
|
|
tst-cpu-features-supports tst-cpu-features-supports-static
|
|
|
|
tests-static += tst-get-cpu-features-static \
|
|
|
|
tst-cpu-features-cpuinfo-static \
|
|
|
|
tst-cpu-features-supports-static
|
2021-01-12 22:41:10 +00:00
|
|
|
ifeq (yes,$(have-ifunc))
|
2021-03-24 00:10:38 +00:00
|
|
|
ifeq (yes,$(have-gcc-ifunc))
|
2021-01-12 22:41:10 +00:00
|
|
|
tests += \
|
|
|
|
tst-ifunc-isa-1 \
|
2021-07-23 08:27:56 +00:00
|
|
|
tst-ifunc-isa-1-static
|
|
|
|
tests-static += \
|
|
|
|
tst-ifunc-isa-1-static
|
2021-08-30 20:59:33 +00:00
|
|
|
test-xfail-tst-ifunc-isa-1 = $(with-lld)
|
|
|
|
test-xfail-tst-ifunc-isa-1-static = $(with-lld)
|
2021-07-23 08:27:56 +00:00
|
|
|
ifneq ($(have-tunables),no)
|
|
|
|
tests += \
|
2021-01-12 22:41:10 +00:00
|
|
|
tst-ifunc-isa-2 \
|
|
|
|
tst-ifunc-isa-2-static
|
|
|
|
tests-static += \
|
|
|
|
tst-ifunc-isa-2-static
|
2021-08-30 20:59:33 +00:00
|
|
|
test-xfail-tst-ifunc-isa-2 = $(with-lld)
|
|
|
|
test-xfail-tst-ifunc-isa-2-static = $(with-lld)
|
2021-01-12 22:41:10 +00:00
|
|
|
endif
|
2021-03-24 00:10:38 +00:00
|
|
|
endif
|
2021-07-23 08:27:56 +00:00
|
|
|
endif
|
2020-10-09 13:06:56 +00:00
|
|
|
ifeq (yes,$(enable-x86-isa-level))
|
|
|
|
tests += tst-isa-level-1
|
|
|
|
modules-names += tst-isa-level-mod-1-baseline \
|
|
|
|
tst-isa-level-mod-1-v2 \
|
|
|
|
tst-isa-level-mod-1-v3 \
|
|
|
|
tst-isa-level-mod-1-v4 \
|
|
|
|
|
|
|
|
# X86 ISA level baseline
|
|
|
|
CFLAGS-tst-isa-level-mod-1-baseline.c += -DINCLUDE_X86_ISA_LEVEL \
|
|
|
|
-DISA_LEVEL=0x1 \
|
|
|
|
-march=x86-64
|
|
|
|
# X86 ISA level v2
|
|
|
|
CFLAGS-tst-isa-level-mod-1-v2.c += -DINCLUDE_X86_ISA_LEVEL \
|
|
|
|
-DISA_LEVEL=0x3 \
|
|
|
|
-march=x86-64
|
|
|
|
# X86 ISA level v3
|
|
|
|
CFLAGS-tst-isa-level-mod-1-v3.c += -DINCLUDE_X86_ISA_LEVEL \
|
|
|
|
-DISA_LEVEL=0x7 \
|
|
|
|
-march=x86-64
|
|
|
|
# X86 ISA level v4
|
|
|
|
CFLAGS-tst-isa-level-mod-1-v4.c += -DINCLUDE_X86_ISA_LEVEL \
|
|
|
|
-DISA_LEVEL=0xf \
|
|
|
|
-march=x86-64
|
|
|
|
|
|
|
|
$(objpfx)tst-isa-level-1.out: $(objpfx)tst-isa-level-mod-1-baseline.so \
|
|
|
|
$(objpfx)tst-isa-level-mod-1-v2.so \
|
|
|
|
$(objpfx)tst-isa-level-mod-1-v3.so \
|
|
|
|
$(objpfx)tst-isa-level-mod-1-v4.so
|
|
|
|
endif
|
2021-01-12 22:41:10 +00:00
|
|
|
ifneq ($(have-tunables),no)
|
|
|
|
tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512F
|
|
|
|
tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV)
|
|
|
|
endif
|
2015-08-13 10:37:47 +00:00
|
|
|
endif
|
x86: Use pad in pthread_unwind_buf to preserve shadow stack register
The pad array in struct pthread_unwind_buf is used by setjmp to save
shadow stack register. We assert that size of struct pthread_unwind_buf
is no less than offset of shadow stack pointer + shadow stack pointer
size.
Since functions, like LIBC_START_MAIN, START_THREAD_DEFN as well as
these with thread cancellation, call setjmp, but never return after
__libc_unwind_longjmp, __libc_unwind_longjmp, which is defined as
__libc_longjmp on x86, doesn't need to restore shadow stack register.
__libc_longjmp, which is a private interface for thread cancellation
implementation in libpthread, is changed to call __longjmp_cancel,
instead of __longjmp. __longjmp_cancel is a new internal function
in libc, which is similar to __longjmp, but doesn't restore shadow
stack register.
The compatibility longjmp and siglongjmp in libpthread.so are changed
to call __libc_siglongjmp, instead of __libc_longjmp, so that they will
restore shadow stack register.
Tested with build-many-glibcs.py.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl/pthread_create.c (START_THREAD_DEFN): Clear previous
handlers after setjmp.
* setjmp/longjmp.c (__libc_longjmp): Don't define alias if
defined.
* sysdeps/unix/sysv/linux/x86/setjmpP.h: Include
<libc-pointer-arith.h>.
(_JUMP_BUF_SIGSET_BITS_PER_WORD): New.
(_JUMP_BUF_SIGSET_NSIG): Changed to 96.
(_JUMP_BUF_SIGSET_NWORDS): Changed to use ALIGN_UP and
_JUMP_BUF_SIGSET_BITS_PER_WORD.
* sysdeps/x86/Makefile (sysdep_routines): Add __longjmp_cancel.
* sysdeps/x86/__longjmp_cancel.S: New file.
* sysdeps/x86/longjmp.c: Likewise.
* sysdeps/x86/nptl/pt-longjmp.c: Likewise.
2018-05-02 13:17:20 +00:00
|
|
|
|
2020-09-22 17:07:48 +00:00
|
|
|
ifeq ($(subdir),math)
|
|
|
|
tests += tst-ldbl-nonnormal-printf
|
|
|
|
endif # $(subdir) == math
|
|
|
|
|
x86: Use pad in pthread_unwind_buf to preserve shadow stack register
The pad array in struct pthread_unwind_buf is used by setjmp to save
shadow stack register. We assert that size of struct pthread_unwind_buf
is no less than offset of shadow stack pointer + shadow stack pointer
size.
Since functions, like LIBC_START_MAIN, START_THREAD_DEFN as well as
these with thread cancellation, call setjmp, but never return after
__libc_unwind_longjmp, __libc_unwind_longjmp, which is defined as
__libc_longjmp on x86, doesn't need to restore shadow stack register.
__libc_longjmp, which is a private interface for thread cancellation
implementation in libpthread, is changed to call __longjmp_cancel,
instead of __longjmp. __longjmp_cancel is a new internal function
in libc, which is similar to __longjmp, but doesn't restore shadow
stack register.
The compatibility longjmp and siglongjmp in libpthread.so are changed
to call __libc_siglongjmp, instead of __libc_longjmp, so that they will
restore shadow stack register.
Tested with build-many-glibcs.py.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl/pthread_create.c (START_THREAD_DEFN): Clear previous
handlers after setjmp.
* setjmp/longjmp.c (__libc_longjmp): Don't define alias if
defined.
* sysdeps/unix/sysv/linux/x86/setjmpP.h: Include
<libc-pointer-arith.h>.
(_JUMP_BUF_SIGSET_BITS_PER_WORD): New.
(_JUMP_BUF_SIGSET_NSIG): Changed to 96.
(_JUMP_BUF_SIGSET_NWORDS): Changed to use ALIGN_UP and
_JUMP_BUF_SIGSET_BITS_PER_WORD.
* sysdeps/x86/Makefile (sysdep_routines): Add __longjmp_cancel.
* sysdeps/x86/__longjmp_cancel.S: New file.
* sysdeps/x86/longjmp.c: Likewise.
* sysdeps/x86/nptl/pt-longjmp.c: Likewise.
2018-05-02 13:17:20 +00:00
|
|
|
ifeq ($(subdir),setjmp)
|
2018-07-14 12:59:29 +00:00
|
|
|
gen-as-const-headers += jmp_buf-ssp.sym
|
x86: Use pad in pthread_unwind_buf to preserve shadow stack register
The pad array in struct pthread_unwind_buf is used by setjmp to save
shadow stack register. We assert that size of struct pthread_unwind_buf
is no less than offset of shadow stack pointer + shadow stack pointer
size.
Since functions, like LIBC_START_MAIN, START_THREAD_DEFN as well as
these with thread cancellation, call setjmp, but never return after
__libc_unwind_longjmp, __libc_unwind_longjmp, which is defined as
__libc_longjmp on x86, doesn't need to restore shadow stack register.
__libc_longjmp, which is a private interface for thread cancellation
implementation in libpthread, is changed to call __longjmp_cancel,
instead of __longjmp. __longjmp_cancel is a new internal function
in libc, which is similar to __longjmp, but doesn't restore shadow
stack register.
The compatibility longjmp and siglongjmp in libpthread.so are changed
to call __libc_siglongjmp, instead of __libc_longjmp, so that they will
restore shadow stack register.
Tested with build-many-glibcs.py.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl/pthread_create.c (START_THREAD_DEFN): Clear previous
handlers after setjmp.
* setjmp/longjmp.c (__libc_longjmp): Don't define alias if
defined.
* sysdeps/unix/sysv/linux/x86/setjmpP.h: Include
<libc-pointer-arith.h>.
(_JUMP_BUF_SIGSET_BITS_PER_WORD): New.
(_JUMP_BUF_SIGSET_NSIG): Changed to 96.
(_JUMP_BUF_SIGSET_NWORDS): Changed to use ALIGN_UP and
_JUMP_BUF_SIGSET_BITS_PER_WORD.
* sysdeps/x86/Makefile (sysdep_routines): Add __longjmp_cancel.
* sysdeps/x86/__longjmp_cancel.S: New file.
* sysdeps/x86/longjmp.c: Likewise.
* sysdeps/x86/nptl/pt-longjmp.c: Likewise.
2018-05-02 13:17:20 +00:00
|
|
|
sysdep_routines += __longjmp_cancel
|
2021-01-13 03:00:13 +00:00
|
|
|
ifneq ($(enable-cet),no)
|
|
|
|
ifneq ($(have-tunables),no)
|
|
|
|
tests += tst-setjmp-cet
|
|
|
|
tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on
|
|
|
|
endif
|
|
|
|
endif
|
x86: Use pad in pthread_unwind_buf to preserve shadow stack register
The pad array in struct pthread_unwind_buf is used by setjmp to save
shadow stack register. We assert that size of struct pthread_unwind_buf
is no less than offset of shadow stack pointer + shadow stack pointer
size.
Since functions, like LIBC_START_MAIN, START_THREAD_DEFN as well as
these with thread cancellation, call setjmp, but never return after
__libc_unwind_longjmp, __libc_unwind_longjmp, which is defined as
__libc_longjmp on x86, doesn't need to restore shadow stack register.
__libc_longjmp, which is a private interface for thread cancellation
implementation in libpthread, is changed to call __longjmp_cancel,
instead of __longjmp. __longjmp_cancel is a new internal function
in libc, which is similar to __longjmp, but doesn't restore shadow
stack register.
The compatibility longjmp and siglongjmp in libpthread.so are changed
to call __libc_siglongjmp, instead of __libc_longjmp, so that they will
restore shadow stack register.
Tested with build-many-glibcs.py.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl/pthread_create.c (START_THREAD_DEFN): Clear previous
handlers after setjmp.
* setjmp/longjmp.c (__libc_longjmp): Don't define alias if
defined.
* sysdeps/unix/sysv/linux/x86/setjmpP.h: Include
<libc-pointer-arith.h>.
(_JUMP_BUF_SIGSET_BITS_PER_WORD): New.
(_JUMP_BUF_SIGSET_NSIG): Changed to 96.
(_JUMP_BUF_SIGSET_NWORDS): Changed to use ALIGN_UP and
_JUMP_BUF_SIGSET_BITS_PER_WORD.
* sysdeps/x86/Makefile (sysdep_routines): Add __longjmp_cancel.
* sysdeps/x86/__longjmp_cancel.S: New file.
* sysdeps/x86/longjmp.c: Likewise.
* sysdeps/x86/nptl/pt-longjmp.c: Likewise.
2018-05-02 13:17:20 +00:00
|
|
|
endif
|
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 21:08:15 +00:00
|
|
|
|
2020-07-11 16:04:34 +00:00
|
|
|
ifeq ($(subdir),string)
|
|
|
|
sysdep_routines += cacheinfo
|
2021-02-23 14:33:10 +00:00
|
|
|
|
|
|
|
tests += \
|
|
|
|
tst-memchr-rtm \
|
|
|
|
tst-memcmp-rtm \
|
|
|
|
tst-memmove-rtm \
|
|
|
|
tst-memrchr-rtm \
|
|
|
|
tst-memset-rtm \
|
|
|
|
tst-strchr-rtm \
|
|
|
|
tst-strcpy-rtm \
|
|
|
|
tst-strlen-rtm \
|
|
|
|
tst-strncmp-rtm \
|
2022-02-18 20:19:15 +00:00
|
|
|
tst-strrchr-rtm \
|
|
|
|
tst-wcsncmp-rtm \
|
|
|
|
# tests
|
2021-02-23 14:33:10 +00:00
|
|
|
|
|
|
|
CFLAGS-tst-memchr-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-memcmp-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-memmove-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-memrchr-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-memset-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-strchr-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-strcpy-rtm.c += -mrtm
|
|
|
|
CFLAGS-tst-strlen-rtm.c += -mrtm
|
2022-02-15 14:18:15 +00:00
|
|
|
CFLAGS-tst-strncmp-rtm.c += -mrtm -Wno-error
|
2021-02-23 14:33:10 +00:00
|
|
|
CFLAGS-tst-strrchr-rtm.c += -mrtm
|
2022-02-18 20:19:15 +00:00
|
|
|
CFLAGS-tst-wcsncmp-rtm.c += -mrtm -Wno-error
|
2020-07-11 16:04:34 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-27 22:44:07 +00:00
|
|
|
ifneq ($(enable-cet),no)
|
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 21:08:15 +00:00
|
|
|
ifeq ($(subdir),elf)
|
|
|
|
sysdep-dl-routines += dl-cet
|
2018-07-25 11:46:53 +00:00
|
|
|
|
2018-11-23 15:30:56 +00:00
|
|
|
tests += tst-cet-legacy-1 tst-cet-legacy-1a tst-cet-legacy-2 \
|
2019-07-01 19:23:10 +00:00
|
|
|
tst-cet-legacy-2a tst-cet-legacy-3 tst-cet-legacy-4 \
|
2020-03-18 11:35:54 +00:00
|
|
|
tst-cet-legacy-5a tst-cet-legacy-6a tst-cet-legacy-7 \
|
2021-01-27 04:48:45 +00:00
|
|
|
tst-cet-legacy-8 tst-cet-legacy-9 tst-cet-legacy-9-static \
|
|
|
|
tst-cet-legacy-10 tst-cet-legacy-10-static
|
|
|
|
tests-static += tst-cet-legacy-9-static tst-cet-legacy-10-static
|
2018-11-23 15:30:56 +00:00
|
|
|
tst-cet-legacy-1a-ARGS = -- $(host-test-program-cmd)
|
2018-07-25 11:46:53 +00:00
|
|
|
ifneq (no,$(have-tunables))
|
2019-07-01 19:23:10 +00:00
|
|
|
tests += tst-cet-legacy-4a tst-cet-legacy-4b tst-cet-legacy-4c \
|
|
|
|
tst-cet-legacy-5b tst-cet-legacy-6b
|
2018-07-25 11:46:53 +00:00
|
|
|
endif
|
|
|
|
modules-names += tst-cet-legacy-mod-1 tst-cet-legacy-mod-2 \
|
2019-07-01 19:23:10 +00:00
|
|
|
tst-cet-legacy-mod-4 tst-cet-legacy-mod-5a \
|
|
|
|
tst-cet-legacy-mod-5b tst-cet-legacy-mod-5c \
|
|
|
|
tst-cet-legacy-mod-6a tst-cet-legacy-mod-6b \
|
|
|
|
tst-cet-legacy-mod-6c
|
2018-07-25 11:46:53 +00:00
|
|
|
|
|
|
|
CFLAGS-tst-cet-legacy-2.c += -fcf-protection=branch
|
|
|
|
CFLAGS-tst-cet-legacy-2a.c += -fcf-protection
|
|
|
|
CFLAGS-tst-cet-legacy-mod-1.c += -fcf-protection=none
|
|
|
|
CFLAGS-tst-cet-legacy-mod-2.c += -fcf-protection=none
|
|
|
|
CFLAGS-tst-cet-legacy-3.c += -fcf-protection=none
|
|
|
|
CFLAGS-tst-cet-legacy-4.c += -fcf-protection=branch
|
|
|
|
CFLAGS-tst-cet-legacy-4a.c += -fcf-protection
|
|
|
|
CFLAGS-tst-cet-legacy-4b.c += -fcf-protection
|
|
|
|
CFLAGS-tst-cet-legacy-mod-4.c += -fcf-protection=none
|
2020-04-27 22:44:07 +00:00
|
|
|
CFLAGS-tst-cet-legacy-5a.c += -fcf-protection -mshstk
|
|
|
|
ifeq ($(enable-cet),permissive)
|
|
|
|
CPPFLAGS-tst-cet-legacy-5a.c += -DCET_IS_PERMISSIVE=1
|
|
|
|
endif
|
|
|
|
CFLAGS-tst-cet-legacy-5b.c += -fcf-protection -mshstk
|
|
|
|
CPPFLAGS-tst-cet-legacy-5b.c += -DCET_DISABLED_BY_ENV=1
|
2020-03-18 11:35:54 +00:00
|
|
|
CFLAGS-tst-cet-legacy-mod-5a.c += -fcf-protection=branch
|
2019-07-01 19:23:10 +00:00
|
|
|
CFLAGS-tst-cet-legacy-mod-5b.c += -fcf-protection
|
|
|
|
CFLAGS-tst-cet-legacy-mod-5c.c += -fcf-protection
|
2020-04-27 22:44:07 +00:00
|
|
|
CFLAGS-tst-cet-legacy-6a.c += -fcf-protection -mshstk
|
|
|
|
ifeq ($(enable-cet),permissive)
|
|
|
|
CPPFLAGS-tst-cet-legacy-6a.c += -DCET_IS_PERMISSIVE=1
|
|
|
|
endif
|
|
|
|
CFLAGS-tst-cet-legacy-6b.c += -fcf-protection -mshstk
|
|
|
|
CPPFLAGS-tst-cet-legacy-6b.c += -DCET_DISABLED_BY_ENV=1
|
2020-03-18 11:35:54 +00:00
|
|
|
CFLAGS-tst-cet-legacy-mod-6a.c += -fcf-protection=branch
|
2019-07-01 19:23:10 +00:00
|
|
|
CFLAGS-tst-cet-legacy-mod-6b.c += -fcf-protection
|
|
|
|
CFLAGS-tst-cet-legacy-mod-6c.c += -fcf-protection
|
2020-03-18 11:35:54 +00:00
|
|
|
CFLAGS-tst-cet-legacy-7.c += -fcf-protection=none
|
|
|
|
CFLAGS-tst-cet-legacy-8.c += -mshstk
|
2021-01-27 04:48:45 +00:00
|
|
|
CFLAGS-tst-cet-legacy-10.c += -mshstk
|
|
|
|
CFLAGS-tst-cet-legacy-10-static.c += -mshstk
|
2018-07-25 11:46:53 +00:00
|
|
|
|
|
|
|
$(objpfx)tst-cet-legacy-1: $(objpfx)tst-cet-legacy-mod-1.so \
|
2018-11-23 15:30:56 +00:00
|
|
|
$(objpfx)tst-cet-legacy-mod-2.so
|
|
|
|
$(objpfx)tst-cet-legacy-1a: $(objpfx)tst-cet-legacy-mod-1.so \
|
2018-07-25 11:46:53 +00:00
|
|
|
$(objpfx)tst-cet-legacy-mod-2.so
|
2021-06-03 06:26:04 +00:00
|
|
|
$(objpfx)tst-cet-legacy-2: $(objpfx)tst-cet-legacy-mod-2.so
|
2018-07-25 11:46:53 +00:00
|
|
|
$(objpfx)tst-cet-legacy-2.out: $(objpfx)tst-cet-legacy-mod-1.so
|
2021-06-03 06:26:04 +00:00
|
|
|
$(objpfx)tst-cet-legacy-2a: $(objpfx)tst-cet-legacy-mod-2.so
|
2018-07-25 11:46:53 +00:00
|
|
|
$(objpfx)tst-cet-legacy-2a.out: $(objpfx)tst-cet-legacy-mod-1.so
|
|
|
|
$(objpfx)tst-cet-legacy-4.out: $(objpfx)tst-cet-legacy-mod-4.so
|
2019-07-01 19:23:10 +00:00
|
|
|
$(objpfx)tst-cet-legacy-5a.out: $(objpfx)tst-cet-legacy-mod-5a.so \
|
|
|
|
$(objpfx)tst-cet-legacy-mod-5b.so
|
|
|
|
$(objpfx)tst-cet-legacy-mod-5a.so: $(objpfx)tst-cet-legacy-mod-5c.so
|
|
|
|
$(objpfx)tst-cet-legacy-mod-5b.so: $(objpfx)tst-cet-legacy-mod-5c.so
|
|
|
|
$(objpfx)tst-cet-legacy-6a.out: $(objpfx)tst-cet-legacy-mod-6a.so \
|
|
|
|
$(objpfx)tst-cet-legacy-mod-6b.so
|
|
|
|
$(objpfx)tst-cet-legacy-mod-6a.so: $(objpfx)tst-cet-legacy-mod-6c.so
|
|
|
|
$(objpfx)tst-cet-legacy-mod-6b.so: $(objpfx)tst-cet-legacy-mod-6c.so
|
|
|
|
LDFLAGS-tst-cet-legacy-mod-6c.so = -Wl,--enable-new-dtags,-z,nodelete
|
2018-07-25 11:46:53 +00:00
|
|
|
ifneq (no,$(have-tunables))
|
|
|
|
$(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so
|
2018-08-02 18:19:19 +00:00
|
|
|
tst-cet-legacy-4a-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=permissive
|
2018-07-25 11:46:53 +00:00
|
|
|
$(objpfx)tst-cet-legacy-4b.out: $(objpfx)tst-cet-legacy-mod-4.so
|
2018-08-02 18:19:19 +00:00
|
|
|
tst-cet-legacy-4b-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=on
|
2018-07-25 11:46:53 +00:00
|
|
|
$(objpfx)tst-cet-legacy-4c.out: $(objpfx)tst-cet-legacy-mod-4.so
|
2018-08-02 18:19:19 +00:00
|
|
|
tst-cet-legacy-4c-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=off
|
2019-07-01 19:23:10 +00:00
|
|
|
$(objpfx)tst-cet-legacy-5b.out: $(objpfx)tst-cet-legacy-mod-5a.so \
|
|
|
|
$(objpfx)tst-cet-legacy-mod-5b.so
|
|
|
|
tst-cet-legacy-5b-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
|
|
|
|
$(objpfx)tst-cet-legacy-6b.out: $(objpfx)tst-cet-legacy-mod-6a.so \
|
|
|
|
$(objpfx)tst-cet-legacy-mod-6b.so
|
|
|
|
tst-cet-legacy-6b-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
|
2021-01-27 04:48:45 +00:00
|
|
|
tst-cet-legacy-9-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
|
|
|
|
tst-cet-legacy-9-static-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
|
2018-07-25 11:46:53 +00:00
|
|
|
endif
|
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 21:08:15 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Add -fcf-protection to CFLAGS when CET is enabled.
|
|
|
|
CFLAGS-.o += -fcf-protection
|
|
|
|
CFLAGS-.os += -fcf-protection
|
|
|
|
CFLAGS-.op += -fcf-protection
|
|
|
|
CFLAGS-.oS += -fcf-protection
|
|
|
|
|
|
|
|
# Compile assembly codes with <cet.h> when CET is enabled.
|
|
|
|
asm-CPPFLAGS += -fcf-protection -include cet.h
|
|
|
|
|
|
|
|
ifeq ($(subdir),elf)
|
|
|
|
ifeq (yes,$(build-shared))
|
|
|
|
tests-special += $(objpfx)check-cet.out
|
|
|
|
endif
|
|
|
|
|
|
|
|
# FIXME: Can't use all-built-dso in elf/Makefile since this file is
|
|
|
|
# processed before elf/Makefile. Duplicate it here.
|
|
|
|
cet-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
|
|
|
|
$(filter-out $(common-objpfx)linkobj/libc.so, \
|
|
|
|
$(sort $(wildcard $(addprefix $(common-objpfx), \
|
|
|
|
*/lib*.so \
|
|
|
|
iconvdata/*.so))))
|
|
|
|
|
|
|
|
$(cet-built-dso:=.note): %.note: %
|
|
|
|
@rm -f $@T
|
|
|
|
LC_ALL=C $(READELF) -n $< > $@T
|
|
|
|
test -s $@T
|
|
|
|
mv -f $@T $@
|
|
|
|
common-generated += $(cet-built-dso:$(common-objpfx)%=%.note)
|
|
|
|
|
|
|
|
$(objpfx)check-cet.out: $(..)sysdeps/x86/check-cet.awk \
|
|
|
|
$(cet-built-dso:=.note)
|
|
|
|
LC_ALL=C $(AWK) -f $^ > $@; \
|
|
|
|
$(evaluate-test)
|
|
|
|
generated += check-cet.out
|
|
|
|
endif
|
|
|
|
endif
|
2021-03-06 18:19:32 +00:00
|
|
|
|
|
|
|
ifeq ($(subdir),posix)
|
|
|
|
tests += \
|
|
|
|
tst-sysconf-cache-linesize \
|
|
|
|
tst-sysconf-cache-linesize-static
|
|
|
|
tests-static += \
|
|
|
|
tst-sysconf-cache-linesize-static
|
|
|
|
endif
|