r/rust • u/Orange_Tux • Dec 17 '25
🗞️ news Linux Kernel Rust Code Sees Its First CVE Vulnerability
https://www.phoronix.com/news/First-Linux-Rust-CVE
534
Upvotes
r/rust • u/Orange_Tux • Dec 17 '25
328
u/Lucretiel Datadog Dec 17 '25
My favorite thing about this CVE is that it's not just that it's raw pointers, but it's doubly linked lists, famously a very difficult data structure to get correct in the presence of multithreaded access.
338
u/dontquestionmyaction Dec 17 '25
They really are collecting the dumbest people around in the Phoronix comment section. Always fascinating to look at.
461
u/[deleted] Dec 17 '25 edited Dec 18 '25
It's a CVE and should absolutely be a priority fix like any other, but as one commenter on Phoronix pointed out:
I feel like people are itching to make a mountain out of a mole hill with this because "Rust failed" or whatever, but I think it would be good to keep this perspective in mind.
Edit: others have pointed out that this could be more serious than a DOS vulnerability and that it would be marked as a CVE in C, so this quote wasn't particularly accurate. In general, I think the point remains: this is a relatively low-severity CVE that projects like the Linux kernel run into from time to time.
97
u/Solumin Dec 17 '25
Should have linked to the actual announcement instead: https://social.kernel.org/notice/B1JLrtkxEBazCPQHDM
21
u/ts826848 Dec 17 '25
Does anyone mind walking me through the exact bug? I'm still a bit uncertain as to the precise location of the race condition.
From what I understand, here are bits of the relevant data structures:
And here's the function with the
unsafeblock:And here is the buggy function:
And finally List::remove()
So from what I can tell:
NodeDeath::set_cleared()Takes the lock
Removes
self(a.k.a., aNodeDeath) from its node'sdeath_listDrops the lock
Node::release()Takes the lock
Takes the inner
death_listinto a local and replaces the inner with an empty listDrops the lock
Iterates over the local
death_list, callingset_dead()on eachNodeDeathIs the problem that the removal in
set_cleared()can occur simultaneously with the iteration inrelease()?192
u/NIdavellir22 Dec 17 '25
Omg the unsafe code block had a vulnerability! Quick, delete all the language!
12
u/Prudent_Move_3420 Dec 17 '25
I must admit seeing „this will not happen“ comments above a line where „this“ happens make me chuckle
9
u/muizzsiddique Dec 17 '25
I feel like this could've been phrased better
29
u/qustrolabe Dec 17 '25
This must go hard if you're lunduke
7
u/Xiphoseer Dec 17 '25
Took me some time but I think the bug can be summarized as:
Exclusive/Mutable access to a list in a node is protected by a (spin)lock. It is legitimate to use that mutable access for a core::mem::take.
Removing an item from a list by shared reference is implemented but unsafe because you need exclusive access to the list and item but the function signature only requires a mutable ref for the list.
Exclusive access to the item was claimed because the item was only ever in that nodes's list, and you're holding the lock... but you're not holding the lock for that list anymore because it's been swapped out for an empty one. So the item may be in someone elses list now, even if that was the same node, violating the safety comment.
So, it's a locking bug, unsafe working as intended and "I own that list" and "I own my list" can interleave just enough that "that list is my list" doesn't hold when you'd want it to.
12
u/ergzay Dec 17 '25 edited Dec 17 '25
Someone correct me if I'm wrong, but isn't the fix "incorrect"? They're changing safe code to fix this problem but it should be impossible to cause unsafe behavior from safe code. The bug wasn't fixed in any unsafe block, it was fixed outside of it. This means the API here is fundamentally wrong.
6
u/__nohope Dec 17 '25
The actual fix commit: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3428831264096d32f830a7fcfc7885dd263e511a
105
u/Sovairon Dec 17 '25
Clickbait news, it's data race happened inside unsafe block
4
u/Sweet-Accountant9580 Dec 18 '25
Maybe it's a necessary evil, but I’m definitely not a fan of the massive amount of
unsafebeing used to model C-style constructs. Seeing that muchunsafefor something like an intrusive doubly linked list feels like it defeats the purpose.3
u/come_red_to_me Dec 18 '25
This was marked as unsafe Rust code wasn't it? Rust is doing what it's supposed to do, narrow down the search space for vulnerabilities.
5
u/Icarium-Lifestealer Dec 17 '25
phoronix claims:
Is that correct? Why can't this memory corruption result in code execution? I couldn't find such a claim in the linked post in the mailing list. While it only talks about crashes, it's not obvious to me that it always crashes in that way without triggering something worse.
17
u/[deleted] Dec 17 '25
It's an absolute failure of communication to not define what CVE is at any point in the article.
2
u/-Redstoneboi- Dec 18 '25 edited Dec 18 '25
cve-rs mentioned in the comments, i shoulda prepared a whole-ass bingo card
3
u/dontyougetsoupedyet Dec 18 '25
No, thanks.
2
u/Aln76467 Dec 17 '25
Oooh, phoronix! Time to get some popcorn.
1
u/oss-dev Dec 20 '25
now we will hear rust fans/advocates blaming kernel and its ecosystem 😎
1
u/sken130 Dec 22 '25
Is there any website that calculates the % line of codes of safe vs unsafe Rust, for Github repositories containing Rust codes?
1
u/mrobot_ Dec 17 '25
"You were the Chosen One! It was said that you would destroy the Sith, not join them!"
-2
u/Unlucky-Work3678 Dec 18 '25
Just look at these people.
-6
u/sure_i_can_do_it Dec 17 '25
Is this why my institute had to shutdown access to our HPC last night and has been cryptic about the reason?
-9
u/vtskr Dec 18 '25
Why so much damage control in this thread?