From patchwork Wed Feb 24 18:34:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8411101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 532729F88A for ; Wed, 24 Feb 2016 18:38:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67D412035B for ; Wed, 24 Feb 2016 18:38:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA7EE20380 for ; Wed, 24 Feb 2016 18:38:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYeIL-0007d5-Pp; Wed, 24 Feb 2016 18:36:17 +0000 Received: from mail-bl2on0079.outbound.protection.outlook.com ([65.55.169.79] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYeIH-0007WJ-QK for linux-arm-kernel@lists.infradead.org; Wed, 24 Feb 2016 18:36:14 +0000 Authentication-Results: de.ibm.com; dkim=none (message not signed) header.d=none;de.ibm.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (95.143.213.121) by BLUPR07MB610.namprd07.prod.outlook.com (10.141.207.15) with Microsoft SMTP Server (TLS) id 15.1.409.15; Wed, 24 Feb 2016 18:35:50 +0000 From: Yury Norov To: , , , , , , , Subject: [PATCH 1/5] all: syscall wrappers: add documentation Date: Wed, 24 Feb 2016 21:34:10 +0300 Message-ID: <1456338854-14901-2-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456338854-14901-1-git-send-email-ynorov@caviumnetworks.com> References: <1456338854-14901-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: HE1PR01CA0023.eurprd01.prod.exchangelabs.com (25.163.2.161) To BLUPR07MB610.namprd07.prod.outlook.com (10.141.207.15) X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB610; 2:/avoS/iJoEi6F413XmjoU8OmET2RW7koLWcfrQ8KvV59wM6ITZWzWRRJ7PMh5kTFJR3wH/Y/PLl/tgonTlc48WsWUrD6tUBqM96Wvz9dkz93+9Da0S6UT7vLs4VeK1Dvm1yoc7+TLwac4NE0+dGKkQ==; 3:DgR6yGoA8Wsab1uZbNMLklbuAE49XIL1lvpWomTDNvmm5VqlOzpmjkJ3CE+qJi3O0zelZGeQTv9kd6xVX6LyoMu6NHnZl2v1DkP+ulGu8eIhzJtI5QtTyYcbZUM0vbcy; 25:cih9xBQxyHFLyblQBHJoMt1KgHcsrBZp/SyMlL34C3zyerWLziPsqmrMWsdgWmQFY/VxxFnJjZuusEcuFylmJtXH6I/Z/Adx/ZdLfy36IL9FVj5wpWZBVPxh1SqqogA6HeJSkr94sMGklvbDqK8PRWLOd+yM+Q6LVrq8v4nEo+AhNGrTDEOHcK2Aok2D4Z2gFHDByz9dSyBt/9pdswGG+VnlNGZMZxetcB/VAly3bXe1fB+2bMQA3PKPb+jbY9siSNBBnN9XUw2DGlvV9mEwduCqXuSg6G3tlYLoLjPijYTS+OnpxptokMuO6WdGhwQ51D2mWOoPTg1pC+jyiFTqvg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB610; X-MS-Office365-Filtering-Correlation-Id: 1f4ba1bf-e24f-4f5c-703e-08d33d495253 X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB610; 20:ajIXMjMM4/tEo9nshmywgnK8n/T6EJrhq1kphdpwKoUHe3yupaII7mBk/y6fha4e6ll2Kf2E3JtJcb9zz6xEu59RRLYJpzpnapHxnpTtDwSGZheGpk3qRsGfEpIyH4SYppLAhnziDaUBSXBuQE6sggBTKayuIpH3SxGWdP/wDwpNerww2gI7gBINmCGkT12LlqE0PcVCv9Dz+qbZleKBxG07nB7s564BDzU3O9eGEq1fGQUQMQvZPm1s1n0QPNr2Ud7SpYu3sOSehxLcR2NTBMm8KLZW6Z4ZE3QrCzaV4IWXdLQKBfT6QzrX2wNhznBSaslg8ZztRqeGYn4ZZPDZ0x0ueveEqDfJXE8JQxhNn+yc2Na9ARQhOyPS/PHC8RIiq1UVzyNsWKt40GNSDkqV6e/6gHpWEWN5W/NWz16Lbv1hJlUgRfVmPDw8AqToPcLRTUWL5JQFyhh+osob9e8DfM8LQt1Gf3pS4HsJO58d3aKI/IBemhUj007Bs5LAFDpUOIkD8WxUrcs3dJXmCFDPGLcyCzlUOi3zZdw6Usmy3VaDBNq7gCeGaa54FwQoQKLkQ04rw67Sd1aEInBbwNNYTo/TXN4nCFoVHXazv95BIMs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR07MB610; BCL:0; PCL:0; RULEID:; SRVR:BLUPR07MB610; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB610; 4:ULtsRC6heN1oSMj5tD4p3VyP5jAk0bKbWdW4BjZandb4sT+pYZ2kaI1W/Mtwh32gOvPvwQ63IYanXOlLRKQuyum93H04nYsDsOyDGwbd74UxZABzlBpiuCACH4dYouL1O7WOX3C7PJDNuSk985mv1SYBfxwVT/zt48MTx1heA2HWoVEwinFB1mS2lI3by+2ZrA+oUYKtrtx1knHTW8RowuQR5FM17dR16i87ZnkDeB3aCwwem6CWm9pBi3Xz2jfEi7b/U9p9FVtWRNzal4it2NLTfSkHt6/8L8vPOp95ienn5kH5kvISJH81roAwU6vORqecBgmPyhJ/KsSX/kIg17mENbmxTbzhyrTkZD0p6R4sEv5JvrzxkX1S0T0nRBeZ X-Forefront-PRVS: 08626BE3A5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(43544003)(87976001)(36756003)(2201001)(5003940100001)(122386002)(76506005)(50226001)(40100003)(33646002)(76176999)(50986999)(189998001)(42186005)(47776003)(5004730100002)(5008740100001)(229853001)(66066001)(586003)(6116002)(92566002)(4001430100002)(3846002)(1096002)(48376002)(4326007)(5001770100001)(77096005)(19580405001)(50466002)(5001960100002)(19580395003)(107886002)(2950100001)(2906002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR07MB610; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR07MB610; 23:oPatbPtEvC4jalFEtwIZa9YW9o08nUwG+oVTDoAnfS?= =?us-ascii?Q?a+G+X5ECRm8AKBFvFCaFGwFUY783AM8334LlDq+MaavWEmagsGdKVuxOiNJ5?= =?us-ascii?Q?agxxpb1mYnhk1qmfd0NajITsYi7zrfDCcAlFfpWOkUPbQSCFAtckX4Tmq580?= =?us-ascii?Q?MzAT5ifpTHb69XJdo58Lhg0MGbQRPLidQCGwPHCwZmpJ0rjsiQlq7NPCzw87?= =?us-ascii?Q?vbSBnm8CeL0cXKdZjMpbAoVT90QZGiU609kRsmVfWf2Q6gwj7cjJxZf2hYPi?= =?us-ascii?Q?p4EDKkWv6riUZV+JsSWbQBmdf5AZ53JHr4GMGq/AtbLlmq0eKKqvhJ/0z0S5?= =?us-ascii?Q?D0JzpVfy9POnen9r48kOZeN0q1s5qocvwoAkggIw029Hris1ryDoU8+hmM4g?= =?us-ascii?Q?tRFerEX6FgLPZrnYGdrvzS/t18mNDJ09MRgky2tvK0tpy6PBU3J0wpoRt2Uz?= =?us-ascii?Q?Vt/UTV9UfwldSPEwuZ+ZmaHOoGycIeFkLLqfRsZ8flVFbd3kLqaCoJaWExTq?= =?us-ascii?Q?Pju0PCLQG7HOnhK2VK6qXJKcZde0i3iikJ4ihFfgQLvLccFap4Va1fWZL1yN?= =?us-ascii?Q?Xcan/W6uJRyY1HqD2PrYkBfCEayPvvpUJCI8EnRE3d0VLG9NMY20IVmgnfdK?= =?us-ascii?Q?1o8eSvNqaqDzjmpFCsHgPEXuk7Kl5Le/14t6U3M8H3z1Zk/YJjz+zDOr3DIQ?= =?us-ascii?Q?+vWrnwIcZpUs3aEfp2ami2BkJK52paz+0gh7hjtyDYCG58wRyz6XtO/I/E8h?= =?us-ascii?Q?R+De4VR9lFxCXaLiXEzZtvpyrQ5XzYPbzvxc+qvqS/JoRtiMyOiPoUmasC2g?= =?us-ascii?Q?LiLSd3roP0yw1nfZCbveilC/ikcrx6UL2RgRMEX49L2coWGagbQtndFSgUQ6?= =?us-ascii?Q?85K3Pzxd+3HBOibhXkGXIfpZOePRkh5Swp23bJDLNenr+tqyHKoO7cOmDHu0?= =?us-ascii?Q?oo/9nbgr9xaurmmoSb/pTwFNCL/WYtRCSMXfbpggWkANrcO9LmHEz1xV+Bzh?= =?us-ascii?Q?HCqM3S1DC12wOOkvaCDGZ7hubATgJeAXQLvMtcgfTkBjj0jz1v4FCoOqeT5R?= =?us-ascii?Q?gwHng=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB610; 5:J9SNvY8HGBXunIyENcNwYINFDSn7X3Tlg6z7BVgU2QDsxANu0YdVygBnNs1LueiSuw7moqShjs5jT+JZIX8znUIzP12cjvNeeqeOtnZeATZNSCALtqe3KPxqHF+nZuuhtXXC1SspDIAb+SqrkbS8Zw==; 24:qr0GBrlLzZzU2VtMazltNUCK2pL5d1XpQl10s2bbiJzBFYxOl+LHBQ34uX+DFRmRTWHKLjnrBVRo32DoMXjzMXdhW4cL6motOEgc8+0gLWw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2016 18:35:50.8103 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB610 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_103614_010096_15EB68CB X-CRM114-Status: UNSURE ( 7.38 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, broonie@kernel.org, bamvor.zhangjian@huawei.com, Yury Norov , joseph@codesourcery.com, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Yury Norov --- Documentation/adding-syscalls.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/adding-syscalls.txt b/Documentation/adding-syscalls.txt index cc2d4ac..1db880c 100644 --- a/Documentation/adding-syscalls.txt +++ b/Documentation/adding-syscalls.txt @@ -341,6 +341,38 @@ To summarize, you need: - instance of __SC_COMP not __SYSCALL in include/uapi/asm-generic/unistd.h +Compatibility System Calls Wrappers +-------------------------------- + +Some architectures prevent 32-bit userspace from access to top halves of 64-bit +registers, but some not. It's not a problem if specific argument is the same +size in kernel and userspace. It also is not a problem if system call is already +handled by compatible routine. Otherwise we'd take care of it. Usually, glibc +and compiler handles register's top halve, but from kernel side, we cannot rely +on it, as malicious code may cause incorrect behaviour and/or security +vulnerabilities. + +For now, only s390 and arm64/ilp32 are affected. + +To clear that top halves, automatic wrappers are introduced. They clear all +required registers before passing control to regular syscall handler. + +If your architecture allows userspace code to access top halves of register, +you need to: + - enable COMPAT_WRAPPER in configuration file; + - declare: "#define __SC_WRAP(nr, sym) [nr] = compat_##sym,", just before + compatible syscall table declaration, if you use generic unistd; or + - declare compat wrappers manually, if you use non-generic syscall table. + The list of unsafe syscalls is in kernel/compat_wrapper. + +If you write new syscall, make sure, its arguments are the same size in both +64- and 32-bits modes. If no, and if there's no explicit compat version for +syscall handler, you need to: + - declare compat version prototype in 'include/linux/compat.h'; + - in 'include/uapi/asm-generic/unistd.h' declare syscall with macro '__SC_WRAP' + instead of '__SYSCALL'; + - add corresponding line to 'kernel/compat_wrapper.c' to let it generate wrapper. + Compatibility System Calls (x86) --------------------------------