From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6218BC433EF for ; Wed, 5 Jan 2022 03:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=o6NZZfdjele60b+ucbC0g6dUtzz+SMjAohcPV73NOtM=; b=n0k9O9XchR5NuJ /PiVGAz/pRsuLTwZTu0LERM88tQClMd6Nu5Mhnfji48jbtFLZ80H0CeucRPHS4Snv+mD1S4PH+3MI kMazxGc0p5uEKLZ8TGrYbCQbbq2X0y0UuKU6Rp5HwkPn9Y3TVvoDR1LHI+d5nELw+cl32oFehfX+r 124LfcV2cC9wo75xAH611yw+zD9lcPTcTqv66o9Ula+QiNkBwSCr6Po/Vh7j5HyMBWM/JpLQ6EEWk Vt2MPdisUqLW/sBpRgP4UGZ72y1NcM7bNGOaEoQft0aXtKrOXmVAEJHijAYlhI2alA/OCTGBNQZg8 SiKC4pMGc2L3SpDEnGnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4wen-00DPvQ-6Z; Wed, 05 Jan 2022 03:08:09 +0000 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4wej-00DPs0-FE for linux-arm-kernel@lists.infradead.org; Wed, 05 Jan 2022 03:08:07 +0000 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R331e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04395; MF=alios_sys_security@linux.alibaba.com; NM=1; PH=DS; RN=5; SR=0; TI=SMTPD_---0V1.8XrV_1641352079; Received: from localhost(mailfrom:alios_sys_security@linux.alibaba.com fp:SMTPD_---0V1.8XrV_1641352079) by smtp.aliyun-inc.com(127.0.0.1); Wed, 05 Jan 2022 11:08:00 +0800 From: AliOS system security To: catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AliOS system security Subject: [PATCH] arm64: fix build error when use rodata_enabled Date: Wed, 5 Jan 2022 11:07:55 +0800 Message-Id: <1641352075-25200-1-git-send-email-alios_sys_security@linux.alibaba.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220104_190805_722536_7F75559F X-CRM114-Status: GOOD ( 10.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org rodata_enabled should be used when CONFIG_STRICT_KERNEL_RWX or CONFIG_STRICT_MODULE_RWX is selected Signed-off-by: AliOS system security --- arch/arm64/mm/mmu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index acfae9b..47f8754 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -596,6 +596,7 @@ static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end, vm_area_add_early(vma); } +#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX) static int __init parse_rodata(char *arg) { int ret = strtobool(arg, &rodata_enabled); @@ -613,11 +614,16 @@ static int __init parse_rodata(char *arg) return 0; } early_param("rodata", parse_rodata); +#endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 static int __init map_entry_trampoline(void) { - pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; + pgprot_t prot = PAGE_KERNEL_EXEC; +#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX) + if (rodata_enabled) + prot = PAGE_KERNEL_ROX; +#endif phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start); /* The trampoline is always mapped and can therefore be global */ @@ -672,7 +678,11 @@ static void __init map_kernel(pgd_t *pgdp) * mapping to install SW breakpoints. Allow this (only) when * explicitly requested with rodata=off. */ - pgprot_t text_prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; + pgprot_t text_prot = PAGE_KERNEL_EXEC; +#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX) + if (rodata_enabled) + text_prot = PAGE_KERNEL_ROX; +#endif /* * If we have a CPU that supports BTI and a kernel built for -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel