BlueHat IL 2023: Microsoft rewriting core Windows libraries in Rust
youtube.com
youtube.com
Highlights:
* 2 projects: dwrite and Win32k
* 2 devs, 6 months to rewrite 152KLOC C++ to 90KLOC Rust re dwrite
* Performance increases of 5-15% re dwrite
* Only about 10% of Win32k code is unsafe
* No perf regressions re Win32k
* Syscall in the Windows kernel now written in RustSince MFC and COM, that outside of the kernel most code is C++, even MSVC libc is actually written in C++ with extern "C" declarations.
Additionally starting with Windows Vista, C++ code started to be allowed on the kernel (VC++ got /kernel flag), and nowadays there is a template library called WIL.
It's a common source of privilege escalation bugs because it runs in kernel mode and accessible via a large surface of user mode apis.
What a miracle!
Rust marketing is the best.
My understanding of what the presenter meant here was "this is gnarly code that's been around for a very long time." Not that it literally remains solely optimized for the 486.
Also worth noting that various parts of MS have declared GDI as legacy at various points in time. Yet it remains a critically important component.
Am I the only one who watched the video?
I watched the video yesterday, before it was even posted to Hacker News.
This is not Rust marketing. This is some MS systems programmers detailing their experience with Rust.
I didn't watch the whole video though. Is that the same number you're quoting?
* The open web, David defeating Goliath Microsoft (arguably like a small open source retailer defeating Amazon today).
* Rust: Not entirely Mozilla, but they played an essential, major role nurturing it, and were among the first to deploy it.
Any others that I'm overlooking?
In addition, I seem to recall that the Alliance For Open Media and its AV1 codec also derives from Mozilla sponsoring Xiph.org's Monty to come up with an unencumbered, next-gen media codec.
Are there any tools to help map out the work that needs to be done? I found myself doing this by hand recently, doing graph search on a piece of paper. I needed to port one function, so I identified all the functions that function called, wrote them down, and then looked into the next layer of functions etc. I manually searched the potential call graphs by reading the code and wrote down all possible functions involved. I then crossed of functions that seemed obvious, such as a function to retrieve the value of a dictionary with a default value, such simple functions are trivial and need no special effort. In the end I had a list of functions that needed to be ported one-by-one and I began working from the bottom up.
I was wondering if there are any tools that could automate this process? It seems to be the beginning of a source-to-source compiler, but such a compiler could be kept simple by embracing that most of the work can be presented to a human to perform manually. The "compilers" only job is to structure the work and break it down into small chunks.
Lots of software tools for generating call graphs. I've used doxygen (free) for it in the past and LDRA (not free) at an early job. This won't generate the new code for you, but will be a lot easier than manually constructing a call graph.
Windows kernel drivers are usually fully asynchronous so I'm curious how rust handles IRPs and completion callbacks and such in the kernel.
glibc has its share of CVEs, and many of the bugs are of the double free, use-after-free, buffer overflow variety. [1]
[0]: https://github.com/redox-os/relibc [1]: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=glibc
The C standard library isn't necessarily a standard library of C code, it's more of a standard library for C code. There's plenty of languages these days where the standard library is built in other languages, somewhere between partially and fully; some portion of the C standard library can probably benefit greatly from the memory lifetime structures of Rust; although the constant need to interface with C code may reduce the effectiveness.
Rust supports shared libraries.
Technically, it also supports Rust ABI dynamic libraries, but their portability is quite fragile due to changes in the compiler. That's why Rust parts of the code are usually statically linked.
I do not know the answer (in this case) and believe this makes a notable difference.
However it is naive to think Big corps don't have an influence on it.