Better handling of integer wraparound in the kernel
Better handling of integer wraparound in the kernel
Posted Jan 29, 2024 2:18 UTC (Mon) by NYKevin (subscriber, #129325)In reply to: Better handling of integer wraparound in the kernel by donald.buczek
Parent article: Better handling of integer wraparound in the kernel
Are there situations where data integrity might dictate failing rather than producing an incorrect value? Of course, but those are properly handled with checked_add() and friends, not with crashing the entire service. If there is any input that can cause your service to crash, it is an outage waiting to happen.
Posted Jan 29, 2024 7:23 UTC (Mon)
by donald.buczek (subscriber, #112892)
[Link] (1 responses)
Considering your example, isn't there a concern that your internal or external user might have other requirements and would prefer no data over wrong data? Overlooking unexpected overflows might result in serious incidents like Cloudbleed [1]. As a customer, I'd rather see a temporary service disruption than having to learn that my private data has been silently exposed and spilled into search engine caches.
[1]: https://blog.cloudflare.com/quantifying-the-impact-of-clo...
Posted Jan 29, 2024 9:25 UTC (Mon)
by NYKevin (subscriber, #129325)
[Link]
This is fine if the program is running on the user's computer. If it is not, then a crash will affect everyone whose requests are being processed by that machine, and in the case of cascade failure, fallout will be wider still. There may be situations where failing rather than producing wrong data is preferred, but it is the responsibility of the programmer to understand that requirement and use checked_add etc. instead of regular arithmetic operators. This is no different to any other functional requirement of a software system - if you write the code wrong, it will not work.
> Overlooking unexpected overflows might result in serious incidents like Cloudbleed [1].
Security is hard. I'm not going to solve the general problem of malicious inputs in an LWN comment, but in general, defensive programming is necessary (not sufficient) to deal with problems of this nature. Most languages do not provide integers that always crash on overflow, so handling overflow correctly is something that serious programmers will find themselves having to deal with on a regular basis regardless. Rust provides the necessary methods for doing this front and center, which is more than you can say for most languages (C is only standardizing the equivalent functions in C23!). If you want stronger guarantees than that, I would suggest rewriting the parser (and perhaps a small part of the parser-adjacent application logic) in wuffs.
Besides, if you allow malicious inputs to cause a crash, you make yourself far more vulnerable to denial of service attacks, which are also a security concern (albeit a less serious one).
Better handling of integer wraparound in the kernel
Better handling of integer wraparound in the kernel