[05/24] x86: Add _CET_ENDBR to functions in dl-tlsdesc.S

Message ID 20180613153207.57232-6-hjl.tools@gmail.com
State New
Headers show
Series
  • CET: Prepare for CET enabling
Related show

Commit Message

H.J. Lu June 13, 2018, 3:31 p.m.
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.
---
 sysdeps/i386/dl-tlsdesc.S   | 7 +++++++
 sysdeps/x86_64/dl-tlsdesc.S | 5 +++++
 2 files changed, 12 insertions(+)

-- 
2.17.1

Comments

Carlos O'Donell July 6, 2018, 2:50 p.m. | #1
On 06/13/2018 11:31 AM, H.J. Lu wrote:
> 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.


Please commit.

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


> ---

>  sysdeps/i386/dl-tlsdesc.S   | 7 +++++++

>  sysdeps/x86_64/dl-tlsdesc.S | 5 +++++

>  2 files changed, 12 insertions(+)

> 

> diff --git a/sysdeps/i386/dl-tlsdesc.S b/sysdeps/i386/dl-tlsdesc.S

> index 2c4764d1aa..128f0af318 100644

> --- a/sysdeps/i386/dl-tlsdesc.S

> +++ b/sysdeps/i386/dl-tlsdesc.S

> @@ -37,6 +37,7 @@

>  	cfi_startproc

>  	.align 16

>  _dl_tlsdesc_return:

> +	_CET_ENDBR

>  	movl	4(%eax), %eax

>  	ret

>  	cfi_endproc

> @@ -58,6 +59,7 @@ _dl_tlsdesc_return:

>  	cfi_startproc

>  	.align 16

>  _dl_tlsdesc_undefweak:

> +	_CET_ENDBR

>  	movl	4(%eax), %eax

>  	subl	%gs:0, %eax

>  	ret

> @@ -99,6 +101,7 @@ _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

> @@ -154,6 +157,7 @@ _dl_tlsdesc_dynamic:

>  	.align 16

>  _dl_tlsdesc_resolve_abs_plus_addend:

>  0:

> +	_CET_ENDBR

>  	pushl	%eax

>  	cfi_adjust_cfa_offset (4)

>  	pushl	%ecx

> @@ -192,6 +196,7 @@ _dl_tlsdesc_resolve_abs_plus_addend:

>  	.align 16

>  _dl_tlsdesc_resolve_rel:

>  0:

> +	_CET_ENDBR

>  	pushl	%eax

>  	cfi_adjust_cfa_offset (4)

>  	pushl	%ecx

> @@ -230,6 +235,7 @@ _dl_tlsdesc_resolve_rel:

>  	.align 16

>  _dl_tlsdesc_resolve_rela:

>  0:

> +	_CET_ENDBR

>  	pushl	%eax

>  	cfi_adjust_cfa_offset (4)

>  	pushl	%ecx

> @@ -268,6 +274,7 @@ _dl_tlsdesc_resolve_rela:

>  	.align 16

>  _dl_tlsdesc_resolve_hold:

>  0:

> +	_CET_ENDBR

>  	pushl	%eax

>  	cfi_adjust_cfa_offset (4)

>  	pushl	%ecx

> diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S

> index 437bd8cde7..80d771cd88 100644

> --- a/sysdeps/x86_64/dl-tlsdesc.S

> +++ b/sysdeps/x86_64/dl-tlsdesc.S

> @@ -37,6 +37,7 @@

>  	cfi_startproc

>  	.align 16

>  _dl_tlsdesc_return:

> +	_CET_ENDBR

>  	movq	8(%rax), %rax

>  	ret

>  	cfi_endproc

> @@ -58,6 +59,7 @@ _dl_tlsdesc_return:

>  	cfi_startproc

>  	.align 16

>  _dl_tlsdesc_undefweak:

> +	_CET_ENDBR

>  	movq	8(%rax), %rax

>  	subq	%fs:0, %rax

>  	ret

> @@ -96,6 +98,7 @@ _dl_tlsdesc_dynamic (register struct tlsdesc *tdp asm ("%rax"))

>  	cfi_startproc

>  	.align 16

>  _dl_tlsdesc_dynamic:

> +	_CET_ENDBR

>  	/* Preserve call-clobbered registers that we modify.

>  	   We need two scratch regs anyway.  */

>  	movq	%rsi, -16(%rsp)

> @@ -166,6 +169,7 @@ _dl_tlsdesc_dynamic:

>  	.align 16

>  	/* The PLT entry will have pushed the link_map pointer.  */

>  _dl_tlsdesc_resolve_rela:

