pkey_mprotect on x64
set protection on a region of memory
sys_pkey_mprotect(unsigned long start, size_t len, unsigned long prot, int pkey)
| number | 329 (0x149) |
|---|---|
| abi | common |
| kconfig | CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS |
| family | pkeys see the whole family on x64 |
| entry point | sys_pkey_mprotect |
| since | Linux 4.9 |
| man page | pkey_mprotect(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 329, the syscall number |
rdi | unsigned long start |
rsi | size_t len |
rdx | unsigned long prot |
r10 | int pkey |
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 380
- arm64 288
- arm 394
- riscv64 288
- ia32 380
- x32 1073742153
- loongarch64 288
- ppc64 386
- ppc 386
- s390x 384
- mips64 5323
- mipsn32 6327
- mipso32 4363
- alpha 524
- arc 288
- csky 288
- hexagon 288
- ia64 1354, removed in 6.7
- m68k 381
- metag 288, removed in 4.17
- microblaze 395
- nds32 288, removed in 5.18
- nios2 288
- openrisc 288
- parisc 351
- score 288, removed in 4.17
- sh 384
- sparc 362
- sparc64 362
- tilegx 288, removed in 4.17
- tilepro 288, removed in 4.17
- xtensa 348
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/pkey_mprotect