[04/24] x86: Add _CET_ENDBR to functions in crti.S

Message ID 20180613153207.57232-5-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 crti.S, which are called indirectly, to
support IBT.

Tested on i686 and x86-64.

	* sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
	(_fini): Likewise.
	* sysdeps/x86_64/crti.S (_init): Likewise.
	(_fini): Likewise.
---
 sysdeps/i386/crti.S   | 2 ++
 sysdeps/x86_64/crti.S | 2 ++
 2 files changed, 4 insertions(+)

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 crti.S, which are called indirectly, to
> support IBT.
> 
> Tested on i686 and x86-64.
> 
> 	* sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
> 	(_fini): Likewise.
> 	* sysdeps/x86_64/crti.S (_init): Likewise.
> 	(_fini): Likewise.

Please commit.

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

> ---
>  sysdeps/i386/crti.S   | 2 ++
>  sysdeps/x86_64/crti.S | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/sysdeps/i386/crti.S b/sysdeps/i386/crti.S
> index ffbc92c22f..65ddc1c934 100644
> --- a/sysdeps/i386/crti.S
> +++ b/sysdeps/i386/crti.S
> @@ -61,6 +61,7 @@
>  	.hidden	_init
>  	.type _init, @function
>  _init:
> +	_CET_ENDBR
>  	pushl %ebx
>  	/* Maintain 16-byte stack alignment for called functions.  */
>  	subl $8, %esp
> @@ -81,6 +82,7 @@ _init:
>  	.hidden	_fini
>  	.type _fini, @function
>  _fini:
> +	_CET_ENDBR
>  	pushl %ebx
>  	subl $8, %esp
>  	LOAD_PIC_REG (bx)
> diff --git a/sysdeps/x86_64/crti.S b/sysdeps/x86_64/crti.S
> index f26915e956..067ac14884 100644
> --- a/sysdeps/x86_64/crti.S
> +++ b/sysdeps/x86_64/crti.S
> @@ -61,6 +61,7 @@
>  	.hidden	_init
>  	.type _init, @function
>  _init:
> +	_CET_ENDBR
>  	/* Maintain 16-byte stack alignment for called functions.  */
>  	subq $8, %rsp
>  #if PREINIT_FUNCTION_WEAK
> @@ -79,4 +80,5 @@ _init:
>  	.hidden	_fini
>  	.type _fini, @function
>  _fini:
> +	_CET_ENDBR
>  	subq $8, %rsp
>
H.J. Lu July 6, 2018, 5 p.m. | #2
On Fri, Jul 6, 2018 at 7:50 AM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 06/13/2018 11:31 AM, H.J. Lu wrote:
>> Add _CET_ENDBR to functions in crti.S, which are called indirectly, to
>> support IBT.
>>
>> Tested on i686 and x86-64.
>>
>>       * sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
>>       (_fini): Likewise.
>>       * sysdeps/x86_64/crti.S (_init): Likewise.
>>       (_fini): Likewise.
>
> Please commit.
>
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>

All my _CET_ENDBR changes depend on:

https://sourceware.org/ml/libc-alpha/2018-06/msg00325.html
Carlos O'Donell July 6, 2018, 6:48 p.m. | #3
On 07/06/2018 01:00 PM, H.J. Lu wrote:
> On Fri, Jul 6, 2018 at 7:50 AM, Carlos O'Donell <carlos@redhat.com> wrote:
>> On 06/13/2018 11:31 AM, H.J. Lu wrote:
>>> Add _CET_ENDBR to functions in crti.S, which are called indirectly, to
>>> support IBT.
>>>
>>> Tested on i686 and x86-64.
>>>
>>>       * sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
>>>       (_fini): Likewise.
>>>       * sysdeps/x86_64/crti.S (_init): Likewise.
>>>       (_fini): Likewise.
>>
>> Please commit.
>>
>> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
>>
> 
> All my _CET_ENDBR changes depend on:
> 
> https://sourceware.org/ml/libc-alpha/2018-06/msg00325.html

Understood, and I'm reviewing that one still.

Patch

diff --git a/sysdeps/i386/crti.S b/sysdeps/i386/crti.S
index ffbc92c22f..65ddc1c934 100644
--- a/sysdeps/i386/crti.S
+++ b/sysdeps/i386/crti.S
@@ -61,6 +61,7 @@ 
 	.hidden	_init
 	.type _init, @function
 _init:
+	_CET_ENDBR
 	pushl %ebx
 	/* Maintain 16-byte stack alignment for called functions.  */
 	subl $8, %esp
@@ -81,6 +82,7 @@  _init:
 	.hidden	_fini
 	.type _fini, @function
 _fini:
+	_CET_ENDBR
 	pushl %ebx
 	subl $8, %esp
 	LOAD_PIC_REG (bx)
diff --git a/sysdeps/x86_64/crti.S b/sysdeps/x86_64/crti.S
index f26915e956..067ac14884 100644
--- a/sysdeps/x86_64/crti.S
+++ b/sysdeps/x86_64/crti.S
@@ -61,6 +61,7 @@ 
 	.hidden	_init
 	.type _init, @function
 _init:
+	_CET_ENDBR
 	/* Maintain 16-byte stack alignment for called functions.  */
 	subq $8, %rsp
 #if PREINIT_FUNCTION_WEAK
@@ -79,4 +80,5 @@  _init:
 	.hidden	_fini
 	.type _fini, @function
 _fini:
+	_CET_ENDBR
 	subq $8, %rsp