prctl on x64
operations on a process or thread
sys_prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
| number | 157 (0x9d) |
|---|---|
| abi | common |
| entry point | sys_prctl |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | prctl(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 157, the syscall number |
rdi | int option |
rsi | unsigned long arg2 |
rdx | unsigned long arg3 |
r10 | unsigned long arg4 |
r8 | unsigned long arg5 |
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 172
- arm64 167
- arm 172
- riscv64 167
- ia32 172
- x32 1073741981
- loongarch64 167
- ppc64 171
- ppc 171
- s390x 172
- mips64 5153
- mipsn32 6153
- mipso32 4192
- alpha 348
- arc 167
- blackfin 172, removed in 4.17
- cris 172, removed in 4.17
- csky 167
- frv 172, removed in 4.17
- hexagon 167
- ia64 1170, removed in 6.7
- m32r 172, removed in 4.17
- m68k 172
- metag 167, removed in 4.17
- microblaze 172
- mn10300 172, removed in 4.17
- nds32 167, removed in 5.18
- nios2 167
- openrisc 167
- parisc 172
- score 167, removed in 4.17
- sh 172
- sparc 147
- sparc64 147
- tilegx 167, removed in 4.17
- tilepro 167, removed in 4.17
- xtensa 130
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/prctl