systemd Added Rust by Refusing Almost Everything Rust Offers
The headline was "systemd adopts Rust." The commit, which I read in the tree, rejects most of how Rust is normally used: no standard library, no cargo, no crates, no rewrites, no Rust in shared libraries. The reasoning is a quiet argument about where systemd's real attack surface is.
When a project the size of systemd announces it is adopting Rust, the story writes itself, and most outlets let it: the memory-safety era comes for the init system, C's last fortress falls, and so on. That framing isn't wrong so much as it's pointed in the wrong direction. I cloned the tree and read what actually landed. The interesting thing about systemd's Rust adoption isn't that it happened — it's how much of Rust the maintainers declined to let in the door.
The policy was merged on 3 November 2026 and is written down, in plain terms, in docs/CODING_STYLE.md. There are already 31 Rust source files and about 6,700 lines of Rust in the tree. And nearly every decision in that policy is a "no" — to the standard library, to cargo, to third-party crates, to rewriting existing C, to building a single shared library out of Rust. What is left after all those noes is a surprisingly interesting idea about what a memory-safe language is actually for in a codebase like this one.
The Policy, in systemd's Own Words
This is not my characterization. It is the top of the Rust section of the coding style document, quoted exactly:
Rust is only used for new leaf components, i.e. programs that nothing else in the tree depends on. Existing C code is not ported to Rust for now, andlibsystemd-shared,libsystemd, the NSS and PAM modules and everything else other components depend on stay C.
Read that twice, because it inverts the usual pitch. The normal argument for Rust is "rewrite the dangerous C in a safe language." systemd's position is the opposite: the shared libraries, the PAM and NSS modules, PID 1 itself — the code with the most reach and the most consequence — all stay in C, and Rust is permitted only in leaf binaries, standalone programs that nothing else links against. The blast radius of a Rust component is deliberately kept to one executable.
The document keeps saying no:
Rust code is built with meson only. cargo is not used.
Only thecoreandlibccrates are permitted.std,allocand any other crate are not, hence all Rust code is#![no_std]. Everything else comes from the in-treesystemd_sharedcrate.
No shared library is built from Rust code.
No cargo, which means no crates.io, which means the supply-chain surface that comes free with most Rust projects is simply absent. No std and no alloc, which is the same constraint the Linux kernel's Rust code works under. And no Rust shared library, which is the load-bearing reason for the whole leaf-binary rule. Rust has no stable ABI and no first-class shared-library story, so Rust code placed in libsystemd-shared would have to be statically duplicated into every one of the project's 180-plus binaries. The maintainers looked at that cost and drew the line rather than paying it.
What "no_std, no alloc" Actually Buys
The part I found most telling is the memory handling, because it is where the team's reasoning becomes visible in code rather than prose. Here is the header of src/rust/systemd-shared/alloc.rs, verbatim from the tree:
//! Memory allocation that never aborts.
//!
//! The `alloc` crate is not used: its collections abort the program when an allocation fails. [`Box`] and
//! [`Vec`] have no such paths. Everything that allocates returns a `Result` with [`AllocError`], which converts
//! into `-ENOMEM`, so a failed allocation is handled like it is in C.
This is a real objection to stock Rust, stated without drama. Rust's standard collections treat allocation failure as unrecoverable: if Vec::push cannot get memory, the program aborts. For an application that is a defensible default. For PID 1 — the process that, if it dies, takes the whole system down with it — "abort on out-of-memory" isn't acceptable. It's a regression from the C code, which treats every allocation as fallible and handles -ENOMEM as an ordinary error. So systemd refuses alloc entirely and ships its own Box and Vec whose allocating operations return a Result. The Rust and C sides share one heap through malloc(), and if the stock alloc crate ever sneaks into a build, the link deliberately fails.
There is a second detail in that same file that is pure security engineering, and it is the kind of thing only a type system gives you cleanly:
Erasingerases memory before it is freed or moved, soVec<u8, Erasing>makes a buffer for secrets a type rather than a convention.
In C, zeroing a buffer that held a key or a password before freeing it is a discipline — a memzero() call you have to remember, that the compiler is free to optimize away, and that a reviewer has to notice is missing. By making the erasing behavior part of the allocator, and therefore part of the type, systemd turns "this buffer holds a secret, scrub it" from a thing you remember into a thing the compiler enforces. Vec<u8, Erasing> cannot forget to wipe itself. That is a real security property obtained from Rust's type system, and notably it has nothing to do with memory safety in the use-after-free sense — it's about data lifetime, not pointer validity.
We recommend reading What Is Rust? to continue reading our selection of content. The choices systemd made only make sense against what Rust normally gives you by default, and this is the short tour of those defaults.
What Is Rust? A plain-language introduction to the language, its ownership model, and what "safe by default" actually means. SudoSecurity
The Quiet Argument: Memory Safety Is Not the Point
The reasoning that ties the whole policy together is a claim the maintainers make in the surrounding discussion, and the code layout reflects it: rewriting systemd's C into Rust would not fix systemd's actual security problems. Its dominant attack surface isn't memory safety. It is filesystem path handling: resolving, opening, and operating on paths safely across symlinks, mount points, and untrusted directory trees, without being tricked into touching the wrong file.
You can see this conviction in which C helper got wrapped first. Among the Rust modules in the systemd_shared crate is chase.rs, the Rust interface to systemd's chase() family — the functions that perform careful, file-descriptor-based path resolution. The team's point is that a mechanical port of a path-handling bug from C to Rust produces a memory-safe program that still resolves the path wrong. Rust's borrow checker does not know that following this symlink crosses a security boundary. If you reproduce the logic, you reproduce the vulnerability, now with a cleaner backtrace.
This is a more sophisticated position than either side of the usual Rust argument tends to take. The maximalist says "memory-safety bugs are 70% of CVEs, rewrite everything." The reactionary says "rewrites introduce bugs, leave it alone." systemd's maintainers are saying something narrower and more useful: know what class of bug dominates your specific codebase, and adopt the tool where it helps that class, not where a slogan says it should. For a program whose crown-jewel bugs are path-resolution races and symlink attacks, memory safety is a real but secondary benefit, and it is not worth destabilizing 180 binaries and a shared library to chase it everywhere at once.
How Careful the Plumbing Is
The conservatism runs all the way down into the build. A few details from the tree that show the posture:
- Minimum Rust version
1.85, edition 2021, pinned inmeson.build. Not bleeding-edge; a known, widely-packaged toolchain. - Rust is optional. Rust does not target every architecture systemd supports, so a build with Rust disabled is fully functional and fully supported. Rust cannot become load-bearing for a platform that cannot compile it.
- Compile-time layout checks. An
assert_layout!macro asserts at compile time that every Rust struct mirroring a C struct has identical size, alignment, and field offsets. The FFI boundary is checked by the compiler, not by hope. - Rust programs must be indistinguishable from C ones. Per the style guide, a Rust binary declares its command line with the same verb and option tables, in the same linker sections, parsed by the same C code, and
test/test-cli-parity.shenforces that a Rust program "must not look or behave any different from one written in C." - Panics abort like a failed assert. Built with
-C panic=abort, a Rust panic is logged atLOG_CRITwith its location, exactly as a failedassert()in C would be — no unwinding, no divergence from the C failure model.
And the tell that this is infrastructure rather than a product launch: the only Rust program carrying a define_main! entry point in the tree right now is a test harness, test-cli-rust.rs. The 6,700 lines that landed are almost entirely the scaffolding — the systemd_shared crate, the allocator, the panic handler, the FFI bindings, the layout asserts — not a shipping Rust daemon. systemd did not rewrite anything in Rust in November 2026. It built the on-ramp, carefully, and wrote down the rules for who may use it.
We recommend reading Rust's Memory Safety, and What It Does and Doesn't Guarantee to continue reading our selection of content. systemd's whole argument depends on the distinction between the bugs Rust's safety model catches and the ones it doesn't, which is exactly what that piece lays out.
Rust's Memory Safety, and What It Does and Doesn't Guarantee What the borrow checker actually prevents, and the classes of bug that live outside its reach. SudoSecurity
What This Doesn't Cover
Everything above is read from the systemd tree: the policy from docs/CODING_STYLE.md, the memory model from src/rust/systemd-shared/alloc.rs and panic.rs, the module list including chase.rs, the rust_msrv = '1.85' and edition from meson.build, and the file and line counts from the checkout. Where I quote, it is the file's own words. I did not read every one of the 31 Rust files line by line, and I have summarized the maintainers' reasoning about path handling and the shared-library ABI from the surrounding discussion and the code's shape rather than from a single quotable manifesto — systemd's rationale is spread across the commit, the style guide, and mailing-list discussion rather than sitting in one document.
I also have not benchmarked anything, compared this approach to the kernel's Rust integration in depth, or tried to predict which leaf binary becomes the first real Rust program in systemd. Those are all worth doing and none of them are claims I am making here.
Out of scope: the decades-long argument about whether systemd should be as large as it is, which is orthogonal to the language question; the general Rust-in-the-kernel debate, which has its own dynamics; and any prediction about whether this cautious on-ramp eventually widens. The policy says "for now" in several places, and "for now" is doing real work in those sentences.
The Actual Point
The reason this is worth more than a one-line "systemd now supports Rust" is that it is a model for how a serious, security-critical project adopts a new language without being captured by the marketing around it. systemd's maintainers did not treat Rust as a safety guarantee to be sprinkled over the codebase. They treated it as a tool with specific strengths and specific costs, and they engineered the integration so that the strengths are available where they help and the costs are quarantined where they would hurt.
The strengths they wanted turned out to be narrower and more interesting than "memory safety": fallible allocation handled by the type system, secret-zeroing made structural instead of manual, FFI layout checked at compile time, and a general raising of the floor for new standalone tools. The costs they refused to pay were the standard library's abort-on-OOM, cargo's supply chain, static duplication across 180 binaries, and the destabilization of a mechanical rewrite that would have produced memory-safe versions of the path-handling bugs that are the actual threat.
That last point is the one to carry out of here, and it generalizes past systemd. "Rewrite it in Rust" is a slogan; "know which class of bug dominates your codebase and adopt the tool precisely where it moves that number" is an engineering decision. systemd made the second one, in public, with the receipts checked into docs/CODING_STYLE.md. You can disagree with where they drew the line. You can't say they drew it carelessly.
The policy text, the allocator and panic documentation, the module list, the minimum Rust version, and the file and line counts are all quoted or counted from the systemd source tree as checked out on 10 November 2026. No benchmarks were run and the maintainers' path-handling rationale is summarized from discussion and code structure, not from a single quoted statement.
$ tail -f /forums
Discussion
Comments live on the community forums — sign in there to reply.