Skip to content

Free frames on task-creation failure; no panic on user PDPT OOM - #188

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

douglasmun merged 1 commit into
mainfrom
fix/memory-fixes

Conversation

@douglasmun

Copy link
Copy Markdown
Owner

Sixth of the seven fix PRs.

Fixes

  • F1 — argv-does-not-fit leak. task_create_user_argv() released only the slot on this branch, leaking the guard page, 8 kernel stack pages, the user guard page, the user stack and the PDPT (24 frames per failure, measured). It now calls task_free_resources() before freeing the slot.
  • F2 — panic on user PDPT OOM. pae_create_user_pdpt() called kernel_panic() when a PDPT/PD allocation failed. The "boot-critical" comment was wrong: it runs on every exec/spawn, so a user who could exhaust memory could crash the kernel. It now frees partial allocations and returns 0. All three callers already handle 0.

Witness

verify/verify-memory-fixes.sh builds with -DTINYOS_FAULT_INJECT (and runs make clean on exit). It runs the hidden kernel-shell command memunwind, which forces three failures and checks pmm_free_frames() across each one, 3 tries per leg:

leg unfixed fixed
argv-nofit deltas -24 -24 -24 0 0 0
pdpt-alloc KERNEL PANIC 0 0 0
pd1-alloc (partial unwind) not reached 0 0 0

Each leg also reports whether its fault actually fired; if one didn't, the result is INCONCLUSIVE, not PASS.

Unfixed: RESULT: FAIL — 2 assertion(s). Fixed: RESULT: PASS.

🤖 Generated with Claude Code

…ation fails

- task_create_user_argv(): the argv-does-not-fit branch released only the
  slot, leaking the guard page, kernel and user stacks, user guard page and
  PDPT (24 frames, measured). It now calls task_free_resources() first.
- pae_create_user_pdpt(): a failed PDPT or PD allocation called
  kernel_panic(). It runs for every exec/spawn, not just at boot, so memory
  exhaustion by any user became a kernel DoS. It now frees what it took and
  returns 0; every caller already handles 0.

verify/verify-memory-fixes.sh forces both paths through a
TINYOS_FAULT_INJECT kernel-shell command (memunwind) and measures free
frames across each failed creation. Unfixed: argv-nofit deltas -24 -24 -24,
then KERNEL PANIC on the PDPT leg. Fixed: all deltas 0, PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@douglasmun
douglasmun merged commit e6012cc into main Oct 11, 2026
2 checks passed
@douglasmun
douglasmun deleted the fix/memory-fixes branch October 11, 2026 16:09
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