5 ms·
This looks very similar to webassembly work going on right now, both use a secure VM, and both run in kernel space. Would webassembly be a more general purpose
by ClumsyPilot 7y ago
This looks very similar to webassembly work going on right now, both use a secure VM, and both run in kernel space.
Would webassembly be a more general purpose way of accomplishing something like this?
- TickleSteve 7y agoA BPF interpreter can literally be ~100 LoC. A WebAssembly VM on the other hand will likely be ~1million LoC (without checking). One is suitable for embedding into a kernel, the other isn't.
- sanxiyn 7y agoWhere did you get ~1million number? https://github.com/bytecodealliance/wasm-micro-runtime https://github.com/bytecodealliance/wasm-micro-runtime is less than 100K LoC for example.
- 0-_-0 7y agoIf a micro runtime is 100K LOC then 1M LOC wasn't unrealistic.
- sanxiyn 7y agoAbout half is tests and sample codes. Runtime proper (core directory) is <50K. It is also WASI runtime. WebAssembly runtime proper (core/iwasm/runtime directory) is more like 10K.
- kbumsik 7y agoThis is a micro runtime that acts as a tiny WASM interpreter. 1M LOC sounds fair when complex runtime features such as JIT or AOT are included.
- nicoburns 7y ago> One is suitable for embedding into a kernel, the other isn't. I'd be very surprised if the linux kernel doesn't eventually get web assembly support.
- manyworlds 7y agoDoubtful. Webassembly is Turing complete, BPF isn’t. Running untrusted unbounded code in the kernel is not smart. BPF was invented with kernel constraints in mind, webassembly was invented with browser constraints in mind. Completely different use cases
- nicoburns 7y ago> Running untrusted unbounded code in the kernel is not smart. Well currently we run code (e.g. drivers) as trusted full-permission code. Surely, web-assembly would be better than this from a security perspective.
- manyworlds 7y agoGenerally kernel code is also written to specific constraints. Out-of-tree drivers are usually bad at conforming and hypothetical out-of-tree webassembly drivers would be bad for similar reasons. Memory safety isn’t enough, using kernel interfaces safely requires conformance that webassembly can’t statically guarantee like BPF can Basic examples: code that takes a lock and never releases it, code that loops forever, code that leaks kernel resources.
- boomlinde 7y agoWhat use case do you envision?
- mkup 7y agoOut-of-tree drivers, support for closed-source drivers in Linux (assuming kernel API for wasm drivers is stable).
- mwcampbell 7y ago> without checking Then how can you possibly know? Do you just assume that because it has "Web" in the name, it must be insanely complicated?
- ClumsyPilot 7y agoThank you, I appreciate the perspective. Perhaps WebAssembly kernel-space programming would still be viable for major trusted projects, like Kafka, where you literally dedicate the entire machine to that application.
- manyworlds 7y agoUnikernel or rump kernel would be better for that purpose
- sho_hn 7y agowebassembly "runs in kernel space"?
- rhencke 7y agoYes, though it's early days yet. See: https://github.com/wasmerio/kernel-wasm https://github.com/wasmerio/kernel-wasm
- jacquesm 7y agoPlease no.
- lightgreen 7y agoCare to explain?
- jacquesm 7y agoThe tendency to dump all kinds of unrelated stuff in the kernel is a very bad trend. It increases the attacks surface of the kernel in unpredictable ways and will lead to security issues, especially with something as complex as an interpreter.
- lightgreen 7y agoInterpreter is very small part of overall kernel codebase, and it is the same interpreter for all kinds of applications written in wa, need to be analyzed only once, but performance benefits of running code in kernel space are huge. Moreover, wa can even make kernel safer but rewriting certain not very performance critical parts of the kernel in wa. But I got your point. Thanks!