Skip to content

pipes, vfs: per-uid shares of the pipe table and the VFS descriptor table - #191

Merged
douglasmun merged 1 commit into
mainfrom
fix/uid-caps-pipes-dirs
Oct 11, 2026
Merged

douglasmun merged 1 commit into
mainfrom
fix/uid-caps-pipes-dirs

Conversation

@douglasmun

Copy link
Copy Markdown
Owner

Closes the two per-uid gaps that doc/SECURITY_AUDIT_2026-10.md §3 listed as open.

What was wrong

  • Pipes: pipe_table[8] had no per-uid share. One user holding all 8 made every other user's PIPE_OP_CREATE fail with -EMFILE.
  • Directory opens: a ramfs directory open takes no ramfs fd, so the ramfs per-uid cap never applied to it. One user's processes could fill the VFS primary pool and starve every other user's opens.

Fix

  • sys_pipe CREATE: a non-root uid holding 4 pipes (PIPE_USER_MAX), or reaching into the last 2 free slots (PIPE_ROOT_RESERVED), gets -EAGAIN. This is the FAT32 fat32: per-uid cap on the open-file table; error paths off the console #181 pattern.
    • owner_uid survives orphaning, so a pipe a child still holds keeps counting.
    • The count, the slot choice and the claim now run in one critical section.
  • vfs_alloc_fd: a non-privileged uid holding 24 descriptors (VFS_USER_MAX_FDS) gets -EAGAIN.
    • 24 is above one process's 16-slot table, so a process with a full table can still exec and spawn.
  • Both refusals are kdbg traces, not console lines.

Witness

verify/verify-uid-caps.sh drives the new /capprobe.elf as a non-root user, twice. The second run is at loglevel debug and requires the refusal traces.

pipes dirs (parent + child)
unfixed 8, then -24 → FAIL 16 + 16, then -24 → FAIL
fixed 4, then -11 → PASS 16 + 8, then -11 → PASS

On the fixed tree the slots come back after release, and nothing prints at the normal loglevel.

Regressions, all PASS: verify-pipe-fixes, verify-pipe-uaf, verify-ramfs-vfs-fixes, verify-fat32-fd-cap.

Not witnessed: the pipe root reserve. It needs two uids holding slots at once, and it shares the counting loop with the per-uid share.

🤖 Generated with Claude Code

…able

Both tables are system-wide and had no per-uid share. One user holding all
8 pipe slots made every other user's PIPE_OP_CREATE fail with -EMFILE. A
ramfs directory open takes no ramfs fd, so it met no per-uid cap at all,
and one user's processes could fill the VFS primary pool and starve every
other user's opens. Both were listed as open in SECURITY_AUDIT_2026-10 §3.

- sys_pipe CREATE: a non-root uid holding PIPE_USER_MAX (4), or reaching
  into the last PIPE_ROOT_RESERVED (2) free slots, gets -EAGAIN. The
  FAT32 #181 pattern. owner_uid survives orphaning, so a pipe a child
  still holds keeps counting. The count, slot choice and claim now run in
  one critical section; previously the free-slot search and the claim
  were split by the buffer allocation.
- vfs_alloc_fd: a non-privileged uid holding VFS_USER_MAX_FDS (24) gets
  VFS_EAGAIN (-11). That is above one process's 16-slot table, so a
  process with a full table can still exec and spawn. vfs_free_fd's
  memset clears owner_uid.
- Both refusals are kdbg traces, not console lines.

verify-uid-caps.sh drives the new /capprobe.elf as a non-root user, twice
(the second time at loglevel debug, to require the refusal traces):
  unfixed tree: FAIL (pipes 8 then -24; dirs parent 16 + child 16, -24)
  fixed tree:   PASS (pipes 4 then -11; dirs parent 16 + child 8, -11;
                both slots come back; no console lines)
Regressions: verify-pipe-fixes, verify-pipe-uaf, verify-ramfs-vfs-fixes,
verify-fat32-fd-cap all PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@douglasmun
douglasmun merged commit 3fe522b into main Oct 11, 2026
1 of 2 checks passed
@douglasmun
douglasmun deleted the fix/uid-caps-pipes-dirs branch October 11, 2026 17:27
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