lchown on x64
change ownership of a file
sys_lchown(const char *filename, uid_t user, gid_t group)
| number | 94 (0x5e) |
|---|---|
| abi | common |
| entry point | sys_lchown |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | lchown(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 94, the syscall number |
rdi | const char *filename |
rsi | uid_t user |
rdx | gid_t group |
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 16
- arm 16
- ia32 16
- x32 1073741918
- ppc64 16
- ppc 16
- s390x 198
- mips64 5092
- mipsn32 6092
- mipso32 4016
- alpha 208
- blackfin 182, removed in 4.17
- cris 16, removed in 4.17
- frv 16, removed in 4.17
- ia64 1124, removed in 6.7
- m68k 182
- microblaze 16
- mn10300 16, removed in 4.17
- parisc 16
- score 1032, removed in 4.17
- sh 16
- sparc 16
- sparc64 16
- xtensa 48
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/lchown