1.\" $OpenBSD: mimmutable.2,v 1.5 2024/01/21 17:46:03 deraadt Exp $ 2.\" 3.\" Copyright (c) 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)mimmutable.2 8.1 (Berkeley) 6/9/93 31.\" 32.Dd $Mdocdate: January 21 2024 $ 33.Dt MIMMUTABLE 2 34.Os 35.Sh NAME 36.Nm mimmutable 37.Nd control the immutability of pages 38.Sh SYNOPSIS 39.In sys/mman.h 40.Ft int 41.Fn mimmutable "void *addr" "size_t len" 42.Sh DESCRIPTION 43The 44.Fn mimmutable 45system call 46changes currently mapped pages in the region to be marked immutable, 47which means their protection or mapping may not be changed in the future. 48Most requests to 49.Xr madvise 2 , 50.Xr minherit 2 , 51.Xr mmap 2 , 52.Xr mprotect 2 , 53.Xr msync 2 , and 54.Xr munmap 2 55to pages marked immutable will return with error 56.Er EPERM . 57.Pp 58Unmapped pages in the region do not retain immutability, but this 59behaviour should not be relied upon. 60.Pp 61Not all implementations will guarantee that the immutable characteristic 62can be set on a page basis; 63the granularity of changes may be as large as an entire region. 64.Sh RETURN VALUES 65.Rv -std 66.Sh ERRORS 67The 68.Fn mimmutable 69system call will fail if: 70.Bl -tag -width Er 71.It Bq Er EINVAL 72The virtual address range specified by the 73.Fa addr 74and 75.Fa len 76arguments is not valid. 77.It Bq Er EPERM 78At least one page has inheritance of 79.Dv MAP_INHERIT_ZERO . 80.El 81.Sh SEE ALSO 82.Xr minherit 2 , 83.Xr mmap 2 , 84.Xr mprotect 2 , 85.Xr munmap 2 86.Sh HISTORY 87The 88.Fn mimmutable 89function first appeared in 90.Ox 7.3 . 91