frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Linux Kernel Rust Code Sees Its First CVE Vulnerability

https://www.phoronix.com/news/First-Linux-Rust-CVE
62•weinzierl•1h ago

Comments

kahlonel•1h ago
Now we have vulnerabilities in two different flavors.
greatgib•1h ago
"That code can lead to memory corruption of the previous/next pointers and in turn cause a crash."

Oh no, what happened to Rust will save us from retarded legacy languages prone to memory corruption?

gfna•57m ago
Well the article did mention it was in an undafe block
pa7ch•1h ago
Honestly seems like zig is shaping up to be a better fit for kernel. Regardless the language that attracts skilled kernel devs will matter more then lang.
postepowanieadm•57m ago
It's true only for unsafe rust.
HumanOstrich•1h ago
They're still 90% of the way to their goal. And there's only 90% left to go.
tekacs•58m ago
To pre-empt the folks who'll come in here and laugh about how Rust should be preventing memory corruption... I'll just directly quote from the mailing list:

  Rust Binder contains the following unsafe operation:
  
   // SAFETY: A `NodeDeath` is never inserted into the death list
   // of any node other than its owner, so it is either in this
   // death list or in no death list.
   unsafe { node_inner.death_list.remove(self) };
  
  This operation is unsafe because when touching the prev/next pointers of
  a list element, we have to ensure that no other thread is also touching
  them in parallel. If the node is present in the list that `remove` is
  called on, then that is fine because we have exclusive access to that
  list. If the node is not in any list, then it's also ok. But if it's
  present in a different list that may be accessed in parallel, then that
  may be a data race on the prev/next pointers.
  
  And unfortunately that is exactly what is happening here. In
  Node::release, we:
  
   1. Take the lock.
   2. Move all items to a local list on the stack.
   3. Drop the lock.
   4. Iterate the local list on the stack.
  
  Combined with threads using the unsafe remove method on the original
  list, this leads to memory corruption of the prev/next pointers. This
  leads to crashes like this one:
samdoesnothing•23m ago
If rust is so inflexible that it requires the use of unsafe to solve problems, that's still rust's fault. You have to consider both safe rust behaviour as well as necessary unsafe code.
woodruffw•18m ago
This is sort of the exact opposite of reality: the point of safe Rust is that it's safe so long as Rust's invariants are preserved, which all other safe Rust preserves by construction. So you only need to audit unsafe Rust code to ensure the safety of a Rust codebase.

(The nuance being that sometimes there's a lot of unsafe Rust, because some domains - like kernel programming - necessitate it. But this is still a better state of affairs than having no code be correct by construction, which is the reality with C.)

gkbrk•15m ago
Which domain doesn't necessitate unsafe? Any large Rust project I check has tons of unsafe in its dependency tree.
treyd•9m ago
And that is fine, because those upstream deps can locally ensure that those sections are correct without any risk that some unrelated code might mis-safely use them unsafely. There is an actual rigorous mathematical proof of this. You have no such guarantees in C/C++.
woodruffw•5m ago
I've written lots of `forbid(unsafe_code)` in Rust; it depends on where in the stack you are and what you're doing.

But as the adjacent commenter notes: having unsafe is not inherently a problem. You need unsafe Rust to interact with C and C++, because they're not safe by construction. This is a good thing!

samdoesnothing•11m ago
It's just moving the goalposts. "If it compiles it works" to "it eliminates all memory bugs" to "well, it's safer than c...".

If Rust doesn't live up to its lofty promises, then it changes the cost-benefit analysis. You might give up almost anything to eliminate all bugs, a lot to eliminate all memory bugs, but what would you give up to eliminate some bugs?

woodruffw•7m ago
Can you show me an example of Rust promising "if it compiles it works"? This seems like an unrealistic thing to believe, and I've never heard anybody working on or in Rust claim that this is something you can just provide with absolute confidence.

The cost-benefit argument for Rust has always been mediated by the fact that Rust will need to interact with (or include) unsafe code in some domains. Per above, that's an explicit goal of Rust: to provide sound abstractions over unsound primitives that can be used soundly by construction.

kstrauser•17m ago
What's the alternative that preserves safe-by-default while still allowing unlimited flexibility to accidentally break things? I mean, Rust allows inline assembly because there are situations where you absolutely must execute specific opcodes, but darned if I want that to be the common case.
thayne•10m ago
That's like saying that if c is so inflexible it requires the use of inline assembly to solve problems, it's C's fault if inline assembly causes undefined behavior.
Phelinofist•18m ago
I know nothing about Rust. But why is unsafe needed? Kinda sounds a lock would make this safe?
aw1621107•7m ago
> I know nothing about Rust. But why is unsafe needed?

The short of it is that for fundamental computer science reasons the ability to always reject unsafe programs comes at the cost of sometimes being unable to verify that an actually-safe program is safe. You can deal with this either by accepting this tradeoff as it is and accepting that some actually-safe programs will be impossible to write, or you can add an escape hatch that the compiler is unable to check but allows you to write those unverifiable programs. Rust chose the latter approach.

> Kinda sounds a lock would make this safe?

There was a lock, but it looks like it didn't cover everything it needed to.

themafia•17m ago
So the prediction that incautious and unverified unsafe {} blocks would cause CVEs seems entirely accurate.
drob518•52m ago
Anybody who thought the simple action of rewriting things in Rust would eliminate all bugs was hopelessly naive. Particularly since Rust allows unsafe operations. That doesn’t mean Rust provides no value over C, just that the value is short of total elimination of bugs. Which was never advertised as the value to begin with.
zamalek•47m ago
> Anybody who thought the simple action of rewriting things in Rust would eliminate all bugs was hopelessly naive

All bugs is typically a strawman typically only used by detractors. The correct claim is: safe Rust eliminates certain classes of bugs. I'd wager the design of std eliminates more (e.g. the different string types), but that doesn't really apply to the kernel.

samdoesnothing•19m ago
> All bugs is typically a strawman typically only used by detractors. The correct claim is: safe Rust eliminates certain classes of bugs. I'd wager the design of std eliminates more (e.g. the different string types), but that doesn't really apply to the kernel.

Which is either 1) not true as evidenced by this bug or 2) a tautology whereby Rust eliminates all bugs that it eliminates.

PartiallyTyped•15m ago
>> safe Rust

> 1) not true as evidenced by this bug

Code used unsafe, putting us out of "safe" rust.

tensor•47m ago
What? I think people think "rust without unsafe" eliminates certain classes of bugs. Are we really going to imply that people don't understand that "unsafe" labeled code is ... uh.. possibly unsafe? I don't believe that these mythical "naive" people exist who think code explicitly labelled unsafe is still safe.
hnlmorg•40m ago
I think the problem lies with the fact that you cannot write kernel code without relying on unsafe blocks of code.

So arguably both camps are correct. Those who advocate Rust rewrites, and those who are against it too.

bangaladore•39m ago
I think part of the problem is people start thinking that unsafe code with a SAFETY comment nearby is probably safe.

Then the safety comment can easily bias the reader into believing that the author has fully understood the problem and all edge cases.

webstrand•34m ago
The SAFETY comment is just a brief description of the important points the author considered when writing the block, and perhaps points you need to consider if you modify it. Do people just blindly assume that comments in an algorithm are correct and not misleading? In other languages they don't, I don't see why rust'd be any different.
Kinrany•24m ago
> unsafe code with a SAFETY comment nearby

That's roughly 100% of unsafe code because a lint in the compiler asks for it.

samdoesnothing•20m ago
> Anybody who thought the simple action of rewriting things in Rust would eliminate all bugs was hopelessly naive.

Classic Motte and Bailey. Rust is often said "if it compiles it runs". When that is obviously not the case, Rust evangelicals claim nobody actually means that and that Rust just eliminates memory bugs. And when that isn't even true, they try to mischaracterize it as "all bugs" when, no, people are expecting it to eliminate all memory bugs because that's what Rust people claim.

themafia•15m ago
> That doesn’t mean Rust provides no value over C

The real question is "does it provide this greater value for _less_ effort?"

The answer seems to be: "No."

bangaladore•47m ago
Correct me if I'm wrong, but this comment is atleast partially incorrect right?

> Since it was in an unsafe block, the error for sure was way easier to find within the codebase than in C. Everything that's not unsafe can be ruled out as a reason for race conditions and the usual memory handling mistakes - that's already a huge win.

The benefit of Rust is you can isolate the possible code that causes an XYZ to an unsafe block*. But that doesn't necessarily mean the error shown is directly related to the unsafe block. Like C++, triggering undefined behavior can in theory cause the program to do anything, including fail spectacularly within seemingly unrelated safe code.

* Excluding cases where safe things are actually possibly unsafe (like some incorrectly marked FFI)

