vmspace_rwmem() baked two policy decisions into one place: that a
write must fault in a *private* copy of the page (VM_PROT_COPY), and
that it requires PRIV_PROC_MEM_WRITE. Both are appropriate for
debugger-style access (proc_rwmem(), proc_writemem()) but not for
every possible writer of another vmspace.
Make vmspace_rwmem() (and vmspace_iop()) take the desired fault
protection as an explicit reqprot argument, and move the privilege
check up into proc_rwmem()/proc_writemem(), which are the callers
that actually implement the debugger policy. Every existing caller
passes exactly the protection it used before, so this is NFC.
This lets a future in-kernel consumer fault pages into another
process's vmspace with VM_PROT_WRITE (a real, process-visible write)
and its own privilege policy.
Note: This patch series overall is very big, more than I feel competent
reviewing, so I feel a bit ill-mannered submitting it yet. Certainly,
everyone should feel free to ignore it until my "unix socket connectat"
series is landed. I am submitting it now anyway simply because I think
the end functionality is very cool, and I don't want it to grow dusty on
my machine.
Assisted-by: Claude Code (Claude Opus 4.8/5 and Fable 5)