]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
i386: Remove CET support
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 5 Jan 2024 13:36:40 +0000 (10:36 -0300)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 19 Aug 2025 13:29:04 +0000 (06:29 -0700)
CET is only support for x86_64, this patch reverts:

  - faaee1f07ed x86: Support shadow stack pointer in setjmp/longjmp.
  - be9ccd27c09 i386: Add _CET_ENDBR to indirect jump targets in
    add_n.S/sub_n.S
  - c02695d7764 x86/CET: Update vfork to prevent child return
  - 5d844e1b725 i386: Enable CET support in ucontext functions
  - 124bcde683 x86: Add _CET_ENDBR to functions in crti.S
  - 562837c002 x86: Add _CET_ENDBR to functions in dl-tlsdesc.S
  - f753fa7dea x86: Support IBT and SHSTK in Intel CET [BZ #21598]
  - 825b58f3fb i386-mcount.S: Add _CET_ENDBR to _mcount and __fentry__
  - 7e119cd582 i386: Use _CET_NOTRACK in i686/memcmp.S
  - 177824e232 i386: Use _CET_NOTRACK in memcmp-sse4.S
  - 0a899af097 i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
  - 7fb613361c i386: Use _CET_NOTRACK in memcpy-ssse3.S
  - 77a8ae0948 i386: Use _CET_NOTRACK in memset-sse2-rep.S
  - 00e7b76a8f i386: Use _CET_NOTRACK in memset-sse2.S
  - 90d15dc577 i386: Use _CET_NOTRACK in strcat-sse2.S
  - f1574581c7 i386: Use _CET_NOTRACK in strcpy-sse2.S
  - 4031d7484a i386/sub_n.S: Add a missing _CET_ENDBR to indirect jump
  - target
  -
Checked on i686-linux-gnu.

(cherry picked from commit 25f1e16ef03a6a8fb1701c4647d46c564480d88c)

31 files changed:
sysdeps/i386/__longjmp.S
sysdeps/i386/add_n.S
sysdeps/i386/bsd-_setjmp.S
sysdeps/i386/bsd-setjmp.S
sysdeps/i386/crti.S
sysdeps/i386/dl-tlsdesc.S
sysdeps/i386/dl-trampoline.S
sysdeps/i386/i386-mcount.S
sysdeps/i386/i686/add_n.S
sysdeps/i386/i686/memcmp.S
sysdeps/i386/i686/multiarch/memcmp-sse4.S
sysdeps/i386/i686/multiarch/memcpy-ssse3-rep.S
sysdeps/i386/i686/multiarch/memcpy-ssse3.S
sysdeps/i386/i686/multiarch/memset-sse2-rep.S
sysdeps/i386/i686/multiarch/memset-sse2.S
sysdeps/i386/i686/multiarch/strcat-sse2.S
sysdeps/i386/i686/multiarch/strcpy-sse2.S
sysdeps/i386/setjmp.S
sysdeps/i386/start.S
sysdeps/i386/sub_n.S
sysdeps/i386/sysdep.h
sysdeps/unix/sysv/linux/i386/____longjmp_chk.S
sysdeps/unix/sysv/linux/i386/getcontext.S
sysdeps/unix/sysv/linux/i386/makecontext.S
sysdeps/unix/sysv/linux/i386/setcontext.S
sysdeps/unix/sysv/linux/i386/swapcontext.S
sysdeps/unix/sysv/linux/i386/sysdep.h
sysdeps/unix/sysv/linux/i386/ucontext_i.sym
sysdeps/unix/sysv/linux/i386/vfork.S
sysdeps/x86/sysdep.h
sysdeps/x86_64/sysdep.h

index 41d4cb8412e544424325c88e50e5258c851f10b9..4dbbcb46173a206dfa97bb60dd3ba0e64b4d1d8d 100644 (file)
 #include <sysdep.h>
 #include <pointer_guard.h>
 #include <jmpbuf-offsets.h>
-#include <jmp_buf-ssp.h>
 #include <asm-syntax.h>
 #include <stap-probe.h>
 
-/* Don't restore shadow stack register if
-   1. Shadow stack isn't enabled.  Or
-   2. __longjmp is defined for __longjmp_cancel.
- */
-#if !SHSTK_ENABLED || defined __longjmp
-# undef SHADOW_STACK_POINTER_OFFSET
-#endif
-
        .text
 ENTRY (__longjmp)
 #ifdef PTR_DEMANGLE
        movl 4(%esp), %eax      /* User's jmp_buf in %eax.  */
 
-# ifdef SHADOW_STACK_POINTER_OFFSET
-#  if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-       /* Check if Shadow Stack is enabled.  */
-       testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz L(skip_ssp)
-#  else
-       xorl %edx, %edx
-#  endif
-       /* Check and adjust the Shadow-Stack-Pointer.  */
-       rdsspd %edx
-       /* And compare it with the saved ssp value.  */
-       subl SHADOW_STACK_POINTER_OFFSET(%eax), %edx
-       je L(skip_ssp)
-       /* Count the number of frames to adjust and adjust it
-          with incssp instruction.  The instruction can adjust
-          the ssp by [0..255] value only thus use a loop if
-          the number of frames is bigger than 255.  */
-       negl %edx
-       shrl $2, %edx
-       /* NB: We saved Shadow-Stack-Pointer of setjmp.  Since we are
-              restoring Shadow-Stack-Pointer of setjmp's caller, we
-              need to unwind shadow stack by one more frame.  */
-       addl $1, %edx
-       movl    $255, %ebx
-L(loop):
-       cmpl    %ebx, %edx
-       cmovb   %edx, %ebx
-       incsspd %ebx
-       subl    %ebx, %edx
-       ja      L(loop)
-L(skip_ssp):
-# endif
        /* Save the return address now.  */
        movl (JB_PC*4)(%eax), %edx
        /* Get the stack pointer.  */
@@ -98,38 +57,6 @@ L(skip_ssp):
 #else
        movl 4(%esp), %ecx      /* User's jmp_buf in %ecx.  */
        movl 8(%esp), %eax      /* Second argument is return value.  */
-# ifdef SHADOW_STACK_POINTER_OFFSET
-#  if IS_IN (libc) && defined SHARED
-       /* Check if Shadow Stack is enabled.  */
-       testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz L(skip_ssp)
-#  endif
-       /* Check and adjust the Shadow-Stack-Pointer.  */
-       xorl %edx, %edx
-       /* Get the current ssp.  */
-       rdsspd  %edx
-       /* And compare it with the saved ssp value.  */
-       subl SHADOW_STACK_POINTER_OFFSET(%ecx), %edx
-       je L(skip_ssp)
-       /* Count the number of frames to adjust and adjust it
-          with incssp instruction.  The instruction can adjust
-          the ssp by [0..255] value only thus use a loop if
-          the number of frames is bigger than 255.  */
-       negl %edx
-       shrl $2, %edx
-       /* NB: We saved Shadow-Stack-Pointer of setjmp.  Since we are
-              restoring Shadow-Stack-Pointer of setjmp's caller, we
-              need to unwind shadow stack by one more frame.  */
-       addl $1, %edx
-       movl    $255, %ebx
-L(loop):
-       cmpl    %ebx, %edx
-       cmovb   %edx, %ebx
-       incsspd %ebx
-       subl    %ebx, %edx
-       ja      L(loop)
-L(skip_ssp):
-# endif
        /* Save the return address now.  */
        movl (JB_PC*4)(%ecx), %edx
        LIBC_PROBE (longjmp, 3, 4@%ecx, -4@%eax, 4@%edx)
index 0c2b059774a885b045ad37fb74403264c9c1b873..9ac7de5308ece2a8b2c05d6471a3a88bebe5cbbe 100644 (file)
@@ -40,13 +40,6 @@ ENTRY (__mpn_add_n)
        cfi_rel_offset (esi, 0)
        movl S2(%esp),%edx
        movl SIZE(%esp),%ecx
-
-#if IBT_ENABLED
-       pushl   %ebx
-       cfi_adjust_cfa_offset (4)
-       cfi_rel_offset (ebx, 0)
-#endif
-
        movl    %ecx,%eax
        shrl    $3,%ecx                 /* compute count for unrolled loop */
        negl    %eax
@@ -58,9 +51,6 @@ ENTRY (__mpn_add_n)
        subl    %eax,%esi               /* ... by a constant when we ... */
        subl    %eax,%edx               /* ... enter the loop */
        shrl    $2,%eax                 /* restore previous value */
-#if IBT_ENABLED
-       leal    -4(,%eax,4),%ebx        /* Count for 4-byte endbr32 */
-#endif
 #ifdef PIC
 /* Calculate start address in loop for PIC.  Due to limitations in some
    assemblers, Loop-L0-3 cannot be put into the leal */
@@ -74,40 +64,30 @@ L(0):       leal    (%eax,%eax,8),%eax
 #else
 /* Calculate start address in loop for non-PIC.  */
        leal    (L(oop) - 3)(%eax,%eax,8),%eax
-#endif
-#if IBT_ENABLED
-       addl    %ebx,%eax               /* Adjust for endbr32 */
 #endif
        jmp     *%eax                   /* jump into loop */
        ALIGN (3)
 L(oop):        movl    (%esi),%eax
        adcl    (%edx),%eax
        movl    %eax,(%edi)
-       _CET_ENDBR
        movl    4(%esi),%eax
        adcl    4(%edx),%eax
        movl    %eax,4(%edi)
-       _CET_ENDBR
        movl    8(%esi),%eax
        adcl    8(%edx),%eax
        movl    %eax,8(%edi)
-       _CET_ENDBR
        movl    12(%esi),%eax
        adcl    12(%edx),%eax
        movl    %eax,12(%edi)
-       _CET_ENDBR
        movl    16(%esi),%eax
        adcl    16(%edx),%eax
        movl    %eax,16(%edi)
-       _CET_ENDBR
        movl    20(%esi),%eax
        adcl    20(%edx),%eax
        movl    %eax,20(%edi)
-       _CET_ENDBR
        movl    24(%esi),%eax
        adcl    24(%edx),%eax
        movl    %eax,24(%edi)
-       _CET_ENDBR
        movl    28(%esi),%eax
        adcl    28(%edx),%eax
        movl    %eax,28(%edi)
@@ -120,11 +100,6 @@ L(oop):    movl    (%esi),%eax
        sbbl    %eax,%eax
        negl    %eax
 
-#if IBT_ENABLED
-       popl    %ebx
-       cfi_adjust_cfa_offset (-4)
-       cfi_restore (ebx)
-#endif
        popl %esi
        cfi_adjust_cfa_offset (-4)
        cfi_restore (esi)
index 575339ba2192fd13218b4261f0de98f241438899..7a47ab395b026ef5a7d0169b2ab1a2c3aa566c85 100644 (file)
 #include <sysdep.h>
 #include <pointer_guard.h>
 #include <jmpbuf-offsets.h>
-#include <jmp_buf-ssp.h>
 #include <stap-probe.h>
 
 #define PARMS  4               /* no space for saved regs */
 #define JMPBUF PARMS
 #define SIGMSK JMPBUF+4
 
-/* Don't save shadow stack register if shadow stack isn't enabled.  */
-#if !SHSTK_ENABLED
-# undef SHADOW_STACK_POINTER_OFFSET
-#endif
-
 ENTRY (_setjmp)
 
        xorl %eax, %eax
@@ -58,21 +52,6 @@ ENTRY (_setjmp)
        movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer.  */
 
        movl %eax, JB_SIZE(%edx) /* No signal mask set.  */
-#ifdef SHADOW_STACK_POINTER_OFFSET
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-       /* Check if Shadow Stack is enabled.  */
-       testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz L(skip_ssp)
-# else
-       xorl %ecx, %ecx
-# endif
-       /* Get the current Shadow-Stack-Pointer and save it.  */
-       rdsspd %ecx
-       movl %ecx, SHADOW_STACK_POINTER_OFFSET(%edx)
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-L(skip_ssp):
-# endif
-#endif
        ret
 END (_setjmp)
 libc_hidden_def (_setjmp)
index 81482c1484123eec90475640268c2548c4bff9e5..2d95f08d98101b3f3f1ebe5705e155e52de26132 100644 (file)
 #include <sysdep.h>
 #include <pointer_guard.h>
 #include <jmpbuf-offsets.h>
-#include <jmp_buf-ssp.h>
 #include <stap-probe.h>
 
 #define PARMS  4               /* no space for saved regs */
 #define JMPBUF PARMS
 #define SIGMSK JMPBUF+4
 
-/* Don't save shadow stack register if shadow stack isn't enabled.  */
-#if !SHSTK_ENABLED
-# undef SHADOW_STACK_POINTER_OFFSET
-#endif
-
 ENTRY (setjmp)
        /* Note that we have to use a non-exported symbol in the next
           jump since otherwise gas will emit it as a jump through the
@@ -58,21 +52,6 @@ ENTRY (setjmp)
 #endif
        movl %ecx, (JB_PC*4)(%eax)
        movl %ebp, (JB_BP*4)(%eax) /* Save caller's frame pointer.  */
-#ifdef SHADOW_STACK_POINTER_OFFSET
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-       /* Check if Shadow Stack is enabled.  */
-       testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz L(skip_ssp)
-# else
-       xorl %ecx, %ecx
-# endif
-       /* Get the current Shadow-Stack-Pointer and save it.  */
-       rdsspd %ecx
-       movl %ecx, SHADOW_STACK_POINTER_OFFSET(%eax)
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-L(skip_ssp):
-# endif
-#endif
 
        /* Call __sigjmp_save.  */
        pushl $1
index 268ae75725910b854599e351a94dd36b27a70840..af132aeea3eed1756226d778ad3c2ce13fbe16da 100644 (file)
@@ -61,7 +61,6 @@
        .hidden _init
        .type _init, @function
 _init:
-       _CET_ENDBR
        pushl %ebx
        /* Maintain 16-byte stack alignment for called functions.  */
        subl $8, %esp
@@ -82,7 +81,6 @@ _init:
        .hidden _fini
        .type _fini, @function
 _fini:
-       _CET_ENDBR
        pushl %ebx
        subl $8, %esp
        LOAD_PIC_REG (bx)
index 9522985ee78720981bf08dd09e8f1f58ada3674c..0574ce714e987ebc85facf3453c20c39907dca3a 100644 (file)
@@ -37,7 +37,6 @@
        cfi_startproc
        .align 16
 _dl_tlsdesc_return:
-       _CET_ENDBR
        movl    4(%eax), %eax
        ret
        cfi_endproc
@@ -59,7 +58,6 @@ _dl_tlsdesc_return:
        cfi_startproc
        .align 16
 _dl_tlsdesc_undefweak:
-       _CET_ENDBR
        movl    4(%eax), %eax
        subl    %gs:0, %eax
        ret
@@ -101,7 +99,6 @@ _dl_tlsdesc_dynamic (struct tlsdesc *tdp)
        cfi_startproc
        .align 16
 _dl_tlsdesc_dynamic:
-       _CET_ENDBR
        /* Like all TLS resolvers, preserve call-clobbered registers.
           We need two scratch regs anyway.  */
        subl    $28, %esp
index 2d55f373b4d5d3795e566df7f4ed3bb48c2b4a67..1c569290a5b73f0e6c5fd00dbbe07f5d996e7d89 100644 (file)
@@ -26,7 +26,6 @@
        .align 16
 _dl_runtime_resolve:
        cfi_adjust_cfa_offset (8)
-       _CET_ENDBR
        pushl %eax              # Preserve registers otherwise clobbered.
        cfi_adjust_cfa_offset (4)
        pushl %ecx
@@ -53,7 +52,6 @@ _dl_runtime_resolve:
        .align 16
 _dl_runtime_resolve_shstk:
        cfi_adjust_cfa_offset (8)
-       _CET_ENDBR
        pushl %eax              # Preserve registers otherwise clobbered.
        cfi_adjust_cfa_offset (4)
        pushl %edx
@@ -78,7 +76,6 @@ _dl_runtime_resolve_shstk:
        .align 16
 _dl_runtime_profile_shstk:
        cfi_adjust_cfa_offset (8)
-       _CET_ENDBR
        pushl %esp
        cfi_adjust_cfa_offset (4)
        addl $8, (%esp)         # Account for the pushed PLT data
@@ -123,7 +120,6 @@ _dl_runtime_profile_shstk:
        .align 16
 _dl_runtime_profile:
        cfi_adjust_cfa_offset (8)
-       _CET_ENDBR
        pushl %esp
        cfi_adjust_cfa_offset (4)
        addl $8, (%esp)         # Account for the pushed PLT data
index 8c4ea9e3d5a54c6b9eea155b4af9407c9d5c53e1..48888599109117732666d8ad410e245dc3e3e5d0 100644 (file)
@@ -29,7 +29,6 @@
        .type C_SYMBOL_NAME(_mcount), @function
        .align ALIGNARG(4)
 C_LABEL(_mcount)
-       _CET_ENDBR
        /* Save the caller-clobbered registers.  */
        pushl %eax
        pushl %ecx
@@ -58,7 +57,6 @@ weak_alias (_mcount, mcount)
        .type C_SYMBOL_NAME(__fentry__), @function
        .align ALIGNARG(4)
 C_LABEL(__fentry__)
-       _CET_ENDBR
        /* Save the caller-clobbered registers.  */
        pushl %eax
        pushl %ecx
index 60c0b8bf8b4f10f3577759bc411c89a750a0368e..ec210df669890510632e776ac9b04f86e22341d5 100644 (file)
@@ -44,13 +44,6 @@ ENTRY (__mpn_add_n)
        cfi_rel_offset (esi, 0)
        movl    S2(%esp),%edx
        movl    SIZE(%esp),%ecx
-
-#if IBT_ENABLED
-       pushl   %ebx
-       cfi_adjust_cfa_offset (4)
-       cfi_rel_offset (ebx, 0)
-#endif
-
        movl    %ecx,%eax
        shrl    $3,%ecx                 /* compute count for unrolled loop */
        negl    %eax
@@ -62,9 +55,6 @@ ENTRY (__mpn_add_n)
        subl    %eax,%esi               /* ... by a constant when we ... */
        subl    %eax,%edx               /* ... enter the loop */
        shrl    $2,%eax                 /* restore previous value */
-#if IBT_ENABLED
-       leal    -4(,%eax,4),%ebx        /* Count for 4-byte endbr32 */
-#endif
 #ifdef PIC
 /* Calculate start address in loop for PIC.  */
        leal    (L(oop)-L(0)-3)(%eax,%eax,8),%eax
@@ -73,40 +63,30 @@ L(0):
 #else
 /* Calculate start address in loop for non-PIC.  */
        leal    (L(oop) - 3)(%eax,%eax,8),%eax
-#endif
-#if IBT_ENABLED
-       addl    %ebx,%eax               /* Adjust for endbr32 */
 #endif
        jmp     *%eax                   /* jump into loop */
        ALIGN (3)
 L(oop):        movl    (%esi),%eax
        adcl    (%edx),%eax
        movl    %eax,(%edi)
-       _CET_ENDBR
        movl    4(%esi),%eax
        adcl    4(%edx),%eax
        movl    %eax,4(%edi)
-       _CET_ENDBR
        movl    8(%esi),%eax
        adcl    8(%edx),%eax
        movl    %eax,8(%edi)
-       _CET_ENDBR
        movl    12(%esi),%eax
        adcl    12(%edx),%eax
        movl    %eax,12(%edi)
-       _CET_ENDBR
        movl    16(%esi),%eax
        adcl    16(%edx),%eax
        movl    %eax,16(%edi)
-       _CET_ENDBR
        movl    20(%esi),%eax
        adcl    20(%edx),%eax
        movl    %eax,20(%edi)
-       _CET_ENDBR
        movl    24(%esi),%eax
        adcl    24(%edx),%eax
        movl    %eax,24(%edi)
-       _CET_ENDBR
        movl    28(%esi),%eax
        adcl    28(%edx),%eax
        movl    %eax,28(%edi)
@@ -119,11 +99,6 @@ L(oop):     movl    (%esi),%eax
        sbbl    %eax,%eax
        negl    %eax
 
-#if IBT_ENABLED
-       popl    %ebx
-       cfi_adjust_cfa_offset (-4)
-       cfi_restore (ebx)
-#endif
        popl %esi
        cfi_adjust_cfa_offset (-4)
        cfi_restore (esi)
index e388c3dfbd9d4663bdf0d5d647e29b04d37e01ac..9005d6381a4408d6fec77e2ec54aa3d826e2fa35 100644 (file)
@@ -80,7 +80,7 @@ L(not_1):
        LOAD_JUMP_TABLE_ENTRY (L(table_32bytes), %ecx)
        addl    %ecx, %edx
        addl    %ecx, %esi
-       _CET_NOTRACK jmp *%ebx
+       jmp     *%ebx
 
        ALIGN (4)
 L(28bytes):
@@ -326,7 +326,7 @@ L(32bytesormore):
        LOAD_JUMP_TABLE_ENTRY (L(table_32bytes), %ecx)
        addl    %ecx, %edx
        addl    %ecx, %esi
-       _CET_NOTRACK jmp *%ebx
+       jmp     *%ebx
 
 L(load_ecx_28):
        addl    $0x4, %edx
index e784e2117693d035ffb6017fec4f11442e826670..449423dd01f05efdcaab3d1ace663f9fbb966622 100644 (file)
@@ -58,7 +58,7 @@
        absolute        address.  */    \
        addl    (%ebx,INDEX,SCALE), %ebx;       \
 /* We loaded the jump table and adjusted EDX/ESI. Go.  */      \
-       _CET_NOTRACK jmp *%ebx
+       jmp *%ebx
 # else
 #  define JMPTBL(I, B) I
 
@@ -66,7 +66,7 @@
        jump    table with relative offsets.  INDEX is a register contains the
        index   into the jump table.   SCALE is the scale of INDEX. */
 #  define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)  \
-       _CET_NOTRACK jmp *TABLE(,INDEX,SCALE)
+       jmp *TABLE(,INDEX,SCALE)
 # endif
 
 
index 19e09314e42ff4da487314b6236ffb8a89815c78..6eb1f541795570ac469a1f09ed4c17767a1b2e8a 100644 (file)
@@ -64,7 +64,7 @@
        absolute address.  */                                   \
     addl       (%ebx,INDEX,SCALE), %ebx;                       \
     /* We loaded the jump table.  Go.  */                      \
-    _CET_NOTRACK jmp *%ebx
+    jmp *%ebx
 
 # define BRANCH_TO_JMPTBL_ENTRY_VALUE(TABLE)                   \
     addl       $(TABLE - .), %ebx
@@ -72,7 +72,7 @@
 # define BRANCH_TO_JMPTBL_ENTRY_TAIL(TABLE, INDEX, SCALE)      \
     addl       (%ebx,INDEX,SCALE), %ebx;                       \
     /* We loaded the jump table.  Go.  */                      \
-    _CET_NOTRACK jmp *%ebx
+    jmp *%ebx
 #else
 # define PARMS         4
 # define ENTRANCE
    absolute offsets.  INDEX is a register contains the index into the
    jump table.  SCALE is the scale of INDEX. */
 # define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)           \
-    _CET_NOTRACK jmp *TABLE(,INDEX,SCALE)
+    jmp *TABLE(,INDEX,SCALE)
 
 # define BRANCH_TO_JMPTBL_ENTRY_VALUE(TABLE)
 
 # define BRANCH_TO_JMPTBL_ENTRY_TAIL(TABLE, INDEX, SCALE)              \
-    _CET_NOTRACK jmp *TABLE(,INDEX,SCALE)
+    jmp *TABLE(,INDEX,SCALE)
 #endif
 
        .section .text.ssse3,"ax",@progbits
index 459fa7b304787b5f7e77add8c786eae2d765f17e..12edb47b481fdf5a4246dcb29152ea30da961b8b 100644 (file)
@@ -64,7 +64,7 @@
        absolute        address.  */            \
        addl    (%ebx, INDEX, SCALE), %ebx;             \
     /* We loaded the jump table.  Go.  */              \
-       _CET_NOTRACK jmp *%ebx
+       jmp *%ebx
 # else
 
 #  define PARMS                4
@@ -78,7 +78,7 @@
        jump table.  SCALE is the scale of INDEX. */
 
 #  define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)          \
-       _CET_NOTRACK jmp *TABLE(, INDEX, SCALE)
+       jmp *TABLE(, INDEX, SCALE)
 # endif
 
        .section .text.ssse3,"ax",@progbits
index 53ac146cd85fed42a9dddf9231e138982cf37b8e..cb3c8f5ebf864ecd2be5c11e603eb03ce498a46b 100644 (file)
@@ -56,7 +56,7 @@
     add                (%ebx,%ecx,4), %ebx;                            \
     add                %ecx, %edx;                                     \
     /* We loaded the jump table and adjusted EDX. Go.  */      \
-    _CET_NOTRACK jmp *%ebx
+    jmp *%ebx
 #else
 # define ENTRANCE
 # define RETURN_END    ret
@@ -68,7 +68,7 @@
    absolute offsets.  */
 # define BRANCH_TO_JMPTBL_ENTRY(TABLE)                         \
     add                %ecx, %edx;                                     \
-    _CET_NOTRACK jmp *TABLE(,%ecx,4)
+    jmp *TABLE(,%ecx,4)
 #endif
 
        .section .text.sse2,"ax",@progbits
index 8566f8b988c0ac6fbb575490d6e255624bcb30b8..30391802d3c8a816902cff082d373d02879a790a 100644 (file)
@@ -56,7 +56,7 @@
     add                (%ebx,%ecx,4), %ebx;                            \
     add                %ecx, %edx;                                     \
     /* We loaded the jump table and adjusted EDX. Go.  */      \
-    _CET_NOTRACK jmp   *%ebx
+    jmp        *%ebx
 #else
 # define ENTRANCE
 # define RETURN_END    ret
@@ -68,7 +68,7 @@
    absolute offsets.  */
 # define BRANCH_TO_JMPTBL_ENTRY(TABLE)                         \
     add                %ecx, %edx;                                     \
-    _CET_NOTRACK jmp *TABLE(,%ecx,4)
+    jmp *TABLE(,%ecx,4)
 #endif
 
        .section .text.sse2,"ax",@progbits
index 329c3711a7f2f9795141355baea22c65f31599f0..94a6941fb5b0977a4eeb80eb321d76eeb4ff42d7 100644 (file)
@@ -49,7 +49,7 @@
        absolute address.  */   \
        addl    (%ecx,INDEX,SCALE), %ecx;       \
        /* We loaded the jump table and adjusted ECX. Go.  */   \
-       _CET_NOTRACK jmp *%ecx
+       jmp *%ecx
 # else
 #  define JMPTBL(I, B) I
 
@@ -58,7 +58,7 @@
        jump table.  SCALE is the scale of INDEX. */
 
 #  define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)  \
-       _CET_NOTRACK jmp *TABLE(,INDEX,SCALE)
+       jmp *TABLE(,INDEX,SCALE)
 # endif
 
 # ifndef STRCAT
index ab7f5444206cfbd552eac76240cf045705d77426..135c6c48bb88b736284d2dcdd948c6570bd42c8f 100644 (file)
@@ -64,7 +64,7 @@
        absolute        address.  */                            \
        addl    (%ecx,INDEX,SCALE), %ecx;                       \
        /* We loaded the jump table and adjusted ECX. Go.  */  \
-       _CET_NOTRACK jmp *%ecx
+       jmp *%ecx
 # else
 #  define JMPTBL(I, B) I
 
@@ -73,7 +73,7 @@
        jump    table.  SCALE is the scale of INDEX. */
 
 #  define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)          \
-       _CET_NOTRACK jmp *TABLE(,INDEX,SCALE)
+       jmp *TABLE(,INDEX,SCALE)
 # endif
 
 .text
index 78513204b40148fba67bc9ee14ef6bf4d820c4dd..bb66672259631483fa9509efc26a6219c0c0ade7 100644 (file)
@@ -19,7 +19,6 @@
 #include <sysdep.h>
 #include <pointer_guard.h>
 #include <jmpbuf-offsets.h>
-#include <jmp_buf-ssp.h>
 #include <asm-syntax.h>
 #include <stap-probe.h>
 
 #define JMPBUF PARMS
 #define SIGMSK JMPBUF+4
 
-/* Don't save shadow stack register if shadow stack isn't enabled.  */
-#if !SHSTK_ENABLED
-# undef SHADOW_STACK_POINTER_OFFSET
-#endif
-
 ENTRY (__sigsetjmp)
 
        movl JMPBUF(%esp), %eax
@@ -53,21 +47,6 @@ ENTRY (__sigsetjmp)
        movl %ecx, (JB_PC*4)(%eax)
        movl %ebp, (JB_BP*4)(%eax) /* Save caller's frame pointer.  */
 
-#ifdef SHADOW_STACK_POINTER_OFFSET
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-       /* Check if Shadow Stack is enabled.  */
-       testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz L(skip_ssp)
-# else
-       xorl %ecx, %ecx
-# endif
-       /* Get the current Shadow-Stack-Pointer and save it.  */
-       rdsspd %ecx
-       movl %ecx, SHADOW_STACK_POINTER_OFFSET(%eax)
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-L(skip_ssp):
-# endif
-#endif
 #if IS_IN (rtld)
        /* In ld.so we never save the signal mask.  */
        xorl %eax, %eax
index 4c98fc65348e4340c15845e0d07e8866f80b787f..542f070cc130aa4d6a13cdc32286fdf9e75546fd 100644 (file)
@@ -132,7 +132,6 @@ ENTRY (_start)
 
 #if defined PIC && !defined SHARED
 __wrap_main:
-       _CET_ENDBR
        jmp     main@PLT
 #endif
 END (_start)
index 35966c90dcb45a9902fa98c6ddaac23a200186eb..8147c1331e169ebaabdac715a47556a24d2f76ae 100644 (file)
@@ -40,13 +40,6 @@ ENTRY (__mpn_sub_n)
        cfi_rel_offset (esi, 0)
        movl    S2(%esp),%edx
        movl    SIZE(%esp),%ecx
-
-#if IBT_ENABLED
-       pushl   %ebx
-       cfi_adjust_cfa_offset (4)
-       cfi_rel_offset (ebx, 0)
-#endif
-
        movl    %ecx,%eax
        shrl    $3,%ecx                 /* compute count for unrolled loop */
        negl    %eax
@@ -58,9 +51,6 @@ ENTRY (__mpn_sub_n)
        subl    %eax,%esi               /* ... by a constant when we ... */
        subl    %eax,%edx               /* ... enter the loop */
        shrl    $2,%eax                 /* restore previous value */
-#if defined __CET__ && (__CET__ & 1) != 0
-       leal    -4(,%eax,4),%ebx        /* Count for 4-byte endbr32 */
-#endif
 #ifdef PIC
 /* Calculate start address in loop for PIC.  Due to limitations in some
    assemblers, Loop-L0-3 cannot be put into the leal */
@@ -74,40 +64,30 @@ L(0):       leal    (%eax,%eax,8),%eax
 #else
 /* Calculate start address in loop for non-PIC.  */
        leal    (L(oop) - 3)(%eax,%eax,8),%eax
-#endif
-#if defined __CET__ && (__CET__ & 1) != 0
-       addl    %ebx,%eax               /* Adjust for endbr32 */
 #endif
        jmp     *%eax                   /* jump into loop */
        ALIGN (3)
 L(oop):        movl    (%esi),%eax
        sbbl    (%edx),%eax
        movl    %eax,(%edi)
-       _CET_ENDBR
        movl    4(%esi),%eax
        sbbl    4(%edx),%eax
        movl    %eax,4(%edi)
-       _CET_ENDBR
        movl    8(%esi),%eax
        sbbl    8(%edx),%eax
        movl    %eax,8(%edi)
-       _CET_ENDBR
        movl    12(%esi),%eax
        sbbl    12(%edx),%eax
        movl    %eax,12(%edi)
-       _CET_ENDBR
        movl    16(%esi),%eax
        sbbl    16(%edx),%eax
        movl    %eax,16(%edi)
-       _CET_ENDBR
        movl    20(%esi),%eax
        sbbl    20(%edx),%eax
        movl    %eax,20(%edi)
-       _CET_ENDBR
        movl    24(%esi),%eax
        sbbl    24(%edx),%eax
        movl    %eax,24(%edi)
-       _CET_ENDBR
        movl    28(%esi),%eax
        sbbl    28(%edx),%eax
        movl    %eax,28(%edi)
@@ -120,11 +100,6 @@ L(oop):    movl    (%esi),%eax
        sbbl    %eax,%eax
        negl    %eax
 
-#if defined __CET__ && (__CET__ & 1) != 0
-       popl    %ebx
-       cfi_adjust_cfa_offset (-4)
-       cfi_restore (ebx)
-#endif
        popl %esi
        cfi_adjust_cfa_offset (-4)
        cfi_restore (esi)
index 0e366974ce28f90b5758387d052adba81477af42..fbc8660f25771773a2c20a632f715f1a5137065c 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <sysdeps/x86/sysdep.h>
 
+#define CET_ENABLED     0
+
 /* It is desirable that the names of PIC thunks match those used by
    GCC so that multiple copies are eliminated by the linker.  Because
    GCC 4.6 and earlier use __i686 in the names, it is necessary to
 
 /* Syntactic details of assembler.  */
 
+/* Define an entry point visible from C.  */
+#define        ENTRY_P2ALIGN(name, alignment)                                        \
+  .globl C_SYMBOL_NAME(name);                                                \
+  .type C_SYMBOL_NAME(name),@function;                                       \
+  .align ALIGNARG(alignment);                                                \
+  C_LABEL(name)                                                                      \
+  cfi_startproc;                                                             \
+  CALL_MCOUNT
+
 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef PROF
 /* The mcount code relies on a normal frame pointer being on the stack
index ed688c015528fabc999da3ffb564c44c3b7633d1..18b5149153404299b93d678d31b4d741a03e9d5c 100644 (file)
 #include <sysdep.h>
 #include <pointer_guard.h>
 #include <jmpbuf-offsets.h>
-#include <jmp_buf-ssp.h>
 #include <asm-syntax.h>
 #include <stap-probe.h>
 
-/* Don't restore shadow stack register if shadow stack isn't enabled.  */
-#if !SHSTK_ENABLED
-# undef SHADOW_STACK_POINTER_OFFSET
-#endif
 
        .section .rodata.str1.1,"aMS",@progbits,1
        .type   longjmp_msg,@object
@@ -52,38 +47,6 @@ longjmp_msg:
 ENTRY (____longjmp_chk)
        movl    4(%esp), %ecx   /* User's jmp_buf in %ecx.  */
 
-#ifdef SHADOW_STACK_POINTER_OFFSET
-# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
-       /* Check if Shadow Stack is enabled.  */
-       testl   $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz      L(skip_ssp)
-# else
-       xorl    %edx, %edx
-# endif
-       /* Check and adjust the Shadow-Stack-Pointer.  */
-       rdsspd  %edx
-       /* And compare it with the saved ssp value.  */
-       subl    SHADOW_STACK_POINTER_OFFSET(%ecx), %edx
-       je      L(skip_ssp)
-       /* Count the number of frames to adjust and adjust it
-          with incssp instruction.  The instruction can adjust
-          the ssp by [0..255] value only thus use a loop if
-          the number of frames is bigger than 255.  */
-       negl    %edx
-       shrl    $2, %edx
-       /* NB: We saved Shadow-Stack-Pointer of setjmp.  Since we are
-              restoring Shadow-Stack-Pointer of setjmp's caller, we
-              need to unwind shadow stack by one more frame.  */
-       addl    $1, %edx
-       movl    $255, %ebx
-L(loop):
-       cmpl    %ebx, %edx
-       cmovb   %edx, %ebx
-       incsspd %ebx
-       subl    %ebx, %edx
-       ja      L(loop)
-L(skip_ssp):
-#endif
        /* Save the return address now.  */
        movl    (JB_PC*4)(%ecx), %edx
        /* Get the stack pointer.  */
index b69a73847b6d15c24e8579e6026fae063f59aef4..1a88bdb9695c57cfe6ffc74bc1b53d95becc9bce 100644 (file)
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <asm/prctl.h>
 
 #include "ucontext_i.h"
 
@@ -42,61 +41,6 @@ ENTRY(__getcontext)
        movw    %fs, %dx
        movl    %edx, oFS(%eax)
 
-#if SHSTK_ENABLED
-       /* Check if shadow stack is enabled.  */
-       testl   $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz      L(no_shstk)
-
-       /* Save EAX in EDX.  */
-       movl    %eax, %edx
-
-       xorl    %eax, %eax
-       cmpl    %gs:SSP_BASE_OFFSET, %eax
-       jnz     L(shadow_stack_bound_recorded)
-
-       /* Save EBX in the first scratch register slot.  */
-       movl    %ebx, oSCRATCH1(%edx)
-
-       /* Get the base address and size of the default shadow stack
-          which must be the current shadow stack since nothing has
-          been recorded yet.  */
-       sub     $24, %esp
-       mov     %esp, %ecx
-       movl    $ARCH_CET_STATUS, %ebx
-       movl    $__NR_arch_prctl, %eax
-       ENTER_KERNEL
-       testl   %eax, %eax
-       jz      L(continue_no_err)
-
-       /* This should never happen.  */
-       hlt
-
-L(continue_no_err):
-       /* Restore EBX from the first scratch register slot.  */
-       movl    oSCRATCH1(%edx), %ebx
-
-       /* Record the base of the current shadow stack.  */
-       movl    8(%esp), %eax
-       movl    %eax, %gs:SSP_BASE_OFFSET
-       add     $24, %esp
-
-L(shadow_stack_bound_recorded):
-       /* Load address of the context data structure.  */
-       movl    4(%esp), %eax
-
-       /* Get the current shadow stack pointer.  */
-       rdsspd  %edx
-       /* NB: Save the caller's shadow stack so that we can jump back
-          to the caller directly.  */
-       addl    $4, %edx
-       movl    %edx, oSSP(%eax)
-
-       /* Save the current shadow stack base in ucontext.  */
-       movl    %gs:SSP_BASE_OFFSET, %edx
-       movl    %edx, (oSSP + 4)(%eax)
-
-L(no_shstk):
-#endif
        /* We have separate floating-point register content memory on the
           stack.  We use the __fpregs_mem block in the context.  Set the
           links up correctly.  */
index 346cdd0e0a79c8bd61cc21a1ff6435aa111bde41..1b6713fdf4a28dd67447adc4da023813ada319a5 100644 (file)
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <asm/prctl.h>
 
 #include "ucontext_i.h"
 
@@ -68,127 +67,6 @@ ENTRY(__makecontext)
        jnz     1b
 2:
 
-#if SHSTK_ENABLED
-       /* Check if Shadow Stack is enabled.  */
-       testl   $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz      L(skip_ssp)
-
-       /* Reload the pointer to ucontext.  */
-       movl    4(%esp), %eax
-
-       /* Shadow stack is enabled.  We need to allocate a new shadow
-          stack.  */
-       subl    oSS_SP(%eax), %edx
-       shrl    $STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT, %edx
-
-       /* Align shadow stack size to 8 bytes.  */
-       addl    $7, %edx
-       andl    $-8, %edx
-
-       /* Store shadow stack size in __ssp[2].  */
-       movl    %edx, (oSSP + 8)(%eax)
-
-       /* Save ESI in the second scratch register slot.  */
-       movl    %esi, oSCRATCH2(%eax)
-       /* Save EDI in the third scratch register slot.  */
-       movl    %edi, oSCRATCH3(%eax)
-
-       /* Save the pointer to ucontext.  */
-       movl    %eax, %edi
-
-       /* Get the original shadow stack pointer.  */
-       rdsspd  %esi
-
-       /* Align the saved original shadow stack pointer to the next
-          8 byte aligned boundary.  */
-       andl    $-8, %esi
-
-       /* Load the top of the new stack into EDX.  */
-       movl    oESP(%eax), %edx
-
-       /* We need to terminate the FDE here because the unwinder looks
-          at ra-1 for unwind information.  */
-       cfi_endproc
-
-       /* Swap the original stack pointer with the top of the new
-          stack.  */
-       xchgl   %esp, %edx
-
-       /* Add 4 bytes since CALL will push the 4-byte return address
-          onto stack.  */
-       addl    $4, %esp
-
-       /* Allocate the new shadow stack.  Save EBX in the first scratch
-          register slot.  */
-       movl    %ebx, oSCRATCH1(%eax)
-
-       /* CET syscall takes 64-bit sizes.  */
-       subl    $16, %esp
-       movl    (oSSP + 8)(%eax), %ecx
-       movl    %ecx, (%esp)
-       movl    $0, 4(%esp)
-       movl    %ecx, 8(%esp)
-       movl    $0, 12(%esp)
-       movl    %esp, %ecx
-
-       movl    $ARCH_CET_ALLOC_SHSTK, %ebx
-       movl    $__NR_arch_prctl, %eax
-       ENTER_KERNEL
-       testl   %eax, %eax
-       jne     L(hlt)          /* This should never happen.  */
-
-       /* Copy the base address of the new shadow stack to __ssp[1].  */
-       movl    (%esp), %eax
-       movl    %eax, (oSSP + 4)(%edi)
-
-       addl    $16, %esp
-
-       /* Restore EBX from the first scratch register slot.  */
-       movl    oSCRATCH1(%edi), %ebx
-
-       /* Get the size of the new shadow stack.  */
-       movl    (oSSP + 8)(%edi), %ecx
-
-       /* Use the restore stoken to restore the new shadow stack.  */
-       rstorssp -8(%eax, %ecx)
-
-       /* Save the restore token at the next 8 byte aligned boundary
-          on the original shadow stack.  */
-       saveprevssp
-
-       /* Push the address of "jmp exitcode" onto the new stack as
-          well as the new shadow stack.  */
-       call    1f
-       jmp     L(exitcode)
-1:
-
-       /* Get the new shadow stack pointer.  */
-       rdsspd  %eax
-
-       /* Use the restore stoken to restore the original shadow stack.  */
-       rstorssp -8(%esi)
-
-       /* Save the restore token on the new shadow stack.  */
-       saveprevssp
-
-       /* Store the new shadow stack pointer in __ssp[0].  */
-       movl    %eax, oSSP(%edi)
-
-       /* Restore the original stack.  */
-       mov     %edx, %esp
-
-       cfi_startproc
-
-       /* Restore ESI from the second scratch register slot.  */
-       movl    oSCRATCH2(%edi), %esi
-       /* Restore EDI from the third scratch register slot.  */
-       movl    oSCRATCH3(%edi), %edi
-
-       ret
-
-L(skip_ssp):
-#endif
-
        /* If the function we call returns we must continue with the
           context which is given in the uc_link element.  To do this
           set the return address for the function the user provides
@@ -244,7 +122,6 @@ L(call_exit):
        call    HIDDEN_JUMPTARGET(exit)
        /* The 'exit' call should never return.  In case it does cause
           the process to terminate.  */
-L(hlt):
        hlt
        cfi_startproc
 END(__makecontext)
index ccd79906fd35f5e9c126e47ea349d780d7bed9d2..0602221af244cdeefac5b30a37f884913b54fd2e 100644 (file)
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <asm/prctl.h>
 
 #include "ucontext_i.h"
 
@@ -56,6 +55,9 @@ ENTRY(__setcontext)
        movl    oFS(%eax), %ecx
        movw    %cx, %fs
 
+       /* Fetch the address to return to.  */
+       movl    oEIP(%eax), %ecx
+
        /* Load the new stack pointer.  */
        cfi_def_cfa (eax, 0)
        cfi_offset (edi, oEDI)
@@ -64,103 +66,6 @@ ENTRY(__setcontext)
        cfi_offset (ebx, oEBX)
        movl    oESP(%eax), %esp
 
-#if SHSTK_ENABLED
-       /* Check if Shadow Stack is enabled.  */
-       testl   $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz      L(no_shstk)
-
-       /* If the base of the target shadow stack is the same as the
-          base of the current shadow stack, we unwind the shadow
-          stack.  Otherwise it is a stack switch and we look for a
-          restore token.  */
-       movl    oSSP(%eax), %esi
-       movl    %esi, %edi
-
-       /* Get the base of the target shadow stack.  */
-       movl    (oSSP + 4)(%eax), %ecx
-       cmpl    %gs:SSP_BASE_OFFSET, %ecx
-       je      L(unwind_shadow_stack)
-
-       /* Align the saved original shadow stack pointer to the next
-          8 byte aligned boundary.  */
-       andl    $-8, %esi
-
-L(find_restore_token_loop):
-       /* Look for a restore token.  */
-       movl    -8(%esi), %ebx
-       andl    $-8, %ebx
-       cmpl    %esi, %ebx
-       je      L(restore_shadow_stack)
-
-       /* Try the next slot.  */
-       subl    $8, %esi
-       jmp     L(find_restore_token_loop)
-
-L(restore_shadow_stack):
-       /* Pop return address from the shadow stack since setcontext
-          will not return.  */
-       movl    $1, %ebx
-       incsspd %ebx
-
-       /* Use the restore stoken to restore the target shadow stack.  */
-       rstorssp -8(%esi)
-
-       /* Save the restore token on the old shadow stack.  NB: This
-          restore token may be checked by setcontext or swapcontext
-          later.  */
-       saveprevssp
-
-       /* Record the new shadow stack base that was switched to.  */
-       movl    (oSSP + 4)(%eax), %ebx
-       movl    %ebx, %gs:SSP_BASE_OFFSET
-
-L(unwind_shadow_stack):
-       rdsspd  %ebx
-       subl    %edi, %ebx
-       je      L(skip_unwind_shadow_stack)
-       negl    %ebx
-       shrl    $2, %ebx
-       movl    $255, %esi
-L(loop):
-       cmpl    %esi, %ebx
-       cmovb   %ebx, %esi
-       incsspd %esi
-       subl    %esi, %ebx
-       ja      L(loop)
-
-L(skip_unwind_shadow_stack):
-
-       /* Load the values of all the preserved registers (except ESP).  */
-       movl    oEDI(%eax), %edi
-       movl    oESI(%eax), %esi
-       movl    oEBP(%eax), %ebp
-       movl    oEBX(%eax), %ebx
-
-       /* Get the return address set with getcontext.  */
-       movl    oEIP(%eax), %ecx
-
-       /* Check if return address is valid for the case when setcontext
-          is invoked from L(exitcode) with linked context.  */
-       rdsspd  %eax
-       cmpl    (%eax), %ecx
-       /* Clear EAX to indicate success.  NB: Don't use xorl to keep
-          EFLAGS for jne.  */
-       movl    $0, %eax
-       jne     L(jmp)
-       /* Return to the new context if return address valid.  */
-       pushl   %ecx
-       ret
-
-L(jmp):
-       /* Jump to the new context directly.  */
-       jmp     *%ecx
-
-L(no_shstk):
-#endif
-
-       /* Fetch the address to return to.  */
-       movl    oEIP(%eax), %ecx
-
        /* Push the return address on the new stack so we can return there.  */
        pushl   %ecx
 
index 551df10c91e972e8b07bec211ce8a5360a95bb84..7800dfefb3d5ae6339af9b1aab193b8e61a882b4 100644 (file)
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <asm/prctl.h>
 
 #include "ucontext_i.h"
 
@@ -76,144 +75,6 @@ ENTRY(__swapcontext)
        movl    oFS(%eax), %edx
        movw    %dx, %fs
 
-#if SHSTK_ENABLED
-       /* Check if Shadow Stack is enabled.  */
-       testl   $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
-       jz      L(no_shstk)
-
-       xorl    %eax, %eax
-       cmpl    %gs:SSP_BASE_OFFSET, %eax
-       jnz     L(shadow_stack_bound_recorded)
-
-       /* Get the base address and size of the default shadow stack
-          which must be the current shadow stack since nothing has
-          been recorded yet.  */
-       sub     $24, %esp
-       mov     %esp, %ecx
-       movl    $ARCH_CET_STATUS, %ebx
-       movl    $__NR_arch_prctl, %eax
-       ENTER_KERNEL
-       testl   %eax, %eax
-       jz      L(continue_no_err)
-
-       /* This should never happen.  */
-       hlt
-
-L(continue_no_err):
-       /* Record the base of the current shadow stack.  */
-       movl    8(%esp), %eax
-       movl    %eax, %gs:SSP_BASE_OFFSET
-       add     $24, %esp
-
-L(shadow_stack_bound_recorded):
-       /* Load address of the context data structure we save in.  */
-       movl    4(%esp), %eax
-
-       /* Load address of the context data structure we swap in  */
-       movl    8(%esp), %edx
-
-       /* If we unwind the stack, we can't undo stack unwinding.  Just
-          save the target shadow stack pointer as the current shadow
-          stack pointer.   */
-       movl    oSSP(%edx), %ecx
-       movl    %ecx, oSSP(%eax)
-
-       /* Save the current shadow stack base in ucontext.  */
-       movl    %gs:SSP_BASE_OFFSET, %ecx
-       movl    %ecx, (oSSP + 4)(%eax)
-
-       /* If the base of the target shadow stack is the same as the
-          base of the current shadow stack, we unwind the shadow
-          stack.  Otherwise it is a stack switch and we look for a
-          restore token.  */
-       movl    oSSP(%edx), %esi
-       movl    %esi, %edi
-
-       /* Get the base of the target shadow stack.  */
-       movl    (oSSP + 4)(%edx), %ecx
-       cmpl    %gs:SSP_BASE_OFFSET, %ecx
-       je      L(unwind_shadow_stack)
-
-       /* Align the saved original shadow stack pointer to the next
-          8 byte aligned boundary.  */
-       andl    $-8, %esi
-
-L(find_restore_token_loop):
-       /* Look for a restore token.  */
-       movl    -8(%esi), %ebx
-       andl    $-8, %ebx
-       cmpl    %esi, %ebx
-       je      L(restore_shadow_stack)
-
-       /* Try the next slot.  */
-       subl    $8, %esi
-       jmp     L(find_restore_token_loop)
-
-L(restore_shadow_stack):
-       /* The target shadow stack will be restored.  Save the current
-          shadow stack pointer.  */
-       rdsspd  %ecx
-       movl    %ecx, oSSP(%eax)
-
-       /* Use the restore stoken to restore the target shadow stack.  */
-       rstorssp -8(%esi)
-
-       /* Save the restore token on the old shadow stack.  NB: This
-          restore token may be checked by setcontext or swapcontext
-          later.  */
-       saveprevssp
-
-       /* Record the new shadow stack base that was switched to.  */
-       movl    (oSSP + 4)(%edx), %ebx
-       movl    %ebx, %gs:SSP_BASE_OFFSET
-
-L(unwind_shadow_stack):
-       rdsspd  %ebx
-       subl    %edi, %ebx
-       je      L(skip_unwind_shadow_stack)
-       negl    %ebx
-       shrl    $2, %ebx
-       movl    $255, %esi
-L(loop):
-       cmpl    %esi, %ebx
-       cmovb   %ebx, %esi
-       incsspd %esi
-       subl    %esi, %ebx
-       ja      L(loop)
-
-L(skip_unwind_shadow_stack):
-
-       /* Load the new stack pointer.  */
-       movl    oESP(%edx), %esp
-
-       /* Load the values of all the preserved registers (except ESP).  */
-       movl    oEDI(%edx), %edi
-       movl    oESI(%edx), %esi
-       movl    oEBP(%edx), %ebp
-       movl    oEBX(%edx), %ebx
-
-       /* Get the return address set with getcontext.  */
-       movl    oEIP(%edx), %ecx
-
-       /* Check if return address is valid for the case when setcontext
-          is invoked from L(exitcode) with linked context.  */
-       rdsspd  %eax
-       cmpl    (%eax), %ecx
-       /* Clear EAX to indicate success.  NB: Don't use xorl to keep
-          EFLAGS for jne.  */
-       movl    $0, %eax
-       jne     L(jmp)
-       /* Return to the new context if return address valid.  */
-       pushl   %ecx
-       ret
-
-L(jmp):
-       /* Jump to the new context directly.  */
-       jmp     *%ecx
-
-L(no_shstk):
-#endif
-
        /* Fetch the address to return to.  */
        movl    oEIP(%eax), %ecx
 
index 87de7d640fa1a9972674adbe5c35a35b91e86c56..46181e2aa2e343c01c5fae99e79ad329a489dd0d 100644 (file)
@@ -446,9 +446,4 @@ struct libc_do_syscall_args
 
 #endif /* __ASSEMBLER__ */
 
-/* Each shadow stack slot takes 4 bytes.  Assuming that each stack
-   frame takes 128 bytes, this is used to compute shadow stack size
-   from stack size.  */
-#define STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT 5
-
 #endif /* linux/i386/sysdep.h */
index 1d8608eafc3f2a676f63b310dbb5eeba2c80c6be..1dfe03d2cc5e8642b1f91295d115b9fc2724814a 100644 (file)
@@ -22,10 +22,6 @@ oEBP         mreg (EBP)
 oESP           mreg (ESP)
 oEBX           mreg (EBX)
 oEIP           mreg (EIP)
-oSCRATCH1      mreg (EAX)
-oSCRATCH2      mreg (ECX)
-oSCRATCH3      mreg (EDX)
 oFPREGS                mcontext (fpregs)
 oSIGMASK       ucontext (uc_sigmask)
 oFPREGSMEM     ucontext (__fpregs_mem)
-oSSP           ucontext (__ssp)
index b23e16a663e50db138655a070e1c17579dd605ba..bb87cd320f074d7b01cb0b6857478130a8c234bd 100644 (file)
@@ -20,6 +20,7 @@
 #include <bits/errno.h>
 #include <tcb-offsets.h>
 
+
 /* Clone the calling process, but without copying the whole address space.
    The calling process is suspended until the new process exits or is
    replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
@@ -46,29 +47,6 @@ ENTRY (__vfork)
        /* Branch forward if it failed.  */
        jae     SYSCALL_ERROR_LABEL
 
-#if SHSTK_ENABLED
-       /* Check if shadow stack is in use.  */
-       xorl    %edx, %edx
-       rdsspd  %edx
-       testl   %edx, %edx
-       /* Normal return if shadow stack isn't in use.  */
-       je      L(no_shstk)
-
-       testl   %eax, %eax
-       /* In parent, normal return.  */
-       jnz     L(no_shstk)
-
-       /* NB: In child, jump back to caller via indirect branch without
-          popping shadow stack which is shared with parent.  Keep shadow
-          stack mismatched so that child returns in the vfork-calling
-          function will trigger SIGSEGV.  */
-       popl    %ecx
-       cfi_adjust_cfa_offset (-4)
-       jmp     *%ecx
-
-L(no_shstk):
-#endif
-
        ret
 
 PSEUDO_END (__vfork)
index 0b3483a77acee770c0219a0983f2277ea9a2cf31..bfe3469f1c4de0db31d5604126acdee5274c9b03 100644 (file)
 
 #include <sysdeps/generic/sysdep.h>
 
-/* __CET__ is defined by GCC with Control-Flow Protection values:
-
-enum cf_protection_level
-{
-  CF_NONE = 0,
-  CF_BRANCH = 1 << 0,
-  CF_RETURN = 1 << 1,
-  CF_FULL = CF_BRANCH | CF_RETURN,
-  CF_SET = 1 << 2
-};
-*/
-
-/* Set if CF_BRANCH (IBT) is enabled.  */
-#define X86_FEATURE_1_IBT      (1U << 0)
-/* Set if CF_RETURN (SHSTK) is enabled.  */
-#define X86_FEATURE_1_SHSTK    (1U << 1)
-
-#ifdef __CET__
-# define CET_ENABLED   1
-# define IBT_ENABLED   (__CET__ & X86_FEATURE_1_IBT)
-# define SHSTK_ENABLED (__CET__ & X86_FEATURE_1_SHSTK)
-#else
-# define CET_ENABLED   0
-# define IBT_ENABLED   0
-# define SHSTK_ENABLED 0
-#endif
-
 /* Offset for fxsave/xsave area used by _dl_runtime_resolve.  Also need
    space to preserve RCX, RDX, RSI, RDI, R8, R9 and RAX.  It must be
    aligned to 16 bytes for fxsave and 64 bytes for xsave.  */
@@ -66,27 +39,10 @@ enum cf_protection_level
 
 /* Syntactic details of assembler.  */
 
-#ifdef _CET_ENDBR
-# define _CET_NOTRACK notrack
-#else
-# define _CET_ENDBR
-# define _CET_NOTRACK
-#endif
-
 /* ELF uses byte-counts for .align, most others use log2 of count of bytes.  */
 #define ALIGNARG(log2) 1<<log2
 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
 
-/* Define an entry point visible from C.  */
-#define        ENTRY_P2ALIGN(name, alignment)                                        \
-  .globl C_SYMBOL_NAME(name);                                                \
-  .type C_SYMBOL_NAME(name),@function;                                       \
-  .align ALIGNARG(alignment);                                                \
-  C_LABEL(name)                                                                      \
-  cfi_startproc;                                                             \
-  _CET_ENDBR;                                                                \
-  CALL_MCOUNT
-
 /* Common entry 16 byte aligns.  */
 #define ENTRY(name) ENTRY_P2ALIGN (name, 4)
 
index 6ca169573d9a17c5955b90109367f5f0580a8ae0..e3304c7f8d0d6bc2a5851b6e18319d749133167b 100644 (file)
 #include <sysdeps/x86/sysdep.h>
 #include <x86-lp_size.h>
 
+/* __CET__ is defined by GCC with Control-Flow Protection values:
+
+enum cf_protection_level
+{
+  CF_NONE = 0,
+  CF_BRANCH = 1 << 0,
+  CF_RETURN = 1 << 1,
+  CF_FULL = CF_BRANCH | CF_RETURN,
+  CF_SET = 1 << 2
+};
+*/
+
+/* Set if CF_BRANCH (IBT) is enabled.  */
+#define X86_FEATURE_1_IBT      (1U << 0)
+/* Set if CF_RETURN (SHSTK) is enabled.  */
+#define X86_FEATURE_1_SHSTK    (1U << 1)
+
+#ifdef __CET__
+# define CET_ENABLED   1
+# define SHSTK_ENABLED (__CET__ & X86_FEATURE_1_SHSTK)
+#else
+# define CET_ENABLED   0
+# define SHSTK_ENABLED 0
+#endif
+
 #ifdef __ASSEMBLER__
 
 /* Syntactic details of assembler.  */
 
+#ifdef _CET_ENDBR
+# define _CET_NOTRACK notrack
+#else
+# define _CET_ENDBR
+# define _CET_NOTRACK
+#endif
+
+/* Define an entry point visible from C.  */
+#define        ENTRY_P2ALIGN(name, alignment)                                        \
+  .globl C_SYMBOL_NAME(name);                                                \
+  .type C_SYMBOL_NAME(name),@function;                                       \
+  .align ALIGNARG(alignment);                                                \
+  C_LABEL(name)                                                                      \
+  cfi_startproc;                                                             \
+  _CET_ENDBR;                                                                \
+  CALL_MCOUNT
+
 /* This macro is for setting proper CFI with DW_CFA_expression describing
    the register as saved relative to %rsp instead of relative to the CFA.
    Expression is DW_OP_drop, DW_OP_breg7 (%rsp is register 7), sleb128 offset