From patchwork Fri Feb 26 14:34:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8437931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0AC9AC0553 for ; Fri, 26 Feb 2016 14:39:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BC38203AC for ; Fri, 26 Feb 2016 14:39:49 +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 2C1B9203A1 for ; Fri, 26 Feb 2016 14:39:48 +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 1aZJX5-0006aX-Mn; Fri, 26 Feb 2016 14:38:15 +0000 Received: from mail-bl2on0086.outbound.protection.outlook.com ([65.55.169.86] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZJUt-0004uH-4A for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2016 14:36:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nP4vDTXuTzhBb4mhwPqY3Vlq0WkZmKLcMbVeHLottUw=; b=Qxeg3llC7k1R/V0wmXberaMHWbERZPHmi1nyAbBC9KId6Tux++AnzA/gBnKZUR+Tw9TeDje14WCqdgRAAAw+ITghV7V7qGFt1YpVB11sWQh3yj7Bc9wWNCmhlH+GTzbHuv/bc3AoJSCalR+y9la33wxNCoCPIlvdctlr/wU6zPQ= 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 BY2PR07MB613.namprd07.prod.outlook.com (10.141.222.144) with Microsoft SMTP Server (TLS) id 15.1.409.15; Fri, 26 Feb 2016 14:35:36 +0000 From: Yury Norov To: , , , , , , , Subject: [PATCH 1/5] all: syscall wrappers: add documentation Date: Fri, 26 Feb 2016 17:34:51 +0300 Message-ID: <1456497295-22991-2-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456497295-22991-1-git-send-email-ynorov@caviumnetworks.com> References: <1456497295-22991-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: DB5PR02CA0007.eurprd02.prod.outlook.com (25.161.237.17) To BY2PR07MB613.namprd07.prod.outlook.com (10.141.222.144) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB613; 2:yWMEA0O3149tYe0D3OBwRx7G6rO/A0lpLiD077LEuj0HELB8l0tWRyx+vO3LrZcH2l5DSL55gJUdijMIwZ8GKN37Azoc6MrKwWVt4+QTlh2TKcX/dEcDUjY1ZpeTj56H3u7MKY3as9AVsbwB3FPYfA==; 3:ChL3IpPZAqXrirCc89mm4z1h1TxR3HpBd+/iA7Jy/aZy31G+x9sGqwYsWYotiB35QqeLMsAO6uEFqN5hajAHEdZjJJBuoOcyCXR7NwseMDnIj+6TE4TzY7+9qBEFQpjH; 25:vRFe6551UfUfwMneSWfx62T64TaW5cQ8VjD0NIDi2ZI8i40zXO9uMlcdRyt4oHbgr9HMJzbK4m3BRwgV6MP5ORviu5KYqt8m9ajnnBAPk7YEIOKPq8x99ueQeL6qVUfoNyoV4RP8DQ+Q3dOLYL7YYjgFT4DY78y4TUzWHHXWATmS0VBqtkQltMQy41HcEVNsIZkW5Mh83Dz/EARwWZm/ojf/5nxv1pHbcUFpVGmonXsC0+4kr6aaiq4AgyI8LDIJ//UlS8EGDuW8/DmXBxkYM7GREmdqA5qXBxl9B2QHqu7q1G/i27ghnfTxgvN1s6cGvjwfp0OAg0cNRkwZ/FJujg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB613; X-MS-Office365-Filtering-Correlation-Id: 1ca0e2a7-96ec-434f-de62-08d33eba1754 X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB613; 20:WQ0kNRtr4DbnSNOVdE6CC5aQX0ogDJsD774T3icnaWWiP5ssFQjfBnf77SkLv/QzotxyaaYQx5poZtQR26gjV+sfpYy0YZolErvyh+fbSuzHzlUXt8PYQtF9LJ4FHXs/cmUPnr5nKQLdp8ZPXwZ5D4Bnt9dhemzHI0kEHXH2a/afmLkbjuUfWr9VPNp7z5XL85o/oIsiDCJosikWyk/6O4+HTSpnT6QILDlhghENAIOJksWMd3WyNmYrOUAZx4n7PomX+4mtqpNP35D9Uy+nlsS46xkvbi0m4ymxzaQXvlTrbW25i7aQwHzX6abaLpnorKgSF91Gme/cufkA/rRDwJ9/F+5iABCVt6T1cauxB6qdRbPLV9TF8VUJYrKcut80ZuPL+O31BkvpC51rR4oSWF9fR9e4wxruLB7ftwrUCOaMV992oubz0A1ApnDYZa4upRQJLrRrEHVhARWzZ94nTtVkUlnusVlNe/sHJ+3VzRybaSuMEKMz4QG2DW31O/I59Dof86MrFZnF+ev9s+h7KTyum6rxC3UaKWgZS+3Kd3gB17C1LLqtvcoF6JA9mtAkMfQsGlisRvoaDAVEZ0gP/AzS5r/gyITmDFdigpvQGJY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY2PR07MB613; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB613; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB613; 4:Cnfjvl7na5iZIJizsZnFY3xZx/8CZvu/wjQaLm5VyD6p27jR4Ad9cpznH9XPBWDQZ+j/9SRxNAIVx+0iJGXqFtj3pQsgV4KIIoZvFXSXg3u1a9iwEBZNEMY2kpYtTud2bh4iIAFYyxxIlSefBR08QDvy6VCF5Ym8opREd9KmT7L02xyt/tVCmrE9Vf3v39Bntdk9JxAeInxP06NiYf2wsWzEBOHsAcMUjlMoql7oLAfNv+8WTXLU4oOJ+RPwuuuQ37RD7KosZTw40VYV95eLByxtzcgGzmEDBMourcUf3fGKrFpB2jey/zvFq2gOdkeT6in96f3pAxihu62Okj4I2d5WngOzh7tFkvzX/Q0poepur5sbsEqyQ/O2oIDo6FHY X-Forefront-PRVS: 0864A36BBF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(43544003)(5003940100001)(2950100001)(19580405001)(19580395003)(77096005)(122386002)(40100003)(50226001)(50466002)(4326007)(6116002)(3846002)(48376002)(586003)(4001430100002)(33646002)(5004730100002)(2906002)(5008740100001)(47776003)(50986999)(2201001)(36756003)(229853001)(189998001)(5001960100002)(5001770100001)(92566002)(66066001)(76176999)(76506005)(42186005)(107886002)(87976001)(1096002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB613; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR07MB613; 23:XsZIrF9w7CYbnToQiYSmYzazhtZmhfIVVza2BFREiD?= =?us-ascii?Q?l4A6DplvjeXCBkqylHLc1lp2tsv4JUdi65P7lhGhoDziqwfnXtjXyTItazvu?= =?us-ascii?Q?GKeWmSiCHsWvqm5oa/K2wktbhcwLxmcp8n0pIJUW12pAPrxUvaN75BvX1OsM?= =?us-ascii?Q?qt8oNRh8G/5Dmv9uOLROa+ctqh898Orb+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q?ozegXWBE4Ogzh2+ThY0pRdZ9cczo15ujg/NryVyjGhpUTSSQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB613; 5:EWp63vemuWEaKMeKOm6EOgQt79dsey1JBcAiNVnnypwih7se+Y6GxomDoDfJAyuzWciBVbaqEboYlhD+IInF/U0/pXcjU6+ROLK9ez+W9AL0J86O2WBA6LcjRk9utJz4rPSS98PgDNGvjPPxhn/1cQ==; 24:py/lFDN8rWmvrb5MLYjBmoxgVGc8MdznKfwWKuEKnJQdcRUq6/yWNPLQ82mC1PlgKtc+tnq+m8i4yprUm+YupROOZKyTIKgJj6IynCnJDbc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2016 14:35:36.0024 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB613 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160226_063559_647715_760D73AD X-CRM114-Status: UNSURE ( 7.19 ) 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.1 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, 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..d02a6bd 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) --------------------------------