Skip to content

Commit 786a457

Browse files
dwmw2bp3tk0v
authored andcommitted
x86/kexec: Push kjump return address even for non-kjump kexec
The version of purgatory code shipped by kexec-tools attempts to look above the top of its stack to find a return address for a kjump, even in a non-kjump kexec. After the commit in Fixes: the word above the stack might not be there, leading to a fault (which is at least now caught by my exception-handling code in kexec). That commit fixed things for the actual kjump path, but no longer "gratuitously" pushes the unused return address to the stack in the non-kjump path. Put that *back* in the non-kjump path, to prevent purgatory from crashing when trying to access it. Fixes: 2cacf7f ("x86/kexec: Fix stack and handling of re-entry point for ::preserve_context") Reported-by: Rohan Kakulawaram <rohanka@google.com> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Tested-by: Rohan Kakulawaram <rohanka@google.com> Cc: <stable@kernel.org> Link: https://patch.msgid.link/32d627134143ffd957891cb697138e839c623211.camel@infradead.org
1 parent 5772f65 commit 786a457

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

arch/x86/kernel/relocate_kernel_64.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
136136
* %r13 original CR4 when relocate_kernel() was invoked
137137
*/
138138

139+
/*
140+
* Set return address to 0 if not preserving context. The purgatory
141+
* shipped in kexec-tools will unconditionally look for the return
142+
* address on the stack and set a kexec_jump_back_entry= command
143+
* line option if it's non-zero. There's no other way that it can
144+
* tell a preserve-context (kjump) kexec from a normal one.
145+
*/
146+
pushq $0
139147
/* store the start address on the stack */
140148
pushq %rdx
141149

0 commit comments

Comments
 (0)