Page MenuHomeFreeBSD

link_elf_obj: Apply protection based on section flags.
ClosedPublic

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

Details

Summary

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

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

Event Timeline

markj created this revision.Fri, Oct 4, 4:12 PM
markj added reviewers: alc, kib.Fri, Oct 4, 4:13 PM
kib added inline comments.Fri, Oct 4, 5:33 PM
sys/kern/link_elf_obj.c
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.Fri, Oct 4, 6:40 PM
sys/kern/link_elf_obj.c
213 ↗(On Diff #62903)

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

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

Assert that vm_map_protect() returns KERN_SUCCESS.

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