Messages in this thread | | | Date | Fri, 11 Aug 2023 09:01:23 +0200 | From | Peter Zijlstra <> | Subject | Re: [RFC][PATCH 02/17] x86/cpu: Clean up SRSO return thunk mess |
| |
On Thu, Aug 10, 2023 at 02:37:56PM +0200, Peter Zijlstra wrote:
> After this patch things look equivalent to: > > SYM_FUNC_START(foo) > ... > ALTERNATIVE "ret; int3" > "jmp __x86_return_thunk", X86_FEATURE_RETHUNK > "jmp srso_return_thunk, X86_FEATURE_SRSO > "jmp srsi_alias_return_thunk", X86_FEATURE_SRSO_ALIAS > SYM_FUNC_END(foo) > > SYM_CODE_START(srso_return_thunk) > UNWIND_HINT_FUNC > ANNOTATE_NOENDBR > call srso_safe_ret; > ud2 > SYM_CODE_END(srso_return_thunk) > > SYM_CODE_START(srso_alias_return_thunk) > UNWIND_HINT_FUNC > ANNOTATE_NOENDBR > call srso_alias_safe_ret; > ud2 > SYM_CODE_END(srso_alias_return_thunk) >
So it looks like the compilers are still not emitting int3 after jmp, even with the SLS options enabled :/
This means the tail end of functions compiled with:
-mharden-sls=all -mfunction-return=thunk-extern
Is still a regular: jmp __x86_return_thunk, no trailing trap.
https://godbolt.org/z/Ecqv76YbE
If we all could please finally fix that, then I can rewrite the above to effectively be:
SYM_FUNC_START(foo) ... ALTERNATIVE "ret; int3" "jmp __x86_return_thunk", X86_FEATURE_RETHUNK "call srso_safe_ret, X86_FEATURE_SRSO "call srso_alias_safe_ret", X86_FEATURE_SRSO_ALIAS int3 // <--- *MISSING* SYM_FUNC_END(foo)
Bonus points if I can compile time tell if a compiler DTRT, feature flag or what have you in the preprocessor would be awesome.
| |