7 ms·
I don't think that this would have been solved by keeping encryption and filesystems outside of the kernel. A stack overflow is a stack overflow, wherever it is
by geofft 10y ago
I don't think that this would have been solved by keeping encryption and filesystems outside of the kernel. A stack overflow is a stack overflow, wherever it is. If you split out all the relevant code out of the kernel but changed nothing else, you'd still be able to escalate privileges to run code in the context of the unencrypted filesystem. At that point, the fact that you weren't able to get to the microkernel is sort of academic—everything of value is in the unencrypted filesystem.
This might be an argument for greater stack protections (say, guard pages) on sensitive code, but you can do that just fine on a monolithic kernel.
- rwmj 10y agoIn both a microkernel and an exokernel, the userspace servers (micro) or the shared libraries (exo) have effectively unlimited stack. If you do exceed the stack limits then the process will crash, which for a microkernel means the service is restarted afresh while for an exokernel means the user process dies. Whereas in Linux you have 16K stack (or only 8K up to a few years ago) and if you exceed it you can overwrite bits of kernel memory, including a crucial struct which was used to exploit the whole kernel as in this exploit. Having a guard page is technically difficult in Linux since there's no virtual memory in the kernel, so you can't have an unmapped page, and even having an extra page is difficult because kernel stacks have to be allocated contiguously (this point might not apply to other monolithic kernels however). So I believe there is a real difference. However my main point is that userspace code is more flexible, so: - It's a lot easier to write than kernel code. - You can write it in different languages, perhaps ones which by design don't have buffer overflows at all. - Even if you write your servers in C, you can enable many more exploit protection features in userspace code. - You can use more complex algorithms, including recursive ones (think trees), so your code might be faster. - You can use garbage collection which means you can manage memory without going crazy, and should have fewer memory leaks. - The barrier to entry is lower, so I'd expect to see a lot more features (eg. strange and exotic filesystems), even if some of those features might be a bit half-baked.
- geofft 10y ago> Having a guard page is technically difficult in Linux since there's no virtual memory in the kernel, so you can't have an unmapped page This isn't true. The last line in the article links to patches that add guard pages to Linux: https://lkml.org/lkml/2016/6/15/1064 https://lkml.org/lkml/2016/6/15/1064 You absolutely have virtual memory in the kernel—that's how the kernel gets to live at a fixed high address in every process, and that's how it gets to read things from userspace when it needs to. When a process makes a system call, the virtual memory map stays exactly the same; the CPU just switches to supervisor mode and starts using a different segment that enables accessing kernel memory. What you don't easily have, at least on Linux, is the ability to page things out (which is sometimes colloquially called "virtual memory" thanks to some customer-facing marketing in the '90s), but that's not an inherent requirement of monolithic kernels. NT, for instance, allows paging out certain parts of kernel memory (though obviously not the parts that are needed to page things back in), at the cost of a bit of mental overhead from driver authors. And this isn't necessarily solved in microkernels or exokernels: your swap device is going to be supported by at least a few userspace drivers. If you're using a machine with full-disk encryption, your disk encryption server isn't allowed to swap. What you also don't have on Linux is different mappings for different kernel threads (all of kernel memory is mapped in every thread, accessible by kernel code only) and memory protection between kernel threads, but you don't really need that, and that wouldn't have helped solve this problem. > kernel stacks have to be allocated contiguously There's no particular reason that segmented stacks (like old Go or old Rust had) couldn't be used in the kernel. They're just complicated, and both Go and Rust found that they were bad for performance. > It's a lot easier to write than kernel code. I'm not convinced by this. Apart from the experimental evidence that monolithic kernels have been far more featureful, there's the inherent problem that you don't really know what assumptions you get to make. You're only in mostly-userspace code; there's the example I mentioned above of the full-disk-encryption driver, which doesn't get to swap because it would be implementing its own swap device. If you want your OS to support swap files, filesystem drivers can't swap. If you have syslog over local sockets, your socket implementation can't syslog. And so forth. What is easier (as I advocated in another comment) is to keep the monolithic kernel model, but pretend that privsep within a single kernel doesn't happen, and run it all within VMs.