News for hackers. Stuff that matters.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by snvzz on Thursday January 20, 2022 @03:43PM (#30014626)
There's likely many more of these.

As a reminder, Linux has millions of lines of code, and all of them run with supervisor privileges.

This is not a good architecture. Generally, you'd try to minimize the attack surface.

Multiserver, microkernel systems based on capabilities is where it's at.

seL4 is the better microkernel to build such a system on.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by athrowaway3z on Thursday January 20, 2022 @04:37PM (#30015431)
There exist people who own their own hardware and are not providing an API to run arbitrary code.

If they get together and build an OS they are generally more interested in throughput than security models.

Both have pro's and con's but the fact is: one is more popular with the "just get something working" crowd for better and worse.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by a-dub on Thursday January 20, 2022 @04:37PM (#30015439)
i predict that tanenbaum will ultimately win the famous monolithic vs. microkernel design debate.

monolithic kernels are good for building features quickly and runtime performance, but the security design reminds me of 90s era computer security approaches, where firewalls were supposed to stop all threats and behind them security was lax on internal networks. microkernels are much more similar to today's more effective defense in depth approaches.

what does it matter if your kernel is fast and featureful if you cannot trust it?

Re:Linux kernel heap buffer overflow in fs_context.c since v... by elihu on Thursday January 20, 2022 @10:32PM (#30018802)
I think Tanenbaum will win the argument in the sense that the way high-security OS kernels will be written will look like programming a microkernel, but when you look at what the hardware actually executes it'll look like a monolithic kernel.

As an example, think of how Rust treats thread communication. The API looks like you're passing messages, but the whole data isn't being copied when you send a message, you're just sending a pointer. The compiler keeps track of making sure ownership rules are respected.

One of the nice things about using a message passing API internally even if the implementation is just single-address-space shared memory is that if you really want more security you can change the implementation to be one where actual message passing takes place, and threads are isolated into separate address spaces like you would do in a proper microkernel. Whether you turn that on or not depends on whether security or performance are more important for your chosen application. It would be much harder to convert something like the Linux kernel into a microkernel.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by VWWHFSfQ on Thursday January 20, 2022 @06:56PM (#30017203)
> i predict that tanenbaum will ultimately win the famous monolithic vs. microkernel design debate.

Tanenbaum already lost the debate a long time ago. Minix is running in Intel CPUs but it's hardly exercising the benefits of a micro-kernel architecture. General-purpose PCs are running mono-kernels.

Maybe the micro-kernel will prove useful at some point in the future, but that's just theoretical. But _this_ war was lost. Maybe they'll win the next one!

Re:Linux kernel heap buffer overflow in fs_context.c since v... by a-dub on Thursday January 20, 2022 @07:16PM (#30017402)
i predict that ultimately the linux kernel will prove too difficult to fully secure.

i predict that the successor will ultimately be a microkernel architecture with ipc that is built from the ground up to be hardened against hostile components and will be accelerated in hardware. i predict we'll see something like realtime cryptographic proofs of both the identity and correct execution of operating system component code and the code of user programs.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by throwaway984393 on Thursday January 20, 2022 @08:12PM (#30017877)
I think the successor is multikernel. Modern systems trip over themselves to provide isolated runtime environments within one kernel, but it's all a waste once you pop a hole in the one kernel. The answer to that is virtualization of entire kernels, ala Firecracker.

Rather than tying ourselves into knots trying to extend the one kernel, we can just run 50 kernels, and have abstractions to connect them into a distributed OS (think Plan9). This allows the kernel to be simpler, provides an easier path to standardized interfaces between components, and lets us infinitely scale a single system, with stronger isolation guarantees.

It's basically a microkernel but the components are farther apart. And because of that you can do things like have multiple different kernel versions interoperate over one stable abstraction/API/whatever. SSI clusters are another example of this, they just happen to be using the same kernel, but they don't have to.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by pjmlp on Friday January 21, 2022 @03:24AM (#30020702)
If he lost why do Linux fakes microkernels with hypervisors and containers to start with?

Also Android has tamed Linux into a pseudo-microkernel with Project Treble, where all drivers are their own processes using Android IPC.

On Android traditional Linux drivers are considered "legacy" and kept around for compatibility with upstream and previous Android versions pre-Treble.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by pjmlp on Friday January 21, 2022 @03:21AM (#30020680)
He already won, microkernels are everywhere on the embedded space.

And lets not forget that those running Intel hardware need Minix to run Linux.

Ah and containers are nothing more than playing at microkernels with monolith OSes.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by snvzz on Thursday January 20, 2022 @05:52PM (#30016490)
>what does it matter if your kernel is fast and featureful if you cannot trust it?

And if the kernel is Linux, I'm not so sure about fast.

Relative to Linux, seL4 has:

- Order of magnitude faster context switch.

- Order of magnitude lower scheduler latency.

- Order of magnitude faster Inter-Process Communication.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by dundarious on Thursday January 20, 2022 @06:51PM (#30017159)
You can't really draw conclusions about systems built on Linux vs seL4 from that though. You can have far more IPC in order to do anything useful in microkernels. I'm not dismissing either OS or architecture, but just saying that extrapolating from micro-metrics is very hard when their use in the different architectures varies significantly.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by VWWHFSfQ on Thursday January 20, 2022 @03:46PM (#30014673)
It's my understanding that the microkernel architecture is slow. Nearly unusably slow. And that's why nobody uses it. Am I off-base? I'm interested!
Re:Linux kernel heap buffer overflow in fs_context.c since v... by jeffbee on Thursday January 20, 2022 @03:57PM (#30014863)
As more and more things move out of the kernel, the perceived performance problems of microkernels look less important. If you are doing your network protocols in user space, and your thread scheduling is in user space, and you're not using a traditional filesystem much, then suddenly nobody cares how fast the kernel is.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by stormbrew on Thursday January 20, 2022 @04:38PM (#30015444)
Yeah this, really. For the most part even monolithic kernels have kind of reversed trend in the last decade or so and there's a lot of push to move critical code out of the kernel. A lot of new kernel apis are built to avoid context switching, and part of that usually involves moving to a more asynchronous kind of communication between process and kernel.

Often these APIs even look an awful lot like late generation microkernel shared memory buffer protocols. DRI and uring in linux for example.

A lot of the "microkernels are inherently slow" meme is built on how earlier port-based message passing kernels like mach worked.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by athrowaway3z on Thursday January 20, 2022 @04:49PM (#30015602)
I'm really not understanding what you're saying here.

What the hell is a microkernel here? What kind of security are you talking about?

User space filesystem and network implementations still need access to the hardware. Multiplexing that access is a kernels job. The more you want to separate and hide that between clients the higher the cost.

As far as i understand your argument you are saying "If an application has a dedicated hard drive there will be little overhead"

Re:Linux kernel heap buffer overflow in fs_context.c since v... by jeffbee on Thursday January 20, 2022 @04:59PM (#30015715)
People think a monolithic kernel can be faster because of high-level abstractions that make many calls within the kernel, for example if I write to a TCP socket and everything else is handled for me, in the kernel, by function calls only. People believe this is faster than having an isolated network stack that has to pass messages to an isolated network driver and all that.

But increasingly people realize that the performance of writing to a TCP socket in a unikernel also pretty much sucks and you get a much better result as you move more and more of it into user space. For example you decide, correctly, that TCP is obsolete and you switch to QUIC. Now the existence of the Linux TCP stack is of no value to you. You furthermore discover that Linux firewall, traffic control, and routing also kinda sucks, so you start using raw networking. Then you discover that trying to get your frames processed on the right core at the right moment isn't great in Linux, so you just take over the whole net device with DPDK.

Now, nothing in the whole Linux network stack is of any use to you at all.

The same thing can happen with storage. Maybe you started with files on XFS but then eventually you were using disaggregated storage where a service takes over the whole device with SPDK, and all the storage users are talking to the service instead of the kernel.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by tialaramex on Thursday January 20, 2022 @09:02PM (#30018280)
Of course, although you may be able to go very much faster, you also now took on all this extra responsibility, and so complexity, and so likely bugs.

Chances are the weird corner case where the TCP implementation blows up was seen in a dozen other Linux applications and fixed, but the same case inside your entirely userspace QUIC implementation gets to explode while the boss is doing the live $100M pitch demo. Awkward.

Code that is competing with Linux for performance is likely to be highly concurrent (a big risk factor for bugs) and doing fancy gymnastics with memory (another risk factor) so we're not talking about a landscape where bugs are rare or one where they're very easy to track down.

I believe this sort of thing is one reason Linux is putting more emphasis on safety. As usual for HN this bug already has people saying both "Rust wouldn't catch this" and "actually Rust would catch this", but even if you're quite sure Rust isn't the answer a safer Linux by whatever means makes this argument better for Linux than it is today.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by pjmlp on Saturday January 22, 2022 @06:41AM (#30035838)
The QUIC implementation was written in Rust, so the live $100M pitch demo is safe.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by adwn on Friday January 21, 2022 @02:13AM (#30020236)
> User space filesystem and network implementations still need access to the hardware.

No, they don't. Filesystems don't need access to the hardware, that part is handled by the block device driver. Network stacks (e.g., TCP/IP) also don't need access to the hardware, that part is handled by the network interface driver.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by snvzz on Thursday January 20, 2022 @05:44PM (#30016386)
There's more myth than truth[0]. In the early days, they were slow. Mach, used in OSX, is a representative of those early days.

Liedtke's L4 proved that a performant microkernel is possible.

Later, SMP changed the scenario considerably, as all of a sudden the microkernel multiserver fits SMP like a globe, while monolithic kernels need the complexity of locks to handle it.

[0] https://news.ycombinator.com/item?id=10824382

Re:Linux kernel heap buffer overflow in fs_context.c since v... by erichocean on Thursday January 20, 2022 @06:56PM (#30017201)
> Mach, used in OSX, is a representative of those early days.

Mach, the microkernel, is not using in OS X and never has been.

Mach, the API, is used (mostly due to legacy reasons).

OS X has a Linux-style monolithic kernel (with legacy Mach APIs in userspace).

Re:Linux kernel heap buffer overflow in fs_context.c since v... by dippersauce on Thursday January 20, 2022 @11:38PM (#30019240)
>Mach, the microkernel, is not using in OS X and never has been.

The version of mach present in XNU is derived from OSFMK, which derives code from UoU's Mach 4 kernel, and from CMU's Mach 3 kernel. It contains improvements related to threading and contexts. It also definitely exists as more than an API. The code that makes up mach is present and identifiable, and thus is "in" XNU. [1]

>Mach, the API, is used (mostly due to legacy reasons).

See above. Abstractions are exposed, and traps are present, but this is not an API clone, it is mach, albeit modified from the original form. It was specifically chosen for its forward thinking benefits. Mach was not the basis for any major Apple OS prior to OS X. There were no "legacy reasons" to motivate its adoption.

>OS X has a Linux-style monolithic kernel (with legacy Mach APIs in userspace).

You do tend to see different opinions on this. Some argue macOS is a hybrid kernel, because it combines elements from a microkernel (mach), a monolithic kernel (BSD), and IOKit. A single address space is shared by the components though, which leads many to call it monolithic. [2]

1. https://github.com/apple/darwin-xnu/tree/main/osfmk

2. https://flylib.com/books/en/3.126.1.67/1/

Re:Linux kernel heap buffer overflow in fs_context.c since v... by pjmlp on Friday January 21, 2022 @03:27AM (#30020725)
Additionally macOS is going further down this path by moving kernel extensions into userspace.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by dralley on Thursday January 20, 2022 @11:00PM (#30018971)
I thought Windows and OSX were closer to hybrid kernels, at least with respect to running a lot of their drivers in userspace.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by dippersauce on Thursday January 20, 2022 @11:41PM (#30019260)
Almost every developer I have worked with considers NT and XNU to be hybrid at this point. Unfortunately, almost everything in the parent comment is incorrect.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by erichocean on Friday January 21, 2022 @07:53PM (#30031943)
> Unfortunately, almost everything in the parent comment is incorrect.

Avie Tevanian would disagree, but what does he know?

P.s. Nice job regurgitating Wikipedia in your other comment, without understanding it. I guess with only 30 karma, you've got to get your HN points somehow… Next time, read the Wikipedia entry on Mach so you'll learn that Mach didn't even become an actual microkernel until version 3.0. OS X's XNU kernel branched at 2.5. Oops.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by roblabla on Thursday January 20, 2022 @07:27PM (#30017507)
The Nintendo Switch operating system, Horizon/NX, is a capability-based microkernel architecture. It's nowhere near unusably slow. In fact, its performance are pretty good. It does "cheat" a bit in that the whole OS runs on a single core, dedicating the remaining three cores to the game. But that may actually be the most efficient use of the hardware.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by dijit on Thursday January 20, 2022 @03:55PM (#30014829)
Yes, it’s going to be slower

All of those security checks between components and memory passing will cause it to be slower.

But that doesn’t mean it’s a worthy trade off.

People write software in python despite it being slower than C++.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by hutrdvnj on Thursday January 20, 2022 @04:02PM (#30014945)
Except that anything that is actually performance critical is written as a C extension python module.

I think that low level filesystem operations are very performance critical.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by jeffbee on Thursday January 20, 2022 @04:14PM (#30015120)
I doubt that mounting a filesystem is performance-critical. You could afford to fork an unprivileged user-space process written in Perl to parse these mount options and that would be fast enough for everyone.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by YarickR2 on Thursday January 20, 2022 @05:07PM (#30015829)
Tell that to dockerd mounting images layer by layer , with k8s doing all kinds of emptyDir/PVC mounts on top. Pod start up speeds are abysmal now, they would be positively glacial with userspafe permissions validations
Re:Linux kernel heap buffer overflow in fs_context.c since v... by stormbrew on Thursday January 20, 2022 @07:48PM (#30017694)
?? The layering unionfs (really aufs or overlayfs) mounts docker does are all in kernel. There's no userspace involvement in the actual file ops. I'm not at all sure what you think any of that has to do with the idea of usermode filesystem handling.

Anyways, on linux userland filesystem stuff (ie. fuse) is slow because the kernel manages the vfs layer and has to mediate. In a system designed for non-privileged vfs it doesn't have to be anywhere near so involved. And beyond that, there's really nothing in particular that a filesystem driver does that needs to be privileged to 'run fast'.

VFS is pretty much the posterchild case for how you can pull things out of a kernel and maintain performance, tbh. There's no reason at all it can't be fast except the kernel getting in the way rather than helping.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by jeffbee on Thursday January 20, 2022 @05:22PM (#30016055)
That's exactly my point. People who are doing lots of mounts are already demonstrably not performance-sensitive to a difference of a few milliseconds. They already waited 20 minutes for the stupid cluster autoscaler to provision a machine for them. They DGAF.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by Shorel on Friday January 21, 2022 @04:18AM (#30021090)
They just need some time off for leisure activities.

https://xkcd.com/303/

Re:Linux kernel heap buffer overflow in fs_context.c since v... by 01100011 on Thursday January 20, 2022 @08:43PM (#30018128)
Generally yes. The microkernel architecture is theoretically better in many ways and this has led to many attempts over the years to switch to that architecture. Some attempts have been relatively successful. Over time, as hardware becomes more heterogeneous and more capable, we are likely going to see a move to microkernels.

Like many engineering decisions, the choice is not always clear cut. Other commenters have suggested microkernels are clearly superior and not choosing them is stupid, but there are many facets to that decision.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by pjmlp on Friday January 21, 2022 @03:25AM (#30020711)
QNX is a microkernel and is used everywhere on embedded space, and it isn't the only one.

Microkernels are the preferred choice in high integrity computing.

Re:Linux kernel heap buffer overflow in fs_context.c since v... by nwmcsween on Thursday January 20, 2022 @04:39PM (#30015456)
This depends on the definition of the word microkernel, in the classical definition yes it will be much slower due to IPC, for something like an exokernel though it will be much faster than even a monolithic kernel.
Re:Linux kernel heap buffer overflow in fs_context.c since v... by ylyn on Friday January 21, 2022 @12:35AM (#30019569)
You likely run only a small subset of those millions of lines, because the bulk of those are in drivers and arch-specific code..
Re:Linux kernel heap buffer overflow in fs_context.c since v... by inshadows on Friday January 21, 2022 @05:14AM (#30021536)
don't forget rust