From patchwork Thu Nov 29 17:05:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10704941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD45A13BB for ; Thu, 29 Nov 2018 17:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B378E2F779 for ; Thu, 29 Nov 2018 17:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A705D2F77C; Thu, 29 Nov 2018 17:09:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4AB072F779 for ; Thu, 29 Nov 2018 17:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1tb673p/ZAQMUIYLXvb9ECycquDyzBu5NtqjaQz5fUY=; b=fXwJUSJveLKeY5 lG2mPZTJW+6/21MuUiBj/OFLbHv1FKIWy7VASdNtUpkkF1CLkthJRgmUyYn8waBcFTPXAHrvC9/vw yjgQBT9upM/lV9+p/W+NvhhsgIJCDMgX9pvlL0j/+2uotj1a6FAQ17l99+lOLn/ajc0O2V44ZHWRB 6WnK9tJw3gpCE4lvoeJWrhONYaAAqWOmCijGMcMR7JZGWLXPxTdCYdsUtP65bzoavCk0V4UYKa4Wt 01n85TH895bRS3BlfaHwSVQoWLMu4NAf7oDnkOA9dtcqaxQibODXRs3aeBFDpQBq38CtNmayBeB3N RVUWke/LYo8mKufPsu7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSPoJ-0003FA-ED; Thu, 29 Nov 2018 17:09:07 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSPlg-0000l0-NN for linux-arm-kernel@lists.infradead.org; Thu, 29 Nov 2018 17:06:39 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 59D181596; Thu, 29 Nov 2018 09:06:21 -0800 (PST) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 467533F59C; Thu, 29 Nov 2018 09:06:19 -0800 (PST) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 11/28] arm64: compat: Refactor aarch32_alloc_vdso_pages() Date: Thu, 29 Nov 2018 17:05:13 +0000 Message-Id: <20181129170530.37789-12-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129170530.37789-1-vincenzo.frascino@arm.com> References: <20181129170530.37789-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181129_090625_428673_934B8E9C X-CRM114-Status: GOOD ( 15.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Catalin Marinas , Daniel Lezcano , Will Deacon , Russell King , Ralf Baechle , Mark Salyzyn , Paul Burton , Thomas Gleixner , Peter Collingbourne Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP aarch32_alloc_vdso_pages() needs to the refactored to make it easier to disable kuser helpers. This patch divides the function in aarch32_alloc_kuser_vdso_page() and aarch32_alloc_sigreturn_vdso_page(). Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Vincenzo Frascino --- arch/arm64/kernel/vdso.c | 49 ++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 88b674079d07..cee7205eefc5 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -74,40 +74,55 @@ static const struct vm_special_mapping aarch32_vdso_spec[2] = { }, }; -static int __init aarch32_alloc_vdso_pages(void) +static int aarch32_alloc_kuser_vdso_page(void) { extern char __kuser_helper_start[], __kuser_helper_end[]; - extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[]; - int kuser_sz = __kuser_helper_end - __kuser_helper_start; - int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start; - unsigned long vdso_pages[2]; - - vdso_pages[0] = get_zeroed_page(GFP_ATOMIC); - if (!vdso_pages[0]) - return -ENOMEM; + unsigned long vdso_page; - vdso_pages[1] = get_zeroed_page(GFP_ATOMIC); - if (!vdso_pages[1]) + vdso_page = get_zeroed_page(GFP_ATOMIC); + if (!vdso_page) return -ENOMEM; /* kuser helpers */ - memcpy((void *)(vdso_pages[0] + 0x1000 - kuser_sz), + memcpy((void *)(vdso_page + 0x1000 - kuser_sz), __kuser_helper_start, kuser_sz); + flush_icache_range(vdso_page, vdso_page + PAGE_SIZE); + + aarch32_vdso_pages[0] = virt_to_page(vdso_page); + + return 0; +} + +static int aarch32_alloc_sigreturn_vdso_page(void) +{ + extern char __aarch32_sigret_code_start[], __aarch32_sigret_code_end[]; + int sigret_sz = __aarch32_sigret_code_end - __aarch32_sigret_code_start; + unsigned long vdso_page; + + vdso_page = get_zeroed_page(GFP_ATOMIC); + if (!vdso_page) + return -ENOMEM; + /* sigreturn code */ - memcpy((void *)vdso_pages[1], + memcpy((void *)vdso_page, __aarch32_sigret_code_start, sigret_sz); - flush_icache_range(vdso_pages[0], vdso_pages[0] + PAGE_SIZE); - flush_icache_range(vdso_pages[1], vdso_pages[1] + PAGE_SIZE); + flush_icache_range(vdso_page, vdso_page + PAGE_SIZE); - aarch32_vdso_pages[0] = virt_to_page(vdso_pages[0]); - aarch32_vdso_pages[1] = virt_to_page(vdso_pages[1]); + aarch32_vdso_pages[1] = virt_to_page(vdso_page); return 0; + +} + +static int __init aarch32_alloc_vdso_pages(void) +{ + return aarch32_alloc_kuser_vdso_page() & + aarch32_alloc_sigreturn_vdso_page(); } arch_initcall(aarch32_alloc_vdso_pages);