x86: Harden syscall dispatch
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest6 patches 7 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | x86_64/entry: Unconditionally use -fno-jump-tablearch/ arch/ arch/ +1 more | +11 | 2 replies | |
| 2/6 | objtool: Add instrumentation_weak()include/ include/ include/ +2 more | +32 | 1 reply | |
| 3/6 | x86_64/entry: Make syscall dispatch noinstrarch/ arch/ | +13 | 0 replies | |
| 4/6 | x86_64/entry: Mark all syscalls __noendbrarch/ arch/ arch/ +1 more | +27 | 4 replies | |
| 5/6 | objtool: Allow EXPORT_SYMBOL() of __noendbr functionsarch/ arch/ arch/ +7 more | +16 | 0 replies | |
| 6/6 | x86_64/entry: Mark C noinstr __noendbrarch/ arch/ arch/ +4 more | +21 | 0 replies |
Reviews trailers per patch
None of the 6 patches has a Reviewed-by or Acked-by.
| Patch | Breno Leitao |
|---|---|
| 1/6 | T-b |
| 2/6 | |
| 3/6 | |
| 4/6 | |
| 5/6 | |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/6] x86: Harden syscall dispatch
Hi!
These few patches harden the syscall dispatch by making -fno-jump-table unconditional for x86_64 and then having all SYSCALL*() macros mark the actual syscall entry points with __noendbr.
Notably, we already have -fno-jump-table for KERNEL_IBT || RETPOLINE, which means effectively everybody already has this. However, making this unconditional has the nice side effect that the compilers must never generate array accesses and it is safe to remove array_index_nospec().
Additionally, since dispatch is now forced to be a binary decision tree with direct (tail) calls, there are no valid indirect calls to any of the syscall functions and they can be marked __noendbr.
This means anything trying to use the sys_call_table[] will fail (on hardware sporting IBT).
All this makes the normal system call hijack a lot more difficult.
Patches also at:
git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/syscall
--- arch/x86/Kconfig | 4 +--- arch/x86/Makefile | 27 +++++++--------------- arch/x86/entry/calling.h | 1 - arch/x86/entry/common.c | 2 +- arch/x86/entry/entry_64.S | 2 +- arch/x86/entry/entry_64_compat.S | 6 ++--- arch/x86/entry/entry_fred.c | 6 ++--- arch/x86/entry/syscall_32.c | 20 ++++++++++------- arch/x86/entry/syscall_64.c | 24 +++++++++++++------- arch/x86/include/asm/entry-common.h | 2 +- arch/x86/include/asm/fred.h | 6 ++--- arch/x86/include/asm/syscall.h | 10 ++++----- arch/x86/include/asm/syscall_wrapper.h | 23 ++++++++++--------- arch/x86/lib/clear_page_64.S | 1 - arch/x86/lib/copy_user_64.S | 1 - arch/x86/lib/copy_user_uncached_64.S | 1 - arch/x86/lib/getuser.S | 4 ---- arch/x86/lib/hweight.S | 3 --- arch/x86/lib/putuser.S | 4 ---- include/linux/annotate.h | 1 + include/linux/instrumentation.h | 17 ++++++++++++++ include/linux/objtool_types.h | 1 + tools/include/linux/objtool_types.h | 1 + tools/objtool/check.c | 41 ++++++++++++++++++++++++++-------- 24 files changed, 118 insertions(+), 90 deletions(-)