this post was submitted on 17 Dec 2025
178 points (98.4% liked)

Technology

77084 readers
2593 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related news or articles.
  3. Be excellent to each other!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, this includes using AI responses and summaries. To ask if your bot can be added please contact a mod.
  9. Check for duplicates before posting, duplicates may be removed
  10. Accounts 7 days and younger will have their posts automatically removed.

Approved Bots


founded 2 years ago
MODERATORS
top 49 comments
sorted by: hot top controversial new old
[–] tekato@lemmy.world 41 points 23 hours ago (1 children)

JavaScript would have prevented this.

[–] isVeryLoud@lemmy.ca 22 points 21 hours ago

You're so right! The Linux kernel should be re-written as a Deno executable

[–] john_t@piefed.ee 104 points 1 day ago (2 children)

No one said rust was invulnerable.

[–] pryre@lemmy.world 84 points 1 day ago (2 children)

I think the other takeaway here is that it was found in a section marked "unsafe". At the very least, that's a useful tool for the Devs to isolate potential problem areas. Comparing that to a pure C codebase where the problem could be anywhere.

[–] hummingbird@lemmy.world 1 points 8 hours ago (2 children)

The funny part is: the fix does not change the unsafe block at all. The issue is elsewhere in safe rust code.

[–] KexPilot@lemmy.world 3 points 4 hours ago* (last edited 4 hours ago)

No. The issue is that an assumption they make in the unsafe block does not actually always hold true. They changed the safe rust code to strenghten the (incorrect) assumption they made in the first place, because that is way easier than rearchitecting the unsafe part. I.e. if the unsafe part was somehow to be written safely, the mitigation they introduced now would not result in any difference in behaviour, it would be correct behaviour both before and after.

Tldr: the problem lies in the unsafe part

[–] pryre@lemmy.world 1 points 7 hours ago

I'll admit, I haven't looked at the code. I would stand by my comment of the unsafe block being a start point.

Countering that however, what is the difference to just debugging effectively? Not sure. I suppose it's down to the people that identified it and fixed it at the end of the day to say if there was any benefit.

[–] vrighter@discuss.tchncs.de -3 points 10 hours ago (1 children)

doesn't change anything if you can't avoid having to write the unsafe parts

[–] nsfw936421@lemmynsfw.com 8 points 9 hours ago

It certainly does. It's way simpler to keep up all invariants and to review the few percent lines of code in unsafe blocks than making sure that the 30 million lines of code are free of undefined behavior.

Is some part of the code it battle tested of course it's complete unreasonable to rewrite it in any language, but if you have to do a major rewrite anyway or write a new component you should definitely use a memory safe language. And no it doesn't matter that there is an unsafe escape hatch because it's literally impossible to write low level kernel stuff or FFI to other languages without unsafe because Rust can't uphold/guarantee the invariants of the hardware itself or the behavior of other languages.

[–] BassTurd@lemmy.world 9 points 1 day ago (1 children)

Boone? There are plenty of fan boys out there that are selling rust like AI, or in other words snake oil.

Rust obviously has built in securities that C doesn't have, but a shitty coder is a shitty coder and bad QC is bad QC. Now we're seeing the reality of the consequences.

Rust and/or other memory safe(r) languages are like the future, but hopefully more people are now seeing the cracks. Just look at cloudflare for a prime example.

[–] pupbiru@aussie.zone 7 points 13 hours ago (1 children)

the cloudflare issues were configuration… they have nothing even remotely relayed to any of this

[–] PushButton@lemmy.world 0 points 11 hours ago (1 children)
[–] pupbiru@aussie.zone 8 points 10 hours ago

The software had a limit on the size of the feature file that was below its doubled size. That caused the software to fail.

this is not a rust problem… nor was the original problem of code writing entries to a file multiple times, and nor is the thing that made it worse: propagation of the poisoned file

[–] some_guy@lemmy.sdf.org 38 points 1 day ago (1 children)

Sucks to be the person who made that commit. Genuinely.

