FreeBSD manual
download PDF document: vm_map_protect.9.pdf
VM_MAP_PROTECT(9) FreeBSD Kernel Developer's Manual VM_MAP_PROTECT(9)
NAME
vm_map_protect - apply protection bits to a virtual memory region
SYNOPSIS
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
int
vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
vm_prot_t new_prot, vm_prot_t new_maxprot, int flags);
DESCRIPTION
The vm_map_protect() function sets the protection bits and maximum
protection bits of the address region bounded by start and end within the
map map.
If the flags argument has the VM_MAP_PROTECT_SET_PROT bit set, then the
effective protection is set to new_prot.
If the flags argument has the VM_MAP_PROTECT_SET_MAXPROT bit set, then
the maximum protection is set to new_maxprot. Protection bits not
included into new_maxprot will be cleared from existing entries.
The values specified by new_prot and new_maxprot are not allowed to
include any protection bits that are not set in existing max_protection
on every entry within the range. The operation will fail if this
condition is violated. For instance, this prevents upgrading a shared
mapping of a read-only file from read-only to read-write.
The specified range must not contain sub-maps.
IMPLEMENTATION NOTES
The function acquires a lock on the map for the duration, by calling
vm_map_lock(9). Also, any in-progress wiring operation on the map
affecting the specified range will cause vm_map_protect to sleep, waiting
for completion.
RETURN VALUES
KERN_SUCCESS The specified protection bits were set
successfully.
KERN_INVALID_ARGUMENT A sub-map entry was encountered in the range,
KERN_PROTECTION_FAILURE The value of new_prot or new_maxprot exceed
max_protection for an entry within the range.
KERN_PROTECTION_FAILURE The map does not allow simultaneous setting
of write and execute permissions, but
new_prot has both VM_PROT_WRITE and
VM_PROT_EXECUTE set.
KERN_RESOURCE_SHORTAGE A copy-on-write mapping is transitioned from
read-only to read-write, and not enough swap
space is available to back the copied pages.
KERN_OUT_OF_BOUNDS Both new protection and new maximum
AUTHORS
This manual page was written by Bruce M Simpson <bms@spc.org>.
FreeBSD 14.0-RELEASE-p11 January 23, 2021 FreeBSD 14.0-RELEASE-p11