<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 18 Mar 2022, 07:04 Chan Kim, <<a href="mailto:ckim@etri.re.kr">ckim@etri.re.kr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="KO" link="#0563C1" vlink="#954F72"><div class="m_2011487295401795956WordSection1"><p class="MsoNormal"><span lang="EN-US">Hello all,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">This is what I see when I search “KERNEL_RWX” during “make menuconfig” for arm64 kernel(5-10.0-rc5). <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">The Kconfig file says CONFIG_STRICT_KERNEL_RWX is for setting text and rodata read-only.</span></p><p class="MsoNormal"><span lang="EN-US"> Symbol: ARCH_OPTIONAL_KERNEL_RWX [=n] <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Type : bool <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Defined at arch/Kconfig:928 </span></p><p class="MsoNormal"><span lang="DE"> Symbol: ARCH_OPTIONAL_KERNEL_RWX_DEFAULT [=n] <u></u><u></u></span></p><p class="MsoNormal"><span lang="DE"> </span><span lang="EN-US">Type : bool <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Defined at arch/Kconfig:931 <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Symbol: STRICT_KERNEL_RWX [=y] <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Type : bool <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Defined at arch/Kconfig:937 <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Prompt: Make kernel text and rodata read-only <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Depends on: ARCH_HAS_STRICT_KERNEL_RWX [=y] <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Visible if: ARCH_HAS_STRICT_KERNEL_RWX [=y] && ARCH_OPTIONAL_KERNEL_RWX [=n] <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> Location: <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> (1) -> General architecture-dependent options </span></p><p class="MsoNormal"><span lang="EN-US">I wanted to try setting STRICT_KERNEL_RWX to =n. It says this option is visible when ARCH_OPTIONAL_KERNEL_RWX is =y which is now =n.</span></p></div></div></blockquote></div></div><div dir="auto">Now I'm a bit confused... why do you say that "It says this option is visible when ARCH_OPTIONAL_KERNEL_RWX is =y"?</div><div dir="auto"><br></div><div dir="auto"></div><div dir="auto">I haven't ever written Kbuild rules but as far as I understand that message "Symbol: STRICT_KERNEL_RWX [=y] [is] Visible if: ARCH_HAS_STRICT_KERNEL_RWX [=y] && ARCH_OPTIONAL_KERNEL_RWX [=n]" seems to say that we can see and enable/disable STRICT_KERNEL_RWX if and only if ARCH_HAS_STRICT_KERNEL_RWX is set to "yes" AND ARCH_OPTIONAL_KERNEL_RWX is set to "no".</div><div dir="auto"><br></div><div dir="auto">Is it me that I'm misunderstanding the above-mentioned message from "make menuconfig"?</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="KO" link="#0563C1" vlink="#954F72"><div class="m_2011487295401795956WordSection1"><p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">So I modified to ARCH_OPTIONAL_KERNEL_RWX=y in arch/Kconfig line 928. (BTW, is it correct to modify this Kconfig file directly? I’m not sure at the moment)</span></p></div></div></blockquote></div></div><div dir="auto">For sure, I'd never do this. Why don't you simply use make menuconfig for enabling/disabling options? Options are strictly interrelated and largely depend on others. Why do you want to bypass dependency checks?</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="KO" link="#0563C1" vlink="#954F72"><div class="m_2011487295401795956WordSection1"><p class="MsoNormal"><span lang="EN-US">Then I could see the STRICT_KERNEL_RWX menu in the menuconfig and I set it to =n as I wanted. <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">But when I build the kernel, I see this errors. </span></p></div></div></blockquote></div></div><div dir="auto">Again, if it's not me that I'm missing something, the following errors are simply explained by your weird way to enable/disable options.</div><div dir="auto"><br></div><div dir="auto">Please correct me if I didn't get something that you wrote (I'm very tired now after a long night staying awoke :))</div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto"><br></div><div dir="auto">Fabio M. De Francesco</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="KO" link="#0563C1" vlink="#954F72"><div class="m_2011487295401795956WordSection1"><p class="MsoNormal"><span lang="EN-US"> ckim@ckim-ubuntu:~/ProjX/LinuxDevDrv/kernel-release-RD-INFRA-2020.11.30$ makeit<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> CALL scripts/atomic/check-atomics.sh<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> CALL scripts/checksyscalls.sh<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> CHK include/generated/compile.h<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> CC arch/arm64/mm/mmu.o<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c: In function 'parse_rodata':<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c:595:28: error: 'rodata_enabled' undeclared (first use in this function)<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> 595 | int ret = strtobool(arg, &rodata_enabled);<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> | ^~~~~~~~~~~~~~<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c:595:28: note: each undeclared identifier is reported only once for each function it appears in<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c: In function 'map_entry_trampoline':<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c:614:18: error: 'rodata_enabled' undeclared (first use in this function)<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> 614 | pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> | ^~~~~~~~~~~~~~<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c: In function 'map_kernel':<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> arch/arm64/mm/mmu.c:669:23: error: 'rodata_enabled' undeclared (first use in this function)<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> 669 | pgprot_t text_prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> | ^~~~~~~~~~~~~~<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> make[2]: *** [scripts/Makefile.build:283: arch/arm64/mm/mmu.o] Error 1<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> make[1]: *** [scripts/Makefile.build:500: arch/arm64/mm] Error 2<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> make: *** [Makefile:1799: arch/arm64] Error 2</span></p><p class="MsoNormal"><span lang="EN-US">variable “rodata_enabled” is defined in init/main.c as below.</span></p><p class="MsoNormal"><span lang="EN-US"> #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> bool rodata_enabled __ro_after_init = true;<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> static int __init set_debug_rodata(char *str)<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> {<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> return strtobool(str, &rodata_enabled);<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> }<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> __setup("rodata=", set_debug_rodata);<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"> #endif</span></p><p class="MsoNormal"><span lang="EN-US">But now since CONFIG_STRICT_KERNEL_RWX=n, it is not defined here(CONFIG_STRICT_MODULE_RWX=n too). <u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">and arch/arm64/mm/mmu.c code is still using `rodata_enabled`. Is this a bug of the code? Or am I missing something?</span></p><p class="MsoNormal"><span lang="EN-US">I can modify init/main.c and include/linux/init.h so that this rodata_enabled and related functions be defined regardless of these CONFIG values and make the errors go away, but I’m curious if this a kind of kernel bug raising compiler error.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">Any comment will be really appreciated.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">Thank you!<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Chan Kim<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p></div></div>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank" rel="noreferrer">Kernelnewbies@kernelnewbies.org</a><br>
<a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div></div></div>