[–] SapphironZA@sh.itjust.works 7 points 22 hours ago

Back luck Brian kernel developer.

[–] Auster@thebrainbin.org 21 points 1 day ago (1 children)

Surprised it took so long.

[–] eager_eagle@lemmy.world 44 points 1 day ago

almost as if using a memory safe language actually reduces the CVEs related to memory

[–] ryannathans@aussie.zone 14 points 1 day ago (5 children)

What's the point of rewriting parts of the kernel in unsafe rust?

[–] Technus@lemmy.zip 80 points 1 day ago (2 children)

Because Rust lets you choose when something is unsafe vs writing all unsafe in code all the time:

Note the other 159 kernel CVEs issued today for fixes in the C portion of the codebase

[–] isVeryLoud@lemmy.ca 3 points 21 hours ago (1 children)

I wonder if this can be adjusted for LoC count in each language

[–] victorz@lemmy.world 7 points 18 hours ago (1 children)

Not sure if that's a fair metric yet.

[–] isVeryLoud@lemmy.ca 4 points 17 hours ago (1 children)

It's not, I have no better idea

[–] nsfw936421@lemmynsfw.com 3 points 9 hours ago

Maybe only counting new/edited LoC in that language. But also probably not completely fair.

[–] ryannathans@aussie.zone 5 points 1 day ago (1 children)

Yes same concept as other languages like C#

[–] Technus@lemmy.zip 7 points 1 day ago (2 children)

You go ahead and write an OS kernel in C# then.

[–] ryannathans@aussie.zone 9 points 1 day ago (1 children)

Why the hell would you do that

[–] Technus@lemmy.zip 4 points 18 hours ago (1 children)

Why would you bring up C# in a thread about kernel programming?

[–] ryannathans@aussie.zone 2 points 17 hours ago* (last edited 17 hours ago) (2 children)

Talking about how unsafe is not some new fancy rust feature and exists in other languages. Your comment makes it sound like the choice is some new wild computing concept.

[–] Hawk@lemmynsfw.com 2 points 13 hours ago

Memory safe languages that are not garbage collected are not all that common. Ada and Rust are two examples.

With great care C++ and zig can be.

I'm sure there's a good reason a lot of the big players and the community at large have picked up rust though. Docs, error messages, cargo community etc.

I would argue that Rust does bring a lot to the table. I certainly would never code in C for work but I'll happily reach for Rust.

[–] AI_toothbrush@lemmy.zip 1 points 17 hours ago (1 children)

Bruh do you actually not get it. The point of rust is that its memory safe(with a huge grain of salt in the case of low level programming) and is a language you can write kernels in. Youre not gonna write a kernel in C# so it doesnt really matter for a discussion about kernels.

[–] ryannathans@aussie.zone 2 points 17 hours ago (1 children)

I think you are lost, nobody is saying use C# for an OS kernel.

[–] boonhet@sopuli.xyz 5 points 1 day ago

Here, someone already wrote a bare bones one. Of course that also uses an unsafe block lol

[–] eager_eagle@lemmy.world 32 points 1 day ago

it's not like the whole driver is written in unsafe rust

[–] mech@feddit.org 18 points 1 day ago (1 children)

Mostly to attract new, younger kernel maintainers.

[–] pinball_wizard@lemmy.zip 22 points 1 day ago

That's legitimately a good reason. They can pry my C from my cold dead hands...but someday someone will have to. May as well think about what that should look like.

[–] ark3@lemmy.dbzer0.com 12 points 1 day ago

unsafe is usually used only when you need to interact with something else like low level or ffi

[–] hal_5700X@sh.itjust.works 3 points 1 day ago (1 children)

Because Rust is the popular thing in FOSS/Linux at the moment.

[–] ryannathans@aussie.zone 17 points 1 day ago (1 children)

For memory safety, which is not unsafe rust

[–] hal_5700X@sh.itjust.works 9 points 1 day ago (3 children)

You say that. But the CVE is a memory corruption bug.

