MPROTECT(2)
π MPROTECT(2) β it's giving "system calls manual" β¨
okay bestie, welcome to mprotect β the System Calls Manual page that lets you change what your memory is allowed to do. protection? we're controlling it. periodt.
π NAME π
mprotect β control the protection of pages
π LIBRARY π
Standard C Library (libc, -lc)
β¨ SYNOPSIS β¨
#include <sys/mman.h>
int
mprotect(void *addr, size_t len, int prot);
π¦ DESCRIPTION π¦
so like. the mprotect() system call changes the specified pages so they have protection prot. that's the whole vibe. π₯
ngl tho, not every implementation is gonna guarantee protection on a page basis β the granularity of protection changes can be as large as an entire region. and a region? it's the virtual address space defined by the start and end addresses of a struct vm_map_entry. iykyk.
currently these protection bits are known, and you can combine them, OR'd together:
PROT_NONEβ No permissions at all. literally none. πPROT_READβ The pages can be read.PROT_WRITEβ The pages can be written.PROT_EXECβ The pages can be executed.
π RETURN VALUES π
the mprotect() function returns the value 0 if successful β slay. otherwise the value -1 is returned and the global variable errno is set to indicate the error. not slay. π
π ERRORS π
the mprotect() system call will fail if:
[EACCES]β The calling process was not allowed to change the protection to the value specified by theprotargument. bestie you do NOT have permission π[EINVAL]β The virtual address range specified by theaddrandlenarguments is not valid.
π SEE ALSO π
madvise(2), mincore(2), msync(2), munmap(2)
π HISTORY π
the mprotect() system call first appeared in 4.4BSD. iconic behavior, honestly. β
π«Ά and that's the whole page, bestie!! this one's from Debian, dated August 3, 2016 β go protect some pages, main character energy only. πβ¨πΈ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms