Repository navigation
Fix three RAMFS/VFS bugs: kshell ls/find bypass READ, write-cap spin, VFS fd panic - #186
Merged
Merged
Conversation
…o VFS fd panic F1: kshell `ls` and `find` walked node->children directly, so any user could list root's 0711 `/` and `ls -l` a file stat refuses them. New primitive ramfs_list() requires READ on the directory listed or the file described; both commands go through it. Replaces the dead ramfs_list/ramfs_readdir. F2: ramfs_write() at the 64 KB cap returned 0 for a nonzero count (a write loop spins forever) and printed a kernel warning on every write crossing the cap. The short write is now silent; a write that cannot land a byte returns RAMFS_WRITE_EFBIG, surfaced to ring 3 as -EFBIG. F3: vfs_alloc_fd() panicked when a privileged caller exhausted the reserved pool -- reachable by root's ring-3 processes opening D:/ until refused. Returns VFS_ENFILE now; the reserved-pool kprintf is gone too. verify/verify-ramfs-vfs-fixes.sh: FAILs 5 assertions on the unfixed tree (listing leak, metadata leak, write=0, 2 warnings, panic), PASSes fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 4 of the audit series.
ls/findwalkednode->childrendirectly: any user listed root's 0711/andls -l'd files stat refuses. New listing primitiveramfs_list()enforces READ on the directory (and on a described file), matching ring 3's open/stat.ramfs_write()at the 64 KB cap returned 0 (write loops spin) and kprintf'd every cap-crossing write from ring 3. Silent short write;-EFBIGwhen nothing fits.vfs_alloc_fd()panicked on reserved-pool exhaustion, reachable by root ring-3 processes openingD:/repeatedly. Returns-ENFILE.Not done here (goes to the docs PR): directory opens still count against no per-uid cap, so one non-root user can fill the 58-slot primary VFS pool.
Test
verify/verify-ramfs-vfs-fixes.sh(newfdprobemodescapwrite,dirfill/dirhold):/scratchstill listed,next=-27, 64 opens then-23,idanswers)🤖 Generated with Claude Code