News for hackers. Stuff that matters.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by tekacs on Wednesday December 17, 2025 @01:04PM (#46303122)
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:
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by themafia on Wednesday December 17, 2025 @01:44PM (#46303678)
So the prediction that incautious and unverified unsafe {} blocks would cause CVEs seems entirely accurate.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by mustache_kimono on Wednesday December 17, 2025 @02:58PM (#46304710)
> So the prediction that incautious and unverified unsafe {} blocks would cause CVEs seems entirely accurate.

This is one/the first CVE caused by a mistake made using unsafe Rust. But it was revealed along with 159 new kernel CVEs found in C code.[0]

It may just be me, but it seems wildly myopic to draw conclusions about Rust, or even, unsafe Rust from one CVE. More CVEs will absolutely happen. But even true Rust haters have to recognize that tide of CVEs in kernel C code runs something like 19+ CVEs per day? What kind of case can you make that "incautious and unverified unsafe {} blocks" is worse than that?

[0]: https://social.kernel.org/notice/B1JLrtkxEBazCPQHDM

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by uecker on Wednesday December 17, 2025 @03:31PM (#46305099)
Github says 0.3% of the kernel code is Rust. But even normalized to lines of code, I think counting CVEs would not measure anything meaningful.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by taproottap on Wednesday December 17, 2025 @04:17PM (#46305622)
It would probably have to be normalized to something slightly different as lines of code necessary to a feature varies by language.. But even with the sad state of CVE quality, I would certainly prefer a language that deflects CVEs for a kernel that is both in places with no updates and in places with forced updates for relevant or irrelevant CVE.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by mustache_kimono on Wednesday December 17, 2025 @04:11PM (#46305562)
> Github says 0.3% of the kernel code is Rust. But even normalized to lines of code, I think counting CVEs would not measure anything meaningful.

Your sense seems more than a little unrigorous. 1/160 = 0.00625. So, several orders of magnitude fewer CVEs per line of code.

And remember this also the first Rust kernel CVE and C kernel code CVEs both continue to accrue at an astonishing rate, and had accrued previously.

Taking a one week snapshot and saying Rust doesn't compare favorably when Rust CVEs are 1/160, and C CVEs are 159/160 is just nuts.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by mustache_kimono on Wednesday December 17, 2025 @09:29PM (#46308309)
> Your sense seems more than a little unrigorous. 1/160 = 0.00625. So, several orders of magnitude fewer CVEs per line of code.

This is incorrect. Chalk it up to the flu and fever! Sorry.

0.00625 == .625%. or about twice the instance of Rust code however as stated above these are just the metric from one patch cycle.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by uecker on Thursday December 18, 2025 @02:58AM (#46310026)
It wasn't me trying to conclude anything from insufficient data.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by pjjpo on Thursday December 18, 2025 @08:25AM (#46312354)
I'm more interested in the % of rust code that is marked unsafe. If you can write a kernel with 1% safe, that sounds pretty great. If the nature of dealing with hardware (AFAIK most of a kernel is device drivers) means something higher, maybe 10%, then maybe safety becomes difficult, especially because unsafety propagates in an unclear way since safe code becomes unsafe to some degree when it calls into it.

I'm also curious about the percentage of implicit unsafe code in C, given there are still compilers and linters checking something, just not at the level of lifetimes etc in Rust. But I guess this isn't easy to calculate.

I like rust for low level projects and see no need to pick C over it personally - but I think it's fair to question the real impact of language safety in a realm that largely has to be unsafe. There's no world where Rust is more unsafe than C though so it's all academic. I just wonder if there's been any analysis on this, in close to metal applications like a kernel.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by mustache_kimono on Thursday December 18, 2025 @03:53PM (#46318552)
> I'm more interested in the % of rust code that is marked unsafe.

I think you should less interested in % unsafe as what the unsafe is used to do, that is, it's likelihood to cause UB, etc. If it's unsafe to interface with C code, or unsafe to do a completely safe transmute, I'm not sure one should care.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by uecker on Friday December 19, 2025 @03:54AM (#46323690)
> There's no world where Rust is more unsafe than C though so it's all academic

I think Rust is more unsafe than C due to supply chain issues in the Rust ecosystem, which have not fully materialized yet. Rust certainly has an advantage in terms of memory safety, but I do not believe it is nearly as big as people like to believe compared to a C project that actually cares about memory safety and applies modern tooling to address safety. There seems to be a lot of confirmation bias. I also believe Rust is much safer for average coders doing average projects by being much safer by default.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by mustache_kimono on Friday December 19, 2025 @03:35PM (#46330588)
> I think Rust is more unsafe than C due to supply chain issues in the Rust ecosystem

This is such an incredibly cheap shot. First, the supply chain issues referenced have nothing to do with Rust, the language, itself. Second, Rust's build system, cargo, may have these issues, but cargo's web fetch features simply aren't used by the Linux kernel.

So -- we can have a debate about which is a better a world to live in, one with or without cargo, but it really has nothing to do with the Linux kernel security.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by thrance on Wednesday December 17, 2025 @04:22PM (#46305670)
To be actually fair, you should probably only look at CVEs concerning new-ish code.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by accelbred on Thursday December 18, 2025 @12:04AM (#46309055)
The kernel policy for CVEs is any patch that is backported, no? So this is just the first Rust patch, post being non-experimental, that was backported?
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by nottorp on Thursday December 18, 2025 @09:05AM (#46312814)
If you tell us $LANGUAGE is the second coming of $DEITY daily, in multiple ways, we will expect that it is the second coming.

What's even the point of introducing Rust into the Linux kernel when you have to use the hidden under the rug unsafe parts of it to function?

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by stouset on Friday December 19, 2025 @01:42AM (#46322894)
All of C is unsafe. Tiny, limited parts of kernel Rust code are unsafe. The percentage of unsafe Rust code will almost certainly decrease over time.

This isn’t really hard to wrap your head around.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by hulitu on Friday December 19, 2025 @02:41AM (#46323247)
> The percentage of unsafe Rust code will almost certainly decrease over time.

Famous last words. /s

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by K0nserv on Wednesday December 17, 2025 @02:01PM (#46303931)
Isn’t it obvious that the primary source of CVEs in Rust programs would be the portions of the program where the human is charge of correctness instead of the compiler?

The relevant question is whether it results in fewer and less severe CVEs than code written in C. So far the answer seems to be a resounding yes

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by Hemospectrum on Wednesday December 17, 2025 @03:05PM (#46304799)
It is not obvious to those who refuse to understand, and who preemptively reject case studies on the grounds that the numbers are surely fabricated.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @02:03PM (#46303971)
"Cause" seems unsubstantiated: I think to justify "cause," we'd need strong evidence that the equivalent bug (or worse) wouldn't have happened in C.

Or another way to put it: clearly this is bad, and unsafe blocks deserve significant scrutiny. But it's unclear how this would have been made better by the code being entirely unsafe, rather than a particular source of unsafety being incorrect.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by ganelonhb on Wednesday December 17, 2025 @02:06PM (#46304014)
The definition of cause is quite clear. “Rust” is obviously not the cause, but it did fail to be the solution, here. You can’t avoid that.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by bigstrat2003 on Wednesday December 17, 2025 @02:13PM (#46304118)
But it didn't promise to be the solution either. Rust has never claimed, nor have its advocates claimed, that unsafe Rust can eliminate memory bugs. Safe Rust can do that (assuming any unsafe code relied upon is sound), but unsafe cannot be and has never promised to be bug free.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by nottorp on Thursday December 18, 2025 @09:06AM (#46312825)
Ok so why is Rust in the kernel if you can't use safe rust there and what's left is not what Rust promises?
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Thursday December 18, 2025 @11:12AM (#46314564)
Most of the kernel's Rust usage is safe Rust. The only unsafe Rust is there to interact with the rest of the kernel and to provide safe abstractions.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @02:10PM (#46304067)
Except that it didn't fail to be the solution: the bug is localized to an explicit escape hatch in Rust's safety rules, rather than being a latent property of the system.

(I think the underlying philosophical disagreement here is this: I think software is always going to have bugs, and that Rust can't - and doesn't promise - to perfectly eliminate them. Instead, what Rust does promise - and deliver on - is that the entire class of memory safety bugs can be eliminated by construction in safe Rust, and localized when present to errors in unsafe Rust. Insofar as that's the promise, Rust has delivered here.)

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by uecker on Wednesday December 17, 2025 @03:04PM (#46304781)
You can label something an "explicit escape hatch" or a "latent property of the system", but in the end such labels are irrelevant. While I agree that it may be easier to review unsafe blocks in Rust compared to reviewing pointer arithmetic, union accesses, and free in C because "unsafe" is a bit more obvious in the source, I think selling this as a game changer was always an exaggeration.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @03:11PM (#46304879)
Having written lots of C and C++ before Rust, this kind of local reasoning + correctness by construction is absolutely a game changer. It's just not a silver bullet, and efforts to miscast Rust as incorrectly claiming to be one seem heavy-handed.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by tialaramex on Wednesday December 17, 2025 @05:57PM (#46306755)
Google's feedback seems to suggest Rust actually might be a silver bullet, in the specific sense meant in the "No Silver Bullet" essay.

That essay doesn't say that silver bullets are a panacea or cure all, instead they're a decimal order of magnitude improvement. The essay gives the example of Structured Programming, an idea which feels so obvious to us today that it's unspoken, but it's really true that once upon a time people wrote unstructured programs (today the only "language" where you even could do this is assembly and nobody does it) where you just jump arbitrarily to unrelated code and resume execution. The result is fucking chaos and languages where you never do that delivered a huge improvement even before I wrote my first line of code in the 1980s.

Google did find that sort of effect in Rust over C++.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by uecker on Thursday December 18, 2025 @01:53AM (#46309626)
As a scientist, I would not trust self reports from the industry too much. Even if those are honest, there are too many things that could bias this.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by n2d4 on Wednesday December 17, 2025 @02:04PM (#46303991)
Sure, but that's not really that interesting or controversial.

The more useful question is, how many CVEs were prevented because unsafe {} blocks receive more caution and scrutiny?

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by themafia on Wednesday December 17, 2025 @05:35PM (#46306523)
If you could find a way to actually measure that it would be useful. I doubt this is actually achievable in our Universe.

If all of C is effectively "unsafe" then wouldn't it receive the _most_ scrutiny?

Since this didn't work then I don't understand Rust's overall strategy.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by goku12 on Wednesday December 17, 2025 @10:25PM (#46308606)
That's not how it works. A larger codebase to scrutinize means that there's more chance of missing a memory safety bug. If you can keep the Rust unsafe block bug-free, you don't need to worry about them anymore in safe Rust. They're talking about attention getting divided all over the code where this distinction is not there (like C code). They always have been.

On top of that, there is something else they say. You have to uphold the invariants inside the unsafe blocks. Rust for Linux documents these invariants as well. The invariant was wrong in this case. The reason I mention this is because this practice has forced even C developers to rethink and improve their code.

Rust specifies very clearly what sort of error it eliminates and where it does that. It reduces the surface area of memory safety bugs to unsafe blocks, and gives you clear guidelines on what you need to ensure manually within the unsafe block to avoid any memory safety bugs. And even when you make a human error in that task, Rust makes it easy to identify them.

There are clear advantages here in terms of the effort required to prevent memory safety bugs, and in making your responsibilities explicit. This has been their claim consistently. Yet, I find that these have to be repeated in every discussion about Rust. It feels like some critics don't care about these arguments at all.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by crote on Thursday December 18, 2025 @03:46AM (#46310308)
Obviously. If you use a language which inherently makes memory safety bugs in regular code impossible, all memory safety bugs will be contained to the "trust me, I know what I'm doing - no need to check this" bypass sections. Similarly, all drownings happen in the presence of water.

The important thing to remember is that in this context C code is one giant unsafe {} block, and you're more likely to drown in the sea than in a puddle.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by torginus on Wednesday December 17, 2025 @03:47PM (#46305297)
Sorry, but this is like saying 'when I am not wrong, I am right 100% of the time'.

The devs didn't write unsafe Rust to experience the thrills of living dangerously, they wrote it because the primitives were impossible to express in safe Rust.

If I were to write a program in C++ that has a thread-safe doubly linked list in it, I'd be able to bet on that linked list will have safety bugs, not because C++ is an unsafe language, but because multi-threading is hard. In fact, I believe most memory safety errors today occur in the presence of multi-threading.

Rust doesn't offer me any way of making sure my code is safe in this case, I have to do the due diligence of trying my best and still accept that bugs might happen because this is a hard problem.

The difference between Rust and C++ in this case, is that the bad parts of Rust are cordoned off with glowing red lines, while the bad parts of C++ are not.

This might help me in minimizing the attack surface in the future, but I suspect Rust's practical benefits will end up less impactful than advertised, even when the language is full realized and at its best, because most memory safety issues occur in code that cannot be expressed in safe Rust and doing it in a safe Rust way is not feasible for some technical reason.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by Phelinofist on Wednesday December 17, 2025 @01:43PM (#46303663)
I know nothing about Rust. But why is unsafe needed? Kinda sounds a lock would make this safe?
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by aw1621107 on Wednesday December 17, 2025 @01:54PM (#46303832)
> 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.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by dijit on Wednesday December 17, 2025 @02:02PM (#46303955)
I think you missed the parents point. We all universally acknowledge the need for the unsafe{} keyword in general; what the parent is saying is: given the constraint of a lock, could this code not have obviated the need for an unsafe block entirely. Thus rendering the memory safety-issue impossible.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by aw1621107 on Wednesday December 17, 2025 @02:26PM (#46304297)
Ah, I see that interpretation now that you spelled it out for me.

Here's what `List::remove` says on its safety requirements [0]:

    /// Removes the provided item from this list and returns it.
    ///
    /// This returns `None` if the item is not in the list. (Note that by the safety requirements,
    /// this means that the item is not in any list.)
    ///
    /// # Safety
    ///
    /// `item` must not be in a different linked list (with the same id).
    pub unsafe fn remove(&mut self, item: &T) -> Option<ListArc<T, ID>> {
At least if I'm understanding things correctly, I don't think that that invariant is something that locks can protect in general. I can't say I'm familiar enough with the code to say whether some other code organization would have eliminated the need for the unsafe block in this specific case.

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

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by Phelinofist on Wednesday December 17, 2025 @02:22PM (#46304235)
Yes, that is what I meant - thanks for actually expressing my thoughts better than me.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by samdoesnothing on Wednesday December 17, 2025 @01:38PM (#46303591)
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.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @01:43PM (#46303660)
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.)

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by gkbrk on Wednesday December 17, 2025 @01:46PM (#46303706)
Which domain doesn't necessitate unsafe? Any large Rust project I check has tons of unsafe in its dependency tree.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by gpm on Wednesday December 17, 2025 @02:37PM (#46304425)
> in its dependency tree.

Ultimately every program depends on things beyond any compilers ability to verify, for example the calls to code not written in that language being correct, or even more fundamentally if you're writing some embedded program that literally has interfaces to foreign code at all the silicon (both that handles IO and that which does the computation) being correct.

The promise of rust isn't that it can make this fundamentally non-compiler-verifiable (i.e. unsafe) dependency go away, it's that you can wrap the dependency in abstractions that make it safe for users of the dependency if the dependency is written correctly.

In most domains rust don't necessitate writing new unsafe code, you rely on the existing unsafe code in your dependencies that is shared, battle tested, and reasonably scoped. This is all rust, or any programming langauge, can promise. The demand that the dependency tree has no unsafe isn't the same as the domain necessitating no unsafe, it's the impossible demand that the domain of writing the low level abstractions that every domain relies on doesn't need unsafe.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @01:56PM (#46303856)
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!

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by informa23 on Wednesday December 17, 2025 @02:06PM (#46304025)
EDIT: Hacker News has limited my ability to respond. Please keep in mind that Rust has a large number of active fans, who may have biases for whatever reasons.

Do you agree or disagree with

https://www.reddit.com/r/rust/comments/16i8lo2/how_unpleasan...

> It is worse than writing equivalent unsafe code in, say, C. The main pain point is that Rust has a rather complicated relationship between raw pointers and non-raw pointers (mainly references and box). Namely is how they invalidate each other. A good rule of thumb is to mix them as little as possible. But eventually the raw-pointer-heavy unsafe code will have to interface with reference-heavy safe code, and that's where the tricky stuff is.

> Unsafe Rust is generally much harder to get right than unsafe C or unsafe C++. There's no sugar coating it. Rust relies on many more invariants and guarantees that you have to account for than C or C++ do, so there's much more mental overhead.

matthieum, a Rust reddit mod and fan of Rust, disagrees with those posts. Whether he is biased or not is up to others to decide.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @02:14PM (#46304130)
I think unsafe Rust is harder to write than C. However, that's because unsafe Rust makes you think about the invariants that you'd need to preserve in a correct C program, so it's no harder to write than correct C.

In other words: unsafe Rust is harder, but only in an apples-and-oranges sense. If you compare it to the same diligence you'd need to exercise in writing safer C, it would be about the same.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by jackrabbit1997 on Wednesday December 17, 2025 @02:24PM (#46304265)
How would you describe the aliasing requirements of C and Rust, and do you consider them the same, as well as equally difficult?
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @02:30PM (#46304343)
Safe Rust has more strict aliasing requirements than C, so to write sound unsafe Rust that interoperates with safe Rust you need to do more work than the equivalent C code would involve. But per above, this is the apples-and-oranges comparison: the equivalent C code will compile, but is statistically more likely to be incorrect. Moreover, it's going to be incorrect in a way that isn't localizable.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by jackrabbit1997 on Wednesday December 17, 2025 @08:57PM (#46308109)
Are you using an LLM to write your posts?
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @09:20PM (#46308257)
No, that’s just how I write. Do you normally insinuate from green accounts?
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by bigstrat2003 on Wednesday December 17, 2025 @02:07PM (#46304030)
Almost all of them. It would be far shorter to list the domains which require unsafe. If you're seeing programmers reach for unsafe in most projects, either you're looking at a lot of low level hardware stuff (which does require unsafe more often than not), or you are seeing cases where unsafe wasn't required but the programmer chose to use it anyway.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by treyd on Wednesday December 17, 2025 @01:52PM (#46303800)
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++.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by informa23 on Wednesday December 17, 2025 @02:01PM (#46303933)
EDIT: Hacker News has limited my ability to respond. Please keep in mind that Rust has a large number of active fans, who may have biases for whatever reasons.

What?

Even the Rust standard library has had UB.

https://materialize.com/blog/rust-concurrency-bug-unbounded-...

And a bug in one crate can cause UB in another crate if that other crate is not designed well and correctly.

https://zackoverflow.dev/writing/unsafe-rust-vs-zig/

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by treyd on Wednesday December 17, 2025 @02:11PM (#46304089)
> And a bug in one crate can cause UB in another crate if that other crate is not designed well and correctly.

Yes! Failure to uphold invariants of the underlying abstract model in an unsafe block breaks the surrounding code, including other crates! That's exactly consistent with what I said. There's nothing special about the stdlib. Like all software, it can have bugs.

What the proof states is that two independently correct blocks of unsafe code cannot, when used together, be incorrect. So the key value there is that you only have to reason about them in isolation, which is not true for C.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by aw1621107 on Wednesday December 17, 2025 @02:07PM (#46304034)
I think you're misunderstanding GP. The claim is that the only party responsible for ensuring correctness is the one providing a safe API to unsafe functionality (the upstream dependency in GP's comment). There's no claim that upstream devs are infalliable nor that the consequences of a mistake are necessarily bounded.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by dijit on Wednesday December 17, 2025 @02:06PM (#46304010)
Those guys were writing a lot of unsafe rust and bumped into UB.

I sound like an apologist, but the Rust team stated that “memory safety is preserved as long as Rusts invariants are”. Feels really clear, people keep missing this point for some reason, almost as if its a gotcha that unsafe rust behaves in the same memory unsafe way as C/C++: when thats exactly the point.

Your verification surface is smaller and has a boundary.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by mlindner on Wednesday December 17, 2025 @02:42PM (#46304503)
Ultimately all software has to touch hardware somewhere. There is no way to verify that the hardware always does what it is supposed to be because reality is not a computer. At the bottom of every dependency tree in any Rust code there always has to be unsafe code. But because Rust is the way it is those interfaces are the only places you need to check for incorrectly written code. Everywhere else that is just using safe code is automatically correct as long as the unsafe code was correct.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by estebank on Thursday December 18, 2025 @10:08AM (#46313482)
> Any large Rust project I check has tons of unsafe in its dependency tree.

This is an argument against encapsulation. All Rust code eventually executes `unsafe` code, because all Rust code eventually interacts with hardware/OS/C-libraries. This is true of all languages. `unsafe` is part of the point of Rust.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by stouset on Friday December 19, 2025 @01:45AM (#46322907)
And all of it is eventually run on an inherently unsafe CPU.

I cannot understand why we are continuing to have to re-litigate the very simple fact that small, bounded areas of potential unsafety are less risky and difficult to audit than all lines of code being unsafe.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by samdoesnothing on Wednesday December 17, 2025 @01:50PM (#46303772)
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?

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @01:54PM (#46303838)
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.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by kstrauser on Wednesday December 17, 2025 @04:10PM (#46305553)
I've also said it, with the implication that the only remaining bugs are likely to be ones in my own logic. Like, suppose I'm writing a budget app and haven't gone to the lengths of making Debit and Credit their own types. I can still accidentally subtract a debit from a balance instead of adding to it. But unless I've gone out of my way to work around Rust's protections, e.g. with unsafe, I know that parts of my code aren't randomly mutating immutables, or opening up subtle use-after-free situations, etc. Now I can spend all my time concentrating on the program's logic instead of tracking those other thousands of gotchas.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by treyd on Wednesday December 17, 2025 @02:37PM (#46304431)
> Can you show me an example of Rust promising "if it compiles it works"? [...] and I've never heard anybody working on or in Rust claim that this is something you can just provide with absolute confidence.

I have heard it and I've stated it before. It's never stated in absolute confidence. As I said in another thread, if it was actually true, then Rust wouldn't need an integrated unit testing framework.

It's referring to the experience that Rust learners have, especially when writing relatively simple code, that's it tends to be hard to misuse libraries in a way that looks correct and compiles but actually fails at runtime. Rust cannot actually provide this guarantee, it's impossible in any language. However there are a lot of common simple tasks (where there's not much complex internal logic that could be subtly incorrect) where the interfaces provided by libraries they're depending on are designed to leverage the type system such that it's difficult to accidentally misuse them.

Like something like not initializing a HTTP client properly. The interfaces make it impossible to obtain an improperly initialized client instance. This is an especially distinct feeling if you're used to dynamic languages where you often have no assurances at all that you didn't typo a field name.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by fwip on Wednesday December 17, 2025 @02:16PM (#46304154)
I've seen (and said) "if it compiles it works," but only when preceded by softening statements like "In my experience," or "most of the time." Because it really does feel like most of the time, the first time your program compiles, it works exactly the way you meant it to.

I can't imagine anybody seriously making that claim as a property of the language.

(edit: fixed a comma and a forgotten word)

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by woodruffw on Wednesday December 17, 2025 @02:25PM (#46304270)
Yeah, I think the experiential claim is reasonable. It's certainly my experience that Rust code that compiles is more confidence-inspiring than Python code that syntax-checks!
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by qcnguy on Thursday December 18, 2025 @04:14AM (#46310488)
https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...

Examples:

6 days ago: Their experience with Rust was positive for all the commonly cited reasons - if it compiles it works

8 days ago: I have to debug Rust code waaaay less than C, for two reasons: (2) Stronger type system - you get an "if it compiles it works" kind of experience

4 months ago: I've been writing Rust code for a while and generally if it compiles, it works.

5 months ago: If it’s Rust, I can just do stuff and I’ve never broken anything. Unit tests of business logic are all the QA I need. Other than that, if it compiles it works.

9 months ago: But even on a basic level Rust has that "if it compiles it works" experience which Go definitely doesn't.

Some people claim that the quote is hyperbolic because it only covers memory errors. But this bug is a memory error, so ...

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by aw1621107 on Thursday December 18, 2025 @04:44AM (#46310674)
> Examples:

GP isn't asking for examples of just anyone making that statement. They're asking for examples of Rust making that promise. Something from the docs or the like.

> Some people claim that the quote is hyperbolic because it only covers memory errors. But this bug is a memory error, so ...

It's a memory error involving unsafe code, so it would be out of scope for whatever promises Rust may or may not have made anyways.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by qcnguy on Friday December 19, 2025 @12:27PM (#46328440)
Rust can't make a promise, only people can. I think it was clear what samdoesnothing meant.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by aw1621107 on Friday December 19, 2025 @01:13PM (#46328971)
I think it's pretty reasonable to interpret "Language X promises Y" as tantamount to said promise appearing in Language X's definition and/or docs. Claims from devs in their official capacities are likely to count as well.

On the other hand, what effectively random third parties say doesn't matter all that much IMO when it comes to these things because what they think a language promises has little to no bearing on what the language actually promises. If I find a bunch of randos claiming Rust promises to give me a unicorn for my birthday it seems rather nonsensical to turn around and criticize Rust for not actually giving me a unicorn in my birthday.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by elpataka on Saturday December 20, 2025 @01:52PM (#46338521)
What docs or language definition are you even talking about? Rust doesn't have an official spec. How can Rust make such a promise if it does not even have an official spec or documentation where it can make it?

As the other commenter said, said promises are made by people. The problem comes from the fact that these people are not always just random internet strangers who don't know a thing about programming who say random stuff that crosses their mind. Sometimes, it comes from the authority of the Rust compiler developers themselves (who apparently also don't seem to know anything about programming, considering that they have made such retarded claims...).

Just look at any talk given by them, or any post made on any forum, or, most importantly, the many instances where such statements are made on the Rust book (which is not an official spec for the language, but it is the closest thing we have, ignoring Ferrocene's spec because rustc is not based on that...).

Also most public speakers who were extremely vocal about Rust and made cookie cutter and easy to digest content for beginner programmers were dead set on selling the language through empty promises and some weird glorification of its capabilities, bordering the behaviour of a cult. Cue in, No Boilerplate, Let's Get Rusty, etc... all of these people have said many times the "if it compiles, you know it works!" statement, which is very popular among Rust programmers, and we all know that that is not true, because anyone with any experience with Rust will be able to tell you that with unsafe Rust, you can shoot yourself in the foot.

Stop selling smoke, this is a programming language, why must it also be a cult?

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by aw1621107 on Sunday December 21, 2025 @01:13AM (#46342690)
> What docs or language definition are you even talking about?

I thought it was pretty clear from context that I was speaking more generally there. Suppose not.

> As the other commenter said, said promises are made by people.

Sure, but when the developers of a language collectively agree that the language they all work on should make a particular promise, I think it's reasonable to condense that to <language> promises <X> rather than writing everything out over and over.

It's kind of similar to how one might say "Company X promises Y" rather than "The management of company X promises Y". It's a convenient shorthand that I think is reasonably understood by most people.

> Rust doesn't have an official spec. How can Rust make such a promise if it does not even have an official spec or documentation where it can make it?

Rust does have official documentation [0]?

And that being said, I don't think a language needs an official spec to make a promise. As far as most programmers are concerned, I'm pretty sure the promises made in language/implementation docs are good enough. K&R was generally good enough for most C programmers before C had a spec, after all (and arguably even after to some extent) :P

> Sometimes, it comes from the authority of the Rust compiler developers themselves []. Just look at any talk given by them, or any post made on any forum

Does it? At least from what I can remember off the top of my head I don't think I've seen such claim from official Rust devs speaking in their capacity as such. Perhaps you might have links to such?

> or, most importantly, the many instances where such statements are made on the Rust book

Are there "many instances"? `rg 'compiles.*it.*works` turns up precisely one (1) instance of that statement in the Rust book [1] and slight variations on that regex don't turn up any additional instances. What the book says portrays that statement in a slightly different light than you seem to think:

> Note: A saying you might hear about languages with strict compilers, such as Haskell and Rust, is “If the code compiles, it works.” But this saying is not universally true. Our project compiles, but it does absolutely nothing! If we were building a real, complete project, this would be a good time to start writing unit tests to check that the code compiles and has the behavior we want.

I wouldn't claim that my search was comprehensive, though, and I also can't claim to know the Rust Book from cover to cover. Maybe you know some spots I missed?

> which is not an official spec for the language, but it is the closest thing we have

I believe that particular honor actually goes to the Rust Reference [2].

> Also most public speakers who were extremely vocal about Rust and made cookie cutter and easy to digest content for beginner programmers were dead set on selling the language through empty promises and some weird glorification of its capabilities, bordering the behaviour of a cult. Cue in, No Boilerplate, Let's Get Rusty, etc... all of these people have said many times the "if it compiles, you know it works!" statement, which is very popular among Rust programmers, and we all know that that is not true, because anyone with any experience with Rust will be able to tell you that with unsafe Rust, you can shoot yourself in the foot.

Again, I don't think what unrelated third parties say has any bearing on what a language actually promises. Rust doesn't owe me a unicorn on my birthday no matter how many enthusiastic public speakers I find.

[0]: https://doc.rust-lang.org/stable/

[1]: https://github.com/rust-lang/book/blob/39aeceaa3aeab845bc451...

[2]: https://doc.rust-lang.org/stable/reference/index.html

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by Pet_Ant on Wednesday December 17, 2025 @01:58PM (#46303884)
It's not moving the goalposts at all. I'm not a Rust programmer, but for years the message has been the same. It's been monotonous and tiring, so I don't know why you think it's new.

Safe Rust code is safe. You know where unsafe code is, because it's marked as unsafe. Yes, you will need some unsafe code in an notable project, but at least you know where it is. If you don't babysit your unsafe code, you get bad things. Someone didn't do the right thing here and I'm sure there will be a post-mortem and lessons learned.

To be comparable, imagine in C you had to mark potentially UB code with ub{} to compile. Until you get that, Rust is still a clear leader.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by thayne on Wednesday December 17, 2025 @01:51PM (#46303787)
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.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by kstrauser on Wednesday December 17, 2025 @01:44PM (#46303673)
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.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by bigstrat2003 on Wednesday December 17, 2025 @02:05PM (#46304001)
> If rust is so inflexible that it requires the use of unsafe to solve problems...

Thankfully, it doesn't. There are very few situations which require unsafe code, though a kernel is going to run into a lot of those by virtue of what it does. But the vast majority of the time, you can write Rust programs without ever once reaching for unsafe.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by ncruces on Thursday December 18, 2025 @05:14AM (#46310881)
It's not a kernel. It's the, admittedly very complicated, concurrent double linked list. I say that with no irony.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by lynndotpy on Wednesday December 17, 2025 @02:07PM (#46304026)
Yes. When writing unsafe, you have to assume you can never trust anything coming from safe rust. But you are also provided far fewer rakes to step on when writing unsafe, and you (ideally) are writing far fewer lines of unsafe code in a Rust project than you would for equivalent C.

Rust is written in Rust, and we still want to be able to e.g. call C code from Rust. (It used to be the case that external C code was not always marked unsafe, but this was fixed recently).

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by quotemstr on Thursday December 18, 2025 @11:04AM (#46314426)
samdoesnothing is making a legitimate point about needing to consider prevalence of unsafe inna Rust program. That he's being downvoted to hell is everything wrong with HN.