From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935698AbeE3GHP (ORCPT ); Wed, 30 May 2018 02:07:15 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:36140 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934498AbeE3GHM (ORCPT ); Wed, 30 May 2018 02:07:12 -0400 X-Google-Smtp-Source: ADUXVKLWOxAtmj0s2MfkhK00SXr6eUgcCFjYRWN05YNob024+G5uTGqC7yRsmGRHKM81VAzQjmXZwA7me7Cw8RZaZVY= MIME-Version: 1.0 In-Reply-To: <20180530055815.GB6463@gmail.com> References: <20180529133622.26982-1-nixiaoming@huawei.com> <20180530055815.GB6463@gmail.com> From: Ard Biesheuvel Date: Wed, 30 May 2018 08:07:10 +0200 Message-ID: Subject: Re: [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro To: Ingo Molnar Cc: nixiaoming , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Kristina Martsenko , Steve Capper , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Vlastimil Babka , Michal Hocko , Dave Hansen , "Williams, Dan J" , "Kirill A. Shutemov" , zhang.jia@linux.alibaba.com, Martin Schwidefsky , Heiko Carstens , Greg Kroah-Hartman , Linux Kernel Mailing List , linux-arm-kernel , "the arch/x86 maintainers" , linux-s390 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30 May 2018 at 07:58, Ingo Molnar wrote: > > * nixiaoming wrote: > >> mark_rodata_ro is only called by the function mark_readonly >> when CONFIG_STRICT_KERNEL_RWX=y >> >> if CONFIG_STRICT_KERNEL_RWX is not set >> a compile warning may be triggered: unused function >> >> Signed-off-by: nixiaoming >> --- >> arch/x86/mm/init_32.c | 2 ++ >> arch/x86/mm/init_64.c | 2 ++ >> 2 files changed, 4 insertions(+) >> >> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c >> index c893c6a..121c567 100644 >> --- a/arch/x86/mm/init_32.c >> +++ b/arch/x86/mm/init_32.c >> @@ -920,6 +920,7 @@ static void mark_nxdata_nx(void) >> set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT); >> } >> >> +#ifdef CONFIG_STRICT_KERNEL_RWX >> void mark_rodata_ro(void) >> { >> unsigned long start = PFN_ALIGN(_text); >> @@ -957,3 +958,4 @@ void mark_rodata_ro(void) >> if (__supported_pte_mask & _PAGE_NX) >> debug_checkwx(); >> } >> +#endif /*end of CONFIG_STRICT_KERNEL_RWX*/ >> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c >> index 0a40060..1b7a1a7 100644 >> --- a/arch/x86/mm/init_64.c >> +++ b/arch/x86/mm/init_64.c >> @@ -1245,6 +1245,7 @@ void set_kernel_text_ro(void) >> set_memory_ro(start, (end - start) >> PAGE_SHIFT); >> } >> >> +#ifdef CONFIG_STRICT_KERNEL_RWX >> void mark_rodata_ro(void) >> { >> unsigned long start = PFN_ALIGN(_text); >> @@ -1298,6 +1299,7 @@ void mark_rodata_ro(void) >> */ >> pti_clone_kernel_text(); >> } >> +#endif > > NAK, this is very ugly and the changelog doesn't appear to be true: the build > warning does not trigger in the default build, correct? > I don't see how the build warning could trigger at all, given that mark_rodata_ro() has external linkage.