This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/21598] i386 _dl_runtime_resolve/_dl_runtime_profile is incompatible with shadow stack


https://sourceware.org/bugzilla/show_bug.cgi?id=21598

--- Comment #75 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/master has been created
        at  cedcc4d7951eb97d30500cae6e38cdeae17dba1c (commit)

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cedcc4d7951eb97d30500cae6e38cdeae17dba1c

commit cedcc4d7951eb97d30500cae6e38cdeae17dba1c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 16:12:20 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in memset-sse2-rep.S

        * sysdeps/i386/i686/multiarch/memset-sse2-rep.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4b64a00e2a649adbe456c3893e4d4c49ec11a473

commit 4b64a00e2a649adbe456c3893e4d4c49ec11a473
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 16:10:46 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in strcat-sse2.S

        * sysdeps/i386/i686/multiarch/strcat-sse2.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=336456814e61a725c2241979e3dcbd7c8af6aa44

commit 336456814e61a725c2241979e3dcbd7c8af6aa44
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 16:09:39 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in strcpy-sse2.S

        * sysdeps/i386/i686/multiarch/strcpy-sse2.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e58b049b5a5435202c92e521b7f91d5617651dc7

commit e58b049b5a5435202c92e521b7f91d5617651dc7
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 16:06:37 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in memcpy-ssse3.S

        * sysdeps/i386/i686/multiarch/memcpy-ssse3.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=18469179d36897e1d0b55e70bdbbb626d158f581

commit 18469179d36897e1d0b55e70bdbbb626d158f581
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 16:04:36 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in memcpy-ssse3-rep.S

        * sysdeps/i386/i686/multiarch/memcpy-ssse3-rep.S
        (BRANCH_TO_JMPTBL_ENTRY_VALUE): Add 4 bytes for 4-byte endbr32.
        Use INDIRECT_JUMP_ENTRY with indirect jump targets to add
        _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1be897c10731565d7eb2a08409b9713917fe735f

commit 1be897c10731565d7eb2a08409b9713917fe735f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 15:57:36 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in memcmp-sse4.S

        * sysdeps/i386/i686/multiarch/memcmp-sse4.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=019692af7295445904b6674d105a90086488b312

commit 019692af7295445904b6674d105a90086488b312
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 15:56:38 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in memset-sse2.S

        * sysdeps/i386/i686/multiarch/memset-sse2.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cfa013a81a25a5d4efbad0288cb078a4cb43a987

commit cfa013a81a25a5d4efbad0288cb078a4cb43a987
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 15:54:52 2018 -0800

    i386: Use INDIRECT_JUMP_ENTRY in i686/memcmp.S

        * sysdeps/i386/i686/memcmp.S: Use INDIRECT_JUMP_ENTRY with
        indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=aab35263895864febff7c5df98654149481204d8

commit aab35263895864febff7c5df98654149481204d8
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 15:50:11 2018 -0800

    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.

        * sysdeps/i386/add_n.S: Include <sysdep.h>, instead of
        "sysdep.h".
        (__mpn_add_n): Save and restore %ebx if __IBT__ is defined.
        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 defined.
        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 defined.
        Add _CET_ENDBR to indirect jump targets and adjust jump
        destination for _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7bbca7b3e54347c0f38493357f975e6b3409aadd

commit 7bbca7b3e54347c0f38493357f975e6b3409aadd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 11:02:21 2018 -0800

    x86-64: Use INDIRECT_JUMP_ENTRY in memcpy-ssse3.S

        * sysdeps/x86_64/multiarch/memcpy-ssse3.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8afb017319a18236d622601c03052d3bc66bda3d

commit 8afb017319a18236d622601c03052d3bc66bda3d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 11:00:05 2018 -0800

    x86-64: Use INDIRECT_JUMP_ENTRY in memcmp-sse4.S

        * sysdeps/x86_64/multiarch/memcmp-sse4.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a96e3a76c2ceae628389f65fefd45d82a88a63b0

commit a96e3a76c2ceae628389f65fefd45d82a88a63b0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 10:57:27 2018 -0800

    x86-64: Use INDIRECT_JUMP_ENTRY in memcpy-ssse3-back.S

        * sysdeps/x86_64/multiarch/memcpy-ssse3-back.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=406ed83ebfc0d46e1c3306c3498465a1c5f46bb5

commit 406ed83ebfc0d46e1c3306c3498465a1c5f46bb5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 10:52:38 2018 -0800

    x86-64: Use INDIRECT_JUMP_ENTRY in strcmp-sse42.S

        * sysdeps/x86_64/multiarch/strcmp-sse42.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=32596da395c7ad054ed744b9d723e2b0d616f86c

