6 ms·
I'm one of those people who think OS kernels should stay as portable and simple as possible (i.e. C89 or some other easily-bootstrappable language, to avoid Ken
by userbinator 5y ago
I'm one of those people who think OS kernels should stay as portable and simple as possible (i.e. C89 or some other easily-bootstrappable language, to avoid Ken Thompson attacks), so this isn't great news to see "the ladder being pulled up another rung". Then again, Linux has already become immensely complex.
- mlindner 5y agoYou're confusing portability with age. Just because something is old does not make it more portable. It arguably makes it less portable as new platforms will not support old language versions.
- thestoicattack 5y agoThe article does mention at least one advantage, so it's not as if the ladder is being pulled up for no reason.
- pm215 5y agoLinux has always relied heavily on GCC extensions, though -- it makes no attempt to actually be C89-compliant portable code. What it actually has is a minimum supported gcc version, which in turn governs whether particular features can be used. In this case the minimum gcc version has for other reasons finally got big enough that C99 and C11 support is definitely present -- the ladder was already this high. (You can also build with clang, but only because clang deliberately aims to support most gcc extensions.)
- Dylan16807 5y agoDeclaring a variable in the middle of a function takes basically no effort to support. Especially compared to all the ridiculous things the kernel gets up to. The ladder's being moved a millimeter.
- mwint 5y agoWhat's a Ken Thompson attack?
- Jtsummers 5y agohttps://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref... Ken Thompson, Reflections on Trusting Trust. EDIT: I don't think I've seen 5 nearly simultaneous replies sharing the same link before.
- ksec 5y ago>EDIT: I don't think I've seen 5 nearly simultaneous replies sharing the same link before. LOL I was searching for a non-PDF link and delayed the reply. It would have been 6 simultaneous answer.
- febstar 5y agoMost likely referring to "Reflections on Trusting Trust" [0]; i.e. when the compiler is itself the attack vector. [0]: https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref...
- esarc 5y agohttps://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref...
- bombcar 5y agohttps://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_ReflectionsonTrustingTrust.pdf https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref... How do you prove your stack is secure?
- gmfawcett 5y agoSolution: the compiler for the microlanguage at the bottom of the stack is none other than the kindly and incorruptible American film star, Tom Hanks.
- mindcrime 5y ago
- pinephoneguy 5y agoYes but Linux won't even build with gcc 4 much less weird compilers like tcc or msvcc. That ship has unfortunately already sailed.
- tiahura 5y agoSounds like GNU/Linux is probably warranted.
- yjftsjthsd-h 5y agoKind of, but you can also use clang. On the other other hand, that's clang with GNU extensions, so /shrug
- pcwalton 5y agoThe advantages of using a newer language greatly outweigh the disadvantages of theoretical "reflections on trusting trust" attacks. By mandating C89, you're condemning thousands of kernel developers to use a language that's over 30 years old because of a theoretical attack that has never happened and seems practically implausible. Does anyone really think there's a backdoor in both GCC and Clang (remember, Linux can be compiled on either)?
- gmadsen 5y agoI am ignorant on nearly all compiler related issues, but there was an article on here not too long ago that was arguing that nearly all os development required old C because choices of the committee would break use cases required under the guise of undefined behavior. is the benefits of "modern C" worth compile times 2-3x times longer?
- pcwalton 5y agoTimes like these I wish I were allowed to say exactly how much money big companies save by using the newest versions of GCC and Clang. The economic value of modern compiler optimizations is staggering.
- bch 5y ago> wish I were allowed to say exactly how much money big companies save[...] Are you able to give hints that would guide us in thought exercises?
- pertymcpert 5y agoOne avenue is to think about it in terms of datacenter compute. If modern compiler optimizations improve performance by 10%, aggregate the perf improvements across the entire world's compute and you get a huge saving.
- bluGill 5y agoFacebook has hinted that they employ smart C++ people because some core optimizations can save on the order of several hundred thousand dollars per year (possibly in the millions). Most of that is off because they don't have to buy as much power to cool the server rooms, some of it is buying less servers as what they have can do more. Facebook doesn't actually say what they save, but they have said they measure it, and we know how much it costs to employ an engineer full time working only on optimization, and we know who some of those engineers are. You have to be very large to notice it, but the likes of Facebook, amazon, and Google have massive warehouses almost entirely filled with computers. It doesn't take much to see how their power bill can add up.
- syncsynchalt 5y agoIMO the C standards are conservative enough that even a standard level "only" a decade old is still fine. With that said, we still have options even when moving to a newer standard. Many new language features can be machine-translated to C89 if needed (similar to how we have protoize / unprotoize, though not always as seamless). If we need to keep a bridge to C89 the kernel authors could hold to a subset of new language features that are amenable to machine translation.
- neysofu 5y agoKen Thompson's hack is purely theoretical, especially in the modern computing landscape where the diversification of software supply chains would make such hack much 1. less effective and 2. easier to detect. If we're talking about kernel security, there are other lower hanging exploits, many of which are enabled by outdated language design decisions and unsafe memory models. As compiler technologies evolve, it becomes not only a necessary evil but rather a better course of action to trust compilers rather than humans tiptoeing around security risks masquerading as language idiosyncrasies.
- yjftsjthsd-h 5y ago> Ken Thompson's hack is purely theoretical Erm. I was always under the impression that he had actually done it, and that his presentation was a historical anecdote. Is that not the case?
- neysofu 5y agoYes, he did, but that just shows that it's possible to inject self-replicating code in a compiler. It doesn't actually tell us how resistant such code is to compiler source changes, audits, binary analysis, etc. which are all required for a successful exploit.
- boogies 5y agoBut the University of Minnesota experiments prove at least some malicious code is capable of passing at least standard Linux code review, right?
- IshKebab 5y agoThat's a completely separate issue. The trusting trust bug requires you to convince people to use your compiler binaries. The thing you're talking about just requires a patch to pass code review. It's more work - you have to figure out a sneaky bug and write a legit looking patch - but anyone can do it. You don't have to be in a position of power already (e.g. being the Debian GCC packager) so overall it is much easier.
- jcranmer 5y agoLinux is not written in C89. It is written in gnu C89, which is a mixture of C89, C99, and a panoply of often poorly-defined gcc-specific features. The number of compilers that can successfully compile Linux is one; not even clang is able to fully do so yet, I believe. Actually, as a compiler writer, I'd go a little bit further and point out that Linux itself isn't even written to the gnu C89 very well; it's often written to a "C is portable assembly" view of the language, which results in nasty grams and invective being hurled at compiler writers if they compile the C specification correctly and not according to the "proper" assembly the code author thought they were getting. One of the benefits of more modern language revisions is that they actually tighten the wording on a lot of the more ambiguous parts of the specification--C11 in particular adds a much more comprehensive memory model that's very shrug in the older revisions of C.
- nikanj 5y agoMy understanding is that Linux has often faced issues where ”compiling the specification correctly” means “Ha-ha gotcha, we can actually throw half your code out of the window because you misread the deep aliasing rules on page 8432 of the spec” Their hesitancy with newer standards is understandable, when viewed against that backdrop
- jcranmer 5y agoOne of these days, I will get around to writing my post as to why that take on undefined behavior is completely wrong. More to the point, though, the only changes to undefined behavior in the C specification in newer versions (compared to C89) are either clarifying things that were already undefined behavior (e.g., INT_MIN % -1) or actually making some undefined behavior well-defined (e.g., allowing type punning via unions).
- comex 5y agoC23 will make calling realloc with a size of 0 into undefined behavior. [1] [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2464.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2464.pdf
- tomcam 5y ago> so this isn't great news to see "the ladder being pulled up another rung" Man I so vibe with that. But the new Cs do have a ton of new features and, more to the point, I trust Linus to make this kind of decision more than just about anyone.
- Zababa 5y ago> to avoid Ken Thompson attacks I was always under the impression that the "message" of Reflections on trusting trust was that you have to trust someone at some point.
- wolrah 5y ago> I'm one of those people who think OS kernels should stay as portable and simple as possible (i.e. C89 or some other easily-bootstrappable language, to avoid Ken Thompson attacks) Why does the complexity of the OS, or even its ability to be compiled by multiple compilers, matter for "trusting trust" attacks? As I've always seen it, the problems and solutions all exist at the compiler level. The whole premise relies on starting with a binary compiler that you are expected to trust. The source is also assumed to be safe and un-tampered for purposes of this discussion because that's an entirely different issue. The solution, of course, is to build the compiler itself with different compilers. If you build the same compiler with two or more different compilers, then use that to compile itself, you should be able to with the right options (see the work that has been done on reproducible builds) get binaries that are equal or close enough to easily compare any differences. At that point if they are the same then you know either it's good or both of the upstream compilers were also compromised. If for whatever reason that's not practical at the top level compiler the same concepts apply going further back in history until you get to some early compiler a bored grad student wrote in the '80s in pure ASM. As a result from a practical sense I don't really see "trusting trust" attacks to be that big of a concern. It's always possible to work your way back down the tree of software until you get to a point where you can actually trust a compiler and then build your way back forward from there. If a compiler starts depending on its own tricks and gets to a point where it can only be successfully compiled by itself, then there are reasons to be suspicious. Even then you'd just have to have the last version to be able to be built by other packages as one more stop along the way to trust.
- jml7c5 5y agoDoes trusted bootstrapping really become that much more difficult? If you're already doing a trusted bootstrap to an old version of GCC, you can use that to build a modern GCC.