mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-kernel@vger.kernel.org, luto@kernel.org,
	torvalds@linux-foundation.org, mingo@kernel.org,
	viro@zeniv.linux.org.uk, akpm@linux-foundation.org
Subject: [RFC PATCH 01/35] syscalls: define goal to not call sys_xyzzy() from within the kernel
Date: Sun, 11 Mar 2018 11:55:23 +0100	[thread overview]
Message-ID: <20180311105557.20807-2-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20180311105557.20807-1-linux@dominikbrodowski.net>

The syscall entry points to the kernel defined by SYSCALL_DEFINEx()
and COMPAT_SYSCALL_DEFINEx() should only be called from userspace
through kernel entry points, but not from the kernel itself. This
will allow cleanups and optimizations to the entry paths *and* to
the parts of the kernel code which currently need to pretend to be
userspace in order to make use of syscalls.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 Documentation/process/adding-syscalls.rst | 14 --------------
 include/linux/syscalls.h                  |  7 +++++++
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/Documentation/process/adding-syscalls.rst b/Documentation/process/adding-syscalls.rst
index 8cc25a06f353..35a14b730da9 100644
--- a/Documentation/process/adding-syscalls.rst
+++ b/Documentation/process/adding-syscalls.rst
@@ -201,12 +201,6 @@ followed by the (type, name) pairs for the parameters as arguments.  Using
 this macro allows metadata about the new system call to be made available for
 other tools.
 
-The new entry point also needs a corresponding function prototype, in
-``include/linux/syscalls.h``, marked as asmlinkage to match the way that system
-calls are invoked::
-
-    asmlinkage long sys_xyzzy(...);
-
 Some architectures (e.g. x86) have their own architecture-specific syscall
 tables, but several other architectures share a generic syscall table. Add your
 new system call to the generic list by adding an entry to the list in
@@ -240,7 +234,6 @@ To summarize, you need a commit that includes:
 
  - ``CONFIG`` option for the new function, normally in ``init/Kconfig``
  - ``SYSCALL_DEFINEn(xyzzy, ...)`` for the entry point
- - corresponding prototype in ``include/linux/syscalls.h``
  - generic table entry in ``include/uapi/asm-generic/unistd.h``
  - fallback stub in ``kernel/sys_ni.c``
 
@@ -302,12 +295,6 @@ needed to deal with them.  (Typically, the ``compat_sys_`` version converts the
 values to 64-bit versions and either calls on to the ``sys_`` version, or both of
 them call a common inner implementation function.)
 
