Live data from Hacker News

Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

github.com

71–80 of 234 posts

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#71
post #60

Lol. I am Malaysian Chinese but I honestly don't think anyone will put into production a Chinese made kernel. The risk is too high, same as no one will use a Linux distro coming out of Russian, Iran or NK. It's just cultural bias in the west.

Supposing it caught on... which do you think is riskier? Running an OS written in mostly memory safe code that somewhat might have tried to slip a backdoor in, or running an OS written in mostly memory unsafe code that has a long history of vulnerabilities and the Chinese almost certainly know about a vulnerability in.

If this catches on and has generally been subject to significant third party code review with positive results, I'm not sure any backdoor is lower cost to use than an equivalent linux vulnerability. To be fair, I'm not sure it isn't either.

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#72
post #46

Earlier quoted context omitted.

More recently, in a similar vein: > Torvalds seemed optimistic that "some clueless young person will decide 'how hard can it be?'" and start their own operating system in Rust or some other language. If they keep at it "for many, many decades", they may get somewhere; "I am looking forward to seeing that". Hohndel clarified that by "clueless", Torvalds was referring to his younger self; "Oh, absolutely, yeah, you hav…

> Hohndel clarified that by "clueless", Torvalds was referring to his younger self As the saying goes "We do this not because it is easy, but because we thought it would be easy." Occasionally these are starts of great things.

Sometimes, we do such things because it’s hard. We enjoy the challenge. Those that succeed are glad to make it, too.

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#73

I think this looks incredible. Like how does one create a compatible abi _for all of linux_??? Wow! > utilize the more productive Rust programming language Nitpick: it’s 2024 and these ‘more productive’ comparisons are silly, completely unscientific, And a bit of a red flag for your project: The most productive language for a developer is the one they understand what is happening one layer below the level of abstract…

> Like how does one create a compatible abi _for all of linux_???

You look at Linux's syscall table[0], read through the documentation to figure out the arguments, data types, flags, return values, etc., and then implement that in your kernel. The Linux ABI is just its "library" interface to userspace.

It's probably not that difficult; writing the rest of the kernel itself is more challenging, and, frankly, more interesting. Certainly matching behavior and semantics can be tricky sometimes, I'm sure. And I wouldn't be surprised if the initial implementation of some things (like io_uring, for example, if it's even supported yet) might be primitive and poorly optimized, or might even use other syscalls to do their work.

But it's doable. While Linux's internal ABI is unstable, the syscall interface is sacred. One of Torvalds' golden rules is you don't break userspace.

[0] https://filippo.io/linux-syscall-table/

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#74

There was also the similar project Kerla¹ but development stalled. Recently people argued that instead of focusing on Rust-for-Linux it would be easier to create a drop-in replacement like these two. I wonder if there are enough people interested to make this happen as a sustained project. ¹ https://github.com/nuta/kerla/

> Recently people argued that instead of focusing on Rust-for-Linux it would be easier to create a drop-in replacement like these two

I guess it depends on what they mean by "easy". Certainly it's easier in the sense that you can just write code all day long, and not have to deal with the politics about Rust inside Linux, or deal with all the existing C interfaces, finding ways to wrap them in Rust in good, useful ways that leverage Rust's strengths but don't make it harder to evolve those C interfaces without trouble on the Rust side.

But the bulk of Linux is device drivers. You can build a kernel in Rust (like Asterinas) that can run all of a regular Linux userland without recompilation, and I imagine it's maybe not even that difficult to do so. But Asterinas only runs on x86_64 VMs right now, and won't run on real hardware. Getting to the point where it could -- especially on modern hardware -- might take years. Supporting all the architectures and various bits of hardware that Linux supports could take decades. I suppose limiting themselves to three or four architectures, and only supporting hardware made more recently could cut that down. But still, it's a daunting project.

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#75

Decades ago Linus Torvalds was asked in an interview if he feared Linux to be replaced by something new. His answer was that some day someone young and hungry would come along, but unless they liked writing device drivers Linux would be safe. This is all paraphrased from my memory, so take it with a grain of salt. I think the gist of it is still valid: Projects like Asterinas are interesting and have a place, but the…

I feel like there's a potentially large audience for a kernel that targets running in a VM. For a lot of workloads, a simple VM kernel could be a win.

How is that different from Linux with all virtio drivers? (You can just not compile real hardware drivers)

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#76

I personally dislike rust, but I love kernels, and so I'll always check these projects out. This is one of the nicer ones. It looks pretty conservative in it's use of Rust's advanced features. The code looks pretty easy to read and follow. There's actually a decent amount of comments (for rust code). Not bad!

Otherwise is a decent language but what makes it difficult is the borrow semantics and lifetimes. Lifetimes are more complicated to get your head around.

But then there's this Arc, Ref, Pinning and what not - how deep is that rabbit hole?

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#77
Side question - I have always wondered how a Linux system is configured at the lowest level?

Let's take example of network. There's IP address, gateway, DNS, routes etc. Depending on distribution we might see something like netplan reading config files and then calling ABI functions?

Or Linux kernel directly also reads some config files? Probably not...

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#78
post #24

Earlier quoted context omitted.

They mention this in https://github.com/asterinas/asterinas/blob/2af9916de92f8ca1... > While we prioritize compatibility, it is important to note that Asterinas does not, nor will it in the future, support the loading of Linux kernel modules.

It's a lot "simpler" to support a Linux userland as that means one needs to "just" emulate all the Linux syscalls, than to implement the literally countless internal APIs needed for drivers etc, as that would otherwise mean literally reimplementing the whole Linux kernel and that's neither realistic, nor too useful.

And that’s not all that simple, as has been experienced by Solaris (never released(?) Linux branded zones, illumos (lx brand), and Windows (WSL1) developers that have tried to make existing kernels act like Linux.

It’s probably easier if the kernel’s key goal is to be compatible with the Linux ABI rather than being compatible with its earlier self while bolting on Linux compatibility.

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#79

> Linux-compatible ABI There's no specification of that ABI, much less a compliance test suite. How complete is this compatibility?

While developing the lx brand on illumos/SmartOS, ltp was helpful. It may not be complete, but it is a pretty good start.

https://linux-test-project.readthedocs.io/en/latest/

Re: Asterinas: OS kernel written in Rust and providing Linux-compatible ABI

#80
post #46

Decades ago Linus Torvalds was asked in an interview if he feared Linux to be replaced by something new. His answer was that some day someone young and hungry would come along, but unless they liked writing device drivers Linux would be safe. This is all paraphrased from my memory, so take it with a grain of salt. I think the gist of it is still valid: Projects like Asterinas are interesting and have a place, but the…

More recently, in a similar vein: > Torvalds seemed optimistic that "some clueless young person will decide 'how hard can it be?'" and start their own operating system in Rust or some other language. If they keep at it "for many, many decades", they may get somewhere; "I am looking forward to seeing that". Hohndel clarified that by "clueless", Torvalds was referring to his younger self; "Oh, absolutely, yeah, you hav…

"You are enthusiastic and write kernel device drivers in rust. Write a device driver for an Intel i350 4 Port gigabit ethernet controller"
Post reply on HN