mprotect on x64
set protection on a region of memory
sys_mprotect(unsigned long start, size_t len, unsigned long prot)
| number | 10 (0xa) |
|---|---|
| abi | common |
| entry point | sys_mprotect |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | mprotect(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 10, the syscall number |
rdi | unsigned long start |
rsi | size_t len |
rdx | unsigned long prot |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 125
- arm64 226
- arm 125
- riscv64 226
- ia32 125
- x32 1073741834
- loongarch64 226
- ppc64 125
- ppc 125
- s390x 125
- mips64 5010
- mipsn32 6010
- mipso32 4125
- alpha 74
- arc 226
- blackfin 125, removed in 4.17
- cris 125, removed in 4.17
- csky 226
- frv 125, removed in 4.17
- hexagon 226
- ia64 1155, removed in 6.7
- m32r 125, removed in 4.17
- m68k 125
- metag 226, removed in 4.17
- microblaze 125
- mn10300 125, removed in 4.17
- nds32 226, removed in 5.18
- nios2 226
- openrisc 226
- parisc 125
- score 226, removed in 4.17
- sh 125
- sparc 74
- sparc64 74
- tilegx 226, removed in 4.17
- tilepro 226, removed in 4.17
- xtensa 82
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/mprotect