diff options
Diffstat (limited to 'debian/patches/bugfix/x86/retbleed/0015-x86-entry-Avoid-very-early-RET.patch')
-rw-r--r-- | debian/patches/bugfix/x86/retbleed/0015-x86-entry-Avoid-very-early-RET.patch | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/debian/patches/bugfix/x86/retbleed/0015-x86-entry-Avoid-very-early-RET.patch b/debian/patches/bugfix/x86/retbleed/0015-x86-entry-Avoid-very-early-RET.patch new file mode 100644 index 000000000..71935dd77 --- /dev/null +++ b/debian/patches/bugfix/x86/retbleed/0015-x86-entry-Avoid-very-early-RET.patch @@ -0,0 +1,59 @@ +From: Peter Zijlstra <peterz@infradead.org> +Date: Tue, 14 Jun 2022 23:15:46 +0200 +Subject: x86/entry: Avoid very early RET +Origin: https://git.kernel.org/linus/7c81c0c9210c9bfab2bae76aab2999de5bad27db + +Commit + + ee774dac0da1 ("x86/entry: Move PUSH_AND_CLEAR_REGS out of error_entry()") + +manages to introduce a CALL/RET pair that is before SWITCH_TO_KERNEL_CR3, +which means it is before RETBleed can be mitigated. + +Revert to an earlier version of the commit in Fixes. Down side is that +this will bloat .text size somewhat. The alternative is fully reverting +it. + +The purpose of this patch was to allow migrating error_entry() to C, +including the whole of kPTI. Much care needs to be taken moving that +forward to not re-introduce this problem of early RETs. + +Fixes: ee774dac0da1 ("x86/entry: Move PUSH_AND_CLEAR_REGS out of error_entry()") +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> +Signed-off-by: Borislav Petkov <bp@suse.de> +Reviewed-by: Josh Poimboeuf <jpoimboe@kernel.org> +Signed-off-by: Borislav Petkov <bp@suse.de> +--- + arch/x86/entry/entry_64.S | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S +index 4300ba49b5ee..9f5d6a4f293e 100644 +--- a/arch/x86/entry/entry_64.S ++++ b/arch/x86/entry/entry_64.S +@@ -322,14 +322,6 @@ SYM_CODE_END(ret_from_fork) + #endif + .endm + +-/* Save all registers in pt_regs */ +-SYM_CODE_START_LOCAL(push_and_clear_regs) +- UNWIND_HINT_FUNC +- PUSH_AND_CLEAR_REGS save_ret=1 +- ENCODE_FRAME_POINTER 8 +- RET +-SYM_CODE_END(push_and_clear_regs) +- + /** + * idtentry_body - Macro to emit code calling the C function + * @cfunc: C function to be called +@@ -337,8 +329,8 @@ SYM_CODE_END(push_and_clear_regs) + */ + .macro idtentry_body cfunc has_error_code:req + +- call push_and_clear_regs +- UNWIND_HINT_REGS ++ PUSH_AND_CLEAR_REGS ++ ENCODE_FRAME_POINTER + + /* + * Call error_entry() and switch to the task stack if from userspace. |