All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/28] Implement SECCOMP based userland
@ 2022-11-22 10:07 benjamin
  2022-11-22 10:07 ` [PATCH v2 01/28] um: Switch printk calls to adhere to correct coding style benjamin
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: benjamin @ 2022-11-22 10:07 UTC (permalink / raw)
  To: linux-um; +Cc: Benjamin Berg

From: Benjamin Berg <benjamin@sipsolutions.net>

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 the current syscall filter can easily be abused by a userspace
process to execute arbitrary host syscalls. I think it is possible to
efficiently detect such attempts and kill the offending processes by
(ab)using the rt_sigaction syscall in order to set/get a flag that
userspace code cannot tamper with.

v2:
 * Fixed FP register store/restore
 * Plenty of other fixes and improvements

Benjamin Berg (28):
  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: Remove stub-data.h include from common-offsets.h
  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             |  42 +-
 arch/um/drivers/line.c                  |  13 +-
 arch/um/include/asm/processor-generic.h |   1 -
 arch/um/include/shared/as-layout.h      |   2 +-
 arch/um/include/shared/common-offsets.h |  14 +-
 arch/um/include/shared/kern_util.h      |   3 +-
 arch/um/include/shared/os.h             |  33 +-
 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                |  12 +-
 arch/um/kernel/ptrace.c                 |   2 -
 arch/um/kernel/signal.c                 |  12 -
 arch/um/kernel/skas/Makefile            |   4 +-
 arch/um/kernel/skas/clone.c             |  33 +-
 arch/um/kernel/skas/mmu.c               |  16 +-
 arch/um/kernel/skas/process.c           |   8 +
 arch/um/kernel/skas/stub.c              | 101 ++++
 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             | 288 +++++----
 arch/um/os-Linux/skas/process.c         | 749 ++++++++++++++++--------
 arch/um/os-Linux/start_up.c             | 244 +++++---
 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                       |  47 +-
 arch/x86/um/os-Linux/Makefile           |   1 -
 arch/x86/um/os-Linux/mcontext.c         | 153 ++++-
 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/ptrace_user.h |  12 +-
 arch/x86/um/shared/sysdep/stub-data.h   |  12 +
 arch/x86/um/shared/sysdep/stub.h        |   4 +
 arch/x86/um/shared/sysdep/stub_32.h     |  78 ++-
 arch/x86/um/shared/sysdep/stub_64.h     |  57 +-
 arch/x86/um/stub_32.S                   |  56 --
 arch/x86/um/stub_64.S                   |  50 --
 arch/x86/um/syscalls_64.c               |  62 +-
 arch/x86/um/tls_64.c                    |   2 +-
 51 files changed, 1500 insertions(+), 968 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

-- 
2.38.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

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

end of thread, other threads:[~2022-11-22 10:27 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 10:07 [PATCH v2 00/28] Implement SECCOMP based userland benjamin
2022-11-22 10:07 ` [PATCH v2 01/28] um: Switch printk calls to adhere to correct coding style benjamin
2022-11-22 10:07 ` [PATCH v2 02/28] um: Declare fix_range_common as a static function benjamin
2022-11-22 10:07 ` [PATCH v2 03/28] um: Drop support for hosts without SYSEMU_SINGLESTEP support benjamin
2022-11-22 10:07 ` [PATCH v2 04/28] um: Drop NULL check from start_userspace benjamin
2022-11-22 10:07 ` [PATCH v2 05/28] um: Make errors to stop ptraced child fatal during startup benjamin
2022-11-22 10:07 ` [PATCH v2 06/28] um: Don't use vfprintf() for os_info() benjamin
2022-11-22 10:07 ` [PATCH v2 07/28] um: Do not use printk in SIGWINCH helper thread benjamin
2022-11-22 10:07 ` [PATCH v2 08/28] um: Reap winch thread if it fails benjamin
2022-11-22 10:07 ` [PATCH v2 09/28] um: Do not use printk in userspace trampoline benjamin
2022-11-22 10:07 ` [PATCH v2 10/28] um: Always inline stub functions benjamin
2022-11-22 10:07 ` [PATCH v2 11/28] um: Rely on PTRACE_SETREGSET to set FS/GS base registers benjamin
2022-11-22 10:07 ` [PATCH v2 12/28] um: Remove unused register save/restore functions benjamin
2022-11-22 10:07 ` [PATCH v2 13/28] um: Mark 32bit syscall helpers as clobbering memory benjamin
2022-11-22 10:07 ` [PATCH v2 14/28] um: Remove stub-data.h include from common-offsets.h benjamin
2022-11-22 10:07 ` [PATCH v2 15/28] um: Create signal stack memory assignment in stub_data benjamin
2022-11-22 10:07 ` [PATCH v2 16/28] um: Add generic stub_syscall6 function benjamin
2022-11-22 10:07 ` [PATCH v2 17/28] um: Rework syscall handling benjamin
2022-11-22 10:07 ` [PATCH v2 18/28] um: Store full CSGSFS and SS register from mcontext benjamin
2022-11-22 10:07 ` [PATCH v2 19/28] um: Pass full mm_id to functions creating helper processes benjamin
2022-11-22 10:07 ` [PATCH v2 20/28] um: Move faultinfo extraction into userspace routine benjamin
2022-11-22 10:07 ` [PATCH v2 21/28] um: Use struct uml_pt_regs for copy_context_skas0 benjamin
2022-11-22 10:07 ` [PATCH v2 22/28] um: Add UML_SECCOMP configuration option benjamin
2022-11-22 10:07 ` [PATCH v2 23/28] um: Add stub side of SECCOMP/futex based process handling benjamin
2022-11-22 10:07 ` [PATCH v2 24/28] um: Add helper functions to get/set state for SECCOMP benjamin
2022-11-22 10:07 ` [PATCH v2 25/28] um: Add SECCOMP support detection and initialization benjamin
2022-11-22 10:07 ` [PATCH v2 26/28] um: Die if a child dies unexpectedly in seccomp mode benjamin
2022-11-22 10:07 ` [PATCH v2 27/28] um: Implement kernel side of SECCOMP based process handling benjamin
2022-11-22 10:07 ` [PATCH v2 28/28] um: Delay flushing syscalls until the thread is restarted benjamin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.