Asterinas: OS kernel written in Rust and providing Linux-compatible ABI
364 points by Klasiaster 8 months ago | 224 comments- akira2501 8 months agoI 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!
- wg0 8 months agoOtherwise 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?
- junon 8 months agoContext: I'm writing a novel kernel in Rust.
Lifetimes aren't bad, the learning curve is admittedly a bit high. Post-v1 rust significantly reduced the number of places you need them and a recent update allows you to elide them even more if memory serves.
Arc isn't any different than other languages, not sure what you're referring to by ref but a reference is just a pointer with added semantic guarantees, and Pin isn't necessary unless you're doing async (not a single Pin shows up in the kernel thus far and I can't imagine why I'd have one going forward).
- mcherm 8 months agoWould you not want to use Pin when sharing memory with a driver or extension written in a different language (eg: C)?
- mcherm 8 months ago
- baq 8 months agoIf you’re writing C and don’t track ownership of values, you’re in a world of hurt. Rust makes you do from day one what you could do in C but unless you have years of experience you think it isn’t necessary.
- wg0 8 months agoOkay, I think it is is more like Typescript. You hate it but one day you just write small JS program and convert it to Typescript to discover that static analysis alone had so many code paths revealed that would have resulted in uncaught errors and then you always feel very uncomfortable writing plain Javascript.
But what about tools like valgrind in context of C?
- metalloid 8 months agoIt was true until LLMs arrive. Feature compilers + IDEs can be integrated with LLMs to help programmers.
Rust was a great idea, before LLMs, but I don't see the motivation for Rust when LLMs can be the solution initial for C/C++ 'problems'.
- wg0 8 months ago
- oersted 8 months agoI don’t entirely agree, you can get used to the borrow checker relatively quickly and you mostly stop thinking about it.
What tends to make Rust complex is advanced use of traits, generics, iterators, closures, wrapper types, async, error types… You start getting these massive semi-autogenerated nested types, the syntax sugar starts generating complex logic for you in the background that you cannot see but have to keep in mind.
It’s tempting to use the advanced type system to encode and enforce complex API semantics, using Rust almost like a formal verifier / theorem prover. But things can easily become overwhelming down that rabbit hole.
- jonathanstrange 8 months agoIt's just overengineered. Many Rust folks don't realize it because they come from C++ and suffer from Stockholm Syndrome.
- jonathanstrange 8 months ago
- KingOfCoders 8 months agoI always feel Arc is the admission that the borrow checker with different/overlapping lifetimes is too difficult, despite what many Rust developers - who liberally use Arc - claim.
- jeroenhd 8 months agoLifetime tracking and ownership are very difficult. That's why languages like C and C++ don't do it. It's also why those languages needs tons of extra validation steps and analysis tools to prevent bugs.
Arc is nothing more than reference counting. C++ can do that too, and I'm sure there are C libraries for it. That's not an admission of anything, it's actually solving the problem rather than ignoring it and hoping it doesn't crash your program in fun and unexpected ways.
Using Arc also comes with a performance hit because validation needs to be done at runtime. You can go back to the faster C/C++ style data exchange by wrapping your code in unsafe {} blocks, though, but the risks of memory corruption, concurrent access, and using deallocated memory are on you if you do it, and those are generally the whole reason people pick Rust over C++ in the first place.
- Galanwe 8 months agoIt's not that the borrow checker is too difficult, it's that it's too limiting.
The _static_ borrow checker can only check what is _statically_ verifiable, which is but a subset of valid programs. There are few things more frustrating than doing something you know is correct, but that you cannot express in your language.
- GolDDranks 8 months agoIt's not just difficult, sometimes it's impossible to statically know a lifetime of a value, so you must dynamically track it. Arc is one of such tools.
- lmm 8 months agoIf tracking lifetimes is simple 90% of the time and complex 10% of the time, maybe a tool that lets you have them automatically managed (with some runtime overhead) that 10% of the time is the right way forward.
- surajrmal 8 months agoArc usually means you've not structured your code to have clear lifetimes where one object clearly outlives another. Typically I see c++ applications avoid it but actually suffer from bugs due to the same structural deficiencies. They said, I think it's almost always possible to to avoid it if you try hard enough. With async you need to use structured concurrency.
- jeroenhd 8 months ago
- oneshtein 8 months agoRust lifetime is just a label for a region of memory with various data, which is discarded at the end of its life time. When compiler enters a function, it creates a memory block to hold data of all variables in the function, and then discards this block at the exit from the function, so these variables are valid for life time of the function call only.
- junon 8 months ago
- IshKebab 8 months agoRust code is usually well commented in my experience.
- cies 8 months agoInstead of asking "what other languages and project (open/closed, big/small, web/mobile/desktop, game/consumerapp/bizapp) have you experience with as to come to this conclusion?" people down vote you.
So lemme ask: what other languages and project (open/closed, big/small, web/mobile/desktop, game/consumerapp/bizapp) have you experience with as to come to this conclusion?
- iknowstuff 8 months agofor the downvoters: it’s true, and it’s because of rustdoc and doctests. comments become publicly browsable documentation, and any code contained within is run as a part of the test suite.
- cgh 8 months agoJavadoc pioneered this 25+ years ago and despite that, there's plenty of poorly-documented Java code out there. Orders of magnitude more of it than all of the Rust code in existence, in fact.
Intuition tells me that Rust is young enough to attract a certain type of early adopter, the kind of programmer who is more likely to document their code well from the outset.
- 1oooqooq 8 months agothink the downvotes are because of relevance. point was not using advanced rust features, not being documented
- cgh 8 months ago
- cies 8 months ago
- wg0 8 months ago
- justmarc 8 months agoI'm interested in these kind of kernels to run very high performance network/IO specific services on bare metal, with minimal system complexity/overheads and hopefully better (potential) stability and security.
The big concern I have however is hardware support, specifically networking hardware.
I think a very interesting approach would be to boot the machine with a FreeBSD or Linux kernel, just for the purposes of hardware as well as network support, and use a sort of Rust OS/abstraction layer for the rest, bypassing or simply not using the originally booted kernel for all user land specific stuff.
- nijave 8 months agoCouldn't you just boot the Linux kernel directly and launch a generic app as pid 1 instead of a full blown init system with a bunch of daemons?
That's basically what you're getting with Docker containers and a shared kernel. AWS Lambda is doing something similar with dedicated kernels with Firecracker VMs
- mjevans 8 months agoYes, you can. You can even have a different Pid 1 configure whatever and then replace it's core image with the new Pid 1.
- justmarc 8 months agoYes, but I wanted to bypass having the complexity of the Linux kernel completely, too.
Basically single app directly to network (the world) and as little as possible else in between.
- afr0ck 8 months agoLinux kernel is not complex. Most of the code runs lock-free. For example, the slab allocator in the kernel uses only a single double_cmpxhg instruction to allocate an object via kmalloc(). The algorithm scales to any number of CPUs and has NUMA awareness. Basically, the most concurrent, lowest allocation latency allocator you can get in the market, which also returns the best objects for the requesting process on big memory systems.
The complexity on the other hand is architectural and logical to achieve scale to hundreds of CPUs, maximise bandwidth and reduce latency as much as possible.
Any normal Rust kernel will either have issues scaling on multi-cores or use tax-heavy synchronisation primitives. The kernel RCU and lock-free algorithm took a long time to be discovered and become mature and optimised aggressively to cater for the complex modern computer architectures of out-of-order execution, pipelining, complex memory hierarchies (especially when it comes to caching) and NUMA.
- afr0ck 8 months ago
- mjevans 8 months ago
- cgh 8 months agoIf you want truly high-performance networking, you can bypass the kernel altogether with DPDK. So you don't have to worry about alternative kernels for other tasks at all. On the downside, DPDK takes over the NIC entirely, removing the kernel from the equation, so if you need the kernel to see network traffic for some reason, it won't work for you.
You can check out hardware support here: https://core.dpdk.org/supported/nics/
- jauntywundrkind 8 months agoThis was true a decade ago, with modern io_uring dpdk is probably an anti-pattern.
- cgh 8 months agoInteresting, it's been awhile since I looked at this stuff so I did a little searching and found this: https://www.diva-portal.org/smash/get/diva2:1789103/FULLTEXT...
Their conclusion is io_uring is still slower but not by much, and future improvements may make the difference negligible. So you're right, at least in part. Given the tradeoffs, DPDK may not be worth it anymore.
- monocasa 8 months agoI'm not sure that's true for a good chunk of the workloads that dpdk really shines on.
A lot of the benefit of dpdk is colocating your data and network stack in the same virtual memory context. io_uring I can see getting you there if you have you're serving fixed files as a cdn kind of like netflix's appliances, but for cases where you're actually doing branchy work on the individual requests, dpdk is probably a little easier to scale up to the faster network cards.
- GoblinSlayer 8 months agoIf you use io_uring, you're subject to vulnerabilities in kernel network stack which you have no control over.
- cgh 8 months ago
- jauntywundrkind 8 months ago
- treeshateorcs 8 months agoi might be wrong but if it's ABI compatible the same drivers will work?
p.s.: i was wrong
>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.
https://asterinas.github.io/book/kernel/linux-compatibility....
- yjftsjthsd-h 8 months agoLinux doesn't even maintain ABI compatibility with itself, nobody else is going to manage it. The possibility that might work is there's a couple projects that maintain just enough API compatibility to reuse driver code from Linux (IIRC FreeBSD does this for some graphics drivers). But even then you're gambling with whether Linux decides to change implementation details one day, since internal APIs explicitly aren't stable.
- bcrl 8 months agoThe Linux kernel community takes ABI compatibility for userland very seriously. That developers in userland are frequently unwilling to understand issues surrounding ABI stability is not the fault of the Linux kernel.
- bcrl 8 months ago
- bicolao 8 months agoThey 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.
- justmarc 8 months agoIt'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.
- justmarc 8 months ago
- justmarc 8 months agoNo, it means you can run Linux userland/apps on this kernel, to the level/depth which they currently support of course.
They might not yet implement everything that's needed to boot a standard Linux userland but you could say boot straight into a web server built for Linux, instead of booting into init for example.
- dathinab 8 months agoin general the ABI is kernel<->user space while the ABI (and potentially even API) on the inside (i.e. for drivers) can change with every kernel version (part of why it's so important to maintain drivers in-tree)
- yjftsjthsd-h 8 months ago
- protoman3000 8 months agoWhy don’t you just use a SmartNIC and P4? It won’t get faster than running on the NIC itself
- nijave 8 months ago
- tiffanyh 8 months agoOT: if you're interested in Asterinas, you might also be interested in Redox (entire OS written in Rust).
- DoctorOW 8 months agoI love Redox as a project because while it still has a massive ways to go, it's the closest to being a new OS/Kernel that has the potential to make it to a viable daily driver. Windows/MacOS/Unix/Linux are all incredibly old by software standards and Redox is bringing some cool design decisions.
- metaketa 8 months agoThis is fascinating! Couldn't really find the kernel code but would love to know more about the applicability. I'm curious since seeing the Unikraft release that promised millisecond container boot times
- cmiller1 8 months ago
- cmiller1 8 months ago
- snvzz 8 months agoRedox has a proper architecture, aka microkernel multiserver.
Thus it is a much more interesting project.
- apatheticonion 8 months agoTo be fair Aester is just a monolithic kernel that philosophically quarantines unsafe code to the lowest level of the kernel.
You still have kernel modules for microkernel-like functionality
- apatheticonion 8 months ago
- DoctorOW 8 months ago
- exabrial 8 months agoI 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 abstraction they are working with. Unless you’re comparing something rating Ruby vs RiscV assembly, it’s just hocus-pocus.
- jmmv 8 months ago> I think this looks incredible. Like how does one create a compatible abi _for all of linux_??? Wow!
FWIW that’s what the Linux compatibility layer in the BSDs does and also what WSL 1 did (https://jmmv.dev/2020/11/wsl-lost-potential.html).
It’s hard to get _everything_ perfectly right but not that difficult to get most of it working.
- NewJazz 8 months agoIIRC Fuschia has something similar. And maybe Redox?
- NewJazz 8 months ago
- dathinab 8 months agoIdk. Asahi Linux GPU driver breaks all "common sense" of "how fast a reliable usable feature rich driver" was produced by a small 3rd party team.
The company I work for has both rust and python projects (through partially pre "reasonable python type linting" using mypy and co.) and the general consensus there is "overall" rust is noticeable more productive (and stable in usage/reliable), especially if you have code which changes a lot.
A company I worked previous for had used rust in the very early days (around 1.0 days) and had one of this "let's throw up a huge prototype code base in a matter of days and then rewrite it later" (basically 90% of code had huge tech dept). But that code base stuck around way longer then intended, caused way less issues then expected. I had to maintain it a bit and in my experience with similar code in Python and Js (and a bit Jave) I expected it to be very painful but surprisingly it wasn't, like at all.
Similar comparing my experience massive time wastes due to having to debug soundness/UB issues in Rust, with experiences in C/C++ it's again way more productive.
So as long as you don't do bad stuff like over obsessing with the type system everything in my experience tells me using Rust is more productive (for many tasks, definitely not all task, there are some really grate frameworks doing a ton of work for you in some languages against which the rust ecosystem atm. can't compete).
---
> Most productive language for a developer is the one they understand what is happening one layer below the level of abstraction they are working with.
I strongly disagree, the most productive language is the one where the developer doesn't have to care much about what happens in a layer below in most cases. At least as long as you don't want obsess over micro optimizations not being worth the time and opportunity cost they come with for most companies/use cases.
- kelnos 8 months ago> 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.
- JoshTriplett 8 months ago> 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.
As well as some subset of the files expected in /dev, /proc, /sys, and similar, which are also part of the userspace ABI. And the startup mechanisms for processes, and the layout of AUXV...
It's absolutely doable, but the interface is wider than just the syscall layer.
- JoshTriplett 8 months ago
- ozgrakkurt 8 months agoEveryone says what they are used to is better or more productive. Even in assembly vs ruby, some stuff are much easier in assembly and maybe impossible in ruby afaik
- exabrial 8 months agoI’m aging myself, but ~17 years ago I was in San Diego for a conference. There was a table level competition to see who could write the fastest program in 20 minutes (we were doing a full text search of a ‘giant’ 5g file). One of the guys at the table wrote some SPARC assembly to optimize character matching that was a hotspot like he was speaking French.
Ah good times.
- exabrial 8 months ago
- jmmv 8 months ago
- pjmlp 8 months agoBesides all examples, Microsoft is now using TockOS for Pluton firmware, another Rust based OS.
- treeshateorcs 8 months agohttps://www.youtube.com/watch?v=3AQ5lpXujGo Asterinas: A safe Rust-based OS kernel for TEE by H. Tian & C. Song (Ant Group & Intel) | OC3 2024
- gghh 8 months agoExactly. I see elsewhere in this page people comparing this project to Linus Torvalds starting an OS in his dorm room while studying CS. Like these were "young and clueless" devs writing an OS for fun.
From the looks of it, this seems like a serious corporate backed project made by employees of the Ant Group, the chinese fintech giant. A more fair comparison would be with Google's Fuchsia OS (defunct) or Huawei's HarmonyOS. It may succeed, it may fail, but it's nothing like a couple of kids doing a passion project to learn Rust.
- gghh 8 months ago
- Alexsky2 8 months agoI’ll mention another OS written in Rust, Twizzler: https://twizzler.io/
Its more of a research OS but still cool.
- Teever 8 months agoAnd I'll mention another one that a friend of mine is working on: uxrt
- Teever 8 months ago
- hkalbasi 8 months ago> In the framekernel OS architecture, the entire OS resides in the same address space (like a monolithic kernel) and is required to be written in Rust. However, there's a twist---the kernel is partitioned in two halves ... the unprivileged Services must be written exclusively in safe Rust.
Unprivileged services can exploit known compiler bugs and do anything they want in safe Rust. How this affects their security model?
- rcxdude 8 months agoI think it's not so much intended as a "you can allow arbitrary untrusted code to run as an unprivileged service" and more "a buggy unprivileged service won't compromise the whole system".
- rcxdude 8 months ago
- Klasiaster 8 months agoThere 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.
- kelnos 8 months ago> 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.
- kelnos 8 months ago
- depressedpanda 8 months agoFrom the README:
> Currently, Asterinas only supports x86-64 VMs. However, our aim for 2024 is to make Asterinas production-ready on x86-64 VMs.
I'm confused.
- wrs 8 months agoI think it’s “Currently, Asterinas only supports x86-64 VMs. However, [rather than working on additional architectures this year,] our aim for 2024 is to make Asterinas production-ready on x86-64 VMs.”
- favorited 8 months agoSounds like their goal is to improve their x86-64 support before implementing other ISAs.
- nurb 8 months agoIt's clearer from the book roadmap:
> By 2024, we aim to achieve production-ready status for VM environments on x86-64. > In 2025 and beyond, we will expand our support for CPU architectures and hardware devices.
- netbsdusers 8 months agoThey lack essential things for a kernel that could be used in production, viz. not kernel panicing during out-of-memory conditions, not an easy thing to retrofit when you have designed without consideration of it. It will probably take a bit more than 2 and a half months to rectify that.
- empath75 8 months agohttps://github.com/rust-lang/rust/issues/48043
They've been working on it for a while so they can get rust into the linux kernel
- empath75 8 months ago
- None4U 8 months agoDistinction here is between "supports" and "production-ready on", not "x86-64" and "x86-64"
- convolvatron 8 months agoit would be nice to know how much userspace it supports. supporting the dynamic loader, reasonable futexes, epoll, signals, uring are all big milestones
- throw4950sh06 8 months ago
- throw4950sh06 8 months ago
- MattPalmer1086 8 months agoYeah, I had to read that a few times... I think they just mean it isn't production ready yet, but that's what they are aiming for.
- wrs 8 months ago
- valunord 8 months agoI like what they're working towards with V in Vinix as well. Exciting times to see such things with ABI compat with Linux opening new paradigms.
- cryptonector 8 months ago> Linux-compatible ABI
There's no specification of that ABI, much less a compliance test suite. How complete is this compatibility?
- mgerdts 8 months agoWhile developing the lx brand on illumos/SmartOS, ltp was helpful. It may not be complete, but it is a pretty good start.
- cryptonector 8 months agoLTP really needs to be a part of Linux itself.
- cryptonector 8 months ago
- Klasiaster 8 months agoHere is a list of implemented syscalls, but of course each checked one could still be slightly incompatible:
https://asterinas.github.io/book/kernel/linux-compatibility....
- cryptonector 8 months agoThere's also tons of ioctls and /proc and what not.
- cryptonector 8 months ago
- mgerdts 8 months ago
- phlip9 8 months agoSuper cool project. Looks like the short-term target use-case is running a Linux-compatible OS in an Intel TDX guest VM with a significantly safer and smaller TCB. Makes sense. This way you also postpone a lot of the HW driver development drudgery and instead only target VM devices.
- spease 8 months agoWhat’s the intended use case for this? Backend containers?
- Animats 8 months agoMakes a lot of sense for virtual machine containers. Inside a container inside a VM, you need far less operating system.
- Animats 8 months ago
- wg0 8 months agoSide 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...
- NewJazz 8 months agoLinux kernel as much as possible tries not to parse or read external data (besides stuff like acpi tables, device trees, hardware registers). For networking, you might look at the iproute codebase to see how they do things like bring a network device up, or create a bridge device, add a route, et cetera.
Edit: looks like iproute2 uses NETLINK, but non-networking tools might use syscalls or device ioctls.
- NewJazz 8 months ago
- snvzz 8 months agoI looked into the architecture. It turns out to be monolithic with marketing[0].
Sure is a lot of text to say: We try to use unsafe as little as possible.
Which is the minimum you'd expect anyways ¯\_(ツ)_/¯
0. https://asterinas.github.io/book/kernel/the-framekernel-arch...
- netbsdusers 8 months agoIt's just what we used to call a "layered architecture".
- netbsdusers 8 months ago
- wiz21c 8 months ago> Linux-compatible ABI
Does it mean it can re-use the drivers written for hardware to run with linux ?
- eptcyka 8 months agoNo. The drivers in Linux are kernel modules, most often in-tree - meaning that the source for the drivers is built along the rest of the kernel source code. Most hardware drivers depend on various common kernel structures that change often - when they do, the source for drivers is fixed practically in the same git branch. There is no driver ABI to speak of.
- dezgeg 8 months agoNo. There is no stable ABI nor API for in-kernel device drivers.
- apatheticonion 8 months agoDo other mainstream kernels have a stable driver API?
I guess the NT kernel needs to. Does Darwin?
- apatheticonion 8 months ago
- eptcyka 8 months ago
- 8 months ago
- apatheticonion 8 months agoI wish I could work on this as my paid day job.
As soon as I can financially retire, I'll make contributing to this my full time job!
- hulitu 8 months ago> Asterinas: OS kernel written in Rust and providing Linux-compatible ABI
> Currently, Asterinas only supports x86-64 VMs.
So no real hardware.
- delduca 8 months agoThis is exactly what I was discussing with a friend who works on the kernel. I don’t think Rust should be supported; the kernel should remain in C. Instead, a completely new kernel in Rust should be created with API/ABI compatibility with the original kernel.
- apatheticonion 8 months agoShame about the lack of a stable kernel driver ABI/API in Linux otherwise this kernel could inherent a lot of drivers.
- apatheticonion 8 months ago
- xiaodai 8 months agoLol. 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.
- edelbitter 8 months agoIts not the Chinese words that scare me. It the English "safety" and "security" referring to specific properties and concepts... but wildly different ones between sentences. Like its all 2009 again and we are hoping we avoided XSS when we picked the appropriate quote/encode/escape method.
- gpm 8 months agoSupposing 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.
- throw4950sh06 8 months agoYou're wrong. A lot of Chinese code and hardware is in production in the west. Huawei networking hardware is widespread, for example.
- tredre3 8 months ago> Huawei networking hardware is widespread
That's an interesting example because Huawei equipment is currently being removed by several Western countries (UK, Canada, US, Germany) specifically because it's Chinese.
https://www.nytimes.com/2024/07/11/business/huawei-germany-b...
https://www.cbc.ca/news/politics/huawei-5g-decision-1.631083...
https://www.gov.uk/government/news/huawei-to-be-removed-from...
https://www.reuters.com/business/media-telecom/us-open-progr...
- cozzyd 8 months agoWhen we got a license for a private LTE network in the middle of the Greenland ice sheet, the one stipulation was we couldn't use Huawei equipment...
- cozzyd 8 months ago
- tredre3 8 months ago
- edelbitter 8 months ago
- jackhalford 8 months agoThe building process happens in a container?
> If everything goes well, Asterinas is now up and running inside a VM.
Seems like the developers are very confident about it too
- 8 months ago
- a99c43f2d565504 8 months agoZig kernel when
- bigfishrunning 8 months agoWhen someone writes one
- bigfishrunning 8 months ago
- fithisux 8 months agoNow we need Rust Windows compatible kernel to save us from Recall.
- rpgraham84 8 months agooh cool, now I can have an unverifiable kernel from a team in China
- weinzierl 8 months agoDecades 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 they will not replace Linux as we have it today.
(Asterinas, from what I understood, doesn't claim to replace Linux, but it a common expectation.)
- loeg 8 months agoMore 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 have to be all kinds of stupid to say 'I can do this'", he said to more laughter. He could not have done it without the "literally tens of thousands of other people"; the "only reason I ever started was that I didn't know how hard it would be, but that's what makes it fun".
- ackfoobar 8 months ago> 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.
- nickpsecurity 8 months agoSometimes, we do such things because it’s hard. We enjoy the challenge. Those that succeed are glad to make it, too.
- nickpsecurity 8 months ago
- m463 8 months ago"You are enthusiastic and write kernel device drivers in rust. Write a device driver for an Intel i350 4 Port gigabit ethernet controller"
- senko 8 months agoYou jest, but I believe @tptacek is using an LLM (ChatGPT?) to understand the details of various Linux kernel subsystem and has said it works quite well for the task.
It's not a great jump from that to "port Linux device driver for XYZ to this new OS in Rust". Won't be perfect but a lot less hassle than doing it from scratch.
- NetOpWibby 8 months agoSome future VC-funded company will unironically have this same requirement
- Y_Y 8 months agoClaude Sonnet 3.5 seemed happy enough to do it, and the start looked promising
but I'm not qualified to judge the quality from eyeballing and I'm certainly not going to go to the trouble of trying to test it.Absolutely! Let's dive into writing a device driver for the Intel i350 4 Port Gigabit Ethernet Controller using Rust. This is an exciting project that combines low-level hardware interaction with the safety and performance benefits of Rust. I'll create a basic structure for our driver, focusing on the key components needed to interact with the device. #![no_std] #![feature(abi_x86_interrupt)] ...
- sshine 8 months agoLLMs are notoriously bad at improvising device drivers in no-std Rust.
- senko 8 months ago
- ackfoobar 8 months ago
- mdhb 8 months agoAlso this mysterious new Fuchsia OS from Google is also shooting for full Linux compatibility and is about to show up in Android, I think this is a much more realistic path of the next generation of operating systems that have a real chance to replace Linux but who knows what their actual plans are here at the moment but I don’t believe for a moment that that project is dead in any way.
- vbezhenar 8 months agoI wonder if decision for stable syscalls was genius? Like imagine that Linux syscalls will become what C ABI is now. And there will be multiple compatible kernels, so you can choose any and run the same userspace.
- surajrmal 8 months agoWhy would you want to support multiple? New versions should always be backwards compatible with older ones, so you'll always have the largest amount of compatibility by targeting the latest upstream. The real challenge comes with supporting applications that want features only available in forked kernels, which I guess could prompt wanting multiple kernels targeting the distinct ABIs.
- surajrmal 8 months ago
- lifty 8 months agoCan you give more details about it being used in Android? I thought they started using it in some small devices like nest but haven’t heard anything about Android
- mdhb 8 months agoIt’s about to turn up inside Android running in a VM [1] but it was less clear exactly for what purpose.
My theory is that this is essentially a long term project to bring the core of Chrome OS and Android to rely on Fuschia for its core which gives them syscall level compatibility with what they both use at the moment and that they would both essentially sit as products on top of that.
This is essentially the exact strategy they used if I remember correctly with the Nest devices where they swapped out the core and left the product on top entirely unchanged. Beyond that in a longer term scenario we might also just see a Fuchsia OS as a combined mobile / desktop workstation setup and I think part of that is also why we are seeing ChromeOS starting to take a dependency on Android’s networking stack as well right now.
[1] https://www.androidauthority.com/microfuchsia-on-android-345...
- mdhb 8 months ago
- vbezhenar 8 months ago
- linsomniac 8 months agoI 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.
- yjftsjthsd-h 8 months agoHow is that different from Linux with all virtio drivers? (You can just not compile real hardware drivers)
- lmm 8 months agoThe point is it would be better than Linux in whatever way that was the reason you were writing it, but you don't have to write hundreds of different device drivers to make your cool new kernel usable.
- m463 8 months agoI would imagine that virtualized device drivers would have a well-defined api and vastly simplified logic.
- rcxdude 8 months agoIf it's written in rust, you might expect less security vulnerabilities (especially if the codebase is also smaller: NB this is potentially counterbalanced by the many eyes on linux). Maybe there would be some extra features you find useful.
- lmm 8 months ago
- lmm 8 months agoThose workloads would probably be better off as unikernels that can run directly on the VM, avoiding the question of which kernel to use entirely.
- rcxdude 8 months agoThere's a difference between "want to run an application with as little extra move parts on a VM" and "want to take an existing system and swap out for a kernel with some better properties, even if it means needing to run it in a VM"
- rcxdude 8 months ago
- pjmlp 8 months agoThis is already the reality today with native cloud computing, managed runtimes.
It doesn't matter how the language gets deployed, if the runtime is on a container, a distroless container, or directly running on an hypervisor.
The runtime provides enough OS like services for the programming language purposes.
- prmoustache 8 months agothis x1000
Provided you have virtio support you are ticking a lot of boxes already.
- eyberg 8 months agoThis is a very large rationale for what we are building with https://nanos.org .
- yjftsjthsd-h 8 months ago
- GoblinSlayer 8 months agoJust ask an AI to riir linux drivers. Anybody tried it?
- 8 months ago
- loeg 8 months ago
- havaker 8 months agoThe license choice is explained with the following:
> [...] we accommodate the business need for proprietary kernel modules. Unlike GPL, the MPL permits the linking of MPL-covered files with proprietary code.
Glancing at the readme, it also looks like they are treating it as a big feature:
> Asterinas surpasses Linux in terms of developer friendliness. It empowers kernel developers to [...] choose between releasing their kernel modules as open source or keeping them proprietary, thanks to the flexibility offered by MPL.
Can't wait to glue some proprietary blobs to this new, secure rust kernel /s
- yjftsjthsd-h 8 months agoI'm curious about the practical aspect: Are they going to freeze a stable driver ABI, or are they going to break proprietary drivers from time to time?
- gpm 8 months agoConsidering their OS as a framework approach I would guess they are more likely to expose a stable API than a stable ABI. Which also plays well with the MPL license (source file based) rather than something like the LGPL (~linking based).
- throw4950sh06 8 months agoThis is the most interesting new OS I have seen in many years.
- throw4950sh06 8 months ago
- gpm 8 months ago
- yjftsjthsd-h 8 months ago
- prmoustache 8 months ago> docker run -it --privileged --network=host --device=/dev/kvm -v $(pwd)/asterinas:/root/asterinas asterinas/asterinas:0.9.3
Is that the new generation of curl | bashism in action?
- oefrha 8 months agoHardly different from downloading random binary installers and executing them. Or random source distributions and (sudo) make install. Or npm/pip/cargo/etc. install random packages. Before anyone mentions distros and package managers, as a former team member of a major package manager I can assure you we don’t vet shit beyond project notability, and new versions are accepted semi-automatically. We’ll yank something after the fact if you report a malicious update, sure.
curl | bash has an actual problem: potential execution of an incomplete script (which can be mitigated with function calling). And there’s the mostly theoretical problem of the server being pwned / sending malicious code just to you (which of course also applies to any other unsigned channel). Arbitrary code execution is never a problem unique to it, but people dunk on it all the time because they saw another person dunking on it in the past.
- hnfong 8 months ago> as a former team member of a major package manager I can assure you we don’t vet shit beyond project notability, and new versions are accepted semi-automatically
An example that illustrates this: https://lwn.net/Articles/22991/
(And wow, it's been 22 years already...?)
- hnfong 8 months ago
- wslh 8 months agoIs the "--privileged" option ironic here? The project is very interesting, but it feels a bit pedantic, especially when emphasizing Rust's safety features while downplaying Linux. At the same time, it seems they're not fully applying those principles themselves, which makes it feel like they're not quite 'eating their own lunch'.
- prmoustache 8 months agoA bit below in the github readme there is a link to the handbook where they explain how to build and run the project using cargo:
https://asterinas.github.io/book/osdk/guide/run-project.html
- prmoustache 8 months ago
- 8 months ago
- oefrha 8 months ago
- sylware 8 months agoLinux is mostly a decades long maintained repository of real hardware programing code, and written in mostly simple "kernel" 'C', not some ultra complex syntax language (unfortunately, it has been tied to compiler specific extensions or "modern C" tantrums, _generic for instance).
Have a look at AMD GPU driver. Massive, and full of 'stabilization/work around' code... happening all the time, for years.
I guess, the real "first thing first" is to design hardware, performant hardware on latest silicon process , with a, as simple as possible, modern, standard and stable hardware programing interface. Because, for many types of hardware, 'now we know how to do it properly' (command hardware ring buffers usually, or a good compromise for modern CPU architecture, like RISC-V).
Another angle of "cleanup", I guess it would be the removal of many of the C compiler extension (or "modern C") tantrums from linux, or at least proper alternatives with not-inline assembly to allow small and alternative compilers to step in.
Personally, I tend to write rv64 assembly (which I interpret on x86_64), but for the userland. If I code C, I push towards mostly "simple and plain C99".
The more I think about it, the more I get the following coming to my mind: 'hardware with simple standard interfaces' and standard assembly for the kernel.
- artemonster 8 months agoHuh? What is this nonsense?? Are you suggesting that you like to write practical-oriented, simple and working solutions instead of yak shaving half a day at perfecting ridiculous type signatures, removing „unsafe“ code and satisfying borrow checker? Proposterous! /s
- artemonster 8 months ago