// rewriting the risky edges
A kernel rewriting its own parsers in Rust.
Not a rebrand. MayteraOS ships a growing memory-safe Rust core:
the security-critical, input-facing parsers that historically cause the worst bugs are
ported one at a time and differentially tested against the C original under
AddressSanitizer before they ship, with a plain-C hardening fix landing alongside so
builds without the Rust subsystem enabled are protected too. Every shipped seam has since
been re-audited against its pre-port original, and we publish what that audit found,
including where our own extraction drifted.
Ported so far: the IP/TCP/UDP checksum routines, SHA-256, the ext2 directory parser
(read and write), GPT/MBR partition-table parsing, the DHCP client, the ELF loader, FAT
long-filename parsing, PNG and JPEG decoding, the TLS handshake, HTTP chunked-transfer
decoding, HTTP/2 framing, AAC/M4A audio decode, WAV parsing, extended-attribute parsing,
the NFS/XDR client, USB Audio Class descriptor parsing, and Ed25519 signature verification.
Two userland apps have followed the same path: the RSS reader now runs on a Rust feed
parser, and Task Manager runs on a Rust data core.
By the numbers: ≈2,281 lines of C replaced by ≈5,168 lines of Rust across
39 kernel components in 7 subsystems (crypto, net, fs, exec, gui, media, drivers). Read
against an honest denominator, that is roughly 0.61% of the kernel's ≈376,000
lines of C/H/ASM, smaller than before not because the Rust share shrank, but because a
separate cleanup pass deleted tens of thousands of lines of unreachable C (see the
changelog). This is the untrusted-input parser, crypto and loader
tier, done thoroughly; it is not a wholesale rewrite, and the kernel remains overwhelmingly C
by design. Performance is a wash: measured cycles-per-operation land roughly a third faster, a
third at parity and a third slower than the C it replaced, mostly FFI and bounds-check overhead
on cold, once-per-file or once-per-connection paths. The Rust port was never sold as a speed
project; the payoff is the advisories below.
We audited our own port, and we publish what it found. All 36 shipped seams have been
re-checked against their pre-port C original under a three-way oracle across roughly 25
million differential vectors, because “we lifted the C verbatim” is a claim, not a
proof. Equivalence to the original C holds for 29 seams, several proven by byte-identity of the
extracted code rather than by testing alone. It does not hold for three (the DHCP, ICMP
and MP4 parsers), where the shipped Rust accepts slightly more than the C did on inputs our own
self-tests could not express: low security impact, but they were labelled as confinements and
they are not, so the labels were wrong. Three more (the ELF, PE and TLS seams) are deliberately
stricter than the code they replace. And two of our extracted C references drifted from the
original, so they are not a faithful rollback target. All 12 advisories were re-witnessed and
all 12 remain valid; three carried wording errors, now
corrected in the open.
12advisories closed
6out-of-bounds writes
6reads / null-deref
4remote
824current fixed build
PROVEN TODAY
The Rust port itself found all 12 of these advisories: real out-of-bounds reads and
writes in the C parsers, several remote and pre-auth, surfaced by porting each parser and
differentially testing the new Rust code against the old C code on hundreds of thousands of
inputs under ASan. Ten are confined by the Rust; two were fixed in plain C, and are credited
that way rather than to the port. Each is published with a CWE class, severity, affected
build range and fixed build at /security, the day it was fixed,
not after the fact.
STILL AHEAD
Most of the kernel is still C. The port is ordered deliberately: crypto hashes and
parsers first, then data structures, then drivers, with core kernel primitives last.
Ports of code already proven correctly bounded (inflate, ARP, DNS, URL parsing, ExFAT,
BMP) are defense-in-depth only and are not counted as advisories, since no reachable
defect was found in them.
Signed OTA updates: updates.maytera.net is a live update and
package server. It serves a signed manifest and a package index, so a MayteraOS install can
check for and fetch updates over the network with the manifest's signature verified rather
than trusting a bare download. The manifest's advertised build number moves as new images are
cut, so it is deliberately not quoted here to avoid going stale; see
Downloads for the live server and its current manifest.
// what it needs
System requirements.
MayteraOS runs comfortably on modest hardware, virtual or real, and
its driver stack has grown well past the original bring-up boxes.
| | Minimum | Recommended |
| CPU | 1 core, x86-64, UEFI firmware | 2+ cores to see SMP |
| RAM | 512 MB | 2 GB (comfortable headroom for the desktop, apps and browser) |
| Graphics | UEFI GOP framebuffer (any GPU it enumerates) | same |
| Storage | ≈1 GB, USB / IDE / SATA / virtio | AHCI/SATA or virtio-blk |
| Input | PS/2 or USB HID keyboard and mouse | same |
| Network | optional | e1000, virtio-net, or USB-Ethernet |
Driver coverage: UEFI GOP framebuffer · USB xHCI with HID (keyboard/mouse), Mass
Storage and hub support · USB-Ethernet (CDC-ECM/NCM, ASIX AX88179/772) ·
USB Audio Class DACs and Intel HD Audio · PS/2 keyboard and mouse ·
ATA/IDE and AHCI/SATA · e1000 and virtio-net · PCI enumeration ·
ACPI shutdown · multi-core SMP, 1–16 cores.
Real-hardware target: a 2013 iMac 14,4 boots to a working desktop
from a USB stick, keyboard and trackpad included.