Page MenuHomeFreeBSD

rtld: Support multiple PT_GNU_RELRO program headers
ClosedPublic

Authored by jhb on Dec 3 2024, 6:53 PM.
Tags
None
Referenced Files
F151368780: D47884.diff
Tue, Apr 7, 10:33 PM
Unknown Object (File)
Sat, Apr 4, 10:57 PM
Unknown Object (File)
Mon, Mar 30, 7:14 AM
Unknown Object (File)
Mon, Mar 30, 12:38 AM
Unknown Object (File)
Sun, Mar 29, 4:03 AM
Unknown Object (File)
Mar 5 2026, 5:11 AM
Unknown Object (File)
Mar 4 2026, 10:44 PM
Unknown Object (File)
Mar 3 2026, 7:19 PM
Subscribers

Details

Summary

Iterate over all the program headers in obj_remap_relro and remove the
relro fields from Obj_Entry.

Skip the call to obj_enforce_relro() in relocate_object() for the rtld
object as well as the main program object. obj_enforce_relro() is
called later when it safe to reference globals such as page_size.

Obtained from: CheriBSD

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 60962
Build 57846: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Dec 3 2024, 6:53 PM
libexec/rtld-elf/rtld.c
5911

I think I picked the wrong one of the 3 copies of this and that this should be:

relro_size = rtld_trunc_page(ph->p_vaddr + ph->p_memsz) -
	      rtld_trunc_page(ph->p_vaddr);
libexec/rtld-elf/rtld.c
5911

Not

relro_size = rtld_round_page(ph->p_vaddr + ph->p_memsz) -
	      rtld_trunc_page(ph->p_vaddr);

?

libexec/rtld-elf/map_object.c
327

This should have used rtld_round_page

libexec/rtld-elf/rtld.c
1677

This should have used rtld_round_page

2375

This is missing adding the sub-page offset of ph->p_vaddr to to the input to rtld_round_page

5911

Geeze, yeah, I guess all 3 versions were broken in some fashion then.

This revision is now accepted and ready to land.Dec 4 2024, 11:13 PM