This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug dynamic-link/21598] i386 _dl_runtime_resolve/_dl_runtime_profile is incompatible with shadow stack
- From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 25 Oct 2017 15:49:39 +0000
- Subject: [Bug dynamic-link/21598] i386 _dl_runtime_resolve/_dl_runtime_profile is incompatible with shadow stack
- Auto-submitted: auto-generated
- References: <bug-21598-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=21598
--- Comment #47 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/cet/property has been created
at 47d00dc7a94d4ffe004138aaf7a3930da0fb96d6 (commit)
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=47d00dc7a94d4ffe004138aaf7a3930da0fb96d6
commit 47d00dc7a94d4ffe004138aaf7a3930da0fb96d6
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jun 28 15:16:46 2017 -0700
i386: Add _dl_runtime_resolve_shstk/_dl_runtime_profile_shstk [BZ #21598]
Add SHSTK compatible symbol resolvers to support Shadow Stack in Intel
Control-flow Enforcement Technology (CET) instructions:
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf
Replace _dl_runtime_resolve and _dl_runtime_profile with
_dl_runtime_resolve_shstk and _dl_runtime_profile_shstk, respectively if
SHSTK is enabled.
[BZ #21598]
* sysdeps/i386/dl-trampoline.S (_dl_runtime_resolve_shstk): New.
(_dl_runtime_profile_shstk): Likewise.
* sysdeps/unix/sysv/linux/i386/dl-cet.c: New file.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=319cbb3efb5ea6772dd11b7c145e5a524f47944c
commit 319cbb3efb5ea6772dd11b7c145e5a524f47944c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Jun 22 04:15:39 2017 -0700
x86: Support IBT and SHSTK in Intel CET
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. GNU_PROPERTY_X86_FEATURE_1_IBT is set 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, if GNU_PROPERTY_X86_FEATURE_1_IBT is
set on the executable, enable IBT.
2. 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. GNU_PROPERTY_X86_FEATURE_1_SHSTK is set 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, if GNU_PROPERTY_X86_FEATURE_1_SHSTK is
set on the executable as well as all shared objects loaded via the
DT_NEEDED tag, enable SHSTK.
2. After SHSTK is enabled, it is an error to load a shared object
without GNU_PROPERTY_X86_FEATURE_1_SHSTK.
When glibc is built with a CET-enabled compiler, CET is enabled by
default, unless --disable-cet is used 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.
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. The optional DL_PROCESS_PT_NOTE
is called to process PT_NOTE segment for GNU program property and
set l_cet.
b. _dl_start_user calls _dl_cet_init, instead of _dl_init, which sets
_dl_x86_feature_1 as well as sets up IBT and SHSTK.
3. For static executables, _dl_setup_cet is called to process PT_NOTE
segment for GNU program property to set _dl_x86_feature_1 as well as set
up IBT and SHSTK.
<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.
* config.h.in (ENABLE_CET): New #undef.
* configure.ac: Add --enable-cet.
* configure: Regenerated.
* elf/dl-load.c (filebuf): Moved before "dynamic-link.h".
(_dl_map_object_from_fd): Call DL_PROCESS_PT_NOTE on PT_NOTE
segment if DL_PROCESS_PT_NOTE is defined.
* elf/rtld.c (dl_main): Likewise.
* elf/dl-support.c: Include <dl-procruntime.c>.
* include/link.h: Include <link_map.h>.
* sysdeps/generic/dl-procruntime.c: New file.
* sysdeps/generic/link_map.h: Likewise.
* sysdeps/unix/sysv/linux/i386/dl-machine.h: Likewise.
* sysdeps/unix/sysv/linux/x86/configure: Likewise.
* sysdeps/unix/sysv/linux/x86/configure.ac: Likewise.
* sysdeps/unix/sysv/linux/x86/dl-cet-nonshared.c: Likewise.
* sysdeps/unix/sysv/linux/x86/dl-cet.c: Likewise.
* sysdeps/unix/sysv/linux/x86/dl-cet.h: Likewise.
* sysdeps/unix/sysv/linux/x86/dl-procruntime.c: Likewise.
* sysdeps/unix/sysv/linux/x86/libc-start.c: Likewise.
* sysdeps/unix/sysv/linux/x86/link_map.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/dl-machine.h: Likewise.
* sysdeps/generic/ldsodefs.h: Include <dl-procruntime.c> in
the writable ld.so namespace.
* sysdeps/i386/dl-machine.h (DL_INIT): New.
(_dl_start_user): Replace _dl_init with DL_INIT.
* sysdeps/unix/sysv/linux/x86/Makefile (sysdep_routines): Add
dl-cet-nonshared if CET is enabled.
(sysdep-dl-routines): Add dl-cet if CET is enabled.
(CFLAGS-.o): Add -finstrument-control-flow -mcet if CET is enabled.
(CFLAGS-.os): Likewise.
(CFLAGS-.op): Likewise.
(CFLAGS-.oS): Likewise.
(asm-CPPFLAGS): Add -finstrument-control-flow -mcet -include cet.h
if CET is enabled.
* sysdeps/x86/libc-start.c (ARCH_INIT_CPU_FEATURES): Define
only if it is undefined.
* sysdeps/x86_64/dl-machine.h (DL_INIT): New.
(_dl_start_user): Replace _dl_init with DL_INIT.
-----------------------------------------------------------------------
--
You are receiving this mail because:
You are on the CC list for the bug.