Re: [tip: x86/bugs] x86/retpoline: Ensure default return thunk isn't used at runtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 19, 2023 at 02:21:40PM +0000, Kaplan, David wrote:
> The return thunk is used for all functions though, including assembly
> coded functions which may use non-standard calling conventions and
> aren't visible to gcc.  I think the only safe thing would be to
> preserve all GPRs across the call to check_thunks.  Something like
> PUSH_REGS/call check_thunks/POP_REGS.

That call nop will be inside the return thunk. I.e., something like
this:

SYM_CODE_START(__x86_return_thunk)
        UNWIND_HINT_FUNC
        ANNOTATE_NOENDBR
        ANNOTATE_UNRET_SAFE
	ALTERNATIVE CALL nop, check_thunks, X86_FEATURE_ALWAYS
	ret
	int3
SYM_CODE_END(__x86_return_thunk)
EXPORT_SYMBOL(__x86_return_thunk)

I suspect that gcc doesn't know that there is a function call in the asm
there, which is also what you hint at - I need to ask a compiler guy.

But yeah, if it doesn't, then we'll need to push/pop regs as you
suggest.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux