News for hackers. Stuff that matters.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by tialaramex on Wednesday December 17, 2025 @01:40PM (#46303628)
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.
Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by informa23 on Wednesday December 17, 2025 @01:52PM (#46303808)
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.

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.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by MyOutfitIsVague on Wednesday December 17, 2025 @02:19PM (#46304205)
It's worth noting that "aliasing" in Rust and C typically mean completely unrelated things.

Strict aliasing in C roughly means that if you initialize memory as a particular type, you can only access it as that type or one of a list of aliasable types look like char. Rust has no such restriction, and has no concept of strict aliasing like this. In Rust, "type aliasing" is allowed, so long as you respect size, alignment, and representability rules.

Aliasing safety in Rust roughly means that you can not have an exclusive reference to an object if any other reference is active for that reference (reality is a little bit more involved than that, but not a lot). C has no such rule.

It's very unfortunate that such similar names were given to these different concepts.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by tialaramex on Wednesday December 17, 2025 @04:26PM (#46305729)
No. Aliasing is a single idea, an alias is another name for the same thing. The concept translates well from its usual English meaning.

The C "strict aliasing" rule is that with important exceptions the name for a thing of type T cannot also be an alias to a thing of type S, and char is an important exception. Linux deliberately switches off this rule.

Rust's rule is that there mustn't be mutable aliases. We will see why that's important in a moment.

Aliasing is an impediment to compiler optimisation. If you've been watching Matt's "Advent of Compiler Optimisation" videos (or reading the accompanying text) it's been covered a little bit in that, Matt uses C and C++ in those videos, so if you're scared of Rust you needn't fear that in the AoCO

But why mutation? Well, the optimisations concern modification. The optimiser does its job by rewriting what you asked for as something (possibly not something you could have expressed at all in your chosen language) that has the same effect but is faster or smaller. Rewrites which avoid "spilling" a register (writing its value to memory) often improve both size and speed of the software, but if there is aliasing then spilling will be essential because the other aliases are referring to the same memory. If there's no modification it doesn't matter, copies are all identical anyway.

Re:Linux Kernel Rust Code Sees Its First CVE Vulnerability by MyOutfitIsVague on Friday December 19, 2025 @03:52PM (#46330760)
Fair enough, I meant in terms of what rules and restrictions exist around aliasing, which are different between the two, but my wording was indeed off.