commit 32596da395c7ad054ed744b9d723e2b0d616f86c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 10:50:56 2018 -0800

    x86-64: Use INDIRECT_JUMP_ENTRY in strcpy-sse2-unaligned.S

        * sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S: Use
        INDIRECT_JUMP_ENTRY with indirect jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8bebd1b14c28b21fa63ab754582e27d303e88d27

commit 8bebd1b14c28b21fa63ab754582e27d303e88d27
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jan 9 05:45:42 2018 -0800

    x86_64: Use INDIRECT_JUMP_ENTRY in strcmp.S

        * sysdeps/x86_64/strcmp.S: Use INDIRECT_JUMP_ENTRY with indirect
        jump targets to add _CET_ENDBR.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2fd8bd4a3b52e8e7bb4a3e1c451b5e5a3c57e9d9

commit 2fd8bd4a3b52e8e7bb4a3e1c451b5e5a3c57e9d9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 10:29:44 2018 -0800

    x86: Add INDIRECT_JUMP_ENTRY

    Add INDIRECT_JUMP_ENTRY to define a label with _CET_ENDBR for indirect
    jump target to support IBT.

        * sysdeps/x86/sysdep.h (INDIRECT_JUMP_ENTRY): New.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=774b7ae083de37109db6c538a737ef8da147d27d

commit 774b7ae083de37109db6c538a737ef8da147d27d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 8 10:42:34 2018 -0800

    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.

        * 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.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=71b414a746690a7fc39e7d99027bb5bd4ac9ad69

commit 71b414a746690a7fc39e7d99027bb5bd4ac9ad69
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 [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.  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
          up IBT and SHSTK.
       c. 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.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.

         [BZ #21598]
        * 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-open.c (dl_open_worker): Call DL_OPEN_CHECK if it is
        defined.
        * sysdeps/unix/sysv/linux/i386/dl-cet.c: New file.
        * sysdeps/unix/sysv/linux/i386/dl-machine.h: Likewise.
        * sysdeps/unix/sysv/linux/x86/check-cet.awk: Likewise.
        * sysdeps/unix/sysv/linux/x86/configure: Likewise.
        * sysdeps/unix/sysv/linux/x86/configure.ac: 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/ldsodefs.h: Likewise.
        * sysdeps/unix/sysv/linux/x86/link_map.h: Likewise.
        * sysdeps/unix/sysv/linux/x86_64/dl-machine.h: Likewise.
        * sysdeps/i386/dl-machine.h (DL_INIT): New.
        (_dl_start_user): Replace _dl_init with DL_INIT.
        * 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/unix/sysv/linux/x86/Makefile (sysdep-dl-routines): Add
        dl-cet if CET is enabled.
        (CFLAGS-.o): Add -fcf-protection -mcet if CET is enabled.
        (CFLAGS-.os): Likewise.
        (CFLAGS-.op): Likewise.
        (CFLAGS-.oS): Likewise.
        (asm-CPPFLAGS): Add -fcf-protection -mcet -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/sysdep.h (_CET_ENDBR): Define if not defined.
        (ENTRY): Add _CET_ENDBR.
        * sysdeps/x86_64/dl-machine.h (DL_INIT): New.
        (_dl_start_user): Replace _dl_init with DL_INIT.
        * sysdeps/x86_64/x32/dl-machine.h (_dl_start_user): Likewise.
        * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Add
        _CET_ENDBR.
        (_dl_runtime_profile): Likewise.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1db1152a5b87dde103083b5f09fdd2d130514745

commit 1db1152a5b87dde103083b5f09fdd2d130514745
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 5 11:58:23 2017 -0800

    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 so that it works with the old smaller cancel_jmp_buf which
    doesn't have space for shadow stack pointer.

    2017-12-07  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
            H.J. Lu  <hongjiu.lu@intel.com>

        * sysdeps/i386/__longjmp.S: Include <jmp_buf-ssp.h>.  Restore
        shadow stack pointer if shadow stack is enabled and
        SHADOW_STACK_POINTER_OFFSET is defined.
        * sysdeps/i386/bsd-_setjmp.S: Likewise.
        * sysdeps/i386/bsd-setjmp.S: Likewise.
        * sysdeps/i386/setjmp.S: Likewise.
        * sysdeps/x86_64/__longjmp.S: Likewise.
        * sysdeps/x86_64/setjmp.S: Likewise.
        * sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Include
        shadow stack pointer if shadow stack is enabled.
        * sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Likewise.
        * sysdeps/unix/sysv/linux/x86/Makefile (gen-as-const-headers):
        Remove jmp_buf-ssp.sym.
        * sysdeps/x86/Makefile (gen-as-const-headers): Add
        jmp_buf-ssp.sym.
        * sysdeps/x86/jmp_buf-ssp.sym: New dummy file.

-----------------------------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]