--- v5
+++ v3
@@ -9,13 +9,11 @@
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
---
- arch/x86/entry/entry_64.S | 2 +-
- arch/x86/include/asm/traps.h | 3 ++
- arch/x86/kernel/idt.c | 4 ++
- arch/x86/kernel/signal_compat.c | 2 +-
- arch/x86/kernel/traps.c | 64 ++++++++++++++++++++++++++++++
- include/uapi/asm-generic/siginfo.h | 3 +-
- 6 files changed, 75 insertions(+), 3 deletions(-)
+ arch/x86/entry/entry_64.S | 2 +-
+ arch/x86/include/asm/traps.h | 3 ++
+ arch/x86/kernel/idt.c | 4 +++
+ arch/x86/kernel/traps.c | 58 ++++++++++++++++++++++++++++++++++++
+ 4 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 957dfb693ecc..5f4914e988df 100644
@@ -59,7 +57,7 @@
};
diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
-index 01adea278a71..66ebc8cb16e2 100644
+index 01adea278a71..2d02fdd599a2 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -104,6 +104,10 @@ static const __initconst struct idt_data def_idts[] = {
@@ -67,30 +65,17 @@
SYSG(IA32_SYSCALL_VECTOR, entry_INT80_32),
#endif
+
-+#ifdef CONFIG_X86_64
++#ifdef CONFIG_X86_INTEL_CET
+ INTG(X86_TRAP_CP, control_protection),
+#endif
};
/*
-diff --git a/arch/x86/kernel/signal_compat.c b/arch/x86/kernel/signal_compat.c
-index 9ccbf0576cd0..c572a3de1037 100644
---- a/arch/x86/kernel/signal_compat.c
-+++ b/arch/x86/kernel/signal_compat.c
-@@ -27,7 +27,7 @@ static inline void signal_compat_build_tests(void)
- */
- BUILD_BUG_ON(NSIGILL != 11);
- BUILD_BUG_ON(NSIGFPE != 15);
-- BUILD_BUG_ON(NSIGSEGV != 7);
-+ BUILD_BUG_ON(NSIGSEGV != 8);
- BUILD_BUG_ON(NSIGBUS != 5);
- BUILD_BUG_ON(NSIGTRAP != 5);
- BUILD_BUG_ON(NSIGCHLD != 6);
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
-index e6db475164ed..4188775681cf 100644
+index e6db475164ed..21a713b96148 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
-@@ -578,6 +578,70 @@ do_general_protection(struct pt_regs *regs, long error_code)
+@@ -578,6 +578,64 @@ do_general_protection(struct pt_regs *regs, long error_code)
}
NOKPROBE_SYMBOL(do_general_protection);
@@ -114,7 +99,6 @@
+do_control_protection(struct pt_regs *regs, long error_code)
+{
+ struct task_struct *tsk;
-+ siginfo_t info;
+
+ RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
+ if (notify_die(DIE_TRAP, "control protection fault", regs,
@@ -145,36 +129,17 @@
+ tsk->comm, task_pid_nr(tsk),
+ regs->ip, regs->sp, error_code,
+ control_protection_err[error_code]);
-+ print_vma_addr(KERN_CONT " in ", regs->ip);
++ print_vma_addr(" in ", regs->ip);
+ pr_cont("\n");
+ }
+
-+ clear_siginfo(&info);
-+ info.si_signo = SIGSEGV;
-+ info.si_errno = error_code;
-+ info.si_code = SEGV_CPERR;
-+ info.si_addr = (void __user*)uprobe_get_trap_addr(regs);
-+ force_sig_info(SIGSEGV, &info, tsk);
++ force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk);
+}
+NOKPROBE_SYMBOL(do_control_protection);
+
dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
{
#ifdef CONFIG_DYNAMIC_FTRACE
-diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h
-index 80e2a7227205..264d8e03270f 100644
---- a/include/uapi/asm-generic/siginfo.h
-+++ b/include/uapi/asm-generic/siginfo.h
-@@ -228,7 +228,8 @@ typedef struct siginfo {
- #define SEGV_ACCADI 5 /* ADI not enabled for mapped object */
- #define SEGV_ADIDERR 6 /* Disrupting MCD error */
- #define SEGV_ADIPERR 7 /* Precise MCD exception */
--#define NSIGSEGV 7
-+#define SEGV_CPERR 8
-+#define NSIGSEGV 8
-
- /*
- * SIGBUS si_codes
--
2.17.1