mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] x86: Harden syscall dispatch
@ 2026-11-02 11:25 Peter Zijlstra
  2026-11-02 11:25 ` [PATCH 1/6] x86_64/entry: Unconditionally use -fno-jump-table Peter Zijlstra
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Peter Zijlstra @ 2026-11-02 11:25 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, peterz, jpoimboe, leitao, keescook, hpa

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(-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-02 17:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 11:25 [PATCH 0/6] x86: Harden syscall dispatch Peter Zijlstra
2026-11-02 11:25 ` [PATCH 1/6] x86_64/entry: Unconditionally use -fno-jump-table Peter Zijlstra
2026-11-02 14:28   ` Breno Leitao
2026-11-02 11:25 ` [PATCH 2/6] objtool: Add instrumentation_weak() Peter Zijlstra
2026-11-02 11:25 ` [PATCH 3/6] x86_64/entry: Make syscall dispatch noinstr Peter Zijlstra
2026-11-02 11:25 ` [PATCH 4/6] x86_64/entry: Mark all syscalls __noendbr Peter Zijlstra
2026-11-02 17:06   ` David Laight
2026-11-02 11:25 ` [PATCH 5/6] objtool: Allow EXPORT_SYMBOL() of __noendbr functions Peter Zijlstra
2026-11-02 11:25 ` [PATCH 6/6] x86_64/entry: Mark C noinstr __noendbr Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®