]> git.ipfire.org Git - thirdparty/glibc.git/commit
linux: Add support for PT_GNU_MUTABLE azanella/memory-seal-v6
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 21 Feb 2025 15:53:07 +0000 (12:53 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 7 Mar 2025 11:46:49 +0000 (08:46 -0300)
commit5624d626dbf1dfa072941befeaf687cdabba4893
tree0593e11debd571066fbfe56a5326208730b37cc4
parent815beee47c1c42e1b7bd5a1ce7b6a34c2013d3dc
linux: Add support for PT_GNU_MUTABLE

The section mark a memory region that should not be sealed if
GNU_PROPERTY_MEMORY_SEAL attribute is present.  PT_GNU_MUTABLE
section names start with ".gnu.mutable" and are maximum page
aligned and have a size of maximum page size.

For instance the code:

  #define GNU_MUTABLE_SECTION_NAME       ".gnu.mutable"

  unsigned char mutable_array1[64]
    __attribute__ ((section (GNU_MUTABLE_SECTION_NAME)))
       = { 0 };
  unsigned char mutable_array2[32]
    __attribute__ ((section (GNU_MUTABLE_SECTION_NAME)))
       = { 0 };

places both 'mutable_array1' and 'mutable_array2' on a page
aligned memory region in a size of a page (the alignment and size
can be change with -Wl,-z,max-page-size= linker option).

The linker sets the alignment and size to make it easier to
loader to avoid sealing the area (since mseal only work on
multiple of page size areas), and to simplify the userland
process to change protection of either seal the area after
initialization.
12 files changed:
elf/dl-load.c
elf/dl-reloc.c
elf/dl-support.c
elf/elf.h
elf/rtld.c
include/link.h
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/tst-dl_mseal-mutable-dlopen.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/tst-dl_mseal-mutable-mod.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/tst-dl_mseal-mutable-mod.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/tst-dl_mseal-mutable-static.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/tst-dl_mseal-mutable.c [new file with mode: 0644]