Page MenuHomeFreeBSD

link_elf_obj: Apply protection based on section flags.

Authored by markj on Oct 4 2019, 4:12 PM.



Unlike the case of DSOs, we cannot assume that protection boundaries are
page-aligned. In this case, we must take the union of the protections
for the sections sharing a page.

There may also be gaps between sections. For instance, the VNET and
DPCPU sections are allocated separately and do not lie within the linker
file mapping. Such gaps are mapped with VM_PROT_READ.

As for link_elf.c, we initially map the file with VM_PROT_ALL and
downgrade once all relocations are processed.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj created this revision.Oct 4 2019, 4:12 PM
markj added reviewers: alc, kib.Oct 4 2019, 4:13 PM
kib added inline comments.Oct 4 2019, 5:33 PM
213 ↗(On Diff #62903)

This relies on KERN_SUCCES == 0, I always want more explicitness in handling Mach<->errno translation.

Also, when could vm_map_protect() above fail ?

markj added inline comments.Oct 4 2019, 6:40 PM
213 ↗(On Diff #62903)

In fact, it should be impossible for vm_map_protect() to fail here.

markj updated this revision to Diff 62917.Oct 4 2019, 7:29 PM

Assert that vm_map_protect() returns KERN_SUCCESS.

kib accepted this revision.Oct 4 2019, 7:46 PM
This revision is now accepted and ready to land.Oct 4 2019, 7:46 PM
This revision was automatically updated to reflect the committed changes.