From patchwork Tue Jan 15 13:55:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10764517 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 9B5B61390 for ; Tue, 15 Jan 2019 13:58:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 894682C124 for ; Tue, 15 Jan 2019 13:58:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D52A2C221; Tue, 15 Jan 2019 13:58:13 +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 17C292C1DF for ; Tue, 15 Jan 2019 13:58:13 +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=RzO4hVi41mcPGIg/3vEEHYUCAvmujJmABo4paOSXP/0=; b=o6TfY/diy8sR5p 9rtmv12HTlVKElupociNZOOxfHlRewzIy8v7V4Sb84/0+0ln14C/XRStn+BDJsBVb9KLN6MwG9DVX nvOukoF6ozmjYuwEOmcsSZ/NsIk2tHKnK4IAXhOAkQBpg8H/3lzbEkn6ehdUnrsOe8OSt3Tr7kXnF zV2LqLLHBbn2VDl+QgmflgxS17GNimLBeZ4zVOhwGqLkvwGV9NOxZpXFXyJFxxLekGeFg+2k5eTWJ VvFPkkUc8MtOUgu4uhIVe2fZxVEJBn/25iyNvz62RasEe5Zemg4t2qP7Bm5+/StkZlequ1hOyUUY2 WUuuQla9fk+ulvARlNbA==; 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 1gjPEG-0005Ic-Uw; Tue, 15 Jan 2019 13:58:09 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjPCq-00041z-TK for linux-arm-kernel@lists.infradead.org; Tue, 15 Jan 2019 13:56:56 +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 661D415AB; Tue, 15 Jan 2019 05:56:40 -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 52C413F70D; Tue, 15 Jan 2019 05:56:38 -0800 (PST) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 07/24] arm64: compat: Refactor aarch32_alloc_vdso_pages() Date: Tue, 15 Jan 2019 13:55:22 +0000 Message-Id: <20190115135539.24762-8-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115135539.24762-1-vincenzo.frascino@arm.com> References: <20190115135539.24762-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-20190115_055641_660399_307EBBC9 X-CRM114-Status: GOOD ( 14.25 ) 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 5df7aeef324a..d438e65299a2 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -75,40 +75,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);