News for hackers. Stuff that matters.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by MarkSweep on Sunday October 02, 2022 @10:54AM (#33056371)
Why is panicing in the kernel on an error not an option? Like kernels can write a core dump and reboot, right?
Re:“Rust is safe” is not some kind of absolute guarantee of ... by cillian64 on Sunday October 02, 2022 @11:10AM (#33056551)
From most users’ points of view, a lot of things the kernel does (e.g. a sound card driver) are non-critical so they’d prefer an error in that driver only killed that driver and not the whole kernel. Similarly, I’d be upset if a server rebooted because of a blip in its CD-ROM driver. And if you can just reload the module which errored, all the better.

It would be cool if kernel Rust could implement a panic handler which just killed the offending module, but I’m assuming from the discussion around panics that this isn’t possible.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by vips7L on Sunday October 02, 2022 @11:37AM (#33056849)
Wasn’t that the whole point of microkernels/minix vs monoliths? With drivers being in the kernel can you even restart the modules?
Re:“Rust is safe” is not some kind of absolute guarantee of ... by cillian64 on Sunday October 02, 2022 @02:20PM (#33058693)
With Linux you can unload and reload modules (rmmod, insmod) so it’s a little un-monolithic in that sense.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by zetaposter on Sunday October 02, 2022 @11:00AM (#33056427)
Yeah ... Just reboot the machine and make me loose all my work, bro.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by charcircuit on Sunday October 02, 2022 @11:46AM (#33056940)
This is why programs automatically saving their state is important.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by jmull on Sunday October 02, 2022 @12:29PM (#33057431)
That's not a solution to OS instability.

Reliably saving state in the face of sudden total failure is both very tricky and app-specific. Just saving state changes automatically won't do it -- partial writes of complex state are likely to be inconsistent without luck or careful design and QA controls (tests, testing, on-going controls to ensure nothing new operates or relies on anything outside the safe state-saving mechanism).

It makes a lot more sense to put the effort into making the OS continue as well as it can, vs requiring every app to harden itself against sudden total failures.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by elteto on Sunday October 02, 2022 @12:16PM (#33057273)
No, this is why kernels prioritizing not crashing is important. Applications saving their work is a nice extra.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by pca006132 on Sunday October 02, 2022 @11:03AM (#33056457)
I guess when the kernel panics, there is nothing to write the core dump for you...
Re:“Rust is safe” is not some kind of absolute guarantee of ... by detaro on Sunday October 02, 2022 @11:07AM (#33056506)
The kernel crash dump mechanism works by reserving some memory, which it boots a fresh copy of the kernel into on kernel panics, which then takes care of reading the old dead kernel from memory and saving the dump.

Of course this working requires the fresh kernel to be able to get up and do that without itself crashing, so it can't capture every scenario. And it is bringing down the system completely, and there's lots of pros and cons to be argued about that vs attempting to continue or limp along.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by yencabulator on Sunday October 02, 2022 @06:03PM (#33060768)
The mechanism you describe is used/usable only in very specific scenarios.

For practically all non-virtualized Linux hosts out there, the kernel crash dump mechanism works by adding ASCII text to kmesg, which is then read by journald, processed a little, and appended to a file -- which just means submitted back to the kernel for writing, which means FS needs to work, disk I/O needs to work, and so on.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by 2OEH8eoCRo0 on Sunday October 02, 2022 @11:06AM (#33056502)
kdump

https://en.wikipedia.org/wiki/Kdump_(Linux)

He also mentions that programs can report problems automatically to the distro devs. For example:

https://retrace.fedoraproject.org/faf/problems/

A kernel dump is not something you always want to upload since it can be large and contain sensitive info. I'm not a kernel dev though.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by pyb on Sunday October 02, 2022 @11:15AM (#33056611)
No need to reboot the machine without warning, and lose data, when the rest of the kernel is probably still functional.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by dijit on Sunday October 02, 2022 @10:57AM (#33056401)
if you panic and you're a kernel you very likely corrupt your filesystem, at the very least.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by layer8 on Sunday October 02, 2022 @11:04AM (#33056474)
While I don’t advocate for kernel panics, journaling filesystems are a thing.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by dijit on Sunday October 02, 2022 @11:06AM (#33056501)
Yes, but even then not all filesystems are journaled.

EFI is FAT, FAT is not journaled. You almost certainly have EFI these days.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by layer8 on Sunday October 02, 2022 @11:17AM (#33056631)
That’s a good point, but EFI isn’t frequently written I believe, so that I would expect that to be a rare circumstance, and even rarer for user data to be affected as a consequence.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by KMnO4 on Sunday October 02, 2022 @11:15AM (#33056613)
EFI is read, but not frequently written.
Re:“Rust is safe” is not some kind of absolute guarantee of ... by dijit on Sunday October 02, 2022 @11:19AM (#33056647)
I'm not sure why that's relevant.

It will be written to on every kernel update and every initramfs update at least, which is what.. once a week on average?

A reply like yours is not so subtly indicating that "it's fine to panic all the time because ultimately you might be fine if you get a panic", which I fundamentally disagree with, other concerns aside.

Also you're suggesting that journaling filesystems are perfect and never lose data, which is also very untrue, in the default case they only protect metadata but there are still circumstances where they can lose data anyway; they're more resilient, not immune.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by wtallis on Sunday October 02, 2022 @11:39AM (#33056860)
> It will be written to on every kernel update and every initramfs update at least, which is what.. once a week on average?

Which distros actually use the EFI System Partition that way? I've usually only seen the ESP used to hold the bootloader itself, with kernels and initramfs and the bootloader config pointing to them stored either in a separate /boot partition or in a /boot directory of the / filesystem.

Re:“Rust is safe” is not some kind of absolute guarantee of ... by hulitu on Sunday October 02, 2022 @11:34AM (#33056803)
Journaling FS can also become corrupted. That's why i don't use XFS (just a quick log replay after a kernel crash. Have some crashes and the FS is corrupted beyond repair.)
Re:“Rust is safe” is not some kind of absolute guarantee of ... by pfortuny on Sunday October 02, 2022 @11:00AM (#33056422)
That is a decision taken by Linus. It might have been different but life is choice. This one has been made while Linus is the boss.