From patchwork Thu Nov 22 14:04:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Currey X-Patchwork-Id: 10694411 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 9939613AD for ; Thu, 22 Nov 2018 15:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8756E2C549 for ; Thu, 22 Nov 2018 15:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B2D02CEAE; Thu, 22 Nov 2018 15:29:32 +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 mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 972AC2C549 for ; Thu, 22 Nov 2018 15:29:30 +0000 (UTC) Received: (qmail 13894 invoked by uid 550); 22 Nov 2018 15:29:22 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 17726 invoked from network); 22 Nov 2018 14:04:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=qdi+0bS4linqvTXoN6BDMEcE4Kx/v77WVn28gx/bGHU=; b=NFxDIoDl +37anZXVD3bR/BfYxL9I4Ii73CxWvUro2WQ6RIZjHVX40Oj8S8vyvKQWuOH+y4n0 wk1NdHcTB3Ybhg+hyRcAQJUa5EXpK+oP0jJDO6cdue4G6TQiYAhsX9RY8AqDfp/L lAcDDPBSq8GUjGHrRj+CLC3OX/hgQ2XVryn71zYVWqqxRnAL6k9OdPDh05c6KhzL eCzFh5T3/2TJafgXV/rWctkubU5r0PtVZN3aOM+JFI09curX9daintauhz/DRC9P t7QwbE1OKaHXLmqTmOlpHEk8zJS1iIn4oWDROHAn1Tz65pb/PLRYbUCuD8S+QZae deovfkzroXRnBA== X-ME-Sender: X-ME-Proxy: From: Russell Currey To: linuxppc-dev@lists.ozlabs.org Cc: mpe@ellerman.id.au, benh@kernel.crashing.org, kernel-hardening@lists.openwall.com, christophe.leroy@c-s.fr, Russell Currey Subject: [PATCH 2/4] powerpc/64: Setup KUP before feature fixups Date: Fri, 23 Nov 2018 01:04:14 +1100 Message-Id: <20181122140416.3447-3-ruscur@russell.cc> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122140416.3447-1-ruscur@russell.cc> References: <20181122140416.3447-1-ruscur@russell.cc> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP The subsequent implementation of KUAP for radix makes use of a MMU feature in order to patch out assembly when KUAP is disabled or unsupported. This won't work unless there's an entry point for KUP support before the feature magic happens, so relocate setup_kup() earlier in setup. Signed-off-by: Russell Currey --- arch/powerpc/kernel/setup_64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 0f4e06ab70a5..cc20dc3e7b69 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -331,6 +331,12 @@ void __init early_setup(unsigned long dt_ptr) */ configure_exceptions(); + /* + * Configure Kernel Userspace Protection. This needs to happen before + * feature fixups for platforms that implement this using features. + */ + setup_kup(); + /* Apply all the dynamic patching */ apply_feature_fixups(); setup_feature_keys(); @@ -372,7 +378,6 @@ void __init early_setup(unsigned long dt_ptr) */ btext_map(); #endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */ - setup_kup(); } #ifdef CONFIG_SMP