CTSRD-CHERI / cheribsd

FreeBSD adapted for CHERI-RISC-V and Arm Morello.
http://cheribsd.org
Other
170 stars 60 forks source link

Morello Restricted System Cap Regs #755

Closed jrtc27 closed 4 years ago

jrtc27 commented 4 years ago

The current Morello kernel neither initialises these register at boot nor saves/restores them in the trapframe, so the reset values are accessible to userspace and userspace can use them to send capabilities between processes. The lack of initialisation is detected by the recently-added test_initregs_restricted_default; there are also _stack and _thread tests but those currently pass because the FVP's reset state for them appears to be NULL (the spec says UNKNOWN), so it's only RDDC_EL0 that is especially problematic due to its almighty reset value, though the cap sharing is an issue for all three.

bsdjhb commented 4 years ago

Until the kernel starts using these, we should store these in the PCB. exec_setregs() needs to set them, cpu_fork() and cpu_thread_copy() needs to copy them from the template thread, and cpu_switch/throw need to save/restore them similar to TLS registers. Note that exec_setregs() will have to explicitly write to the registers as well just as it does for TLS.