--- v15
+++ v23
@@ -1,23 +1,22 @@
-An indirect CALL/JMP moves the indirect branch tracking (IBT) state machine
-to WAIT_ENDBR status until the instruction reaches an ENDBR opcode. If the
-CALL/JMP does not reach an ENDBR opcode, the processor raises a control-
-protection fault. WAIT_ENDBR status can be read from MSR_IA32_U_CET.
-
-WAIT_ENDBR is cleared for signal handling, and restored for sigreturn.
+When an indirect CALL/JMP instruction is executed and before it reaches
+the target, it is in 'WAIT_ENDBR' status, which can be read from
+MSR_IA32_U_CET. The status is part of a task's status before a signal is
+raised and preserved in the signal frame. It is restored for sigreturn.
IBT state machine is described in Intel SDM Vol. 1, Sec. 18.3.
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
+Reviewed-by: Kees Cook <keescook@chromium.org>
---
- arch/x86/kernel/cet.c | 27 +++++++++++++++++++++++++--
+ arch/x86/kernel/cet.c | 26 ++++++++++++++++++++++++--
arch/x86/kernel/fpu/signal.c | 8 +++++---
- 2 files changed, 30 insertions(+), 5 deletions(-)
+ 2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cet.c b/arch/x86/kernel/cet.c
-index 1dcd16aa4f90..0edcbd70f408 100644
+index 3361706ba950..34a26eb7f259 100644
--- a/arch/x86/kernel/cet.c
+++ b/arch/x86/kernel/cet.c
-@@ -295,6 +295,13 @@ void cet_restore_signal(struct sc_ext *sc_ext)
+@@ -300,6 +300,13 @@ void cet_restore_signal(struct sc_ext *sc_ext)
msr_val |= CET_SHSTK_EN;
}
@@ -31,13 +30,12 @@
if (test_thread_flag(TIF_NEED_FPU_LOAD))
cet_user_state->user_cet = msr_val;
else
-@@ -335,9 +342,25 @@ int cet_setup_signal(bool ia32, unsigned long rstor_addr, struct sc_ext *sc_ext)
+@@ -340,9 +347,24 @@ int cet_setup_signal(bool ia32, unsigned long rstor_addr, struct sc_ext *sc_ext)
sc_ext->ssp = new_ssp;
}
- if (ssp) {
+ if (ssp || cet->ibt_enabled) {
-+
start_update_msrs();
- wrmsrl(MSR_IA32_PL3_SSP, ssp);
+
@@ -60,7 +58,7 @@
}
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
-index c0c2141cb4b3..077853ef6f48 100644
+index 270e4649f435..b914d74c8ba6 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -57,7 +57,8 @@ int save_cet_to_sigframe(int ia32, void __user *fp, unsigned long restorer)