This is the mail archive of the 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]

Re: V2: [PATCH 02/24] x86: Support shadow stack pointer in setjmp/longjmp

On Sun, Jul 15, 2018 at 12:22 PM, Florian Weimer <> wrote:
> * H. J. Lu:
>>> #undef.  I think you can avoid that by using #if SHTSTK_ENABLED
>>> instead of #ifdef SHADOW_STACK_POINTER_OFFSET, which also expresses
>>> the intent more accurately.
>> It is done on purpose.  sysdeps/x86_64/__longjmp.S has
>> /* 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
>> #endif
> It's a bit awkward.

Linux and Hurd share the same implementation of setjmp/longjmp. But

1. For Linux, SHADOW_STACK_POINTER_OFFSET is always defined regardless if
CET is enabled.
2.For Hurd, SHADOW_STACK_POINTER_OFFSET is undefined since it is unknown
how to save shadow stack pointer.
3. When CET is enabled, setjmp/longjmp is assembled twice.  One preserves
shadow stack pointer and the other doesn't.  Both versions support IBT.
4. All assembly files are compiled with the same compiler options.

SHADOW_STACK_POINTER_OFFSET is used to control if shadow stack pointer
should be preserved:

1. If CET isn't enabled, undef SHADOW_STACK_POINTER_OFFSET.
2. If CET is enabled, undef SHADOW_STACK_POINTER_OFFSET when not to
preserve shadow stack pointer.

>> Subject: [PATCH] x86_64: Undef SHADOW_STACK_POINTER_OFFSET last
>> Since SHADOW_STACK_POINTER_OFFSET is defined in jmp_buf-ssp.h, we must
>> undef SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.
>> * sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Undef
>> SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.
> This looks okay as a fix.

I will check it in.



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