Live data from Hacker News

Rewrite Linux Kernel in Rust?

dominuscarnufex.github.io

61–70 of 133 posts

Re: Rewrite Linux Kernel in Rust?

#61
post #52

Earlier quoted context omitted.

Do you get anything with him? I was under the impression dereference safety wasn't a priority.

Nim or Rust might be appropriate depending on the project. To me the idea of replacing C with either of them comes down to a value-sell of how much you value Rust's safety guarantees and whether you're willing to make the investment of learning to use it or if you're just going to wrap everything in unsafe{}. Considering you're talking to C programmers, I don't think they value that safety very much. If they did, at…

pardon my ignorance, but wasn't "safe-and-performant" impossible before rust?

Isn't choosing a GC-language some trading off performance for safety?

Re: Rewrite Linux Kernel in Rust?

#62
post #51

I'd rather see a rewrite of QNX in Rust, as open source. The QNX kernel isn't very large, but it offers most of POSIX, so you can run programs on it. (L4 is nice, but it does so little that people just use it as a hypervisor to run Linux. This doesn't simplify the problem.) If you rewrite the Linux kernel in Rust, one module at a time, you'll just end up with C written in Rust syntax, with raw pointers all over the p…

I was thinking the same thing but for http://www.minix3.org/

Re: Rewrite Linux Kernel in Rust?

#63
post #23
post #9

Without making any assertions as to the benefits or problems of integrating Rust into the Linux kernel to replace components, I just want to point out it's really cool that you can and that someone has gone through the trouble of documenting how. That's just awesome. Discussion about whether this is a good idea or not, and the problems of doing so, can now commence in earnest, and without the pesky problem of it bein…

Yeah it's always great to see concepts implemented and working. My favorite similar project I would use as an argument to bring Nim into a legacy C codebase is https://github.com/ckkashyap/nimxv6 which started off by taking the xv6 kernel and replacing uart.c with uart.nim. Every step of the way you can test your translation was correct, and once you have Nim in the build process you can start using it for new things…

> Yeah it's always great to see concepts implemented and working.

I agree. It's easy to criticize ideas that may seem futile at first, but there is nothing like a working implementation to take the wind out of the critics' proverbial sail.

Re: Rewrite Linux Kernel in Rust?

#64
post #49

This was a fun write up. On the off chance the author is reading the comments here, there are a couple security features they need to add for it to be more complete (I'm probably missing some things). 1) They should add a call to access_ok(VERIFY_WRITE, pointer, mem::size_of ()) in rust_syscall_handle to ensures that the user space pointer points to valid userspace memory of the right shape for the syscall type. 2) T…

Don't know about HN but a friend of the author posted this on reddit and was commenting there: https://www.reddit.com/r/programming/comments/6f235k/rewrite...

edit: they also submitted it on HN, but it looks like they didn't get the "winning" submission: https://news.ycombinator.com/submitted?id=fjallidergodur

Re: Rewrite Linux Kernel in Rust?

#65

Earlier quoted context omitted.

If there were a fork and the fork were to gain momentum it might be not be up to Linus. A project like this might attract new developers because it might be less intimidating than joining the Linux kernel proper. There would also be the attraction of learning Rust in a very real world context. edit:s/in/it

This is a good argument if a massive amount of effort was piled into this with lots of refactoring on top of it. Meanwhile, it doesn't have a snowball's chance in hell of accomplishing anything.

> Meanwhile, it doesn't have a snowball's chance in hell of accomplishing anything.

That's only true if you believe that the only possible accomplishment is to become the #1 kernel in the world.

Meanwhile, it's a very interesting project and it's a clear proof of technical proficiency. There are not many people in the world who can claim that they've written a kernel, let alone one in a cutting-edge programming language like Rust. I would love to have something like that on CV. Meanwhile, criticizing other people's projects does nothing to advance your career.

Re: Rewrite Linux Kernel in Rust?

#66
post #51

I'd rather see a rewrite of QNX in Rust, as open source. The QNX kernel isn't very large, but it offers most of POSIX, so you can run programs on it. (L4 is nice, but it does so little that people just use it as a hypervisor to run Linux. This doesn't simplify the problem.) If you rewrite the Linux kernel in Rust, one module at a time, you'll just end up with C written in Rust syntax, with raw pointers all over the p…

I was thinking the same thing but for http://www.minix3.org/

fun anecdote, it seems that minix3 is the ancestor of the OS running in Intel Management Engine http://blog.ptsecurity.com/2017/04/intel-me-way-of-static-an...

Re: Rewrite Linux Kernel in Rust?

#68
post #52

Earlier quoted context omitted.

Nim or Rust might be appropriate depending on the project. To me the idea of replacing C with either of them comes down to a value-sell of how much you value Rust's safety guarantees and whether you're willing to make the investment of learning to use it or if you're just going to wrap everything in unsafe{}. Considering you're talking to C programmers, I don't think they value that safety very much. If they did, at…

pardon my ignorance, but wasn't "safe-and-performant" impossible before rust? Isn't choosing a GC-language some trading off performance for safety?

There were other attempts to bridge safety and performance.

C++11 already gets​ pretty close to that, but Microsoft's M# was used to write a research OS and is probably the closest.

Re: Rewrite Linux Kernel in Rust?

#69
post #17

Earlier quoted context omitted.

I'll grant that, but it's a programming language, so I kind of expect it to follow the order assignment does when I write in C++, C#, etc.

AT&T assembly style significantly predates C++ (and C# by like two decades), and co-evolved with C. And strictly this isn't an assignment, anyway. Assignment is an abstract operation in a programming language. This is a machine instruction[1] for a physical machine, which does exactly one thing. [1] Pause while the peanut gallery points out that in fact there are like ninety six different instructions in x86 called s…

What.

When did `mov` get 96 different instructions?

Re: Rewrite Linux Kernel in Rust?

#70
post #49

This was a fun write up. On the off chance the author is reading the comments here, there are a couple security features they need to add for it to be more complete (I'm probably missing some things). 1) They should add a call to access_ok(VERIFY_WRITE, pointer, mem::size_of ()) in rust_syscall_handle to ensures that the user space pointer points to valid userspace memory of the right shape for the syscall type. 2) T…

Don't know about HN but a friend of the author posted this on reddit and was commenting there: https://www.reddit.com/r/programming/comments/6f235k/rewrite... edit: they also submitted it on HN, but it looks like they didn't get the "winning" submission: https://news.ycombinator.com/submitted?id=fjallidergodur

I am said friend, we're reading the discussion.
Post reply on HN