3 ms·
> Historically, ASLR on Apple’s platforms had one architectural weakness: the shared cache region, containing most of the system libraries in a single prelinked
by saagarjha 6y ago
> Historically, ASLR on Apple’s platforms had one architectural weakness: the shared cache region, containing most of the system libraries in a single prelinked blob, was only randomized per boot, and so would stay at the same address across all processes.
Historically ASLR on Apple’s platforms has had many weaknesses, mostly stemming from poor randomization across many different subsystems :P
What I’m also really curious to know is what the performance implications will be of isa PAC…
- pjmlp 6y agoEven if it turns out to be a bit slower, it is the pursuit of speed at the expense of bounds checking that has brought us here, although other ill fated OSes proved that it didn't had to be that way.
- astrange 6y agoExploitations like this are much more complicated than lacking bounds checking; after all most web exploits start by defeating the supposedly memory safe JS interpreter.
- pjmlp 6y agoBecause they trigger bugs in the underlying engine code written in C and C++.
- astrange 6y agoIf your JIT interpreter is written in a safe language it can still have memory bugs because it’s generating and executing assembly directly.
- wizzwizz4 6y agoThat sounds like a challenge.
- pjmlp 6y agoIt might, just like the microcode, firmware and hardware design can have such bugs. Safe languages don't magically make all code impossible to exploit, they just reduce the attack surface to logical errors, instead of having to deal with UB and memory corruption as well. The same way that helmets and belts don't save people from dying all in all kinds of accidents, yet they surely help reducing the mortality numbers. I enjoy languages with helmets and belts.
- szc 6y agoSlap, slap, slap. I do not think you did a complete or accurate analysis. Randomization is NOT free. Randomization either requires that the values are pre-computed before install (which means delivering and pre-computing N different versions) or it is computed it on device. If the randomization is computed on-device how to you validate that the binary or a library has not been "substituted" - persistent malware, APT? The "compute on device" was a feature of very old macOS versions - it was annoying and took quite a lot of resources. "TOTAL ASLR" depends on a CPU arch if it fully endorses over all addresses position independent code and data (Q: homework for ARM, x86_64...). If the ABI allows violations of this you cannot glide / slide all code and data addresses without significant runtime costs. This will likely result in a compromise.
- saagarjha 6y agoI believe my analysis is both accurate and complete; actually, I would dispute many of the things you mention. "Baking in" randomization into a binary before installing it is rare; on Apple's platforms ASLR is done at runtime. I am well aware that ASLR does not come for free; it requires position-independent code to function and support from the kernel to do randomization (for image base addresses and anonymous mmaps) and a dynamic linker aware of how to apply relocations. On iOS PIE code has been required for many years, and the various OS subsystems are not only aware of ASLR but ensure validity of code signatures regardless of load address. I suspect the expensive process that you are referring to is shared cache prebinding, which was never a thing on iOS AFAIK and is no longer used on macOS either. To be clear, I am not complaining about a lack of ASLR where it would be prohibitive, such as mapping the shared cache at a different address for every process (which, unless done carefully, would kill the benefits of it being in shared memory as the pages would all be dirtied). I am talking more about various instances where Apple has generally used very poor slides for reasons that aren't all that great, leading to the randomization being easy to break.
- szc 6y agoSorry no. This is not about the main executable - this is a misdirection. The comments you make about the "main binary" are 100% correct. But, they do not address my comment at all. My comments were entirely about the shared cache region and how it can be moved. I again ask you to do the homework - please calculate how it could be done better given the address spaces involved. Address spaces going from 32bit to 64bit have gotten better, but this does need to be kept into consideration given the size of the object involved and the API / CPU instructions available (please, I ask you to consider all of the addressing modes available to the ABI for all of the currently supported platforms) [added] It is likely the individual objects that compose the share cache region are compiled independently. There are lots of individual objects! Resolving the dependencies of the composite shared object are likely expensive. Historically I observe that the contextual data available to a static or dynamic linker has been very constrained, which makes relinking / reallocation objects a challenge.
- szc 6y agoI am posting this as an independent comment. There isn't a "popular" CPU architecture that is 100% PIC for all of the allowed address ranges. There are "optimizations" the compiler can choose for limited addresses "reaches". Please consider independently compiled libraries that are aggregated into something larger, specifically languages that permit subclassing and inheritance. How can they be moved within an address space? If there is a hierarchy of address availability this means that ASLR cannot be implemented in a pure way - it must involve runtime fix-ups if the base address changes. If the length of an instruction must change because of the addressing mode, what happens? How can you do ALSR? Do you rewrite all instructions (is there space? was space allocated?) or always use the most expensive address mode?
- johncolanduoni 6y agoThe major architectures & ABIs are all capable of producing and loading fully position independent code. The performance impact varies; for x86_64 and aarch64 instruction pointer relative addressing reduces the number of relocations that are needed by quite a lot. Languages that support subclassing and inheritance don’t represent any special hazard to relocation; ultimately these are built out of data and function symbols that need to be supported even if you’re only compiling C.
- saagarjha 6y agoCompilers know how to generate code that is position independent. Apple requires such code on the iPhone. Therefore, all code that runs is slidable using ASLR. Whether you want to call that "the most expensive address mode" or not (it's really not all that expensive) is up to you. (Also, note that arm64 has fixed-length instructions regardless.)