Microsoft vice president David Weston revealed this week that Microsoft will follow Linux and rewrite parts of the Windows kernel in Rust.
“We’re in the crawl stage of crawl, walk, run of Rust in Windows,” Mr. Weston said during an appearance at the Microsoft’s BlueHat IL 2023 conference. “We’re talking about one of the most complex engineering products on the planet. But our goal is to do this to improve security … So you will actually see Windows booting with Rust in the kernel in probably the next several weeks or months, which is really cool. The basic goal here is to convert some of these internal C++ data types into their Rust equivalents.”
The sample code he displayed demonstrated part of the reason for this conversion: the Rust code is much easier to write and understand than the current C++ code. It’s also safer and more secure: for those unfamiliar, Rust is a modern C-like programming language that’s beloved by developers because its forces the creation of safe, native code without the overhead of managed languages.
According to Weston, Microsoft has already rewritten 36,000 lines of code in the Windows kernel in Rust, in addition to another 152,000 lines of code it wrote for a proof of concept DirectWrite Core library, and the performance is excellent with no regressions compared to the old C++ code. He also called out that “there is now a syscall, in the Windows kernel, written in Rust.” A syscall, or system call, is how user mode applications interact with internal kernel functions (to oversimplify it).
I’m curious to see how Microsoft calls out this work in the future, but the DirectWrite Core library is available now in the Windows App SDK, and some GDI work is coming soon to Insiders. What Microsoft won’t be doing is replacing the entire “40 years of work” in C/C++ in the kernel with Rust, but I’m sure it makes sense to replace some of that work to remove legacy attack surfaces while moving new kernel work to Rust, as is the case with Linux: the recently released Linux 6.1 kernel is the first to include Rust code.