From patchwork Tue Apr 5 22:08:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8755771 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 1E5609F3D1 for ; Tue, 5 Apr 2016 22:12:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 370DD202A1 for ; Tue, 5 Apr 2016 22:12:02 +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 4349B20263 for ; Tue, 5 Apr 2016 22:12:01 +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 1anZAa-0004um-S1; Tue, 05 Apr 2016 22:09:56 +0000 Received: from mail-eopbgr640071.outbound.protection.outlook.com ([40.107.64.71] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1anZAW-0004rI-8U for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2016 22:09:53 +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=WaaDKFpROXlV4FR+CSuJKRQPGI6Ftxo3w0ZEnnnkFy8=; b=IPZQfFzjGq0rpHDG4YeW/T46DX5cCwTOuzthYl1ra5OvOprcuqyEPyX60dO3NIfqQPp+VrbtJu+HTW/XTB1mp1/q0w4XQKcJIOJR9CHE2Q2rZS2gPw4wPzPtr7GJyYEaWbLA6ve3W3wRa+gHxi49WhykP46auGF6mAlncRPZQqk= Authentication-Results: arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (95.143.213.121) by CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) with Microsoft SMTP Server (TLS) id 15.1.447.15; Tue, 5 Apr 2016 22:09:28 +0000 From: Yury Norov To: , , , Subject: [PATCH 01/25] all: syscall wrappers: add documentation Date: Wed, 6 Apr 2016 01:08:23 +0300 Message-ID: <1459894127-17698-2-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> References: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM2PR03CA0040.eurprd03.prod.outlook.com (10.160.207.50) To CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) X-MS-Office365-Filtering-Correlation-Id: aa063969-f580-49c3-7bd3-08d35d9ef56a X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 2:uigSIC9c6JALP974IxJ0Pq+Law9hFf9ll7WRT4Wgwz1KMHvYfXHt8eNIJ6udZVK3nGaglGjlVtZMhtgwIHV/hEwT2jDfANCOIDlKuunCmWLQKrOAFloiCwgXjy40bnCSZmNm+Prd8AwZq7GrVQfFeqFbm9VSQQZRwtniPjOqoPIZB/n2o5XP8Do7B0s3OTZk; 3:vGouNim2LS/8Jv9nvuRjO2YjuPzNw53Z+sxPJzfYAqc3nFFsGxNwfgy5UC6Efx4V4Fj/wjBbFNAp/9dMA4YXoOptE2B6X0bfxHhNklLo8v8En+xjjzARNITyo1T9tUpb; 25:opDhUC8rtyyWFzrUOx2MaVInN2ILbpg+pQp8CGM1wQDBbRIxKRfiaa33W6Qk4CnscwAinSoo4Iv7LQncwpwkSgF27VBX4TytzsioS71uXCUN3ClbzOKUHACjcj/9glzx5xhJ5ZyKnZBCARdNsb8XgJwES/rnjuwumylb48f7/5bsiRWj54cu3WlSpNcjvRNnkQ4c9u5QPTuPHAmOPXptnLChRT+GLRpXDVuCweGYubzTFae3ISCIPIT17C5G5g1hjJbLEZnidb7bQ1iSiDjk7h0T6fehMCyToeMfeMyvSpDy016sek2Ivc7mWjx7fmiGE7JRc1J9Rlxvty93xKOokJnyPP44d7worMF5JG9w8ZU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB619; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 20:SEhbSrpVd5a9aeETc9WWGFaWW8GChhJHtbHKN7CeYoABBAX2q7GgiTBVQXnGcn6XHJbPhcptLSVI3PHejIYRoy2YjKoA4cci2S3AGrHnDI+mazXMVhu+Qo0DVgFBV3eE4A08Fvs+29e7z6S+w+LpA1iVjzb82kZJcFcQqfMlgeOgZSx439UVV31RpFUVwbsq/PvqqneNPAX5Z0BYVTANkdyZDnagcvB8Z3uruuY4xjPwHT2+83n/+yJ7iZXymz/rRgl7wUH/TWcHgQXAnnQv40D+V7d3h55OZw1+th4vb93k5s+dBI439x26GcyyxRvh0XKciEf3xnllVsUsY5OhFLqZJ48Qw8vS5BPbvwiCTSW7S/L1U2JdJv3K0HtKrjfCBv2jILmkgLgvkemdYhhkSToXSpuGFp0RGdjVfBTGhkv1zdKuGe/nhqf7oTkcJs+fk7bFFQptNE8M6GXam5gcdZlY2dDCCU5FUuFJJsZjj+bivrIpqgD2FLyaqfm10axUwTKh8bTCvCwJ+VX2CqOjWn9JMVOYeswSqrJ0ku4BRD0aB2Nc3GkSNd8wpcQuxocIXtkHzdpyFf5WPJF2UGBcghThBw9LcOByGdagDBUHpKQ= 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)(10201501046)(3002001); SRVR:CO2PR07MB619; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB619; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 4:7nErMrfiLOW/6dGhx6Qb5RIUAjrvLQ+XFR+cbOcmLiV4MsFB9Vls8B10vovun6v2PQR4DMQdk+psixuPx9xefuhmJetuzFTyKQh6OMKn6kKLtlwTFveWv7cPytaoLK3MdfvHT0fjoLdRcnqNViWq/8j0omHJsWmbL7x040dUjZU871yGdYlUWwlCBITmj9V2BNcmikNUqf1P/2At936WTGG8BOTn4r3G9PUPvDj8KniMD/DnYuMxuVMXB11juDVh3ZfJHriZgSZOJErpjWedBVqaEPHoDEdAwEiD1kezEC3cZx/OfI7X5RZmI9yqpdrglDXzjL1gz4BdBR20cOEcjJ0NuVa8koBDDZwIBIiggIYRNU8gIcOyeOteTbZvQy7m X-Forefront-PRVS: 0903DD1D85 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(43544003)(76506005)(48376002)(42186005)(189998001)(36756003)(81166005)(19580405001)(19580395003)(92566002)(47776003)(66066001)(50226001)(50466002)(5001770100001)(4326007)(586003)(33646002)(5004730100002)(3846002)(5003940100001)(2950100001)(50986999)(1096002)(229853001)(2201001)(76176999)(5008740100001)(77096005)(6116002)(2906002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB619; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB619; 23:jC1EfcQgPbqxUzIShwqw3ZynEsheX9GBUuF6YjrYUp?= =?us-ascii?Q?T6MFyVnV5lXxRxdVvAXG3gWWnOMsFT77RMUMfKY374DpOs5UleKX6pHbuG8B?= =?us-ascii?Q?KbC5ugPyabG48vbwGJGdu9yfUEz9eWZt8K5/5TZ3xBu7UoLZQlKeeJEOaSWj?= =?us-ascii?Q?KWMpFOv7wnP0hSIeCSSpo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gQt0vgh3vu9nxru4za0IZFJB78MzPAXiFi9AjzPlYilwy/81JpL350vC/kH7yBenxciFdlbamRjqvCYTdbhrw9OXLMMVmUKFdteJPmqJOug==; 24:wrPiMjWvSp+r/ueAH62atm9q4C11gfg8pnTcqb3fxia3K1HOF163o5AUfxguAM1OCMlv+VsDZhM2FMzfjmxvVwOZ9IlkpvoExB/Bhv3k2GI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 22:09:28.8452 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB619 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_150952_570324_4B9AD71A X-CRM114-Status: UNSURE ( 7.20 ) 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: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, linux-doc@vger.kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, bamvor.zhangjian@huawei.com, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, 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=-5.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 Acked-by: Heiko Carstens --- 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) --------------------------------