Page MenuHomeFreeBSD

kern: lift the privilege check out of `vmspace_rwmem()`
AbandonedPublic

Authored by inquire_JohnEricson.me on Thu, Aug 6, 4:05 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 27, 2:24 PM
Unknown Object (File)
Wed, Aug 26, 10:35 AM
Unknown Object (File)
Tue, Aug 25, 10:46 PM
Unknown Object (File)
Sun, Aug 23, 10:01 PM
Unknown Object (File)
Fri, Aug 21, 9:57 PM
Unknown Object (File)
Tue, Aug 18, 9:45 PM
Unknown Object (File)
Mon, Aug 17, 8:28 PM
Unknown Object (File)
Mon, Aug 17, 3:21 AM
Subscribers

Details

Reviewers
markj
glebius
kib
Summary

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)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75406
Build 72289: arc lint + arc unit

Event Timeline

See the comment I left on D58685, I hope to come back to that someday, but not yet. That makes this not needed either.

Parts of this I kinda like anyways ---- I think it is good practice with an eye to capability mode to separate out ambient authority privilege checks from operations. But I will still not bother with it now as low priority.