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]
- Subject: Re: [tip: x86/bugs] x86/retpoline: Ensure default return thunk isn't used at runtime
- From: Borislav Petkov <bp@xxxxxxxxx>
- Date: Thu, 19 Oct 2023 16:39:51 +0200
- Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "linux-tip-commits@xxxxxxxxxxxxxxx" <linux-tip-commits@xxxxxxxxxxxxxxx>, "Peter Zijlstra (Intel)" <peterz@xxxxxxxxxxxxx>, "x86@xxxxxxxxxx" <x86@xxxxxxxxxx>, David Howells <dhowells@xxxxxxxxxx>
- In-reply-to: <SN6PR12MB2702AC3C27D25414FE4260F994D4A@SN6PR12MB2702.namprd12.prod.outlook.com>
- References: <20231018132352.GBZS/caGJ8Wk9kmTbg@fat_crate.local> <ZS/f8DeEIWhBtBeb@gmail.com> <20231018151245.GCZS/17QhDGe7q6K+w@fat_crate.local> <20231018155433.z4auwckr5s27wnig@treble> <20231018175531.GEZTAcE2p92U1AuVp1@fat_crate.local> <20231018203747.GJZTBCG7mv5HL4w6CC@fat_crate.local> <20231019063527.iwgyioxi2gznnshp@treble> <20231019065928.mrvhtfaya22p2uzw@treble> <20231019141514.GCZTE58qPOvcJCiBp3@fat_crate.local> <SN6PR12MB2702AC3C27D25414FE4260F994D4A@SN6PR12MB2702.namprd12.prod.outlook.com>
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]