History

x86/shstk: Add user control-protection fault handler

A control-protection fault is triggered when a control-flow transfer attempt violates Shadow Stack or Indirect Branch Tracking constraints. For example, the return address for a RET instruction differs from the copy on the shadow stack. There already exists a control-protection fault handler for handling kernel IBT faults. Refactor this fault handler into separate user and kernel handlers, like the page fault handler. Add a control-protection handler for usermode. To avoid ifdeffery, put them both in a new file cet.c, which is compiled in the case of either of the two CET features supported in the kernel: kernel IBT or user mode shadow stack. Move some static inline functions from traps.c into a header so they can be used in cet.c. Opportunistically fix a comment in the kernel IBT part of the fault handler that is on the end of the line instead of preceding it. Keep the same behavior for the kernel side of the fault handler, except for converting a BUG to a WARN in the case of a #CP happening when the feature is missing. This unifies the behavior with the new shadow stack code, and also prevents the kernel from crashing under this situation which is potentially recoverable. The control-protection fault handler works in a similar way as the general protection fault handler. It provides the si_code SEGV_CPERR to the signal handler.

Rick Edgecombe committed 3 years ago

Commit a5f6c2a1 parent 98cfa4616 files · +117 −34Browse files

Showing the changes to include/uapi (1 of 16 files). Show all

Unified · Split

include/uapi/asm-generic/siginfo.h+2−1
@@ -242,7 +242,8 @@ typedef struct siginfo { · 241 unmodified lines
242242 #define SEGV_ADIPERR 7 /* Precise MCD exception */
243243 #define SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */
244244 #define SEGV_MTESERR 9 /* Synchronous ARM MTE exception */
245−#define NSIGSEGV 9
245+#define SEGV_CPERR 10 /* Control protection fault */
246+#define NSIGSEGV 10
246247
247248 /*
248249 * SIGBUS si_codes

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t