<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br><div><br><blockquote type="cite"><div>On 10-Jan-2023, at 6:17 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:</div><br class="Apple-interchange-newline"><div><div>If a relocatable kernel is loaded at a non-zero address and told not to<br>relocate to zero (kdump or RELOCATABLE_TEST), the mapping of the<br>interrupt code at zero is left with RWX permissions.<br><br>That is a security weakness, and leads to a warning at boot if<br>CONFIG_DEBUG_WX is enabled:<br><br> powerpc/mm: Found insecure W+X mapping at address 00000000056435bc/0xc000000000000000<br> WARNING: CPU: 1 PID: 1 at arch/powerpc/mm/ptdump/ptdump.c:193 note_page+0x484/0x4c0<br> CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc1-00001-g8ae8e98aea82-dirty #175<br> Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1202 0xf000005 of:SLOF,git-dd0dca hv:linux,kvm pSeries<br> NIP: c0000000004a1c34 LR: c0000000004a1c30 CTR: 0000000000000000<br> REGS: c000000003503770 TRAP: 0700 Not tainted (6.2.0-rc1-00001-g8ae8e98aea82-dirty)<br> MSR: 8000000002029033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 24000220 XER: 00000000<br> CFAR: c000000000545a58 IRQMASK: 0<br> ...<br> NIP note_page+0x484/0x4c0<br> LR note_page+0x480/0x4c0<br> Call Trace:<br> note_page+0x480/0x4c0 (unreliable)<br> ptdump_pmd_entry+0xc8/0x100<br> walk_pgd_range+0x618/0xab0<br> walk_page_range_novma+0x74/0xc0<br> ptdump_walk_pgd+0x98/0x170<br> ptdump_check_wx+0x94/0x100<br> mark_rodata_ro+0x30/0x70<br> kernel_init+0x78/0x1a0<br> ret_from_kernel_thread+0x5c/0x64<br><br>The fix has two parts. Firstly the pages from zero up to the end of<br>interrupts need to be marked read-only, so that they are left with R-X<br>permissions. Secondly the mapping logic needs to be taught to ensure<br>there is a page boundary at the end of the interrupt region, so that the<br>permission change only applies to the interrupt text, and not the region<br>following it.<br><br>Fixes: c55d7b5e6426 ("powerpc: Remove STRICT_KERNEL_RWX incompatibility with RELOCATABLE")<br>Signed-off-by: Michael Ellerman <mpe@ellerman.id.au><br>---<br></div></div></blockquote><div><br></div>Thanks Michael. This fixes the problem reported earlier</div><div><br></div><div>https://lore.kernel.org/linuxppc-dev/48206911-FD3D-401A-A69D-1A79403E79E2@linux.ibm.com/</div><div><br></div><div>Reported-by: Sachin Sant <sachinp@linux.ibm.com></div><div>Tested-by: <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Sachin Sant <</span>sachinp@linux.ibm.com<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">></span></div><div><br></div><div><font color="#000000"><span style="caret-color: rgb(0, 0, 0);">- Sachin</span></font></div></body></html>