Page MenuHomeFreeBSD

rtld: Support multiple PT_GNU_RELRO program headers
ClosedPublic

Authored by jhb on Tue, Dec 3, 6:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 10:28 AM
Unknown Object (File)
Sun, Dec 8, 8:21 AM
Unknown Object (File)
Fri, Dec 6, 10:39 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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Tue, Dec 3, 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.Wed, Dec 4, 11:13 PM