LWN: Comments on "Next steps for Rust in the kernel" https://lwn.net/Articles/908347/ This is a special feed containing comments posted to the individual LWN article titled "Next steps for Rust in the kernel". en-us Sun, 19 Oct 2025 15:32:07 +0000 Sun, 19 Oct 2025 15:32:07 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Next steps for Rust in the kernel https://lwn.net/Articles/908944/ https://lwn.net/Articles/908944/ tialaramex <div class="FormattedComment"> Crucial in Rust culture is also writing safety rationales. Here&#x27;s a nice succinct one from the implementation of alloc::vec::Vec<br> <p> // SAFETY: After filling holes, all items are in contiguous memory.<br> <p> These should live next to unsafe { /* ... */ } blocks, the compiler can&#x27;t read your safety rationale, but a human can, and it can really help distinguish between cases where you&#x27;re an idiot and this code, though it looked wrong to you, is correct; and cases where you&#x27;re a genius, and this code even though it looked right to its author is actually wrong and needs fixing. If the safety rationale makes a claim that is false, that&#x27;s a problem. At the least, we need a patch to the rationale. But, maybe the code is wrong too.<br> </div> Wed, 21 Sep 2022 23:10:40 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908898/ https://lwn.net/Articles/908898/ Tuna-Fish <div class="FormattedComment"> How? By the time Rust will be used for anything other than toy drivers, Rust-GCC should be done, so Linux with Rust will compile anywhere that Linux without Rust can.<br> </div> Wed, 21 Sep 2022 14:11:57 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908894/ https://lwn.net/Articles/908894/ khim <p>So very true. Unsafe Rust forms <a href="https://en.wikipedia.org/wiki/Trusted_computing_base">TCB</a> which “normal” safe Rust uses to implement “business logic”.</p> <p>But <code>unsafe</code> keyword is better. I worked on a codebase which was similarly separated into “trusted” and “untrusted” components.</p> <p>And newcomers invariably tried to add stuff to the “trusted” side! I guess logic was: it's “trusted”, thus it's obviously “better”.</p> <p>But <code>unsafe</code> just doesn't feel like that. People know you can add <code>unsafe</code> code, but the name itself prompts them to be careful.</p> Wed, 21 Sep 2022 13:40:37 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908859/ https://lwn.net/Articles/908859/ khim <font class="QuotedText">&gt; Both would have to be per-file opt-ins, of course.</font> <p>Except it's not really possible. Think something like <a href="https://en.cppreference.com/w/cpp/memory/align">std::align</a>: if such low-level functions are not properly marked that all these “escape analysis” quickly turns into farce.</p> <p>In theory it should be possible to keep “new, clean code” and “old, dirty, code” clearly separated and then slowly rewrite things, but if you consider how long it takes to, e.g., <a href="https://lwn.net/Articles/905777/">remove strlcpy</a>… it doesn't look feasible at all.</p> Wed, 21 Sep 2022 13:30:00 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908860/ https://lwn.net/Articles/908860/ Wol <div class="FormattedComment"> <font class="QuotedText">&gt; The &quot;unsafe&quot; keyword allows unrestricted liberties, including inline assembly. Interestingly, &quot;unsafe&quot; can also be read as &quot;trusted&quot;. Safe Rust doesn&#x27;t trust, it verifies.</font><br> <p> Hmmm, that&#x27;s a VERY interesting take ...<br> <p> Cheers,<br> Wol<br> </div> Wed, 21 Sep 2022 13:21:20 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908854/ https://lwn.net/Articles/908854/ oxidizer <div class="FormattedComment"> Good comments about C, however Rust doesn&#x27;t have an issue here.<br> <p> The &quot;unsafe&quot; keyword allows unrestricted liberties, including inline assembly. Interestingly, &quot;unsafe&quot; can also be read as &quot;trusted&quot;. Safe Rust doesn&#x27;t trust, it verifies.<br> </div> Wed, 21 Sep 2022 13:03:03 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908852/ https://lwn.net/Articles/908852/ Wol <div class="FormattedComment"> This is the classic Pascal / Modula dichotomy.<br> <p> If you try and enforce correctness, the language becomes unusable. Especially if you try and enforce the *wrong* mathematical model (Which is why I rail against SQL and relational - imnsho they&#x27;ve picked the wrong model, sets instead of lists ...). (Correctness is a property of a mathematical model, not of the scientific &quot;does it actually work in the real world.)<br> <p> C just doesn&#x27;t have a model. C++ appears to try and impose a model on top of C.<br> <p> Where Rust appears to score is that like Modula-2, it has a &quot;strict model with escape hatches&quot;. So like C you can do anything, but the language makes it absolutely clear that you are gambling with whether it will work ...<br> <p> And the problem with C is that the gcc guys are apparently trying to enforce a model that does not mesh with the way the kernel works, hence all these &quot;escape hatch&quot; flags, and maybe why some kernel guys are keen to try Rust. Modula-2 was before its time ... :-)<br> <p> Cheers,<br> Wol<br> </div> Wed, 21 Sep 2022 10:52:52 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908849/ https://lwn.net/Articles/908849/ linusw <div class="FormattedComment"> As I was rambling on in my own little bubble over at the kernelorg blog about Rust, I came to the conclusion that what we are doing with Rust is to increase the abstraction of the language, not just making it more safe, but abstraction does bring safety. But since this point has been stressed since 1968 there is a reason why C has prevailed, and it is exactly the (casting) and general ability to act like a big macro assembler. Doing C safe would mean to remove exactly these features and thereby remove the appeal of C. (This is not really my opinion, but extrapolated from Niklaus Wirth.)<br> <a href="https://people.kernel.org/linusw/rust-in-perspective">https://people.kernel.org/linusw/rust-in-perspective</a><br> <p> </div> Wed, 21 Sep 2022 09:03:38 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908839/ https://lwn.net/Articles/908839/ pbonzini <div class="FormattedComment"> The idea was to start with very simple stuff like forcing manual conversion of integer types and explicitly noting in the prototypes which pointer arguments that are can escape the called functions. Both would have to be per-file opt-ins, of course.<br> </div> Wed, 21 Sep 2022 06:51:57 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908835/ https://lwn.net/Articles/908835/ taladar <div class="FormattedComment"> What is it with all those people who don&#x27;t understand that many (especially safety) features can not be retrofitted into established languages while maintaining backwards compatibility?<br> <p> Either you end up with something that accepts all existing programs (maintains backwards compatibility) or with something that rejects the existing programs that do unsafe things, both isn&#x27;t possible at the same time.<br> <p> Of course the desire to keep the old code around is also at odds with significantly improving it. If you have a language with significantly improved idioms and safety features (e.g. Rust&#x27;s Result instead of inline error codes) you would still have to deal with the fact that 99% of your code is written to not take advantage of them. And if you have to rewrite all your code anyway, why not rewrite it in a safer new language?<br> <p> In my experience two languages that are very similar (e.g. C and C+retrofitted safety features) are much harder to keep apart in your head too than two languages that are significantly different.<br> <p> <p> </div> Wed, 21 Sep 2022 05:56:19 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908822/ https://lwn.net/Articles/908822/ mirabilos <div class="FormattedComment"> This is an unportable catastrophe…<br> </div> Tue, 20 Sep 2022 22:28:26 +0000 Next steps for Rust in the kernel https://lwn.net/Articles/908716/ https://lwn.net/Articles/908716/ jhoblitt <div class="FormattedComment"> People who live in C houses shouldn&#x27;t (void)stones.<br> </div> Tue, 20 Sep 2022 01:38:39 +0000