From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: alx.manpages@gmail.com, linux-man@vger.kernel.org
Subject: Re: [PATCH v4] prctl.2: Document Syscall User Dispatch
Date: Wed, 23 Dec 2020 14:30:12 -0300 [thread overview]
Message-ID: <87r1ngzazf.fsf@collabora.com> (raw)
In-Reply-To: <41369525-d6f0-0897-123c-fd82cead89ea@gmail.com> (Michael Kerrisk's message of "Wed, 23 Dec 2020 11:40:18 +0100")
"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> writes:
> Hello Gabriel,
>
> On 12/22/20 9:25 PM, Gabriel Krisman Bertazi wrote:
>> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
>>
>> ---
>> Changes since v3:
>> (suggested by Michael Kerrisk)
>> - Explain what dispatch to user space means.
>> - Document the fact that the memory region is a single consecutive
>> range.
>> - Explain failure if *arg5 is set to a bad value.
>> - fix english typo.
>> - Define what 'invalid memory region' means.
>>
>> Changes since v2:
>> (suggested by Alejandro Colomar)
>> - selective -> selectively
>> - Add missing oxford comma.
>>
>> Changes since v1:
>> (suggested by Alejandro Colomar)
>> - Use semantic lines
>> - Fix usage of .{B|I}R and .{B|I}
>> - Don't format literals
>> - Fix preferred spelling of userspace
>> - Fix case of word
>> ---
>> man2/prctl.2 | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 122 insertions(+)
>>
>> diff --git a/man2/prctl.2 b/man2/prctl.2
>> index f25f05fdb593..71261a736964 100644
>> --- a/man2/prctl.2
>> +++ b/man2/prctl.2
>> @@ -1533,6 +1533,98 @@ For more information, see the kernel source file
>> (or
>> .I Documentation/arm64/sve.txt
>> before Linux 5.3).
>> +.TP
>> +.\" prctl PR_SET_SYSCALL_USER_DISPATCH
>> +.\" commit 1446e1df9eb183fdf81c3f0715402f1d7595d4
>> +.BR PR_SET_SYSCALL_USER_DISPATCH " (since Linux 5.11, x86 only)"
>> +.IP
>> +Configure the Syscall User Dispatch mechanism
>> +for the calling thread,
>> +to selectively intercept system calls
>> +and dispatch them back to be instrumented by user space
>> +through
>> +.BR SIGSYS .
>
> I think that "dispatch them back to be instrumented by user space"
> doesn't really explain anything to someone unfamiliar with SUD.
>
> How about something like this (if it is correct):
>
> [[
> The Syscall User Dispatch mechanism allows an application to
> selectively intercept system calls so that they can be emulated
> within the application itself. Interception takes the form a
> thread-directed SIGSYS signal that is delivered to the thread
> when it makes a system call. Upon rece(The system call is not executed
> by the kernel.)
> ]]
>
>> +This gives user space the opportunity to emulate the system call
>> +and modify its return value.
>
> How is the system call emulated? What I mean is: does one
> emulate it from the SIGSYS handler? That needs to be more
> clearly stated.
I am rethinking the mention to emulation in the manpage, as that goes
beyond SUD. In fact, it is one usecase that can be implemented using
SUD and signal handlers, but there are others.
I'm using your suggestion above slightly modified, to avoid the term emulation.
>
>> +.IP
>> +When a system call is dispatched back to user space
>> +by this mechanism,
>> +it is not executed by the kernel.
>> +When the signal handler returns,
>> +the system call completes immediately
>> +with the return value set
>> +by the signal handler.
>> +(See
>> +.BR sigaction (2)
>> +for information on setting the return value).
>
> I can's see anything in sigaction(2) that explains how to set the
> return value. Am I missing something or do you have a patch in
> progress for that page?
the way you modify the syscall return value is not part of SUD, instead
it is generic to how signals are handled. so I'm dropping this bit.
--
Gabriel Krisman Bertazi
prev parent reply other threads:[~2020-12-23 17:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-22 20:25 [PATCH v4] prctl.2: Document Syscall User Dispatch Gabriel Krisman Bertazi
2020-12-23 10:40 ` Michael Kerrisk (man-pages)
2020-12-23 17:30 ` Gabriel Krisman Bertazi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1ngzazf.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=alx.manpages@gmail.com \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox