fchmodat¶
Intro¶
fchmodat - change permissions of a file relative to a directory file descriptor.
Description¶
The fchmodat()
system call allows changing the permissions of a specified file
or directory, similar to chmod()
.
However, fchmodat()
offers additional flexibility by operating relative to a
directory identified by a file descriptor. This feature proves useful,
especially when working with directory contexts where the absolute path to a
target file or directory isn't directly known or accessible.
Arguments¶
dirfd
:int
[K] - File descriptor pointing to the directory relative to which the pathname is interpreted.pathname
:const char *
[U] - The path of the file or directory whose permissions are to be changed.mode
:mode_t
[K] - A bitmask specifying the new permissions to be set for the file or directory.flags
:int
[K] - Flags that modify function behavior (e.g.,AT_SYMLINK_NOFOLLOW
ensures symbolic links aren't followed).
Permission Bits¶
S_ISUID (04000)
: Set-user-IDS_ISGID (02000)
: Set-group-IDS_ISVTX (01000)
: Sticky bitS_IRUSR (00400)
: Read by ownerS_IWUSR (00200)
: Write by ownerS_IXUSR (00100)
: Execute/search by ownerS_IRGRP (00040)
: Read by groupS_IWGRP (00020)
: Write by groupS_IXGRP (00010)
: Execute/search by groupS_IROTH (00004)
: Read by othersS_IWOTH (00002)
: Write by othersS_IXOTH (00001)
: Execute/search by others
Available Tags¶
- K - Originated from kernel-space.
- U - Originated from user space.
- TOCTOU - Vulnerable to TOCTOU (time of check, time of use).
- OPT - Optional argument - might not always be available (passed with null value).
Hooks¶
sys_fchmodat¶
Type¶
Tracepoint (through sys_enter
).
Purpose¶
To observe and capture instances of the fchmodat()
system call invocation,
detailing the file or directory targeted, and the new permissions being set.
Example Use Case¶
In security-centric environments, tracking permissions alterations of files and directories is pivotal to ensure consistent access controls and prevent unauthorized access.
Issues¶
Misuse of the fchmodat()
system call can unintentionally expose sensitive
files or directories, making them susceptible to unauthorized access or
tampering.
Related Events¶
chmod()
- Change permissions of a file.fchmod()
- Change permissions of a file through its file descriptor.
This document was automatically generated by OpenAI and reviewed by a Human.