-The compat entry point also needs a corresponding function prototype, in
-``include/linux/compat.h``, marked as asmlinkage to match the way that system
-calls are invoked::
-
-    asmlinkage long compat_sys_xyzzy(...);
-
 If the system call involves a structure that is laid out differently on 32-bit
 and 64-bit systems, say ``struct xyzzy_args``, then the include/linux/compat.h
 header file should also include a compat version of the structure (``struct
@@ -344,7 +331,6 @@ version; the entry in ``include/uapi/asm-generic/unistd.h`` should use
 To summarize, you need:
 
  - a ``COMPAT_SYSCALL_DEFINEn(xyzzy, ...)`` for the compat entry point
- - corresponding prototype in ``include/linux/compat.h``
  - (if needed) 32-bit mapping struct in ``include/linux/compat.h``
  - instance of ``__SC_COMP`` not ``__SYSCALL`` in
    ``include/uapi/asm-generic/unistd.h``
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a78186d826d7..700a83a9c1ad 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -941,4 +941,11 @@ asmlinkage long sys_pkey_free(int pkey);
 asmlinkage long sys_statx(int dfd, const char __user *path, unsigned flags,
 			  unsigned mask, struct statx __user *buffer);
 
+
+/*
+ * The kernel should not use call syscalls (i.e., sys_xyzyyz()) directly.
+ * Instead, use one of the following functions which work equivalent to
+ * the syscall they are named for.
+ */
+
 #endif
-- 
2.16.2

  reply	other threads:[~2018-03-11 11:00 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11 10:55 [RFC PATCH 00/35] remove in-kernel syscall invocations Dominik Brodowski
2018-03-11 10:55 ` Dominik Brodowski [this message]
2018-03-11 15:24   ` [RFC PATCH 01/35] syscalls: define goal to not call sys_xyzzy() from within the kernel Andy Lutomirski
2018-03-12  7:27     ` Ingo Molnar
2018-03-12 19:14     ` Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 02/35] syscalls: use kernel_wait4() instead of sys_wait4() Dominik Brodowski
2018-03-12  7:29   ` Ingo Molnar
2018-03-11 10:55 ` [RFC PATCH 03/35] syscalls: mm_release(): use do_futex() instead of sys_futex() Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 04/35] syscalls: do not call sys_getpgid() within the kernel Dominik Brodowski
2018-03-12  8:35   ` Christoph Hellwig
2018-03-12 20:01     ` Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 05/35] syscalls: do not call sys_readlinkat() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 06/35] syscalls: do not call sys_pipe2() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 07/35] syscalls: do not call sys_renameat2() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 08/35] syscalls: do not call sys_futimesat() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 09/35] syscalls: do not call sys_epoll_*() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 10/35] syscalls: do not call sys_signalfd4() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 11/35] syscalls: do not call sys_eventfd2() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 12/35] syscalls: do not call sys_rt_sigpending() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 13/35] syscalls: do not call sys_ioperm() " Dominik Brodowski
2018-03-11 15:20   ` Andy Lutomirski
2018-03-15 16:43   ` Greg Kroah-Hartman
2018-03-11 10:55 ` [RFC PATCH 14/35] syscalls: do not call sys_mount() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 15/35] syscalls: do not call sys_umount() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 16/35] syscalls: do not call sys_dup{,3}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 17/35] syscalls: do not call sys_chroot() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 18/35] syscalls: do not call sys_write() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 19/35] syscalls: do not call sys_unshare() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 20/35] syscalls: do not call sys_fadvise64{,_64}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 21/35] syscalls: do not call sys_mmap_pgoff() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 22/35] syscalls: do not call sys_chdir() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 23/35] syscalls: do not call sys_sync_file_range() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 24/35] syscalls: do not call sys_unlink() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 25/35] hostfs: rename do_rmdir() to hostfs_do_rmdir() Dominik Brodowski
2018-03-11 11:19   ` Richard Weinberger
2018-03-11 10:55 ` [RFC PATCH 26/35] syscalls: do not call sys_rmdir() within the kernel Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 27/35] syscalls: do not call sys_mkdir{,at}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 28/35] syscalls: do not call sys_symlink{,at}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 29/35] syscalls: do not call sys_mknod{,at}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 30/35] syscalls: do not call sys_link{,at}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 31/35] syscalls: do not call sys_{f,}chmod{at,}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 32/35] syscalls: do not call sys_{f,}access{,at}() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 33/35] syscalls: do not call sys_ftruncate() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 34/35] syscalls: do not call sys_{,l,f}chown() " Dominik Brodowski
2018-03-11 10:55 ` [RFC PATCH 35/35] syscalls: do not call sys_close() " Dominik Brodowski
2018-03-12  7:37   ` Ingo Molnar
2018-03-12 19:43     ` Dominik Brodowski
2018-03-13  5:46       ` Ingo Molnar
2018-03-11 20:15 ` [RFC PATCH 00/35] remove in-kernel syscall invocations Linus Torvalds
2018-03-12 21:39   ` Dominik Brodowski
2018-03-12  7:32 ` Ingo Molnar
2018-03-12 19:30   ` Dominik Brodowski
2018-03-13  5:48     ` Ingo Molnar

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=20180311105557.20807-2-linux@dominikbrodowski.net \
    --to=linux@dominikbrodowski.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®