<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:"Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
{font-family:"Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
text-autospace:none;
word-break:break-hangul;
font-size:10.0pt;
font-family:"Malgun Gothic";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Malgun Gothic";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Malgun Gothic";}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:3.0cm 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=KO link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hello all,<o:p></o:p></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). <o:p></o:p></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.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Symbol: ARCH_OPTIONAL_KERNEL_RWX [=n] <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Type : bool <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Defined at arch/Kconfig:928 <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=DE> Symbol: ARCH_OPTIONAL_KERNEL_RWX_DEFAULT [=n] <o:p></o:p></span></p><p class=MsoNormal><span lang=DE> </span><span lang=EN-US>Type : bool <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Defined at arch/Kconfig:931 <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> Symbol: STRICT_KERNEL_RWX [=y] <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Type : bool <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Defined at arch/Kconfig:937 <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Prompt: Make kernel text and rodata read-only <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Depends on: ARCH_HAS_STRICT_KERNEL_RWX [=y] <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Visible if: ARCH_HAS_STRICT_KERNEL_RWX [=y] && ARCH_OPTIONAL_KERNEL_RWX [=n] <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> Location: <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> (1) -> General architecture-dependent options <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></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. <o:p></o:p></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) <o:p></o:p></span></p><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. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>But when I build the kernel, I see this errors. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> ckim@ckim-ubuntu:~/ProjX/LinuxDevDrv/kernel-release-RD-INFRA-2020.11.30$ makeit<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CALL scripts/atomic/check-atomics.sh<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CALL scripts/checksyscalls.sh<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CHK include/generated/compile.h<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CC arch/arm64/mm/mmu.o<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> arch/arm64/mm/mmu.c: In function 'parse_rodata':<o:p></o:p></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)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> 595 | int ret = strtobool(arg, &rodata_enabled);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> | ^~~~~~~~~~~~~~<o:p></o:p></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<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> arch/arm64/mm/mmu.c: In function 'map_entry_trampoline':<o:p></o:p></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)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> 614 | pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> | ^~~~~~~~~~~~~~<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> arch/arm64/mm/mmu.c: In function 'map_kernel':<o:p></o:p></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)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> 669 | pgprot_t text_prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> | ^~~~~~~~~~~~~~<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> make[2]: *** [scripts/Makefile.build:283: arch/arm64/mm/mmu.o] Error 1<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> make[1]: *** [scripts/Makefile.build:500: arch/arm64/mm] Error 2<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> make: *** [Makefile:1799: arch/arm64] Error 2<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>variable “rodata_enabled” is defined in init/main.c as below. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> bool rodata_enabled __ro_after_init = true;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> static int __init set_debug_rodata(char *str)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> return strtobool(str, &rodata_enabled);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> __setup("rodata=", set_debug_rodata);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> #endif<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></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). <o:p></o:p></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?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></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.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Any comment will be really appreciated.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thank you!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Chan Kim<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>