MIMMUTABLE(2)

NAME
mimmutable - control the immutability of pages

SYNOPSIS
#include <sys/mman.h>
int
mimmutable(void *addr, size_t len);

DESCRIPTION
The mimmutable() system call changes currently mapped pages in the region to be marked immutable, which means their protection or mapping may not be changed in the future. mmap(2), mprotect(2), and munmap(2) to pages marked immutable will return with error EPERM.

Unmapped pages in the region do not retain immutability, but this behaviour should not be relied upon.

Not all implementations will guarantee that the immutable characteristic can be set on a page basis; the granularity of changes may be as large as an entire region.

Immutability cannot be set on regions marked with minherit(2) MAP_INHERIT_ZERO.

RETURN VALUES

ERRORS
The mimmutable() system call will fail if:

[EINVAL]
    The virtual address range specified by the addr and len arguments is not valid.

SEE ALSO
mmap(2), mprotect(2), munmap(2)

HISTORY
The mimmutable() function first appeared in OpenBSD 7.3.

CAVEATS
At present, mprotect(2) may reduce permissions on immutable pages marked PROT_READ | PROT_WRITE to the less permissive PROT_READ. This one-way operation is permitted for an introductory period to observe how software uses this mechanism. It may change to require explicit mutable region annotation with __attribute__((section(".openbsd.mutable"))) and explicit calls to mimmutable().