4 ms·
Yeah, I am extremely confused at this, too. I am a developer by profession who happens to care about security because I care about delivering a good product. I'
by geofft 9y ago
Yeah, I am extremely confused at this, too. I am a developer by profession who happens to care about security because I care about delivering a good product. I'm not a "security person." Bounds-checking is a way for me to deliver a good product, and killing buggy code is sort of my job. Bounds-checking should be enabled in production.
- ryandrake 9y agoOne size does not fit all. Any debugging safety net will have a cost in terms of performance, and you usually have to pay that cost regardless of whether your code has bugs. It's why we don't release debug builds to customers or use them in production. If it is vital to your application to detect a certain kind of bug in production, then turn the checking on in production and pay the cost. Maybe it is not vital to my application or my application does not have these bugs. In my case it would be needless to pay the cost. To me, essential to delivering a good product is detecting and killing defective code before delivery. I recognize however, that this attitude is becoming more and more old fashioned.
- Aaargh20318 9y ago> To me, essential to delivering a good product is detecting and killing defective code before delivery. The problem is that you cannot prove the non-existence of bugs, even if you formally verify all your code, you've only proven that it conforms to spec, not that the spec is flawless. This is why you should always code defensively. Assume all code is buggy and take steps to deal with that. Code is written by humans, and humans make mistakes. That doesn't mean that you shouldn't try to deliver a flawless product, only that you should acknowledge the fact that you're going to fail.
- eru 9y agoYour argument would be in favour of a defensive spec, not in favour of a defensive implementation. To explain: your spec will have a few hygiene clauses like 'no stack overflow' or 'no crashes' and some things about what useful things the program should actually do. The latter is hard to formalise and deserve defense in depth. Lots of the former are easy to formalise and you can rely on the compiler to get it right. And that's what we are doing already anyway: even in C we just trust that a loop will compile to the appropriate conditional jumps and don't add defensive measures to check that.
- Aaargh20318 9y agoThe point is that you're not going to do formal verification of your software. There is actually very little formally verified software out there, and the verified code that does exist is relatively small. And no, you can't rely on the compiler to get it right. Maybe if you only write Haskell you can get there 99% but there will always be human errors in code that the compiler can't find.
- eru 9y agoWe rely on computers to get parts of our spec right all the time. Yes, a higher level language lets you offload more to the computer (like Haskell), but even in C we are doing some off that. Yes, in practice you seldom have much of a formal spec, agreed.
- geofft 9y ago> One size does not fit all. Any debugging safety net will have a cost in terms of performance, and you usually have to pay that cost regardless of whether your code has bugs. It's why we don't release debug builds to customers or use them in production. You should benchmark this. It is not true in the general case that any safety net will certainly have a cost. Here is a really good example of someone actually enabling checked arithmetic in production, benchmarking, and finding no measurable change in performance: https://www.reddit.com/r/rust/comments/2nlis8/which_classes_of_errors_remain_with_rust/cmeqh47/?context=2 https://www.reddit.com/r/rust/comments/2nlis8/which_classes_... Given that memory access is much slower than an integer comparison within the CPU, it's entirely possible that a bounds check can have zero performance impact, if it runs while the memory is being fetched, and your code is generally correct (i.e., does not cause the bounds check to raise an exception most of the time). Premature optimization is the root of all evil. (And if you're really interested in performance at the expense of security, consider running a unikernel: a lot of people run environments where there's essentially a single user on the box, and therefore no effective privsep. So why mess with copying things between userspace and kernelspace, enabling hardware protected memory, etc. when you don't need to?)
- marcosdumay 9y ago> killing buggy code is sort of my job Here "killing" buggy code means literally "kill -9" it. Is this really your job?
- geofft 9y agoIf the two options are that or letting it corrupt data, then yes. I'm on call for my own services. If I write a buffer overflow that can be exploited in production, I'd rather be woken up than hacked. We don't have a 100% SLA for uptime. We can be down for a bit and not have broken any of our commitments to customers. (My current job's SLA is super lenient, actually, and outside business hours, the control plane can be down for a while as long as the services being managed are up.) We do effectively have a 100% SLA for security, because there's no way to reset the world to an un-hacked state.
- hibbelig 9y agoIt's been "corrupting data" for 20 years now. What's worse: the 21st year of corrupting data, or immediately killing all those processes that used to be running fine yesterday? Or to put it another way: Let's say it takes one year to straighten out all those cases. What should happen during that year? Linus' option is that the kernel keeps running like it has been running the last 20 years. Linus is against the option that all those cases crash straight away. What you wrote about your code is that you can make sure to avoid those bugs in the first place, by putting in bounds checks. But that's not the position Linus is in. Linus has to deal with the past 20 years of lack of such checks.
- geofft 9y agoThat would make sense if the kernel is static, but it's not. New code is going in, and new applications are using the kernel, and new people are using the kernel constantly. New attackers with new techniques are showing up every day, too. And the new code in the kernel is likely introducing new bugs. I understand Linus' position about userspace backwards compatibility. I don't think anyone actually takes advantage of it in practice to the extent he seems to believe. That's why Red Hat maintains extremely long-term forks of the kernel from an ancient stable release, and even distros that do not make or lose money on compatibility (e.g. Debian) don't update kernel versions in stable releases. I've worked at what amounted to a Linux-on-the-desktop startup, and we were afraid to upgrade the kernel without upgrading a pile of userspace (udev, X, libGL, etc.) in concert - and when Ubuntu announced https://wiki.ubuntu.com/Kernel/LTSEnablementStack https://wiki.ubuntu.com/Kernel/LTSEnablementStack we were quite happy because it meant we could stop upgrading to every non-LTS Ubuntu release just to pick up hardware support. I've worked at a high-frequency trading shop that was hesitant to upgrade even point releases without significant vetting. These are both places where we hired people specifically for kernel expertise and where understanding the Linux kernel was part of our competitive advantage; it's hard for me to believe that the average company doing webdev on their Macs and running production on some random Linux AMI is more confident in kernel upgrades. So, if you have some worry that your kernel that's been serving you for the last 20 years will start crashing instead of corrupting data, there's an easy answer: stay on your stable branch, which you're probably already doing. Make your kernel static enough that the argument makes sense. I would firmly agree with an argument that new security hardening techniques do not belong in a stable branch. Go run some test traffic on the new kernel, but keep the old one in production while you do that. But I don't think anyone is served well by the advice to go ahead and take a new kernel release and trust that it won't corrupt data just because previous kernel versions haven't done so for the past 20 years. Or, for that matter, that the new kernel release won't start killing your processes. A misconfigured OOM killer is just a bug, too.
- jstewartmobile 9y agoFrom what I understood, the argument wasn't over bounds-checking or not. It was over warn vs kill on out-of-bounds.