News for hackers. Stuff that matters.
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.