malcolmgreaves•35m ago
The point at which you _could_ start to have undefined behavior is within an `unsafe` block or function. So even if the "failure" occurred in some "safe" part of the code, the conditions to make that failure would start in the unsafe code.

When debugging, we care about where the assumptions we had were violated. Not where we observe a bad effect of these violated assumptions.

I think you get here yourself when you say:

> triggering undefined behavior can in theory cause the program to do anything, including fail spectacularly within seemingly unrelated safe code

The bug isn't where it failed spectacularly. It's where the C++ code triggered undefined behavior.

Put another way: if the undefined behavior _didn't_ cause a crash / corrupted data, the bug _still_ exists. We just haven't observed any bad effects from it.

landr0id•34m ago
From my experience UB in Rust can manifest a bit differently than in C or C++, but still generally has enough smoke in the right area.

I believe their point was that they only needed to audit only the unsafe blocks to find the actual root cause of the bug once they had an idea of the problematic area.

lousken•31m ago
Why do they allow unsafe parts in linux kernel in the first place? Why rewriting C code into unsafe rust?
om8•22m ago
https://steveklabnik.com/writing/does-unsafe-undermine-rusts...
tialaramex•21m ago
Rust is very nice for encapsulation. C isn't great at that work, and of course it can't express the idea that whatever we've encapsulated is now safe to use this way, in C everything looks equally safe/ unsafe.
informa23•9m ago
On the other hand, Rust has some rules that are more difficult to uphold than C, for instance regarding aliasing. Especially in the Linux kernel, where it was decided that strict aliasing should be turned off when compiling C. When Rust-unsafe is used, the programmer has the responsibility of not violating those rules. That can be tricky, and many Rust developers either try to avoid using unsafe, or lean heavily on Miri, even though Miri can't handle everything.
K0nserv•20m ago
It's important to note that the `unsafe` keyword is poorly named. What it does is unlock a few more capabilities at the cost of upholding the invariants the spec requires. It should really be called "assured" or something. The programmer is taking the wheel from the compiler and promising to drive safely.

As for why there is unsafe in the kernel? There are things, especially in a kernel, that cannot be expressed in safe Rust.

Still, having smaller sections of unsafe is a boon because you isolate these locations of elevated power, meaning they are auditable and obvious. Rust also excels at wrapping unsafe in safe abstractions that are impossible to misuse. A common comparison point is that in C your entire program is effectively unsafe, whereas in Rust it's a subset.

informa23•13m ago
> Still, having smaller sections of unsafe is a boon because you isolate these locations of elevated power, meaning they are auditable and obvious.

The Rustonomicon makes it very clear that it is generally insufficient to only verify correctness of Rust-unsafe blocks. If the absence of UB in a Rust-unsafe block depends on Rust-not-unsafe code in the surrounding module, potentially the whole module has to be verified for correctness. And that assumes that the module has correct encapsulation, otherwise even more may have to be verified. And a single buggy change to Rust-not-unsafe code can cause UB, if a Rust-unsafe block somewhere depends on that code to be correct.

speed_spread•15m ago
You need unsafe Rust for FFI - interfacing with the rest of the kernel which is still C, uses raw pointers, has no generics, doesn't track ownership, etc. One day there might enough Rust in the kernel to have pure-Rust subsystems APIs which would no longer require unsafe blocks to use. This would reverse the requirements as C would be a second class citizen with these APIs (not that C would notice or care). How far Rust is to get pushed remains to be seen but it might a long time to get there.
informa23•5m ago
Multiple reasons:

1: Marketing and social media brigading, as Linus put it.

2: Pattern matching and enums, which are genuinely good.

3: Rust has some trade-offs that are closer to C++ than C, and those trade-offs have advantages and disadvantages.

4: Module system.

5: More modern macros.

6: Other advantages.

Rust also has a large heap of drawbacks.

tialaramex•23m ago
I guess the problem here is that you and the writer have different understandings of what "the error" means.

The author is thinking about "the error" as some source code that's incorrect. "Your error was not bringing gloves and a hat to the snowball fight" but you're thinking "the error" is some diagnostic result that shows there was a problem. "My error is that I'm covered in freezing snow".

Does that help?

informa23•18m ago
The absence of UB, undefined behavior, everything-bad-can-happen, in an Rust-unsafe block can depend on Rust-not-unsafe code in the surrounding module. Thus, even a single block of unsafe can in theory require going through the whole module to figure out where it went wrong or to ensure correctness. And if access control was not properly used, possibly more than the module.

