How I Found a 20-Year-Old Linux Kernel Bug
robert.ocallahan.org
robert.ocallahan.org
The bug was in from day 1.
If users encounter a weird result, report it, and have someone call them an idiot because they misunderstood a nuance of the system... they're probably not going to take the time to report next time around.
(And I get it, there's that common issue that people consistently misunderstand and you continually get reports about. But each one of those users might also be a user who finds a real bug next time.)
(Not saying it's easy, but it's a sign...)
bad/rookie dev: omg dumb user
good dev: closes bug issue, files new issue to fix docs.
https://github.com/torvalds/linux/commit/18aba41cbfbcd138e9f...
Segfaults are horrible, but bugs like these are even more so. Crawling, sneaking, living in your walls. Stealing precious CPU cycles and memory from millions of machines at once--petabytes and petaflops when you add it all up.
Worst yet, they don't make a peep until you shine the holy light of benchmarks, code reviews, automated testing, or the (un)lucky corner case on them.
At least segfaults let you know something's definitely wrong. These bugs? Now that's insidious.
(disclamer: I'm one of the QuickFuzz [0] developers and I'm very interested in testing for this kind of bugs)
https://labdcc.fceia.unr.edu.ar/~amista/article.pdf
Feel free to contact us by email in case you need.
> I guess once in a while it would fail if your allocator happens to land one at the end of a page.
I always wonder why the kernel does not just warn when this API is used or yank it. Any software stuck with this API can barely know about 802.11n and is probably wondering what is 802.11ac or 802.11ax. Only some old or broken device drivers require this API.
Linux distros should just stop enabling this API.
proposed patch here:
https://bugzilla.kernel.org/attachment.cgi?id=256997&action=...
In particular it seems to me like this could have been fixed with a better, machine-readable description of the types/structures for each ioctl, plus a static analysis tool that makes sure that the kernel does a copy_from_user on exactly what the documented input types are and no more or less. There is already a halfhearted attempt to encode type information in ioctls (the _IOR, _IOW, etc. macros), so I think this is doable. I'm not sure how much work is required to trace copy_from/to_user statically, but it certainly seems like it would be far less work than 20 years of people using these syscalls.
As another example, I think "given enough eyeballs, all bugs are shallow" would be a poor reason to eschew writing tests for your code.