add_key on x64
add a key to the kernel's key management facility
sys_add_key(const char *_type, const char *_description, const void *_payload, size_t plen, key_serial_t destringid)
| number | 248 (0xf8) |
|---|---|
| abi | common |
| kconfig | CONFIG_KEYS |
| family | keys see the whole family on x64 |
| entry point | sys_add_key |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | add_key(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 248, the syscall number |
rdi | const char *_type |
rsi | const char *_description |
rdx | const void *_payload |
r10 | size_t plen |
r8 | key_serial_t destringid |
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 286
- arm64 217
- arm 309
- riscv64 217
- ia32 286
- x32 1073742072
- loongarch64 217
- ppc64 269
- ppc 269
- s390x 278
- mips64 5239
- mipsn32 6243
- mipso32 4280
- alpha 439
- arc 217
- blackfin 286, removed in 4.17
- cris 286, removed in 4.17
- csky 217
- frv 286, removed in 4.17
- hexagon 217
- ia64 1271, removed in 6.7
- m32r 286, removed in 4.17
- m68k 279
- metag 217, removed in 4.17
- microblaze 286
- mn10300 286, removed in 4.17
- nds32 217, removed in 5.18
- nios2 217
- openrisc 217
- parisc 264
- score 217, removed in 4.17
- sh 285
- sparc 281
- sparc64 281
- tilegx 217, removed in 4.17
- tilepro 217, removed in 4.17
- xtensa 256
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/add_key