If you look at the mentioned patches, the fixes are to code outside the described unsafe block, in Rust-not-unsafe code. It is perfectly possible to introduce UB through changes to "safe" Rust, if those changes end up violating some assumptions in some Rust-unsafe block somewhere.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux...

Another way to introduce UB in Rust-not-unsafe, is if no_std is used. In that case, a simple stack overflow can cause UB, no Rust-unsafe required.

Surprisingly many Rust developers do not understand these points. It may take some of the shine off of Rust, so some Rust fans refrain from explaining it properly. Which is not good.

troglo-byte•22m ago
I'll confess I'm a bit less than well-read on this, but I can't help but wonder. How can increasing the number of languages in use within one enormous project possibly reduce critical vulnerabilities over the next decade?

If we're looking beyond one decade, then:

- As with all other utility, the future must be discounted compared to the present.

- A language that might look sterling today might fall behind tomorrow.

- Something something AI by 2035.

phendrenad2•17m ago
I feel like everyone involved in the Linux Kernel Rust world is ironically woefully unaware of how Rust actually works, and what it's actually capable of. I suspect that Rust gurus agree with me, but don't want to say anything because it would hurt Rust adoption in places where it actually is helpful (encryption algorithms...)

Kernels - and especially the Linux kernel - are high-performance systems that require lots of shared mutable state. Every driver is a glorified while loop waiting for an IRQ so it can copy a chunk of data from one shared mutable buffer to another shared mutable buffer. So there will need to be some level of unsafe in the code.

There's a fallacy that if 95% of the code is safe, and 5% is unsafe, then that code is only 5% as likely to contain memory errors as a comparable C program. But, to reiterate what another commenter said, and something I've predicted for a long time, the tendency for the "unsafe block" to become instrumented by the "safe block" will always exist. People will loosen the API contract between the "safe" and "unsafe" sides until an error in the "safe" side kicks off an error in the "unsafe" side.

