seccomp: add the synchronous mode for seccomp_unotify
authorAndrei Vagin <avagin@google.com>
Wed, 8 Mar 2023 07:31:59 +0000 (23:31 -0800)
committerKees Cook <keescook@chromium.org>
Mon, 17 Jul 2023 23:08:08 +0000 (16:08 -0700)
commit48a1084a8b7423642b5f17ca6202f6f277c5392b
treed8d1fe9f2e2c0a5d92fd18218e6f5f3ca55f59f1
parent6f63904c8f3edb65bd85c1be01d69214ff8ca4c5
seccomp: add the synchronous mode for seccomp_unotify

seccomp_unotify allows more privileged processes do actions on behalf
of less privileged processes.

In many cases, the workflow is fully synchronous. It means a target
process triggers a system call and passes controls to a supervisor
process that handles the system call and returns controls to the target
process. In this context, "synchronous" means that only one process is
running and another one is waiting.

There is the WF_CURRENT_CPU flag that is used to advise the scheduler to
move the wakee to the current CPU. For such synchronous workflows, it
makes context switches a few times faster.

Right now, each interaction takes 12µs. With this patch, it takes about
3µs.

This change introduce the SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP flag that
it used to enable the sync mode.

Signed-off-by: Andrei Vagin <avagin@google.com>
Acked-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230308073201.3102738-5-avagin@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
include/uapi/linux/seccomp.h
kernel/seccomp.c