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:15:14 +0200
- Cc: Ingo Molnar <mingo@xxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, linux-tip-commits@xxxxxxxxxxxxxxx, David Kaplan <david.kaplan@xxxxxxx>, "Peter Zijlstra (Intel)" <peterz@xxxxxxxxxxxxx>, x86@xxxxxxxxxx, David Howells <dhowells@xxxxxxxxxx>
- In-reply-to: <20231019065928.mrvhtfaya22p2uzw@treble>
- References: <20231012141031.GHZSf+V1NjjUJTc9a9@fat_crate.local> <169713303534.3135.10558074245117750218.tip-bot2@tip-bot2> <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>
On Wed, Oct 18, 2023 at 11:59:28PM -0700, Josh Poimboeuf wrote:
> One last idea, since the return thunk is used everywhere (even non-ABI
> compliant functions) it might be possible the "call check_thunks" (and
> its call to warn_printk) is clobbering some registers which some code
> (exception handling entry code?) doesn't appreciate.
Yeah, that is still unclean, I'd say. gcc doesn't know that we patch in
a CALL insn in the alternative. What should work is to have
alternative_call
there which alternates between two calls and gcc knows there's a call so
it can act accordingly wrt callee-* regs.
Considering how __x86_return_thunk is there only until alternatives have
run, we could do something like
ALTERNATIVE_CALL nop, check_thunks
where nop is a function which doesn't do anything.
I say "ALTERNATIVE_CALL" because we don't have a _CALL asm macro yet.
And then in check_thunks() we can do all kinds of screaming, tainting
and setting mitigation status to vulnerable, etc.
Anyway something along those lines.
Thx.
--
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]