clone on x64
create a child process
sys_clone(unsigned long clone_flags, unsigned long newsp, int *parent_tidptr, int *child_tidptr, unsigned long tls)
| number | 56 (0x38) |
|---|---|
| abi | common |
| entry point | sys_clone |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | clone(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 56, the syscall number |
rdi | unsigned long clone_flags |
rsi | unsigned long newsp |
rdx | int *parent_tidptr |
r10 | int *child_tidptr |
r8 | unsigned long tls |
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 120
- arm64 220
- arm 120
- riscv64 220
- ia32 120
- x32 1073741880
- loongarch64 220
- ppc64 120
- ppc 120
- s390x 120
- mips64 5055
- mipsn32 6055
- mipso32 4120
- alpha 312
- arc 220
- blackfin 120, removed in 4.17
- cris 120, removed in 4.17
- csky 220
- frv 120, removed in 4.17
- hexagon 220
- ia64 1128, removed in 6.7
- m32r 120, removed in 4.17
- m68k 120
- metag 220, removed in 4.17
- microblaze 120
- mn10300 120, removed in 4.17
- nds32 220, removed in 5.18
- nios2 220
- openrisc 220
- parisc 120
- score 220, removed in 4.17
- sh 120
- sparc 217
- sparc64 217
- tilegx 220, removed in 4.17
- tilepro 220, removed in 4.17
- xtensa 116
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/clone