So today #musl discovered a longstanding 🤦🤦🤦 bug in Linux's ELF loader...
For whatever reason, Linux has two copies of the ELF loading code in binfmt_elf.c, one for the main program and the other for the "program interpreter" (dynamic linker). The former handles BSS right but the latter doesn't.
ELF program LOAD segments can have p_memsz>p_filesz, representing a mapping larger in memory than in the image on disk, with the remainder zero-filled (mapping zero paged if needed).
For the main program, Linux handles this fine. But for the interpreter, it only maps p_filesz, not p_memsz. Then, at the very end, it goes back and performs one additional mapping for the remaining "bss" if needed.
This happens to work if there's only one data segment mapping that utilizes p_memsz>p_filesz, or if where the page boundaries fall make it so that no additional mapping is needed.
Unfortunately, lld wants to make multiple LOAD segments with data, one for the GOT and related machinery, and the other for actual program data. In this case, the kernel just doesn't map enough memory for the GOT, and process crashes (in ldso) on entry. 🤦
I think Linux may also be failing to do the right zero-fill (leaving junk mapped from disk present) even when it's not crossing a page boundary. Depending on what the linker did (e.g. if it put data segment before GOT seg rather than after), this could cause severe malfunctions.
The kernel has apparently always had this brokenness, and kernels in the wild will have it for decades to come. So does lld need to stop generating such output? Or should ldso do some workaround on itself in case it was linked this way?
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Spicy take: spatial memory unsafety (ala the OpenSSL bug) is a nearly solved problem in C with modern tooling and could be even moreso with a little effort. Temporal memory unsafety is the only hard part and where memory safe languages shine...
..but the need for temporal memory safety can be largely avoided with programming styles that just don't use complicated object lifetimes.
Re: spatial unsafety, one observation I noticed again in the OpenSSL bug was that, even in the presence of ssp, there's a risk that overflows clobber pointers other than the return address before overflow is caught at return...
On the verge of Twitter possibly becoming (even more of a) cesspit, and folks rushing to offer inadequate alternatives, some thoughts on what value Twitter has...
Why is it that, while other social media and group chat platforms are full of junk from over a year ago being passed around and treated like news, Twitter is on top of uncovering stuff as it happens, debunking bs, and surfacing relevant expertise?
IMO, it's because the core value of Twitter is as a source of trust in domain expertise that comes from the unified public social graph of follow relationships and individually curated follows.
Ok, so my poll a couple days ago came out strongly in favor of 3D printing tweets on main. Little did I suspect the first followup would be in the intersection of 3D printing and infosec... 😬 🧵 coming.
Some background: Klipper is the modern motion control & firmware system for these kind of machines, with high level model running on a Python capable host (usually rpi with Linux) & mcu only processing very low level motor stepping, etc.
This is as opposed to doing all the motion planning math, ui, etc. on an underpowered mcu in a monolithic Arduino-style C++ program (Marlin), which become a limiting factor for high speed & quality (very oversimplified explanation but hey it's not the point).
Often maintaining musl, I encounter attempts to contribute from new folks who see "cleaning something up" or making a minor or questionable optimization as an easy way to get involved, and end up turning them down. 2/N
This has prompted me to think a little bit more about why. On the surface, it's because it makes more review burden for me and for others who don't want to just trust me but check correctness of changes, with little measurable value.
This is software that gratuitously inserts gender into nongendered language (possibly radically altering meaning) and reproduces all the biases of the corpus it was trained on. 2/N
It absolutely will use more or less ominous English phrasing for the same concepts from different languages simply based on the biases it was trained on with regard for what subjects in the source language are commonly translated into English. 3/N
Wow, turning Windows Defender off makes Windows like 100x faster and fixes catastrophic OOM crashing. But it's nearly impossible to do on Windows 10 Home.
All the old registry ways to disable Defender have been removed, and stopping the service is blocked by some undocumented access control layer. Only group policy can turn it off and Home lacks GP.
Fortunately Home actually does have group policy, but it's just not installed. There's an undocumented way to add it without even needing network access.