[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240226094925.95835-4-qirui.001@bytedance.com>
Date: Mon, 26 Feb 2024 17:49:25 +0800
From: Rui Qi <qirui.001@...edance.com>
To: bp@...en8.de,
mingo@...hat.com,
tglx@...utronix.de,
hpa@...or.com,
jpoimboe@...hat.com,
peterz@...radead.org,
mbenes@...e.cz,
gregkh@...uxfoundation.org,
stable@...r.kernel.org,
alexandre.chartre@...cle.com
Cc: x86@...nel.org,
linux-kernel@...r.kernel.org,
Rui Qi <qirui.001@...edance.com>
Subject: [PATCH 3/3] x86/speculation: Support intra-function call validation
commit 8afd1c7da2b0 ("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: 8afd1c7da2b0 ("x86/speculation: Change FILL_RETURN_BUFFER to work with objtool")
Signed-off-by: Rui Qi <qirui.001@...edance.com>
---
arch/x86/include/asm/nospec-branch.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index c8819358a332..a88135c358c0 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -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_\@:
--
2.39.2 (Apple Git-143)
Powered by blists - more mailing lists