The Sequoia seq_file vulnerability
The Sequoia seq_file vulnerability
Posted Jul 25, 2021 18:21 UTC (Sun) by tialaramex (subscriber, #21167)In reply to: The Sequoia seq_file vulnerability by geuder
Parent article: The Sequoia seq_file vulnerability
If you would rather overflow checks also happen in production, you can ask for the Rust compiler setting overflow-checks = true in your production builds, as well as debug where it is default.
However, that would turn such bugs into a kernel crash, rather than local root. Not really what you want.
Rust also lets you explicitly say what you intend to happen for overflow. For example you can say you want saturating arithmetic (127_i8.saturating_add(1_i8) == 127_i8) or wrapping arithmetic (127_i8.wrapping_add(1_i8) == -128_i8) and now, at last, you've actually expressed your intention and so it's more likely this code might do what you intended rather than crashing or worse.
Ultimately if the programmer did not express any intent, it's difficult to see what a practical general purpose language ought to do.
In WUFFS they get to just reject all programs that don't specify. So if you look at byte A and byte B and you purport that you can add those together A+B and store the result as one byte, the WUFFS compiler rejects that code. You need to spell out constraints so that A and B will be small enough for this to work (WUFFS will check the constraints at runtime and error out if they are not met) OR explain how the addition should saturate or wrap to get one byte out (then WUFFS generates code that does so).
This feels like an appropriate discipline in their situation, but most programmers would chafe badly under those conditions.
Posted Aug 6, 2021 9:40 UTC (Fri)
by Randakar (guest, #27808)
[Link]
In lieu of the compiler explicitly rejecting such conversions (which it should) the next best thing is to fail in the most loud and noisy way possible so that this type of bug has a bigger chance to get noticed.
Silently doing unexpected things is almost always worse than an error, even if it crashes the system.
The Sequoia seq_file vulnerability