pivot_root on x64
change the root mount
sys_pivot_root(const char *new_root, const char *put_old)
| number | 155 (0x9b) |
|---|---|
| abi | common |
| entry point | sys_pivot_root |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | pivot_root(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 155, the syscall number |
rdi | const char *new_root |
rsi | const char *put_old |
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 217
- arm64 41
- arm 218
- riscv64 41
- ia32 217
- x32 1073741979
- loongarch64 41
- ppc64 203
- ppc 203
- s390x 217
- mips64 5151
- mipsn32 6151
- mipso32 4216
- alpha 374
- arc 41
- blackfin 217, removed in 4.17
- cris 217, removed in 4.17
- csky 41
- frv 217, removed in 4.17
- hexagon 41
- ia64 1207, removed in 6.7
- m32r 217, removed in 4.17
- m68k 217
- metag 41, removed in 4.17
- microblaze 217
- mn10300 217, removed in 4.17
- nds32 41, removed in 5.18
- nios2 41
- openrisc 41
- parisc 67
- score 41, removed in 4.17
- sh 217
- sparc 146
- sparc64 146
- tilegx 41, removed in 4.17
- tilepro 41, removed in 4.17
- xtensa 175
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/pivot_root