MCPcopy Create free account
hub / github.com/F-Stack/f-stack / link_elf_protect_range

Function link_elf_protect_range

freebsd/kern/link_elf_obj.c:200–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198SYSINIT(link_elf_obj, SI_SUB_KLD, SI_ORDER_SECOND, link_elf_init, NULL);
199
200static void
201link_elf_protect_range(elf_file_t ef, vm_offset_t start, vm_offset_t end,
202 vm_prot_t prot)
203{
204 int error __unused;
205
206 KASSERT(start <= end && start >= (vm_offset_t)ef->address &&
207 end <= round_page((vm_offset_t)ef->address + ef->lf.size),
208 ("link_elf_protect_range: invalid range %#jx-%#jx",
209 (uintmax_t)start, (uintmax_t)end));
210
211 if (start == end)
212 return;
213 if (ef->preloaded) {
214#ifdef __amd64__
215 error = pmap_change_prot(start, end - start, prot);
216 KASSERT(error == 0,
217 ("link_elf_protect_range: pmap_change_prot() returned %d",
218 error));
219#endif
220 return;
221 }
222 error = vm_map_protect(kernel_map, start, end, prot, 0,
223 VM_MAP_PROTECT_SET_PROT);
224 KASSERT(error == KERN_SUCCESS,
225 ("link_elf_protect_range: vm_map_protect() returned %d", error));
226}
227
228/*
229 * Restrict permissions on linker file memory based on section flags.

Callers 2

link_elf_obj.cFile · 0.85
link_elf_link_preloadFunction · 0.85

Calls 2

vm_map_protectFunction · 0.85
pmap_change_protFunction · 0.50

Tested by

no test coverage detected