Writing Linux Kernel Modules in Safe Rust
Talkat Linux Security Summit North America 2019 · on Tuesday, 2019-08-20· at 13:45· Sapphire D, Hilton San Diego Bayfront·
summary
65% of kernel CVEs are memory‑unsafety bugs, so a Rust-based module framework is built that uses bindgen and cargo‑xbuild with clang/LLVM interoperability, kmalloc-backed global allocator hooks, and user slice pointer APIs that consume buffers to prevent double‑fetch. A safe wrapper pattern exposes kernel file_operations as Rust traits, registers a character device that emits JSON via serde, and runs in QEMU; performance is comparable and a release build with JSON is about 1 MB. Sources and build scripts are on GitHub.
AI-written summary · about
chapters (35)
- 0:00Intro
- 0:57Memory unsafety
- 1:2249% - Chrome
- 2:0670% - Microsoft
- 2:2465% - Ubuntu
- 2:3665% - Android
- 2:51UAF Static Analysis
- 3:48Hardening C
- 4:25Isolation
- 6:26What do we want out of our language?
- 8:40A whirlwind tour of Rust, focusing on safety
- 8:53Hello world!
- 9:50Uninitialized variables
- 10:25Structs
- 11:43Traits
- 12:26Generics and polymorphism
- 12:47Trait objects and runtime polymorphism
- 14:13Enums with data
- 14:51Option and Result
- 16:47Error handling
- 17:54Panics and unwinding
- 20:07Dangling references
- 21:47Mutable references are unique references
- 23:44Atomics
- 25:37Safe and unsafe Rust
- 30:42Compiling
- 31:00Bindings
- 31:19Mapping kernel APIs to Safe Rust
- 32:09Heap allocations just work
- 32:37What about _user pointers?
- 34:29Concurrency!
- 35:32FileOperations must be Sync!
- 39:16Architecture support
- 45:13Real world out-of-tree module usage?
- 45:34Better kbuild integration
related talks
45mBuilding Safe and Secure Systems in Rust
44mSecure isolation in Rust
39mFrom C to Rust: Bringing Rust Abstractions to Embedded Linux
19mCounterexamples in Safe Rust
46mBypass Kernel Barriers: Fuzzing Linux Kernel in Userspace With LKL
01h 09mThe Rust Programming Language: Origin, History and Why it's so important for Arm today
34mTailor-Made Security: Building a Kubernetes Specific Hypervisor
52mWelcome & Opening Remarks & Meaningful Bounds Checking in the Linux Kernel
