---
name: "vm_map_protect"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/vm_map_protect"
---

# vm\_map\_protect(9)

apply protection bits to a virtual memory region

## 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*, *boolean\_t set\_max*);

## DESCRIPTION

The **vm\_map\_protect**() function sets the protection bits of the address region bounded by *start* and *end* within the map *map* to *new\_prot*.

If *set\_max* is TRUE, *new\_prot* is treated as the new *max\_protection* setting for each underlying entry. Otherwise, only the *protection* field is affected.

The range MUST be contiguous, and MUST NOT contain sub-maps.

## IMPLEMENTATION NOTES

The function acquires a lock on the *map* for the duration, by calling [vm\_map\_lock(9)](/vm_map_lock/9.md).

## RETURN VALUES

The **vm\_map\_protect**() function returns KERN\_SUCCESS if the protection bits could be set successfully.

If a sub-map entry was encountered in the range, KERN\_INVALID\_ARGUMENT is returned. If the value of *new\_prot* would exceed *max\_protection* for an entry within the range, KERN\_PROTECTION\_FAILURE is returned.

## SEE ALSO

[vm\_map(9)](/vm_map/9.md)

## AUTHORS

This manual page was written by Bruce M Simpson ⟨bms@spc.org⟩.