> +	_CET_ENDBR

>  	cfi_adjust_cfa_offset (8)

>  	/* Save all call-clobbered registers.  Add 8 bytes for push in

>  	   the PLT entry to align the stack.  */

> @@ -216,6 +220,7 @@ _dl_tlsdesc_resolve_rela:

>  	.align 16

>  _dl_tlsdesc_resolve_hold:

>  0:

> +	_CET_ENDBR

>  	/* Save all call-clobbered registers.  */

>  	subq	$72, %rsp

>  	cfi_adjust_cfa_offset (72)

> 



-- 
Cheers,
Carlos.

Patch

diff --git a/sysdeps/i386/dl-tlsdesc.S b/sysdeps/i386/dl-tlsdesc.S
index 2c4764d1aa..128f0af318 100644
--- a/sysdeps/i386/dl-tlsdesc.S
+++ b/sysdeps/i386/dl-tlsdesc.S
@@ -37,6 +37,7 @@ 
 	cfi_startproc
 	.align 16
 _dl_tlsdesc_return:
+	_CET_ENDBR
 	movl	4(%eax), %eax
 	ret
 	cfi_endproc
@@ -58,6 +59,7 @@  _dl_tlsdesc_return:
 	cfi_startproc
 	.align 16
 _dl_tlsdesc_undefweak:
+	_CET_ENDBR
 	movl	4(%eax), %eax
 	subl	%gs:0, %eax
 	ret
@@ -99,6 +101,7 @@  _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
@@ -154,6 +157,7 @@  _dl_tlsdesc_dynamic:
 	.align 16
 _dl_tlsdesc_resolve_abs_plus_addend:
 0:
+	_CET_ENDBR
 	pushl	%eax
 	cfi_adjust_cfa_offset (4)
 	pushl	%ecx
@@ -192,6 +196,7 @@  _dl_tlsdesc_resolve_abs_plus_addend:
 	.align 16
 _dl_tlsdesc_resolve_rel:
 0:
+	_CET_ENDBR
 	pushl	%eax
 	cfi_adjust_cfa_offset (4)
 	pushl	%ecx
@@ -230,6 +235,7 @@  _dl_tlsdesc_resolve_rel:
 	.align 16
 _dl_tlsdesc_resolve_rela:
 0:
+	_CET_ENDBR
 	pushl	%eax
 	cfi_adjust_cfa_offset (4)
 	pushl	%ecx
@@ -268,6 +274,7 @@  _dl_tlsdesc_resolve_rela:
 	.align 16
 _dl_tlsdesc_resolve_hold:
 0:
+	_CET_ENDBR
 	pushl	%eax
 	cfi_adjust_cfa_offset (4)
 	pushl	%ecx
diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S
index 437bd8cde7..80d771cd88 100644
--- a/sysdeps/x86_64/dl-tlsdesc.S
+++ b/sysdeps/x86_64/dl-tlsdesc.S
@@ -37,6 +37,7 @@ 
 	cfi_startproc
 	.align 16
 _dl_tlsdesc_return:
+	_CET_ENDBR
 	movq	8(%rax), %rax
 	ret
 	cfi_endproc
@@ -58,6 +59,7 @@  _dl_tlsdesc_return:
 	cfi_startproc
 	.align 16
 _dl_tlsdesc_undefweak:
+	_CET_ENDBR
 	movq	8(%rax), %rax
 	subq	%fs:0, %rax
 	ret
@@ -96,6 +98,7 @@  _dl_tlsdesc_dynamic (register struct tlsdesc *tdp asm ("%rax"))
 	cfi_startproc
 	.align 16
 _dl_tlsdesc_dynamic:
+	_CET_ENDBR
 	/* Preserve call-clobbered registers that we modify.
 	   We need two scratch regs anyway.  */
 	movq	%rsi, -16(%rsp)
@@ -166,6 +169,7 @@  _dl_tlsdesc_dynamic:
 	.align 16
 	/* The PLT entry will have pushed the link_map pointer.  */
 _dl_tlsdesc_resolve_rela:
+	_CET_ENDBR
 	cfi_adjust_cfa_offset (8)
 	/* Save all call-clobbered registers.  Add 8 bytes for push in
 	   the PLT entry to align the stack.  */
@@ -216,6 +220,7 @@  _dl_tlsdesc_resolve_rela:
 	.align 16
 _dl_tlsdesc_resolve_hold:
 0:
+	_CET_ENDBR
 	/* Save all call-clobbered registers.  */
 	subq	$72, %rsp
 	cfi_adjust_cfa_offset (72)