CommunityNews

CommunityNews

Linus Torvalds on Rust support in kernel

On Wed, Apr 14, 2021 at 11:46 AM ojeda@kernel.org wrote:

Some of you have noticed the past few weeks and months that
a serious attempt to bring a second language to the kernel was
being forged. We are finally here, with an RFC that adds support
for Rust to the Linux kernel.

So I replied with my reactions to a couple of the individual patches,
but on the whole I don’t hate it.

HOWEVER.

I do think that the “run-time failure panic” is a fundamental issue.

I may not understand the ramifications of when it can happen, so maybe
it’s less of an issue than I think it is, but very fundamentally I
think that if some Rust allocation can cause a panic, this is simply
fundamentally not acceptable.

Allocation failures in a driver or non-core code - and that is by
definition all of any new Rust code - can never EVER validly cause
panics. Same goes for “oh, some case I didn’t test used 128-bit
integers or floating point”.

So if the Rust compiler causes hidden allocations that cannot be
caught and returned as errors, then I seriously think that this whole
approach needs to be entirely NAK’ed, and the Rust infrastructure -
whether at the compiler level or in the kernel wrappers - needs more
work.

So if the panic was just some placeholder for things that can be
caught, then I think that catching code absolutely needs to be
written, and not left as a to-do.

And if the panic situation is some fundamental “this is what the Rust
compiler does for internal allocation failures”, then I think it needs
more than just kernel wrapper work - it needs the Rust compiler to be
fixed.

Because kernel code is different from random user-space system tools.
Running out of memory simply MUST NOT cause an abort. It needs to
just result in an error return.

I don’t know enough about how the out-of-memory situations would be
triggered and caught to actually know whether this is a fundamental
problem or not, so my reaction comes from ignorance, but basically the
rule has to be that there are absolutely zero run-time “panic()”
calls. Unsafe code has to either be caught at compile time, or it has
to be handled dynamically as just a regular error.

With the main point of Rust being safety, there is no way I will ever
accept “panic dynamically” (whether due to out-of-memory or due to
anything else - I also reacted to the “floating point use causes
dynamic panics”) as a feature in the Rust model.

       Linus

https://lkml.org/lkml/2021/4/14/1099

This thread was posted by one of our members via one of our news source trackers.

Where Next?

Popular Linux topics Top

First poster: bot
The Red Hat-sponsored Fedora Project has released its latest Linux distribution, Fedora 33. https://www.techrepublic.com/article/fedora...
New
First poster: bot
The Year of the Linux Desktop. The year of the Linux desktop has arrived. This is a guide for how to improve the Linux desktop experienc...
New
First poster: bot
It looks like thanks to AMD’s increasing sales and continuing successes in the enterprise space with more HPC wins and the like, AMD is h...
New
First poster: AstonJ
In a few weeks, Fedora 34 will be released, and alongside it - you will get to use Gnome 40, the next version of this namesake desktop en...
New
First poster: bot
This thread was posted by one of our members via one of our news source trackers.
New
First poster: bot
Thirty years ago, Linus Torvalds was a 21 year old student at the University of Helsinki when he first released the Linux Kernel. His ann...
New
First poster: bot
The Linux HOWTOs are detailed “how to” documents on specific subjects. The HOWTO index lists all HOWTOs along with short descriptions. Th...
New
CommunityNews
As movement toward memory-safe languages, and Rust in particular, continues to grow, it is worth looking at one of the larger scale effor...
New
First poster: bot
Refusing to support my friends’ and family members’ devices that do not run Linux is the next step in my personal fight against products ...
New
First poster: bot
Introduction Linux from scratch (LFS) is a step-by-step tutorial for building your own Linux distribution. Using the LFS approach, you st...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
AstonJ
Or looking forward to? :nerd_face:
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New