Implement SECCOMP based userland
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest27 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/27 | um: Switch printk calls to adhere to correct coding stylearch/ arch/ arch/ | +69 | 0 replies | |
| 2/27 | um: Declare fix_range_common as a static functionarch/ | +2 | 0 replies | |
| 3/27 | um: Drop support for hosts without SYSEMU_SINGLESTEP supportarch/ arch/ arch/ +8 more | +15 | 2 replies | |
| 4/27 | um: Drop NULL check from start_userspacearch/ | +24 | 0 replies | |
| 5/27 | um: Make errors to stop ptraced child fatal during startuparch/ | +12 | 0 replies | |
| 6/27 | um: Don't use vfprintf() for os_info()arch/ | +17 | 0 replies | |
| 7/27 | um: Do not use printk in SIGWINCH helper threadarch/ | +13 | 0 replies | |
| 8/27 | um: Reap winch thread if it failsarch/ arch/ | +18 | 0 replies | |
| 9/27 | um: Do not use printk in userspace trampolinearch/ | +6 | 0 replies | |
| 10/27 | um: Always inline stub functionsarch/ arch/ | +19 | 0 replies | |
| 11/27 | um: Rely on PTRACE_SETREGSET to set FS/GS base registersarch/ arch/ arch/ +4 more | +13 | 0 replies | |
| 12/27 | um: Remove unused register save/restore functionsarch/ arch/ | +0 | 0 replies | |
| 13/27 | um: Mark 32bit syscall helpers as clobbering memoryarch/ | +12 | 0 replies | |
| 14/27 | um: Create signal stack memory assignment in stub_dataarch/ arch/ arch/ | +24 | 0 replies | |
| 15/27 | um: Add generic stub_syscall6 functionarch/ arch/ | +38 | 0 replies | |
| 16/27 | um: Rework syscall handlingarch/ arch/ arch/ +13 more | +262 | 0 replies | |
| 17/27 | um: Store full CSGSFS and SS register from mcontextarch/ | +1 | 0 replies | |
| 18/27 | um: Pass full mm_id to functions creating helper processesarch/ arch/ arch/ | +32 | 0 replies | |
| 19/27 | um: Move faultinfo extraction into userspace routinearch/ | +7 | 0 replies | |
| 20/27 | um: Use struct uml_pt_regs for copy_context_skas0arch/ | +7 | 0 replies | |
| 21/27 | um: Add UML_SECCOMP configuration optionarch/ | +19 | 0 replies | |
| 22/27 | um: Add stub side of SECCOMP/futex based process handlingarch/ arch/ arch/ +4 more | +122 | 0 replies | |
| 23/27 | um: Add helper functions to get/set state for SECCOMParch/ arch/ | +109 | 0 replies | |
| 24/27 | um: Add SECCOMP support detection and initializationarch/ arch/ arch/ +1 more | +141 | 0 replies | |
| 25/27 | um: Die if a child dies unexpectedly in seccomp modearch/ arch/ arch/ | +48 | 0 replies | |
| 26/27 | um: Implement kernel side of SECCOMP based process handlingarch/ arch/ arch/ | +414 | 0 replies | |
| 27/27 | um: Delay flushing syscalls until the thread is restartedarch/ arch/ arch/ +1 more | +38 | 0 replies |
Reviews trailers per patch
None of the 27 patches has a Reviewed-by or Acked-by.
| Patch | Johannes Berg |
|---|---|
| 1/27 | |
| 2/27 | |
| 3/27 | |
| 4/27 | |
| 5/27 | |
| 6/27 | |
| 7/27 | |
| 8/27 | |
| 9/27 | |
| 10/27 | |
| 11/27 | |
| 12/27 | |
| 13/27 | |
| 14/27 | |
| 15/27 | |
| 16/27 | |
| 17/27 | |
| 18/27 | |
| 19/27 | |
| 20/27 | |
| 21/27 | |
| 22/27 | Co-authored-by |
| 23/27 | |
| 24/27 | |
| 25/27 | |
| 26/27 | Co-authored-by |
| 27/27 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 00/27] Implement SECCOMP based userland
Currently UML uses ptrace in order to implement userspace processes. This works really well, however, it requires six context switches per pagefault (get faultinfo, run syscalls, continue process).
By switching to use SECCOMP, the whole process becomes more collaborative as the userspace process can run code, including host syscalls, before jumping into the kernel and after the kernel returns control. This means pagefaults only require two context switches to be processed.
In pagefault heavy scenarios (e.g. fork/exec) the performance increase of doing this can be considerable, with runtimes dropping by 30% or more.
Note that this implementation is not safe as userspace code could jump directly to the syscall instruction in order to execute an arbitrary host syscall. This should be fixable by remapping the page RW for a short time in order to NOP out the syscall instruction.
Because of this, the seccomp mode is disabled by default.
Benjamin Berg (27):
um: Switch printk calls to adhere to correct coding style
um: Declare fix_range_common as a static function
um: Drop support for hosts without SYSEMU_SINGLESTEP support
um: Drop NULL check from start_userspace
um: Make errors to stop ptraced child fatal during startup
um: Don't use vfprintf() for os_info()
um: Do not use printk in SIGWINCH helper thread
um: Reap winch thread if it fails
um: Do not use printk in userspace trampoline
um: Always inline stub functions
um: Rely on PTRACE_SETREGSET to set FS/GS base registers
um: Remove unused register save/restore functions
um: Mark 32bit syscall helpers as clobbering memory
um: Create signal stack memory assignment in stub_data
um: Add generic stub_syscall6 function
um: Rework syscall handling
um: Store full CSGSFS and SS register from mcontext
um: Pass full mm_id to functions creating helper processes
um: Move faultinfo extraction into userspace routine
um: Use struct uml_pt_regs for copy_context_skas0
um: Add UML_SECCOMP configuration option
um: Add stub side of SECCOMP/futex based process handling
um: Add helper functions to get/set state for SECCOMP
um: Add SECCOMP support detection and initialization
um: Die if a child dies unexpectedly in seccomp mode
um: Implement kernel side of SECCOMP based process handling
um: Delay flushing syscalls until the thread is restarted
arch/um/Kconfig | 19 + arch/um/drivers/chan_user.c | 41 +- arch/um/drivers/line.c | 13 +- arch/um/include/asm/processor-generic.h | 1 - arch/um/include/shared/kern_util.h | 1 - arch/um/include/shared/os.h | 32 +- arch/um/include/shared/ptrace_user.h | 41 -- arch/um/include/shared/registers.h | 2 - arch/um/include/shared/skas/mm_id.h | 1 + arch/um/include/shared/skas/skas.h | 7 + arch/um/include/shared/skas/stub-data.h | 41 +- arch/um/include/shared/user.h | 8 + arch/um/kernel/exec.c | 10 +- arch/um/kernel/process.c | 75 +-- arch/um/kernel/ptrace.c | 2 - arch/um/kernel/signal.c | 12 - arch/um/kernel/skas/Makefile | 4 +- arch/um/kernel/skas/clone.c | 32 +- arch/um/kernel/skas/mmu.c | 6 +- arch/um/kernel/skas/process.c | 8 + arch/um/kernel/skas/stub.c | 105 ++++ arch/um/kernel/tlb.c | 54 +- arch/um/os-Linux/process.c | 40 ++ arch/um/os-Linux/registers.c | 24 +- arch/um/os-Linux/signal.c | 7 + arch/um/os-Linux/skas/mem.c | 278 ++++----- arch/um/os-Linux/skas/process.c | 722 ++++++++++++++++-------- arch/um/os-Linux/start_up.c | 240 ++++---- arch/um/os-Linux/util.c | 19 +- arch/x86/um/Makefile | 2 +- arch/x86/um/asm/elf.h | 4 +- arch/x86/um/asm/processor_64.h | 3 - arch/x86/um/ldt.c | 45 +- arch/x86/um/os-Linux/Makefile | 1 - arch/x86/um/os-Linux/mcontext.c | 103 +++- arch/x86/um/os-Linux/prctl.c | 12 - arch/x86/um/ptrace_32.c | 24 - arch/x86/um/ptrace_64.c | 26 - arch/x86/um/shared/sysdep/mcontext.h | 9 + arch/x86/um/shared/sysdep/ptrace_32.h | 4 - arch/x86/um/shared/sysdep/stub-data.h | 11 + arch/x86/um/shared/sysdep/stub.h | 4 + arch/x86/um/shared/sysdep/stub_32.h | 66 ++- arch/x86/um/shared/sysdep/stub_64.h | 41 +- arch/x86/um/stub_32.S | 56 -- arch/x86/um/stub_64.S | 50 -- arch/x86/um/syscalls_64.c | 59 +- arch/x86/um/tls_64.c | 2 +- 48 files changed, 1375 insertions(+), 992 deletions(-) create mode 100644 arch/um/kernel/skas/stub.c delete mode 100644 arch/x86/um/os-Linux/prctl.c create mode 100644 arch/x86/um/shared/sysdep/stub-data.h delete mode 100644 arch/x86/um/stub_32.S delete mode 100644 arch/x86/um/stub_64.S
Signature · 7 lines
2.29.2 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um