Re:Formal Mechanised Semantics of CHERI C: Capabilities, Und...
by vzaliva on Friday April 19, 2024 @02:00AM
(#40083834)
In CHERI, the `data` pointer in your example is not merely a 64-bit pointer (assuming ARM Morello architecture) but a special 128-bit data structure called a `capability`, which encodes within it the bounds of the memory block allocated to it. The hardware will prevent any out-of-bounds access, even if you manage to bypass any C language type checks, for example, by using inline assembly. So, this offers a pretty strong level of memory protection.
[ Parent
| on HN ]
Re:Formal Mechanised Semantics of CHERI C: Capabilities, Und...
by PhilipRoman on Friday April 19, 2024 @02:11AM
(#40083879)
Yes, but the capability will be enforcing the bound w.r.t "capacity", not "length" as that is the allocated size. From CHERI's point of view "length" is just some random user defined variable with no effect on bounds checks.
Re:Formal Mechanised Semantics of CHERI C: Capabilities, Und...
by Peter_Sewell on Friday April 19, 2024 @02:24AM
(#40083942)
If you want to narrow the bounds of `data` on reuse, you can do easily do that in CHERI C (you'd need to also keep the larger capability somewhere to rederive the `data` capability from, either in this struct or elsewhere, depending where the allocation come from).
Re:Formal Mechanised Semantics of CHERI C: Capabilities, Und...
by PhilipRoman on Friday April 19, 2024 @02:57AM
(#40084087)
Oh that is great news, I was not aware that CHERI was this powerful. Interesting if this could be abused by JIT compilers to provide free runtime bounds checks, kind of like the free null pointer checks done by catching SEGV.