socketpair on x64
create a pair of connected sockets
sys_socketpair(int family, int type, int protocol, int *usockvec)
| number | 53 (0x35) |
|---|---|
| abi | common |
| entry point | sys_socketpair |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | socketpair(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 53, the syscall number |
rdi | int family |
rsi | int type |
rdx | int protocol |
r10 | int *usockvec |
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 360
- arm64 199
- arm 288
- riscv64 199
- ia32 360
- x32 1073741877
- loongarch64 199
- ppc64 333
- ppc 333
- s390x 360
- mips64 5052
- mipsn32 6052
- mipso32 4184
- alpha 135
- arc 199
- blackfin 330, removed in 4.17
- csky 199
- hexagon 199
- ia64 1197, removed in 6.7
- m68k 357
- metag 199, removed in 4.17
- microblaze 346
- nds32 199, removed in 5.18
- nios2 199
- openrisc 199
- parisc 56
- score 199, removed in 4.17
- sh 347
- sparc 135
- sparc64 135
- tilegx 199, removed in 4.17
- tilepro 199, removed in 4.17
- xtensa 112
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/socketpair