[PATCH v1 0/8] x86_64 SandBox Mode arch hooks

From: Petr Tesarik
Date: Wed Feb 14 2024 - 06:36:03 EST


From: Petr Tesarik <petr.tesarik1@xxxxxxxxxxxxxxxxxxx>

This patch series implements x86_64 arch hooks for the generic SandBox
Mode infrastructure.

SandBox Mode on x86_64 is implemented as follows:

* The target function runs with CPL 3 (same as user mode) within its
own virtual address space.
* Interrupt entry/exit paths are modified to let the interrupt handlers
always run with kernel CR3 and restore sandbox CR3 when returning to
sandbox mode.
* To avoid undesirable user mode processing (FPU state, signals, etc.),
the value of pt_regs->cs is temporarily adjusted to make it look like
coming from kernel mode.
* On a CPU fault, execution stops immediately, returning -EFAULT to
the caller.

Petr Tesarik (8):
sbm: x86: page table arch hooks
sbm: x86: execute target function on sandbox mode stack
sbm: x86: map system data structures into the sandbox
sbm: x86: allocate and map an exception stack
sbm: x86: handle sandbox mode faults
sbm: x86: switch to sandbox mode pages in arch_sbm_exec()
sbm: documentation of the x86-64 SandBox Mode implementation
sbm: x86: lazy TLB flushing

Documentation/security/sandbox-mode.rst | 25 ++
arch/x86/Kconfig | 1 +
arch/x86/entry/entry_64.S | 123 ++++++
arch/x86/include/asm/page_64_types.h | 1 +
arch/x86/include/asm/ptrace.h | 21 +
arch/x86/include/asm/sbm.h | 83 ++++
arch/x86/include/asm/segment.h | 7 +
arch/x86/include/asm/thread_info.h | 3 +
arch/x86/kernel/Makefile | 2 +
arch/x86/kernel/asm-offsets.c | 10 +
arch/x86/kernel/sbm/Makefile | 16 +
arch/x86/kernel/sbm/call_64.S | 95 +++++
arch/x86/kernel/sbm/core.c | 499 ++++++++++++++++++++++++
arch/x86/kernel/traps.c | 14 +-
arch/x86/mm/fault.c | 6 +
15 files changed, 905 insertions(+), 1 deletion(-)
create mode 100644 arch/x86/include/asm/sbm.h
create mode 100644 arch/x86/kernel/sbm/Makefile
create mode 100644 arch/x86/kernel/sbm/call_64.S
create mode 100644 arch/x86/kernel/sbm/core.c

--
2.34.1