Page MenuHomeFreeBSD

rtld: When relocating, map without PROT_EXEC
ClosedPublic

Authored by emaste on Jan 4 2021, 5:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 4 2024, 10:49 PM
Unknown Object (File)
Oct 4 2024, 3:04 PM
Unknown Object (File)
Oct 2 2024, 6:01 AM
Unknown Object (File)
Oct 2 2024, 3:48 AM
Unknown Object (File)
Oct 2 2024, 2:19 AM
Unknown Object (File)
Sep 29 2024, 6:38 AM
Unknown Object (File)
Sep 28 2024, 7:24 PM
Unknown Object (File)
Sep 27 2024, 7:39 AM
Subscribers

Details

Summary

This makes text segment relocation work under W^X.


I have encountered this when loading lucet-compiled shared objects with W^X (D24933).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

libexec/rtld-elf/rtld.c
2986–2987

maybe clearer if we incorporate the PROT_WRITE part from above?

something like

prot = convert_prot(ph->p_flags);
if (before)
        prot = prot & ~PROT_EXEC | PROT_WRITE;
libexec/rtld-elf/rtld.c
2986–2987

There is no much reason to use convert_prot() in'before' case at all, then. Only PF_R survives. It can be

prot = before ? (PROT_READ | PROT_WRITE) : convert_prot(ph->p_flags);
emaste updated this revision to Diff 81672.
emaste edited reviewers, added: val_packett.cool; removed: emaste.

Update per kib's suggestion

This revision is now accepted and ready to land.Jan 5 2021, 3:04 PM
This revision was automatically updated to reflect the committed changes.