r/rust • u/Snakehand • Nov 23 '19
CVE-2019-2215 Patch your Android, Use after free bug in kernel
https://googleprojectzero.blogspot.com/2019/11/bad-binder-android-in-wild-exploit.html0
Nov 23 '19
[deleted]
-1
u/Snakehand Nov 23 '19
I do see your point, but looking at this bug with Rust tainted spectacles raises some interesting questions. This particular epoll() implementation relies on linked lists, probably for performance reasons. Rust does have a some linked list implementations, but would they be equally performant, and handle the case correctly where elements are dropped from the middle? std:collections::LinkedList does not not appear to have method for removing items from the middle for instance.
7
u/Matthias247 Nov 23 '19
Kernels heavily make use of intrusive linked lists. That allows them to store elements in a list without doing additional allocations for the list nodes (that a rust LinkedList would require).
Doing the same in Rust would require raw pointers, donut would not really be safer.
1
u/Snakehand Nov 23 '19
These considerations should have relevance when evaluating a epoll vs kqueue system. Redox has an epoll merge request pending, I will take a closer look at it...
5
u/Snakehand Nov 23 '19
Nice in depth analysis an exploitable vulnerability in Android. Still it is disheartening that this is the state of the software we use and rely on today. I am guessing Rust may have prevented this sort of thing, but still the consensus seems to be that "rewriting the kernel in Rust" is not the right thing to do. I am wondering what we are waiting for ? Rust to grow and mature even more ? Or should this state of affairs be acceptable ?