This would be what's known as software-based fault isolation, right? Here's a paper from 1993:
https://dl.acm.org/doi/abs/10.1145/168619.168635
I don't understand why this idea keeps failing to take hold even though it's constantly reintroduced in various forms. Surely now, 30 years after that paper was published, we can bear the "slightly increased execution time for distrusted modules" in return for (as the paper suggests) faster communication between isolated modules?
So basically like that one Rust hardware project that gets posted periodically?
You could probably do it pretty decently in C via `pkey_mprotect` (probably with `dlmopen`).
What is really needed, is sane memory model where you can easily call any function with buffers (pointer + size) and it is allowed to access only these buffers and nothing else(note). Not this mess coming from C where this is difficult by design.
(note)since HN likes to split hairs: except for its private storage and other well thought exceptions