<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pavvan Kumaar on Medium]]></title>
        <description><![CDATA[Stories by Pavvan Kumaar on Medium]]></description>
        <link>https://medium.com/@inboxofpbk?source=rss-8e702d932148------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cHzJ_Y2oGdCuKrFhPw_P6g@2x.jpeg</url>
            <title>Stories by Pavvan Kumaar on Medium</title>
            <link>https://medium.com/@inboxofpbk?source=rss-8e702d932148------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:21:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@inboxofpbk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Linux 6.x Uses Rust to Prevent Memory Leaks?]]></title>
            <link>https://medium.com/@inboxofpbk/how-linux-6-x-uses-rust-to-prevent-memory-leaks-a86c2ba6ab0e?source=rss-8e702d932148------2</link>
            <guid isPermaLink="false">https://medium.com/p/a86c2ba6ab0e</guid>
            <category><![CDATA[linux-6]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[rust-in-linux]]></category>
            <dc:creator><![CDATA[Pavvan Kumaar]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 13:03:22 GMT</pubDate>
            <atom:updated>2026-02-01T13:03:22.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICzsPKPv6xcRjAYP3MCRLQ.jpeg" /></figure><p>There’s a saying in systems programming: “Memory is where bugs go to hide.” For decades, the Linux kernel — the invisible engine powering everything from your Android phone to Google’s data centers — has been locked in a quiet war against a class of bugs that should have been solved long ago. Memory leaks. Use-after-free errors. Buffer overflows. Null pointer dereferences. These aren’t exotic, hard-to-find flaws. They are the bread and butter of kernel vulnerabilities, and they have been devastating.</p><p>In late 2025, the Linux kernel community made a decision that stunned many in the tech world: Rust — a language barely a decade old — was declared no longer experimental. It was permanent. It was here to stay.</p><p>This is the story of how that happened, why it matters, and what it means for the billions of devices that run Linux every single day.</p><h3>The Problem: 30 Million Lines of C, and a Two-Thirds Vulnerability Rate</h3><p>To understand why Rust entered the Linux kernel, you first need to understand the scale of the problem it was brought in to solve.</p><p>The Linux kernel is written almost entirely in C — a language created in the 1970s that gives programmers extraordinary power over hardware. C lets you manipulate memory directly, allocate and free it manually, and squeeze every last cycle out of a processor. It is, in many ways, the perfect language for writing an operating system. But that raw power comes with a razor-thin margin for error.</p><p>In 2019, Alex Gaynor and Geoffrey Thomas presented a sobering statistic at the Linux Security Summit: roughly two-thirds of all Linux kernel vulnerabilities trace back to memory safety issues. Not logic errors. Not flawed algorithms. Memory. The kind of bugs where a developer forgets to free a buffer, accidentally uses memory after it’s been released, or writes past the end of an allocated block.</p><p>By 2025, the kernel had ballooned to over 34 million lines of C code. Every single line was a potential place where a memory mistake could be hiding. And in a kernel that runs on servers handling financial transactions, military systems, cloud infrastructure, and billions of smartphones, a single memory bug isn’t just an inconvenience — it’s a security vulnerability waiting to be exploited.</p><p>The kernel community needed a new tool. Something that could enforce memory safety at the language level, not just rely on developers remembering the rules.</p><h3>Enter Rust: A Language That Makes Memory Bugs Impossible (Almost)</h3><p>Rust, first released by Mozilla in 2010, was designed from the ground up to solve exactly this problem. Its core innovation is an ownership system — a set of compile-time rules that track who owns a piece of memory, who can read it, who can write to it, and when it must be freed. If you try to use memory after it’s been freed, the Rust compiler won’t let your code compile. If you try to have two mutable references to the same data at the same time, the compiler catches it before you ever run the program.</p><p>In safe Rust — the default mode — entire categories of bugs simply cannot exist:</p><p><strong>Use-after-free errors</strong> vanish because the ownership system ensures that once memory is freed, no reference to it remains in scope. The compiler tracks this statically, at build time.</p><p><strong>Memory leaks</strong> are dramatically reduced because Rust’s ownership rules ensure that every allocation has a clear, deterministic point where it will be freed. When an owned value goes out of scope, its memory is automatically reclaimed — no free() call needed, no chance of forgetting one.</p><p><strong>Buffer overflows</strong> are prevented because Rust’s standard collections perform bounds checking, and raw pointer arithmetic is confined to unsafe blocks that must be explicitly justified and documented.</p><p><strong>Data races</strong> are eliminated at compile time. Rust’s type system enforces that shared data is either read-only or exclusively owned by a single thread at any given moment.</p><p>This is not a runtime safety net. This is not a linter or a static analysis tool that sometimes catches bugs. This is the language itself refusing to compile code that violates these rules. It’s the closest thing programming has to a guarantee.</p><h3>The Integration: How Rust Entered the Kernel</h3><p>The idea of adding Rust to Linux wasn’t born in a vacuum. It emerged from years of frustration with the sheer impossibility of auditing 34 million lines of C for memory safety. Major tech companies — Amazon, Google, Microsoft — had already seen the writing on the wall. Seventy percent of the security vulnerabilities in their own C and C++ codebases stemmed from memory corruption. The U.S. Cybersecurity and Infrastructure Security Agency (CISA) had begun formally recommending memory-safe languages for critical systems.</p><p>In 2021, Miguel Ojeda, a kernel developer backed by the ISF (Internet Security Research Group), published the original RFC — a formal proposal — to add Rust to the Linux kernel. The plan was deliberately modest. Nobody proposed rewriting Linux in Rust. The kernel has 34 million lines of C, and it works. The goal was surgical: write new drivers, modules, and subsystems in Rust, where memory safety would provide the greatest security benefit without destabilizing the mature C code that underpins everything.</p><p>Linux 6.1, released in late 2022, merged the first Rust infrastructure into the kernel. It was a foundation — roughly 12,600 lines of code that established how Rust would interact with the C kernel: how memory would be allocated, how types would be mapped between the two languages, and how documentation and safety requirements would be enforced.</p><p>From there, the integration grew methodically across successive kernel releases.</p><h3>The Technical Architecture: How Rust and C Coexist</h3><p>One of the most impressive aspects of the Rust-for-Linux project is how it works alongside decades of existing C code. The two languages don’t simply share a binary. They communicate through a carefully designed layer of abstractions.</p><p><strong>Foreign Function Interfaces (FFI)</strong> allow Rust code to call C functions and vice versa. This is the bridge. When a Rust driver needs to interact with a kernel subsystem written in C, it does so through safe wrappers — Rust functions that expose the C API in a type-safe, memory-safe form.</p><p><strong>Safe wrappers over kernel C APIs</strong> are the heart of the integration. The Rust-for-Linux project doesn’t just dump raw C function pointers into Rust. Instead, developers build idiomatic Rust abstractions — structs, traits, and enums — that wrap the underlying C APIs. These wrappers enforce Rust’s ownership and borrowing rules around kernel resources, ensuring that even when the code underneath is C, the Rust layer prevents misuse.</p><p><strong>Kernel-specific crates</strong> (Rust’s equivalent of libraries) handle the unique constraints of kernel development. Unlike user-space programs, kernel code can’t use the standard memory allocator or rely on heap allocation in the usual way. The Rust-for-Linux project built custom crates that mimic C’s low-level memory control while still enforcing Rust’s safety guarantees.</p><p><strong>Documentation as enforcement</strong> is another distinguishing feature. The project requires that all public APIs, safety preconditions, unsafe blocks, and type invariants be documented. This isn&#39;t optional. It&#39;s baked into the tooling. Every time a developer writes an unsafe block — a region where Rust&#39;s safety rules are temporarily relaxed — they must explain why it&#39;s safe, what assumptions are being made, and what would break if those assumptions were violated.</p><h3>The Milestone Releases: A Timeline of Rust Growing Up in the Kernel</h3><p>Each Linux 6.x release brought Rust closer to becoming a first-class citizen:</p><p><strong>Linux 6.1 (2022)</strong> — The foundation. Rust infrastructure merged into the kernel for the first time. No drivers yet, but the plumbing was in place.</p><p><strong>Linux 6.8 (2024)</strong> — The first Rust drivers appeared in the kernel tree. Small, focused, but a proof of concept that Rust could actually work in this environment.</p><p><strong>Linux 6.12 (2024)</strong> — Android 16 devices shipped with a Rust-based ashmem (anonymous shared memory) allocator built on this kernel version. For the first time, Rust in the Linux kernel wasn’t theoretical — it was running on millions of real devices.</p><p><strong>Linux 6.13 (2025)</strong> — Greg Kroah-Hartman, one of the kernel’s most senior maintainers, called this release “the tipping point.” New in-place modules, bindings, and trace events made it genuinely practical to write Rust drivers across a wide range of subsystems. PCI and platform driver support was on the horizon, which would open up the vast majority of driver subsystems to Rust.</p><p><strong>December 2025 — The Summit</strong> — At the Linux Kernel Maintainers Summit in Tokyo, the assembled developers reached consensus: the experiment was over. Rust was no longer tagged as experimental in the kernel’s documentation. Miguel Ojeda posted the patch declaring, simply, “the experiment is done, i.e. Rust is here to stay.”</p><h3>What Rust Actually Prevents in the Kernel: A Concrete Look</h3><p>It’s easy to speak in abstractions about “memory safety.” Let’s make it concrete.</p><p>Consider a common pattern in kernel driver development: a driver allocates a block of memory to hold device state, registers an interrupt handler that uses that memory, and eventually frees it when the device is removed. In C, this is a juggling act. If the interrupt fires after the memory is freed — even by a few microseconds — you have a use-after-free bug. The handler reads or writes garbage. On a server, this might crash the system. In the hands of an attacker, it can become a privilege escalation exploit.</p><p>In Rust, this scenario is structurally prevented. The ownership system ensures that the interrupt handler holds a valid reference to the memory only as long as the memory exists. If you try to free the memory while the handler still holds a reference, the compiler refuses to compile your code. The bug doesn’t exist. It was never possible.</p><p>Or consider memory leaks. In C, every malloc() must be paired with a free(). In a complex driver with multiple error paths, it&#39;s trivially easy to miss one. The memory leaks silently. Over time, the system runs out of memory.</p><p>In Rust, memory is freed automatically when it goes out of scope — a concept called drop semantics. There is no free() to forget. When a value is no longer needed, Rust&#39;s runtime reclaims the memory deterministically. Leaks become structurally unlikely rather than a matter of developer discipline.</p><h3>The Honest Caveat: Rust Isn’t a Silver Bullet</h3><p>The story would be incomplete without acknowledging what Rust doesn’t solve.</p><p>Rust eliminates memory safety bugs in safe Rust. But kernel development sometimes requires unsafe operations — direct memory manipulation, hardware register access, interaction with legacy C code. These regions are marked with the unsafe keyword, and in these blocks, Rust&#39;s guarantees don&#39;t apply. The developer is promising the compiler: &quot;I&#39;ve verified this is safe. Trust me.&quot;</p><p>In December 2025, the very first CVE (Common Vulnerabilities and Exposures) was issued for Rust code in the Linux kernel — CVE-2025–68260. The bug was in an unsafe block. A safety comment incorrectly documented the invariants the code depended on. A node could be moved to a temporary list in a way the comment didn&#39;t account for, breaking the assumption that made the unsafe block valid.</p><p>It was, in a sense, exactly the kind of bug Rust was designed to surface. The unsafe block forced the developer to state their assumptions. When those assumptions turned out to be wrong, the bug was immediately locatable — developers knew exactly where to look. In equivalent C code, finding the root cause would have required extensive debugging.</p><p>On the same day that CVE was published, the C portion of the Linux kernel had 159 CVEs issued. One versus 159. Rust hasn’t eliminated bugs. But it has changed their distribution — concentrating them at explicit boundaries where they’re easier to find, reason about, and fix.</p><h3>The Bigger Picture: What This Means for the Future of Linux</h3><p>As of early 2026, the Linux kernel contains about 34 million lines of C and only around 25,000 lines of Rust. Rust is not replacing C. It won’t for decades — if ever. The kernel’s C codebase is too large, too battle-tested, and too deeply understood to be rewritten.</p><p>But the trajectory is clear. Greg Kroah-Hartman has said that Rust drivers are proving safer than their C equivalents. Major distributions — Fedora, Ubuntu, Debian — are moving toward enabling Rust in their default kernels. Companies like Google and Microsoft, already heavy Rust adopters in their own infrastructure, are expected to accelerate contributions. And the fact that millions of Android devices are already running Rust-based kernel components in production has settled the most fundamental question: Does it work?</p><p>Yes. It works.</p><p>The next phase will see Rust expand into “leaf” drivers — network interfaces, storage controllers, NVMe devices — where the Rust-for-Linux bindings already expose safe wrappers over kernel C APIs. File systems and networking stacks are longer-term targets. The open-source NVIDIA driver project, called Nova, is being written in Rust from the ground up.</p><h3>Why This Matters Beyond Linux</h3><p>The Linux kernel’s adoption of Rust sends a signal that ripples far beyond the kernel itself. Linux is the operating system of the internet. It runs the majority of the world’s servers, powers Android, underpins cloud infrastructure at Google, Amazon, and Microsoft, and is embedded in everything from cars to industrial control systems.</p><p>When the Linux kernel says “we’re choosing memory safety,” every ecosystem that depends on Linux moves with it. The U.S. government has already begun formally recommending memory-safe languages for critical software. The Linux kernel’s decision gives that recommendation teeth.</p><p>For the next generation of systems programmers, the path forward is now unmistakable: deep knowledge of C, fluency in Rust’s safety guarantees, and the ability to work at the seam between the two. This isn’t a niche skill. It’s becoming foundational.</p><h3>The Bottom Line</h3><p>Memory bugs have been the single largest source of Linux kernel vulnerabilities for decades. The kernel community spent years debating whether a new language could help. They built the infrastructure carefully. They proved it worked on millions of real devices. They watched the first CVE — and saw that even when Rust code did have a bug, it was easier to find and fix than anything C could offer.</p><p>And in December 2025, in a summit room in Tokyo, the verdict came in: the experiment is done.</p><p>Rust is here to stay.</p><p>The Linux kernel’s bet on Rust isn’t about replacing a 50-year-old language. It’s about adding a layer of structural safety to the most critical piece of software infrastructure on Earth — and proving, one driver at a time, that it works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a86c2ba6ab0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>