How to talk to your parents about hardware memory safety
cheriot.org
cheriot.org
My code mostly compiled on CHERI without issue-- I was hoping to find some interesting bug as that's a pretty realistic prospect when porting to CHERI but didn't do so on the code I've tried so far.
They control the entire stack, even down to the silicon.
(Among other tricks, 64-bit platforms don't actually use every bit in their address space, which means you can store things in the unused bits.)
ARM as in 32-bit arm already does this. If the lowest bit of the pointer is set to one when control jumps there it is treated as thumb (2 byte) instructions rather than A32 (4 byte) - that lower bit is still masked away of course.
The QARMA block cipher ARM proposes for PAC (but does not mandate, any can be used) "signs" (it isn't really signing, more like a mac but whatever) pointers with an authentication code as small as 3 bits.
That might sound nuts but a 3 bit code means you have 1/8 chance of bruteforcing correctly. Raise to the power of the number of required forged pointers and you can see how an exploit can be made very unreliable. E.g. if you need 4 forged pointers you now have (1/8)^4 chance of succeeding.
lol. We had 32-bit pointers on 386/486 systems in the early '90s, on systems with frequently less than 4MB of RAM.
If making pointers 4x bigger on systems with 2000x the amount of memory is a problem, I'm not sure how we're going to be able to solve anything ever again.
> Also, it confuses any code that assumes you can convert a pointer to a long (or long long) and back.
Well, that's why we invented intptr_t. Back in... checks notes C99. 25 years ago.
smh
Other than the temporal safety overheads-- which you could skil and still have spatial safety worth using-- the worst CHERI does is increase the memory bandwidth for pointers, so in a pathological case you might imagine a 2x slowdown.
In some cases it could make things faster and simpler though, since the CHERI approach can get process isolation without a MMU or TLB, so those overheads could be reduced or eliminated.
> Also, it confuses any code that assumes you can convert a pointer to a long (or long long) and back
such code is already pretty unportable on existing systems.
You can't implement an xor linked list on CHERI (at least not in the pure mode)... hardly seems like much of a loss. :)
So we really are reinventing the Lisp machine with extra steps.
As for porting, it very much depends what you're doing. Operating systems and language runtimes, especially those with JITs, have intimate knowledge of the architecture and like to play cute tricks with pointers, so those are disproportionately involved to port. General user code requires very little, if any, porting. In one study, a basic KDE+X11 desktop stack was ported to CHERI, seeing 0.026% LoC changes across 6 million LoC, or 1584 lines. It's non-zero, and of course there is a lot of code out there so even a tiny fraction of it isn't insignificant, but it is very small as these things go.
Is there documentation of the scheme that allows this? I did some quick Googling and found CHERIvoke (which is not concurrent at all) and Cornucopia (which requires scanning some user pages while the world is stopped). Are you referring to something newer?
Or is there some new fancy dedicated hardware registers involved?
It'll be the end of jailbreaking, and another step towards the dystopian digital totalitarianism Stallman warned us about.
[To those who think there will still be alternatives: do you not think they'll also follow, under the threat of being called "insecure" and "unsafe"?]
I, for one, would appreciate a device that isn't riddled with memory bugs that are exploitable principally by nation states; one might say buggy code is the backdoor free software folk are so paranoid about
It's just being realistic. Obviously, it would be great if there were laws guaranteeing the users' right to have full control over devices they've purchased, but I think most people have accepted that this ship has sailed. So we can only really hang on to the little control we still have, which is usually achieved without the manufacturer's permission.
BTW: Stallman is brought up too which is actually very relevant for why this is such a losing argument: jailbreaks are cool and all but today they are basically irrelevant for the average user. This is just like Stallman fighting for GPL is nice but only really for people who compile their software themselves. People like the ability to have control over their software but going about it from the perspective of a software engineer who can write code or hack things is very exclusionary.
TL;DR: CHERI changes how pointer work and needs both hard and software support _all through the stack from kernel over drivers to your end user application. Companies will be very careful (slow) about evaluating and adapting it, there are many challenges both technical and organizational(people).
TL;DR2: CHERI is experimental both in software and hardware I think there isn't even a python interpreter which works with the fully enforced (pure-capability) CHERI.
Now to be clear how much your software needs to change depends a bit on weather you use the pure-capability API or the hybrid API but if you use the hybrid API and don't recompile your code in a way which might require code changes you are not getting any security benefit and at least the kernel (and in turn in-kernel drivers) should all work in pure-capability mode.
But that means your pointers now all are 128bit consisting of an address and a tag. And while a lot of pure C/C++ standard compatible code not doing anything fancy will work, a lot of C/C++ code does fancy things and will not work. E.g.you can't cast a CHERI pointer to a int and back and expect it to work as the int only represents the address but not the tag (through doing so is anyway highly problematic due to pointer provenance). C/C++ programs written using a "C is just high level assembly" or a "pointers are just memory addresses" or a "data is just bits in RAM" approach already cause a lot of issues today due to UB and with CHERI this approaches work even less.
And even if you program does work, due to 128bit pointer size it might have performance problems it didn't had before needing optimizations it didn't need before.
And non of this is even considering weather or not it can effectively be integrated in the current Apple ARM hardware without causing layout or performance issues (it might but it might also not, I think only apple can answer that properly. I mean it definitely is possible but it comes at a (work time=money) cost which might be not so small).
If I would be Apple I would wait for the adoption until the ecosystem around CHERI becomes more mature and when it start showing signs of success help it actively to become more mature. But for that you need:
- non experimental ARM ISA extensions
- better language support (I don't think there is any Swift CHERI support)
- more experience with porting large software stacks to it
- porting of their Kernel, drivers
- porting of their core libraries (for simplicity lets assume iOS), notably here is e.g. their JavaScript VM
- adopting their current iOS specific security mechanisms to CHERI
- creating a lot of tooling to make migration for developers feasibly (no less effort then they had to go through for the x86->ARM migration)
and even then they still would need to support running apps in a compatibility mode for many years as they can't expect existing apps to be made compatible with CHERI as they can't expect all of the software stack that apps use to be made compatible. They might simple not care for smaller devs and force them but they can't do so for many of the larger companies core apps people expect.
And all of this steps have supper funny surprise issues as there is code you can't make work with pure-capability cherry as it's too much designed around "clever tricks" which do not work with cherry. Like how does it affects JITs/AOTs and could there be cases where you can't make it work with pure-capability mode in a performant way. Like e.g. can you even make WASM AOT work with CHERI and if not can you require browsers to now have CHERI-WASM and non CHERI-WASM???
There’s also motivations. Companies usually don’t care about real security because they’ll be rich anyway. FOSS people are motivated by what they enjoy which is rarely securing the codebase. Relevant to Apple and Google, some companies will ignore good solutions, even permissively licensed, because they’re Not Invented Here. It has to be their way or it won’t happen at all.
Any of these might be motivators for Apple not baking in something like CHERI. I agree with you that they’re in the best position. If I was ever hired by them, and able to influence a big decision, baking memory safety into the CPU in a compatibility-preserving way was one of the first decisions I’d have made. It would be a huge differentiator.
I also expect them to eventually adopt ARM MTE was well.
https://hacks.mozilla.org/2020/02/securing-firefox-with-weba...
But the good ones rely on PAC (pointer signing), which comes from CHERI and x86 doesn't have it.
0: https://www.kernel.org/doc/html/v5.5/x86/intel_mpx.html 1: https://lwn.net/Articles/643797/
Yet another example of Intel's failure to deliver.
making it airtight and useful in an existing programming environment is less straightforward
I am sure the author does not really believe older people can't understand CHERI. One of the original contributors to CHERI is Peter G. Neumann, born 1932, programming since the 1950s. Chisnall (the author of this piece) and Neumann are among the co-authors of a paper on CHERI presented at ASPLOS'24 this year [1]
I guess this shows the risk in using humor in scientific writing -- you never know how it will land.
[1] https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/cheri...
It made it impossible for me to continue reading the paper, though. Ah well.