socket on x64
create an endpoint for communication
sys_socket(int family, int type, int protocol)
| number | 41 (0x29) |
|---|---|
| abi | common |
| entry point | sys_socket |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | socket(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 41, the syscall number |
rdi | int family |
rsi | int type |
rdx | int protocol |
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 359
- arm64 198
- arm 281
- riscv64 198
- ia32 359
- x32 1073741865
- loongarch64 198
- ppc64 326
- ppc 326
- s390x 359
- mips64 5040
- mipsn32 6040
- mipso32 4183
- alpha 97
- arc 198
- blackfin 329, removed in 4.17
- csky 198
- hexagon 198
- ia64 1190, removed in 6.7
- m68k 356
- metag 198, removed in 4.17
- microblaze 345
- nds32 198, removed in 5.18
- nios2 198
- openrisc 198
- parisc 17
- score 198, removed in 4.17
- sh 340
- sparc 97
- sparc64 97
- tilegx 198, removed in 4.17
- tilepro 198, removed in 4.17
- xtensa 96
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/socket