fs: enforce path search and unify inode permission helpers - #19599
Conversation
e36afa6 to
a8f1284
Compare
|
a8f1284 to
6e313b4
Compare
|
@Abhishekmishra2808 why does MemBrowse is reporting firmware increasing size even when CONFIG_DISABLE_MOUNTPOINT is disabled? |
|
@acassis , The growth is not from mount code. Those boards also typically leave We can zero cost when CONFIG_FS_PERMISSION=n, and wrap those call sites in #ifdef CONFIG_FS_PERMISSION so the stubs disappear from the binary, right? |
Yes, I think removing these stubs when FS_PERMISSION is disabled it the right approach |
Require X_OK on path ancestors and mountpoint gates via inode_checkpathperm(), and use inode_checkperm() for inode mode checks. inode_checkpathperm() takes the inode tree read lock (or INODE_CHECK_LOCKED when the caller already holds it) and can fold a non-zero amode check onto the target inode in the same call. When CONFIG_FS_PERMISSION is disabled, inode_checkperm/inode_checkpathperm are empty macros returning 0 so there is no stub .text cost. Skip mountpoint R/W open-mode checks in inode_checkopenperm(); keep traversal separate from open. Add an optional mountpt_operations.permission hook (tmpfs when CONFIG_FS_PERMISSION) for in-volume DAC without making the VFS mount-crossing path depend on it. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Document inode_checkperm / inode_checkpathperm, mountpoint traverse vs open semantics, and the optional mountpt_operations.permission hook in file_permission.rst. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
6a24fc8 to
a2b1d0f
Compare
|
@acassis PTAL |
|
Thank you very much @Abhishekmishra2808 ! |
Summary
This change adds path-search permission checks
(inode_checksearchpath)so every ancestor and mountpoint gate must allow X_OK, and unifies inode mode checks oninode_permission().Mountpoint open no longer treats directory R/W bits as file open modes; traverse stays separate. An optional mountpt_operations.permission hook is added for in-volume DAC (tmpfs), without making VFS mount-crossing depend on it. Documentation describes the interface and mount-crossing behavior.Impact
A private pseudoFS parent can no longer be bypassed by opening paths under a filesystem mounted beneath it. Non-root access gets EACCES when parent/mount traverse is denied. Behavior is unchanged when
CONFIG_FS_PERMISSIONis off. Filesystems that leave permission NULL are unaffected beyond the new VFS traverse checks on the mountpoint inode.Testing
Non-root (euid=1000) denied access to a file under tmpfs mounted beneath a private (0700) pseudoFS directory - mount-crossing traverse enforcement.
Prints the secret (allowed under 0755).