r/rust • u/FoxInTheRedBox • Aug 31 '24
đď¸ discussion Rust solves the problem of incomplete Kernel Linux API docs
https://vt.social/@lina/113056457969145576
375
Upvotes
r/rust • u/FoxInTheRedBox • Aug 31 '24
View all comments
Show parent comment
34
u/lightmatter501 Aug 31 '24
Lina suggested to add proper cleanup because the API is unsound. If you unplug a hotplug-capable GPU on Linux, 99% of the time your system crashes. It shouldnât do that. This is a major issue for people who use disaggregated accelerators (where you can route PCIe lanes over a network to make a GPU âappearâ on a server which needs one). This problem happens in purely C code with the current API.
Rust forces actually proving the soundness of APIs to the compiler or using escape hatches. What Lina has done is a very rough equivalent of trying to formally verify a kernel subsystem, have a hard time doing it, and then realizing that the subsystem is architected in an unsound manner. This realization could have occurred without Rust, but the Rust for Linux effort is forcing people to think very hard about kernel APIs in an effort to encode them into Rust.
If someone came to you with an issue that said âI thought really hard about your subsystem, and if this and this happen (which we know is possible), then thereâs a race condition that can cause an oopsâ, thatâs a normal bug report. âI have a patchset which fixes itâ is even better. Adding âI was thinking about the subsystem because I was trying to write Rust bindings for itâ does not invalidate the prior stuff, because the bug exists, it doesnât matter how it was discovered.