Skip to content

fs/vfs: add parent-directory permission checks for unlink, mkdir and rename#18902

Open
Abhishekmishra2808 wants to merge 1 commit into
apache:masterfrom
Abhishekmishra2808:fs/inode-checkperm-vfs-ops
Open

fs/vfs: add parent-directory permission checks for unlink, mkdir and rename#18902
Abhishekmishra2808 wants to merge 1 commit into
apache:masterfrom
Abhishekmishra2808:fs/inode-checkperm-vfs-ops

Conversation

@Abhishekmishra2808
Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

Implemented pseudoFS permission enforcement for VFS mutation operations: unlink(), mkdir(), and rename().
This change introduces parent-directory permission validation using inode_checkdirperm() before modifying pseudoFS inode topology. Unauthorized operations now correctly return -EACCES based on effective uid/gid and inode mode bits.
The implementation preserves existing mountpoint filesystem behavior and correctly handles rename path-rewrite cases such as mv file dir/.

Impact

This extends pseudoFS permission enforcement by extending checks beyond open() into filesystem mutation paths. The update prevents unauthorized file removal, directory creation, and file renaming/moves

including bypass scenarios where rename operations could previously modify filesystem state without proper parent-directory permission checks.

Testing

image

ostest also passed

@Abhishekmishra2808 Abhishekmishra2808 changed the title Fs/inode checkperm vfs ops fs/vfs: add parent-directory permission checks for unlink, mkdir and rename May 19, 2026
@github-actions github-actions Bot added Area: File System File System issues Size: M The size of the change in this PR is medium labels May 19, 2026
Comment thread fs/vfs/fs_rename.c
Comment thread fs/inode/fs_inode.c
Comment thread fs/inode/fs_inode.c Outdated
Add pseudoFS permission enforcement for unlink(), mkdir(), and rename() VFS mutation operations.

This change validates parent-directory permissions before modifying pseudoFS inode topology and returns -EACCES for unauthorized operations.

The implementation preserves mountpoint filesystem behavior and fixes multiple inode lifetime/search-state issues in the rename path.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
@Abhishekmishra2808 Abhishekmishra2808 force-pushed the fs/inode-checkperm-vfs-ops branch from a90a4d0 to 0e9e246 Compare May 20, 2026 10:09
Comment thread fs/inode/fs_inode.c
Comment thread fs/inode/fs_inode.c
return OK;
}

if ((oflags & O_RDOK) != 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move out of if/else to avoid the dup with line 257-265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: File System File System issues Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants