Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03b19c7f authored by Rui Qi's avatar Rui Qi Committed by Greg Kroah-Hartman
Browse files

x86/speculation: Support intra-function call validation



commit 8afd1c7d ("x86/speculation: Change FILL_RETURN_BUFFER
 to work with objtool") does not support intra-function call
 stack validation, which causes kernel live patching to fail.
This commit adds support for this, and after testing, the kernel
 live patching feature is restored to normal.

Fixes: 8afd1c7d ("x86/speculation: Change FILL_RETURN_BUFFER to work with objtool")
Cc: <stable@vger.kernel.org> # v5.4.250+
Signed-off-by: default avatarRui Qi <qirui.001@bytedance.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f8f25fde
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
#include <asm/unwind_hints.h>
#include <asm/percpu.h>

#include <linux/frame.h>
#include <asm/unwind_hints.h>
/*
 * This should be used immediately before a retpoline alternative. It tells
 * objtool where the retpolines are so that it can make sense of the control
@@ -51,14 +53,18 @@
#define __FILL_RETURN_BUFFER(reg, nr, sp)	\
	mov	$(nr/2), reg;			\
771:						\
	ANNOTATE_INTRA_FUNCTION_CALL;           \
	call	772f;				\
773:	/* speculation trap */			\
	UNWIND_HINT_EMPTY;		\
	pause;					\
	lfence;					\
	jmp	773b;				\
772:						\
	ANNOTATE_INTRA_FUNCTION_CALL;           \
	call	774f;				\
775:	/* speculation trap */			\
	UNWIND_HINT_EMPTY;                      \
	pause;					\
	lfence;					\
	jmp	775b;				\
@@ -152,6 +158,7 @@
.endm

.macro ISSUE_UNBALANCED_RET_GUARD
	ANNOTATE_INTRA_FUNCTION_CALL;
	call .Lunbalanced_ret_guard_\@
	int3
.Lunbalanced_ret_guard_\@:
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@
	".popsection\n\t"

#define UNWIND_HINT_SAVE UNWIND_HINT(0, 0, UNWIND_HINT_TYPE_SAVE, 0)

#define UNWIND_HINT_EMPTY
#define UNWIND_HINT_RESTORE UNWIND_HINT(0, 0, UNWIND_HINT_TYPE_RESTORE, 0)

#endif /* __ASSEMBLY__ */