[–] dgriffith@aussie.zone 48 points 1 day ago (1 children)

Which is worse?

  • Entire driver written in a non memory safe language?
  • The interface to the rest of the kernel is marked as unsafe and then the other X percent is safe from memory corruption?

Surely if X > 0 then this is still a net improvement?

[–] sik0fewl@lemmy.ca 6 points 1 day ago (1 children)

I don't know, but I found this article interesting with respect to unsafe Rust - https://lightpanda.io/blog/posts/why-we-built-lightpanda-in-zig

[–] killingspark@feddit.org 4 points 1 day ago

After writing this comment I noticed it became a bit ranty, sorry for that. Something about this article rubbed a bit in the wrong way.

The relevant section seems to be this:

Browser engines and garbage-collected runtimes are classic examples of code that fights the borrow checker. You’re constantly juggling different memory regions: per-page arenas, shared caches, temporary buffers, objects with complex interdependencies. These patterns don’t map cleanly to Rust’s ownership model. You end up either paying performance costs (using indices instead of pointers, unnecessary clones) or diving into unsafe code where raw pointer ergonomics are poor and Miri becomes your constant companion.

The first half is obviously correct, this kind of data model doesn't work well for the ownership model rust uses for its borrowchecker. I don't like the conclusion though. Rust makes you pay the performance costs necessary to make your code safe. You would need to pay similar costs in other languages if you intend on writing safe code.

Sure, if you are fine with potential memory corruption bugs, you don't need these costs, but that's not how I would want to code.

The other thing bugging me is how miri being your companion is framed as something bad. Why? Miri is one the best things about rusts unsafe code tooling. It's like valgrind, or sanitisers but better.

Now, the raw pointer ergonomics could be better, I'll give them that. But if you dive deep into what rust does with raw pointers, or rather what they are planning to do, is really really cool. Provenance and supporting cheri natively is just not possible for languages that chose the ergonomic of a raw integer over what rust does.

[–] JustAnotherKay@lemmy.world 9 points 1 day ago

They’re not calling Rust unsafe. There is a memory safe mode and a memory unsafe mode in Rust, and this was built in unsafe Rust which allowed for the memory bug to be exploited

[–] ryannathans@aussie.zone 0 points 1 day ago (1 children)

You don't understand what unsafe means

[–] sem@piefed.blahaj.zone 8 points 1 day ago* (last edited 18 hours ago) (1 children)

Rust by default will not allow you to make certain kinds of errora, which is great. But if you are doing something advanced, ~~down at the hardware level~~ [see below], you might need to disable those defaults in order to write the code you need. This is what people mean by "unsafe" -- lacking the normal memory safeguards.

With careful coding, "unsafe rust" or normal C, for that matter, can be free of bugs and safe. But if programmers make a mistake, vulnerabilities can creep in more easily in the unsafe sections.

Is that basically it?

[–] CandleTiger@programming.dev 7 points 1 day ago (1 children)

But if you are doing something advanced, down at the hardware level

This part is wrong. Otherwise yes correct.

The “unsafe” code in rust is allowed to access memory locations in ways that skip the compiler’s check and guarantee that that memory location has valid data. They programmer is on their own to ensure that.

Which as you say is just the normal state of affairs for all C code.

This is needed not because of hardware access but just because sometimes the proof that the access is safe is beyond what the compiler is able to represent.

[–] sem@piefed.blahaj.zone 1 points 18 hours ago (1 children)

Thank you for the correction, I'll edit my comment.

sometimes the proof that the access is

safe is bevond what the compiler is able to represent

Could you say a few more words about this? In what situations do you have to write 'unsafe-tagged' code blocks? Could this be changed by improvements to the compiler? Or is it necessitated by the type of task being done by the code?

[–] CandleTiger@programming.dev 2 points 13 hours ago

Check out the excellent tutorial # Learn Rust With Entirely Too Many Linked Lists especially chapters five and six. It has a lot more words, it’s entertaining, engaging, and informative.