lkml.org 
[lkml]   [2020]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v4 1/2] kernel: Implement selective syscall userspace redirection
Date

Hi Thomas,

Thanks for the valuable feedback!

Thomas Gleixner <tglx@linutronix.de> writes:
> Gabriel Krisman Bertazi <krisman@collabora.com> writes:
>> Introduce a mechanism to quickly disable/enable syscall handling for a
>> specific process and redirect to userspace via SIGSYS. This is useful
>> for processes with parts that require syscall redirection and parts that
>> don't, but who need to perform this boundary crossing really fast,
>> without paying the cost of a system call to reconfigure syscall handling
>> on each boundary transition. This is particularly important for Windows
>> games running over Wine.
>>
>> The proposed interface looks like this:
>>
>> prctl(PR_SET_SYSCALL_USER_DISPATCH, <op>, <start_addr>, <end_addr>, [selector])
>>
>> The range [<start_addr>,<end_addr>] is a part of the process memory map
>> that is allowed to by-pass the redirection code and dispatch syscalls
>> directly, such that in fast paths a process doesn't need to disable the
>> trap nor the kernel has to check the selector. This is essential to
>> return from SIGSYS to a blocked area without triggering another SIGSYS
>> from rt_sigreturn.
>
> Why isn't rt_sigreturn() exempt from that redirection in the first
> place?

This was actually a design decision for me.

The main use case I'm considering is emulation of applications written
for other OSs (games over wine), which means this dispatcher code is
exposed to applications built against different ABIs, who trigger
syscalls with bogus parameters (from a linux perspective)

In this emulation scenario, I cannot really trust the syscall number
means rt_sigreturn, so I try to only base the dispatcher decision on the
memory region and selector variable.

I think the best we can do is what Andy said: to exempt rt_sigreturn
when it comes from the vdso, for architectures that do it that way.

>
>> ---
>> arch/Kconfig | 20 ++++++
>> arch/x86/Kconfig | 1 +
>> arch/x86/entry/common.c | 5 ++
>> arch/x86/include/asm/thread_info.h | 4 +-
>> arch/x86/kernel/signal_compat.c | 2 +-
>> fs/exec.c | 2 +
>> include/linux/sched.h | 3 +
>> include/linux/syscall_user_dispatch.h | 50 +++++++++++++++
>> include/uapi/asm-generic/siginfo.h | 3 +-
>> include/uapi/linux/prctl.h | 5 ++
>> kernel/Makefile | 1 +
>> kernel/fork.c | 1 +
>> kernel/sys.c | 5 ++
>> kernel/syscall_user_dispatch.c | 92 +++++++++++++++++++++++++++
>
> A big combo patch is not how we do that. Please split it up into the
> core part and a patch enabling it for a particular architexture.
>
> As I said in my reply to Andy, this wants to go on top of the generic
> entry/exit work stuff:
>
> https://lore.kernel.org/r/20200716182208.180916541@linutronix.de
>
> and then syscall_user_dispatch.c ends up in kernel/entry/ and the
> dispatching function is not exposed outside of that directory.
>
> I'm going to post a new version later today. Will cc you.

Thanks. Will do!


--
Gabriel Krisman Bertazi

\
 
 \ /
  Last update: 2020-07-20 15:47    [W:0.071 / U:1.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site