aw1621107•17m ago
Direct link to the mailing list entry at [0]. The fix for 6.19-rc1 is commit 3e0ae02ba831 [1]. The patch is pretty small (added some extra context since the function it's from is short):

        pub(crate) fn release(&self) {
            let mut guard = self.owner.inner.lock();
            while let Some(work) = self.inner.access_mut(&mut guard).oneway_todo.pop_front() {
                drop(guard);
                work.into_arc().cancel();
                guard = self.owner.inner.lock();
            }

    -       let death_list = core::mem::take(&mut self.inner.access_mut(&mut guard).death_list);
    -       drop(guard);
    -       for death in death_list {
    +       while let Some(death) = self.inner.access_mut(&mut guard).death_list.pop_front() {
    +           drop(guard);
                death.into_arc().set_dead();
    +           guard = self.owner.inner.lock();
            }
        }
And here is the unsafe block mentioned in the commit message with some more context [3]:

    fn set_cleared(self: &DArc<Self>, abort: bool) -> bool {
        // <snip>

        // Remove death notification from node.
        if needs_removal {
            let mut owner_inner = self.node.owner.inner.lock();
            let node_inner = self.node.inner.access_mut(&mut owner_inner);
            // SAFETY: A `NodeDeath` is never inserted into the death list of any node other than
            // its owner, so it is either in this death list or in no death list.
            unsafe { node_inner.death_list.remove(self) };
        }
        needs_queueing
    }
[0]: https://lore.kernel.org/linux-cve-announce/2025121614-CVE-20...

[1]: https://github.com/torvalds/linux/commit/3e0ae02ba831da2b707...

[2]: https://github.com/torvalds/linux/blob/3e0ae02ba831da2b70790...

[3]: https://github.com/torvalds/linux/blob/3e0ae02ba831da2b70790...

samdoesnothing•15m ago
I think it's pretty telling that there are people in this thread trying to pre-empt the expected criticism in this thread. Might be worth thinking why there might be criticism, and why it wouldn't be the case if it was a different language.

Abusing x86 instructions to optimize PS3 emulation [RPCS3] [video]

https://www.youtube.com/watch?v=40tyEVx_umY
1•davikr•1m ago•0 comments

The Oscars Moving to YouTube Beginning in 2029, Will Stream Free Worldwide

https://variety.com/2025/film/news/oscars-youtube-2029-1236610989/
1•Risse•2m ago•0 comments

Exclusive-How China built its 'Manhattan Project' to rival the West in AI chips

https://finance.yahoo.com/news/exclusive-china-built-manhattan-project-141758929.html
1•WheelsAtLarge•2m ago•0 comments

DB migration tool – For those of us who don't use SQLAlchemy

https://github.com/rodmena-limited/migretti
1•rodmena•2m ago•0 comments

Open source platform for BYOC deployments

https://github.com/nuonco/nuon
1•MorehouseJ09•2m ago•0 comments

Evaluating AI's ability to perform scientific research tasks

https://openai.com/index/frontierscience/
1•Anon84•3m ago•0 comments

Crash clock says satellites in orbit are three days from disaster

https://www.newscientist.com/article/2508752-crash-clock-says-satellites-in-orbit-are-three-days-...
2•Breadmaker•3m ago•0 comments

Yet antoher RAG – for code generation with impressive correctness

https://github.com/rodmena-limited/ragit
1•rodmena•3m ago•0 comments

The quick and dirty genius of Luhn algorithm

https://evgeniipendragon.com/posts/the-quick-and-dirty-genius-of-luhn-algorithm/
1•EPendragon•4m ago•0 comments

Titan Mining Commences Graphite Processing at Empire State Mines in New York

https://www.titanminingcorp.com/news/news-releases/titan-mining-commences-graphite-processing-at-...
1•kotaKat•4m ago•0 comments

Log Structured Merge Trees

http://www.benstopford.com/2015/02/14/log-structured-merge-trees/
2•whatisabcdefgh•5m ago•0 comments

Meta pauses third-party headset program

https://www.roadtovr.com/meta-horizon-os-third-party-headset-cancelled-asus-lenovo/
1•dagmx•5m ago•0 comments

Rust in ClickHouse

https://clickhouse.com/blog/alexey-p99-2025-rust-in-clickhouse
1•Abbit•6m ago•0 comments

MiniMax Agent

https://agent.minimax.io
2•SpyCoder77•7m ago•0 comments

A Roadmap for Federal AI Legislation

https://a16z.com/a-roadmap-for-federal-ai-legislation-protect-people-empower-builders-win-the-fut...
1•kjhughes•8m ago•0 comments

Show HN: Modeling the US Debt as a Healthcare Pricing Failure ($26T Gap)

https://taprootlogic.substack.com/p/the-us-debt-crisis-a-52-trillion
1•kmundy•8m ago•0 comments

Show HN: Bob the Fixer – SonarQube and MCP tools for a fix→test→re-scan loop

https://github.com/andrearaponi/bob-the-fixer
1•andrearaponi12•8m ago•0 comments

Make Me CEO of Mozilla

https://blog.kingcons.io/posts/make-me-ceo-of-mozilla.html
3•phyzome•9m ago•0 comments

Implicit Position-Based Fluids (IPBF)

https://graphics.cs.utah.edu/research/projects/ipbf/
3•ibobev•9m ago•0 comments

Sample Space Partitioning and Spatiotemporal Resampling for Specular Manifolds

https://graphics.cs.utah.edu/research/projects/psms-restir/
2•ibobev•9m ago•0 comments

The Politics of Superintelligence

https://www.noemamag.com/the-politics-of-superintelligence/
1•buellerbueller•10m ago•0 comments

Device Logs Anywhere

https://blog.golioth.io/device-logs-anywhere-with-golioth-pipelines/
1•hasheddan•11m ago•0 comments

A2UI: An open project for agent-driven interfaces

https://developers.googleblog.com/introducing-a2ui-an-open-project-for-agent-driven-interfaces/
1•jarmitage•11m ago•1 comments

Containrrr/watchtower is now archived

https://github.com/containrrr/watchtower/discussions/2135
1•wooben•12m ago•0 comments

Anchored Diffusion Language Model

https://anchored-diffusion-llm.github.io
1•nathan-barry•13m ago•0 comments

Project Everest

https://project-everest.github.io/
1•whatisabcdefgh•14m ago•0 comments

Show HN: Voice-to-text for macOS using Groq's free Whisper API

https://github.com/bokan/stt
1•bbokan•15m ago•0 comments

AI, AI Oh

https://thinkhuman.com/aiaioh/
2•jamesgill•18m ago•0 comments

Finland is in midst of racist firestorm

https://www.bbc.com/news/articles/cde657xj3pxo
5•crazybonkersai•19m ago•3 comments

Temporal: Getting started with JavaScript's new date time API

https://2ality.com/2021/06/temporal-api.html
1•fanf2•20m ago•0 comments