Received: by 10.213.65.68 with SMTP id h4csp145463imn; Thu, 15 Mar 2018 12:14:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELudt2wPYbNp8hWGJfqNs7rzINgynnpwjJx9l92rmfycGIyDQvFDkqXxVy/fqytdyS76vW1M X-Received: by 2002:a17:902:a5c5:: with SMTP id t5-v6mr2865697plq.244.1521141253055; Thu, 15 Mar 2018 12:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521141253; cv=none; d=google.com; s=arc-20160816; b=F+jzy8dzEPDt9omB6B3HDJx4IUrRxqylNK0ItU42jEdflgeH9BJpuKMEfKnNSCIFwN Auh/h6FKFUlcmmPignBrlJgNYTt6SPXUBp9Q7MMDTrEWhDQsfjsbG+E45a/6usQQjHLq KvdqDk1OD8WA+QxOAx4vdmWpmu+TNvi2i6fkUu0USBjLpv5vJh8IJ6i5MqYKBE0f0bfm jvRFV6S5Lln1UmAQYGMaC6eLRkJJUKpNelIER3jKulws1JlJSazxOw5XMPwc0I+NW+t+ Z20op0OS6rMktBNqWbpjFs5qeSWyT4mHB1DEtTemXA1Ga9u5QD5O1UVO2nIDo1sCYz73 mfVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=6QZIrQIgc1TnHm+MYktwDgBDbVe9yNbQ28ir4yU4dAw=; b=BI/0QnhvGFtud/dm6nFpdz6KaeeCmo32/J2c3tq6LRyzeqYAZeH5SoQxnmDOna63JL GYeDyD5DJzLjc02XG5dbFAiem/47oSxsWRpILpiylOWHq49wUtLI0Sya4AfFLon1ZW8U xi0fU8B19R6Pq9b/KkVJmb6KbCg0qFuskteaSL2u5ILMd7AElrMSLUYxdpWDad1QpvNO lzAOw0yurl4v9xDRjMDPj/UAWeQBHy+BfQ2yAILCrop3umeZXbNVfJFTk5ALZW6/Z0GB +V7fvjQUYOCJ5JjbNDbGg8/q30Rz/wHvEo/N4HgIh4jtTTu+eaD9N3AvxHfjk7iFGduO iuUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q72si1270093pfi.207.2018.03.15.12.13.58; Thu, 15 Mar 2018 12:14:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbeCOTMZ (ORCPT + 99 others); Thu, 15 Mar 2018 15:12:25 -0400 Received: from isilmar-4.linta.de ([136.243.71.142]:36144 "EHLO isilmar-4.linta.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932475AbeCOTGV (ORCPT ); Thu, 15 Mar 2018 15:06:21 -0400 Received: from light.dominikbrodowski.net (isilmar.linta [10.0.0.1]) by isilmar-4.linta.de (Postfix) with ESMTPS id 55FD5200914; Thu, 15 Mar 2018 19:06:18 +0000 (UTC) Received: by light.dominikbrodowski.net (Postfix, from userid 1000) id AC191201B3; Thu, 15 Mar 2018 20:05:36 +0100 (CET) From: Dominik Brodowski To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk Cc: luto@kernel.org, mingo@kernel.org, akpm@linux-foundation.org, arnd@arndb.de Subject: [PATCH v2 01/36] syscalls: define goal to not call sys_xyzzy() from within the kernel Date: Thu, 15 Mar 2018 20:04:54 +0100 Message-Id: <20180315190529.20943-2-linux@dominikbrodowski.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180315190529.20943-1-linux@dominikbrodowski.net> References: <20180315190529.20943-1-linux@dominikbrodowski.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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..0526286a0314 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); + +/* + * Kernel code should not call syscalls (i.e., sys_xyzyyz()) directly. + * Instead, use one of the functions which work equivalently, such as + * the ksys_xyzyyz() functions prototyped below. + */ + #endif -- 2.16.2