Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/libexec/ld.elf_so



Module Name:    src
Committed By:   riastradh
Date:           Fri Apr 18 02:16:16 UTC 2025

Modified Files:
        src/libexec/ld.elf_so: reloc.c rtld.c

Log Message:
ld.elf_so(1): Defer RELRO a bit for eagerly-bound (-z now) programs.

GNU binutils links programs a little differently if they're eagerly
bound with -Wl,-z,now.  In particular, the part of the .got relocated
for ifuncs is covered by the RELRO region in eagerly-bound programs
(-z now), but not in lazily-bound programs (default).

Presumably this is done under the premise that eagerly-bound programs
will resolve all ifuncs at startup _before_ mprotecting the main
object's RELRO region.  But ld.elf_so was mprotecting it first, in
_rtld_do_copy_relocations, and then resolving ifuncs -- at which the
memory locations where it tries to write the resolutions will be
mapped read-only.

(In contrast, for lazily bound programs, ifuncs may also be resolved
lazily, so the locations they relocate are _not_ covered by the RELRO
region and we don't run into any trouble)

To avoid this trouble, for eagerly-bound programs, we defer the RELRO
mprotect of the main object by a little bit -- we move it from
_rtld_do_copy_relocations to just after _rtld_call_init_functions.

PR lib/57792: SIGSEGV in ld.elf_so / _rtld_call_ifunc


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/libexec/ld.elf_so/reloc.c
cvs rdiff -u -r1.218 -r1.219 src/libexec/ld.elf_so/rtld.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index