From 9044b3fce410a9346f93e3b240babfe0e5cafb27 Mon Sep 17 00:00:00 2001 From: kettenis Date: Thu, 10 Nov 2022 16:14:50 +0000 Subject: [PATCH] Since the introduction of automatic immutable from the kernel, the munmap() of ld.so boot.text region is now (silently) failing because the region is contained within the text LOAD, which is immutable. So create a new btext LOAD with flags PF_X|PF_R|PF_OPENBSD_MUTABLE, and place all boot.text objects in there. This LOAD must also be page-aligned so it doesn't skip unmapping some of the object region, previously it was hilariously unaligned. ok kettenis and guenther seemed to like it also This one is for powerpc64 and a modified version of the diff deraadt@ mailed out to make sure the LOADs are in increasing address order. --- libexec/ld.so/powerpc64/ld.script | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libexec/ld.so/powerpc64/ld.script b/libexec/ld.so/powerpc64/ld.script index 96614bc9732..5e4546614c0 100644 --- a/libexec/ld.so/powerpc64/ld.script +++ b/libexec/ld.so/powerpc64/ld.script @@ -1,6 +1,7 @@ PHDRS { rodata PT_LOAD FILEHDR PHDRS FLAGS (4); + btext PT_LOAD FLAGS (0x08000005); text PT_LOAD; data PT_LOAD; random PT_OPENBSD_RANDOMIZE; @@ -23,11 +24,12 @@ SECTIONS . = ALIGN(0x10000); .boot.text : { + . = ALIGN(0x1000); boot_text_start = .; *(.boot.text) + . = ALIGN(0x1000); boot_text_end = .; - } :text - . = ALIGN(0x1000); + } :btext .text : { *(.text .text.*) } :text /* RELRO DATA */ -- 2.20.1