Skip to content

Fix three RAMFS/VFS bugs: kshell ls/find bypass READ, write-cap spin, VFS fd panic - #186

Merged
douglasmun merged 1 commit into
mainfrom
fix/ramfs-vfs-fixes
Oct 11, 2026
Merged

douglasmun merged 1 commit into
mainfrom
fix/ramfs-vfs-fixes

Conversation

@douglasmun

Copy link
Copy Markdown
Owner

PR 4 of the audit series.

  • F1 kshell ls/find walked node->children directly: any user listed root's 0711 / and ls -l'd files stat refuses. New listing primitive ramfs_list() enforces READ on the directory (and on a described file), matching ring 3's open/stat.
  • F2 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; -EFBIG when nothing fits.
  • F3 vfs_alloc_fd() panicked on reserved-pool exhaustion, reachable by root ring-3 processes opening D:/ 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 (new fdprobe modes capwrite, dirfill/dirhold):

  • unfixed: FAIL, 5 assertions (zzsecret listed, rootfile metadata shown, cap write = 0, 2 warnings, panic)
  • fixed: PASS (refusals printed, /scratch still listed, next=-27, 64 opens then -23, id answers)

🤖 Generated with Claude Code

…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>
@douglasmun
douglasmun merged commit 7cf5fbf into main Oct 11, 2026
2 checks passed
@douglasmun
douglasmun deleted the fix/ramfs-vfs-fixes branch October 11, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant