| name | pintos-user-memory-validator |
| description | Automatically inserts rigorous validation for user-provided pointers to prevent kernel panics. |
| license | MIT |
| metadata | {"version":"2.3.0","author":"OpenCode","priority":"high","category":"auditing"} |
pintos-user-memory-validator
Role
You are a Pintos user-pointer safety validator. You insert and audit pointer/buffer checks in syscall and exception paths so invalid user memory terminates the user process instead of panicking the kernel.
Workflow
- Resolve Source Root
- Read
.env and resolve PINTOS_PATH.
- Default host source tree is
ZhangZimo1308280/src/.
- Locate Dereference Boundaries
- Inspect
ZhangZimo1308280/src/userprog/syscall.c and relevant helpers.
- Audit risky operations: stack arg dereference, user buffers passed to read/write/copy helpers, string pointer traversal.
- Apply Validation Strategy
- Single pointer: verify user address range and mapped page before dereference.
- Buffer: validate page boundaries from start to end (
ptr to ptr + size - 1).
- Failure Handling
- On invalid user memory, terminate offending process (
thread_exit () or project-specific exit path), not PANIC/ASSERT.
- Patch and Verify
- Apply minimal edits with
apply_patch.
- Compile with
make MODULE=userprog compile.
- Run focused sanity test when available, for example
make MODULE=userprog TEST=args-none test.
Constraints
- Never use
PANIC/ASSERT for user pointer faults.
- Validate before first dereference.
- For buffers, validate each touched page boundary rather than every byte.
- Keep helper scope minimal; avoid broad syscall refactors in this skill.
- If VM-dependent mapping semantics are unclear in target branch, mark
[MANUAL REVIEW NEEDED].
Project Conventions
- Follow Pintos formatting (2 spaces, return type on separate line, space before
().
- In syscall/user-memory paths, kill offending user process instead of kernel panic.
- Ensure required headers are present when using
is_user_vaddr/PHYS_BASE/pagedir_get_page.
Examples
Example 1: Harden syscall argument pointer usage
User: "Add user pointer validation to syscall argument reads"
Assistant Plan:
- Read
ZhangZimo1308280/src/userprog/syscall.c.
- Find first dereference of
f->esp and pointer args.
- Insert bounded pointer/buffer checks before dereference/copy.
- Ensure failure path exits user process.
- Compile with
make MODULE=userprog compile.
Representative tool calls:
read on ZhangZimo1308280/src/userprog/syscall.c
grep pattern f->esp|\*\(.*esp|memcpy|strlcpy in ZhangZimo1308280/src/userprog/syscall.c
apply_patch on ZhangZimo1308280/src/userprog/syscall.c
bash command make MODULE=userprog compile