Comment Re:Nope (Score 1) 151
Yeah, I think I should have read the code not just the CVE. It looks to me like a direct port of the C code with every other line being unsafe. I would put serious doubt on "efficient reasons". There are always multiple ways to write efficent code and one of those ways is usually safe or in the case of a data structure like this there will be a way to write it which involves much less unsafe code.
I've read the code now. So the safety statement is "unsafe { node_inner.death_list.remove(self) };" is okay because a node is either in a single list or in no list at all.
But "for death in death_list {" breaks this because it's moved part of the list onto the local stack. When you iterate though a list in Rust, it consumes the list destroying it. You avoid that by doing "for death in &death_list {". The fix just makes the safety statement true by deleting the nodes in place. This requires you to lock each node as you delete it but that isn't the fix in it's self.
I've read the code now. So the safety statement is "unsafe { node_inner.death_list.remove(self) };" is okay because a node is either in a single list or in no list at all.
But "for death in death_list {" breaks this because it's moved part of the list onto the local stack. When you iterate though a list in Rust, it consumes the list destroying it. You avoid that by doing "for death in &death_list {". The fix just makes the safety statement true by deleting the nodes in place. This requires you to lock each node as you delete it but that isn't the fix in it's self.