Re: [PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-19 Thread H.J. Lu
On Wed, Jul 18, 2018 at 12:34:28PM -0700, Kostya Serebryany wrote: > On Wed, Jul 18, 2018 at 12:29 PM H.J. Lu wrote: > > > > On Wed, Jul 18, 2018 at 11:45 AM, Kostya Serebryany wrote: > > > On Wed, Jul 18, 2018 at 11:40 AM H.J. Lu wrote: > > >> > > >> On Wed, Jul 18, 2018 at 11:18 AM, Kostya Ser

Re: [PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-18 Thread Kostya Serebryany via gcc-patches
On Wed, Jul 18, 2018 at 12:29 PM H.J. Lu wrote: > > On Wed, Jul 18, 2018 at 11:45 AM, Kostya Serebryany wrote: > > On Wed, Jul 18, 2018 at 11:40 AM H.J. Lu wrote: > >> > >> On Wed, Jul 18, 2018 at 11:18 AM, Kostya Serebryany > >> wrote: > >> > What's ENDBR and do we really need to have it in c

Re: [PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-18 Thread H.J. Lu
On Wed, Jul 18, 2018 at 11:45 AM, Kostya Serebryany wrote: > On Wed, Jul 18, 2018 at 11:40 AM H.J. Lu wrote: >> >> On Wed, Jul 18, 2018 at 11:18 AM, Kostya Serebryany wrote: >> > What's ENDBR and do we really need to have it in compiler-rt? >> >> When shadow stack from Intel CET is enabled, the

Re: [PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-18 Thread Kostya Serebryany via gcc-patches
On Wed, Jul 18, 2018 at 11:40 AM H.J. Lu wrote: > > On Wed, Jul 18, 2018 at 11:18 AM, Kostya Serebryany wrote: > > What's ENDBR and do we really need to have it in compiler-rt? > > When shadow stack from Intel CET is enabled, the first instruction of all > indirect branch targets must be a speci

Re: [PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-18 Thread H.J. Lu
On Wed, Jul 18, 2018 at 11:18 AM, Kostya Serebryany wrote: > What's ENDBR and do we really need to have it in compiler-rt? When shadow stack from Intel CET is enabled, the first instruction of all indirect branch targets must be a special instruction, ENDBR. In this case, int res = REAL(swapco

Re: [PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-18 Thread Kostya Serebryany via gcc-patches
What's ENDBR and do we really need to have it in compiler-rt? As usual, I am opposed to any gcc compiler-rt that bypass upstream. --kcc On Wed, Jul 18, 2018 at 8:37 AM H.J. Lu wrote: > > asan/asan_interceptors.cc has > > ... > int res = REAL(swapcontext)(oucp, ucp); > ... > > REAL(swapcontext

[PATCH] Call REAL(swapcontext) with indirect_return attribute on x86

2018-07-18 Thread H.J. Lu
asan/asan_interceptors.cc has ... int res = REAL(swapcontext)(oucp, ucp); ... REAL(swapcontext) is a function pointer to swapcontext in libc. Since swapcontext may return via indirect branch on x86 when shadow stack is enabled, we need to call REAL(swapcontext) with indirect_return attribute o