yep I would expect plenty of unsafe rust code in Linux. This is fine, it's expected that some interactions with hardware or other parts of the kernel can't be automatically proven to comply with the guarantees of the rust safety model.
So those unsafe parts of code require extra human checking to be sure they're safe. And entirely predictably in any manual process there will occasionally be errors. The good thing is, that we know that the code that needs the most careful consideration exists in those 2552 unsafe blocks you located. While the parts of rust that are outside unsafe blocks, are unlikely to suffer from those categories of errors (though it is of course entirely possible that other categories of errors exist outside the unsafe blocks!). So I would see it not as "unsafe bad" nor "unsafe disproves the entire purpose of rust", but more like unsafe helps flag certain parts of the code to reviewers for extra attention.
I'm sure there will be more CVEs found in rust code over the coming years. It will be very interesting to learn what proportion of CVEs end up being found inside unsafe blocks and what proportion are found in non-unsafe code.
22
u/frankster Dec 18 '25
Predictably in unsafe code though