kernel/fs: Introduce check_write_stat_permissions utility method.

Like check_access_permissions() but for write_stat() hook instead
of access().

Basic logic copied from BFS, but with the UID/GID logic rewritten
to better conform to behavior on other OSes: notably, we allow
chown() requests that keep the UID the same to go through, same
as Linux seems to, which should fix #19666. We now also validate
that the GID is one of the current team's groups.
This commit is contained in:
Augustin Cavalier
2025-07-07 15:10:01 -04:00
parent 7ed202f9ed
commit 9ea1065b16
5 changed files with 103 additions and 0 deletions
+3
View File
@@ -331,8 +331,11 @@ extern status_t unremove_vnode(fs_volume* volume, ino_t vnodeID);
extern status_t get_vnode_removed(fs_volume* volume, ino_t vnodeID,
bool* _removed);
extern fs_volume* volume_for_vnode(fs_vnode* vnode);
extern status_t check_access_permissions(int accessMode, mode_t mode,
gid_t nodeGroupID, uid_t nodeUserID);
extern status_t check_write_stat_permissions(gid_t nodeGroupID, uid_t nodeUserID,
mode_t nodeMode, uint32 mask, const struct stat* stat);
extern status_t read_pages(int fd, off_t pos, const struct iovec* vecs,
size_t count, size_t* _numBytes);