Skip to content

Commit 2114796

Browse files
dwmw2bp3tk0v
authored andcommitted
x86/kexec: Mark machine_kexec() with __nocfi
A recent commit caused the relocate_kernel() function to be invoked through a function pointer, but it does not have CFI information. The resulting trap occurs after the IDT and GDT have been invalidated, leading to a triple-fault if CONFIG_CFI_CLANG is enabled. Using SYM_TYPED_FUNC_START() to provide the CFI information looks like it will require a prolonged battle with objtool. And is fairly pointless anyway, as the actual signature comes from a __kcfi_typeid_… symbol emitted from the C code based on the function prototype it thinks that relocate_kernel has, rendering the check somewhat tautological. The simple fix is just to mark machine_kexec() with __nocfi. Fixes: eeebbde ("x86/kexec: Invoke copy of relocate_kernel() instead of the original") Reported-by: Nathan Chancellor <[email protected]> Suggested-by: Nathan Chancellor <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eeed915 commit 2114796

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/machine_kexec_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void machine_kexec_cleanup(struct kimage *image)
342342
* Do not allocate memory (or fail in any way) in machine_kexec().
343343
* We are past the point of no return, committed to rebooting now.
344344
*/
345-
void machine_kexec(struct kimage *image)
345+
void __nocfi machine_kexec(struct kimage *image)
346346
{
347347
unsigned long (*relocate_kernel_ptr)(unsigned long indirection_page,
348348
unsigned long pa_control_page,

0 commit comments

Comments
 (0)