Page MenuHomeFreeBSD

proc_rwmem check PRIV_PROC_MEM_WRITE when writing
ClosedPublic

Authored by sjg on Nov 8 2024, 5:09 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 27, 1:08 PM
Unknown Object (File)
Mon, Jan 20, 4:49 AM
Unknown Object (File)
Sat, Jan 18, 6:39 AM
Unknown Object (File)
Dec 27 2024, 7:44 PM
Unknown Object (File)
Dec 26 2024, 8:05 AM
Unknown Object (File)
Dec 26 2024, 4:18 AM
Unknown Object (File)
Dec 26 2024, 2:46 AM
Unknown Object (File)
Dec 25 2024, 9:05 AM
Subscribers

Details

Summary

This will fail when mac_veriexec is enforced.

Move the check from procfs_doprocmem to proc_rwmem to ensure all
cases are covered.

Sponsored by: Juniper Networks, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sjg requested review of this revision.Nov 8 2024, 5:09 AM

proc_rwmem() is also called by ptrace() and cuse(4). I can imagine you also want to prevent process tampering via ptrace(), but what about cuse(4), and more generally other potential uses where data transfers are performed by proc_rwmem()?

If this is a concern, an alternative would be to add a check of PRIV_PROC_MEM_WRITE directly in kern_ptrace().

sys/sys/priv.h
518

proc_rwmem() is also called by ptrace() and cuse(4). I can imagine you also want to prevent process tampering via ptrace(), but what about cuse(4), and more generally other potential uses where data transfers are performed by proc_rwmem()?

If this is a concern, an alternative would be to add a check of PRIV_PROC_MEM_WRITE directly in kern_ptrace().

The point is to disallow arbitrary modifications of process memory. kern_ptrace() is not the only interface which permits this, proc_rwmem() can be reached via dtrace as well. veriexec has ways to exempt executables from this restriction, e.g., so that one can use gdb. I think executables which operate a cuse server would require similar handling, and that's probably acceptable.

This revision is now accepted and ready to land.Nov 8 2024, 1:57 PM

The point is to disallow arbitrary modifications of process memory. kern_ptrace() is not the only interface which permits this, proc_rwmem() can be reached via dtrace as well. veriexec has ways to exempt executables from this restriction, e.g., so that one can use gdb.

Yes, I agree (and am already aware).

I think executables which operate a cuse server would require similar handling, and that's probably acceptable.

That I wasn't sure of, by lack of cuse knowledge, thanks for sharing this info. It seems to me that if proc_rwmem() is used to send data to another process that explicitly requested it and if cuse enforces that the data can only be sent to the requested addresses (out of the control of the sending server process), then that send should be accepted regardless of PRIV_PROC_MEM_WRITE. But I don't know if it's the case, and even if it is I agree it doesn't matter at first order.