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 C9329C433EF for ; Wed, 5 Jan 2022 10:48:58 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bSoa5QSjAFtmIi3q6Ez9D4tcX3O7STL4gJhrb9ZLwsw=; b=pg3RNbtPFvntTk JG3yN/OBfRf8RjDyIqLDkhGUpMB3nXH2gSVSmtH6p/J7kTUlWF/zghjrha85+5Rc4dIyYgejkp6uK 2/4tGMD97CYzUyoFslfkmtnPn17KkKFo+VZ5BLUZ4XPgjacjeEhc7Z+Hyb0u1TtAKIqMGibavdj8k VpGTKyv8IJ0lLVZRUoS/FidtUDI4rM7P1oHsg/mqPjudFyQ7OVu75amKrTii+iIDZkDfFdmAbz9/s sspxiHnfi5JNLH3TZQDfi/KHktp1qemEyS/koVoMDulnSHxger3De2j4H6qt3A8Z+rOgI/JyZLY7P 394P9HE6QeRLyo/SIkFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n53pi-00EZok-3k; Wed, 05 Jan 2022 10:47:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n53pe-00EZml-5Y for linux-arm-kernel@lists.infradead.org; Wed, 05 Jan 2022 10:47:51 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 241401042; Wed, 5 Jan 2022 02:47:47 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.10.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF87B3F5A1; Wed, 5 Jan 2022 02:47:45 -0800 (PST) Date: Wed, 5 Jan 2022 10:47:35 +0000 From: Mark Rutland To: AliOS system security Cc: Anshuman Khandual , catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: fix build error when use rodata_enabled Message-ID: References: <1641352075-25200-1-git-send-email-alios_sys_security@linux.alibaba.com> <0432f592-789b-7c92-8d7a-99191d7bc669@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0432f592-789b-7c92-8d7a-99191d7bc669@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220105_024750_338618_113DDE43 X-CRM114-Status: GOOD ( 31.26 ) 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: , 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 On Wed, Jan 05, 2022 at 02:51:05PM +0530, Anshuman Khandual wrote: > Hello, > > On 1/5/22 8:37 AM, AliOS system security wrote: > > rodata_enabled should be used when CONFIG_STRICT_KERNEL_RWX > > or CONFIG_STRICT_MODULE_RWX is selected Further to Anshuman's comments here, for a build issue, please include the specific build error in the commit log, and describe the configuration where this manifests. For the reasons Anshuman gives below I do not see how this can be a problem in mainline. Thanks, Mark. > Both these configs get selected invariably with CONFIG_ARM64 in the > platform config file (arch/arm64/Kconfig). I guess there can not be > any such situation, where both configs will be missing/not selected > given ARCH_OPTIONAL_KERNEL_RWX[or _DEFAULT] is not enabled on arm64. > > config ARM64 > def_bool y > select ACPI_CCA_REQUIRED if ACPI > ..... > select ARCH_HAS_STRICT_KERNEL_RWX > select ARCH_HAS_STRICT_MODULE_RWX > ..... > > Hence for all practical purpose, rodata_enabled could be considered > always available. I am sure there other similar situations as well, > where code elements are not wrapped around if the config option is > always present. > > > > > Signed-off-by: AliOS system security > > Also please refer Documentation/process/submitting-patches.rst for > the rules regarding names, that can be used for a commit sign off. > > ------------------------------------------------------------------------ > then you just add a line saying:: > > Signed-off-by: Random J Developer > > using your real name (sorry, no pseudonyms or anonymous contributions.) > ------------------------------------------------------------------------ > > - Anshuman > > > --- > > 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 > > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel