From patchwork Thu Jan 14 17:23:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8034721 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 E39489F3F6 for ; Thu, 14 Jan 2016 17:37:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C60B20497 for ; Thu, 14 Jan 2016 17:37:38 +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 EAA2A20439 for ; Thu, 14 Jan 2016 17:37:36 +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 1aJloY-00073L-4b; Thu, 14 Jan 2016 17:36:02 +0000 Received: from mail-by2on0054.outbound.protection.outlook.com ([207.46.100.54] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJlhk-000735-3K for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2016 17:29:06 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@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.361.13; Thu, 14 Jan 2016 17:28:37 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 21/21] arm64: ilp32: wrap syscalls to remove top 32-bit vulnerability Date: Thu, 14 Jan 2016 20:23:18 +0300 Message-ID: <1452792198-10718-22-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> References: <1452792198-10718-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 CO2PR07MB619.namprd07.prod.outlook.com (10.141.228.151) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 2:npR0HKg9HncBDGlBPAC0x5CHGdEGT2D6VOpTXVRM8XoRnOjYAsZQ6rTkveDie1VAhmcIzABozIBKhOaqwcbzqOAR21krqA7jqAGl+B/ytZbQtFg7gswA99TGOeR63PZQkZze+Xge3iEefEJx9QBLMA==; 3:uezupSxDmvvs6x1Vmr+/SMvThG0Ru/29jsmT6OOaju4JeVRUlihFhUmPu6nzhlyfJuAPyaViehe2QdZEdS1ESHUNKkzMlO5ucFME03ovUpu2N1ppeU5fECw4P29VLEjr; 25:v/Lss0GfoUJEL3lNBzovqB7sA4GylHyNZ96xCnkumT7xFuN1MSkYAw5JQAPgQdBIefaoMZWVkrWu1RBv09XpLzPK8nUwOppJ2UulryI/sRXQI1BVaQkWm5xwB4cQJBPPOrRDvBFByZZNH6JZuQIwvfB3lJB8Mrs5vXuE2txIjN7TJBGLU7utjJoVObrqqY3WCjycTDZHjO8gG2CcS5kSNIbdLRVBm2e4+gFwKIgnt83Qhy9CSDfwHz7cJz71/Zau X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB619; X-MS-Office365-Filtering-Correlation-Id: 553ddd44-050e-46f0-6670-08d31d08235c X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 20:aPhVyUqJbZMlw/z9EbM3C5pDhg1gZuSWAhwhVXjYTroUUIirPXbHs+pM6jE4qnmhmph5Z9aoGdEJ2Kky0aFeYfC4N4Cfg/21qwv/EBYitf0IyAAFvwon7sN80Lb0xQgTTXBbTFH7CFT9PR4U6+IzpjfabRMyhwhupUDK8Dk7C1XB1GmZ/8iRy5o7BkPOY5pBkXh4q9pHVXOSrRgAKgu8lkFvoQ3gg2nNlCDnY2JU6rgCy1c4+XuWqd8CZgr4uQZQ03NxM2+26NS5QdbwXK2AhsZ3UuA3YLcb+XNE48SG4q3692IsxbRvgKWMc49xK8R+DoF5FopiTb+sZ/iny1hvmMZ5sHJz7UVHo1gXN537E7KC4gvs5hiV5ropFHgxPm7xxkseZp4guvFrRM+yuA4xBckxq/1+++ihvNLSYauziILF5xfaNhZTGD/2H6bx97Mg1GViZ21TCxdN0JNa/b93RTDanJ8laxa9EGEUeDgM0Ip58vGOsZxfubYHZ9/p5mbs5KqcPNsiOFlzORKr7VZkaq06JztydO6iVecKo0qeeJxbcPh+Ox8qzxg+kR6PatNsby/P7itpakqmWg1JZTnHQbOKc4QZxsYc2J/GQxacwq8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:CO2PR07MB619; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB619; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 4:Umm1kZZEOsmk4MN8XcH8ltetrkH2j8oO85CVEIoXBTiYhp/ga38wxTtJIRZpzdXhbYUMc+nSYG2ErjKHqkqfp/aK2jZAGaKK9YLmfEzuFXx2d58GZ0zHZ11Rv/9VgTDX8RCCgty+fP8lh18Tl6qziKAwXGJoj+x6/NZYlhEuu+o3lODv1/vrRa/Oe6fCkDgK9ZVpOShstFumevbSf5PUigR1//M9VVuor4nI+tszKrIJOLtwAvMD0y0Fe1wSQVZY0CAt+WpBsJYmvCEzW8e/5SgjRcZmmZbUYk7W5ujlZs7u+84OQC9tHrPZV3RnS56mHvpnEBf+iqmuu1igs/ix9Ji0ujcVQHwXZaUqfQaz6qvnxeCYStL+p4Rm+IF1iqqf82/JGlTxHbUVZRlMeFUu8NqVJYSiUXqeAlsh8fV6LWQ= X-Forefront-PRVS: 08213D42D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(5004730100002)(101416001)(106356001)(97736004)(586003)(66066001)(81156007)(3846002)(5008740100001)(2906002)(5003940100001)(48376002)(36756003)(1096002)(19580395003)(2201001)(5001960100002)(189998001)(87976001)(2950100001)(50466002)(42186005)(33646002)(6116002)(229853001)(77096005)(40100003)(47776003)(105586002)(50986999)(122386002)(76506005)(4326007)(50226001)(19580405001)(5001770100001)(92566002)(76176999)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB619; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB619; 23:Wuevqbvqmncu7rpbfSUMJcNZFgj0pO0tmP8WNlGdS3?= =?us-ascii?Q?joD+B+AS54EwQBzPks0U4ZDDlwghGeIlC7GgMz5mjiUlKYYZWEE7FJcqlTDz?= =?us-ascii?Q?xvzLtFWZI/57nKHf+rsrSa+G58rrN1k3YA/589BefquwDHIA8DAXRIWoAqK3?= =?us-ascii?Q?bEDKiqgzFS2KWN0/u6SdQzaq4WfzjsWG3P0GU8AfKNQfGN9beSgi7YMvD/l5?= =?us-ascii?Q?iHSDGdAzddZSuQInfF/7FW9qKWMVNft7Z9V1Il9PdITfrCEJ7Tm5LYAoLRq4?= =?us-ascii?Q?xODZOcnif1FNGXecbagUZt8aMYC355Dpy9K4Y3xqI2+p7zZWQmGwkG58Cqqq?= =?us-ascii?Q?KXF9U33EdRjzcyi5XaWZptYATyMRB+C47YEYGrVsE9jKI99y81iEBh7XKx3O?= =?us-ascii?Q?GFbZgqPqlhFag0nyXgAIewoiMRgyigRA0h4UARWUczudapQVqRUAIM3BOs0m?= =?us-ascii?Q?ShhtX6nryWpR1CWpAFQwyGnOLsydrYLFaUWwI3AbUfvrTt0n9LvI/XpwE7hJ?= =?us-ascii?Q?7ByD/GB6JNfie+3qSgEwquBpcOT3kX2E8uywWL7sBMqp+AYEDyQ1IbHIruMr?= =?us-ascii?Q?n29NUCOI4bEmmO6GYHBlkKvI42p4VCIFg/HfOlU+vmkyhbn+Hvg8sMKHnErT?= =?us-ascii?Q?kCnU5Se1sCupOIi4ZRLysdcFpss0L078SqEwePxkylYqhaOGnAPf03pg5k76?= =?us-ascii?Q?7OR0epH+IEL3MOf8zqsM79kto+8V4Gli2oPa1nzj0iKUC+ZAwIoI3oyPXKyT?= =?us-ascii?Q?GGaLg1OJEQ7OJRr4i8Pjy6ptSmSsmVAkkediHQj6HtqklaCXGEYDo8C0xhek?= =?us-ascii?Q?9j2BAOavcvpsEDvse/x6NXx5PC1bn98a5SYKFgGfG3SJzVLopIGsMJK7erIE?= =?us-ascii?Q?njCxpKQXHJ1ivlo2mM8GIyI7nn5IXUyjNVUnQn/15ylclLbQU6Ebl9uu3ghg?= =?us-ascii?Q?2dyUeTHWCOg2Rb+4HNTv+IUpveZInrgJSLo8ksEkO5uzPA7tQqPm1x0UtprS?= =?us-ascii?Q?F7vNDUthTjUrl02El5boU6IIiHsiM7kSulCD+CMJDONYzLQ35YNqKyZbeL8h?= =?us-ascii?Q?eRIX0pZr/A5LLpe/uFGInJq6dO82qIQgluIQmGhRpR3zHeRiyWmGFrWMez/e?= =?us-ascii?Q?U/CpT2onI=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB619; 5:fX4c4PcdLuV3WgNuM4vPrBqyYXE/Djfdx/2xOCjtqR/mrKVQYIft3f+Lv1KfWIRao+mCTIL/mSgIYfP6PT81JYNVeGbNsEfVqUOxUrfhvgLDOdKdXY4H664fo71kdhYtvK+lL0RPm++zuez1nTmhzQ==; 24:V70FOBH4EfapOU7qMqY08Fl/05gHx451EHiirpjKs+sKuoeKJ5qP+mD/rU1yIMRQMND3TMkkfYBaqRUc3h1zTGuBvJ1mxzIQ4DzmAf+x1sU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2016 17:28:37.5042 (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-20160114_092900_612264_51A87A92 X-CRM114-Status: GOOD ( 12.33 ) 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, schwab@suse.de, broonie@kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, ynorov@caviumnetworks.com, jan.dakinevich@gmail.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=-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 The wrapper that clears top halves of registers looks like this: 0000000000000068 : COMPAT_SYSCALL_WRAP3(mknod, const char __user *, filename, umode_t, mode, unsigned, dev); 68: a9bf7bfd stp x29, x30, [sp,#-16]! 6c: 910003fd mov x29, sp 70: 2a0003e0 mov w0, w0 74: 94000000 bl 0 78: a8c17bfd ldp x29, x30, [sp],#16 7c: d65f03c0 ret It looks quite nice overall. Unsafe pointer type is fixed with "mov w0, w0", and safe types are untouched. Signed-off-by: Yury Norov --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/compat_wrapper.h | 14 ++++++++++++++ arch/arm64/kernel/sys_ilp32.c | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 arch/arm64/include/asm/compat_wrapper.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 8606c15..0344fc0 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -785,6 +785,7 @@ config AARCH32_EL0 config ARM64_ILP32 bool "Kernel support for ILP32" + select COMPAT_WRAPPER help This option enables support for AArch64 ILP32 user space. ILP32 is an ABI where long and pointers are 32bits but it uses the AARCH64 diff --git a/arch/arm64/include/asm/compat_wrapper.h b/arch/arm64/include/asm/compat_wrapper.h new file mode 100644 index 0000000..651b4e8 --- /dev/null +++ b/arch/arm64/include/asm/compat_wrapper.h @@ -0,0 +1,14 @@ +#ifndef __ASM_COMPAT_WRAPPER +#define __ASM_COMPAT_WRAPPER + +/* + * Compat system call wrappers. + */ + +/* + * This file is empty as arm64 is satisfied with generic + * definitions of __SC_COMPAT_TYPE, _SC_COMPAT_CAST and + * COMPAT_SYSCALL_WRAPx. + */ + +#endif /* __ASM_COMPAT_WRAPPER */ diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c index bed308c..c63725b 100644 --- a/arch/arm64/kernel/sys_ilp32.c +++ b/arch/arm64/kernel/sys_ilp32.c @@ -27,6 +27,7 @@ #include #include #include +#include #include /* Using non-compat syscalls where necessary */ @@ -50,11 +51,13 @@ asmlinkage long ilp32_sys_rt_sigreturn_wrapper(void); #undef __SYSCALL #undef __SC_COMP +#undef __SC_WRAP #undef __SC_3264 #undef __SC_COMP_3264 #define __SYSCALL_COMPAT #define __SYSCALL(nr, sym) [nr] = sym, +#define __SC_WRAP(nr, sym) [nr] = compat_##sym, /* * The sys_call_ilp32_table array must be 4K aligned to be accessible from