Kernel Memory Failure Diagnosis Subproject
Status: Planned subproject. The investigation design and acceptance gates are defined; no runnable memory-failure lab or result is claimed yet.
Outcome
Build a reviewable debugging portfolio that proves the ability to distinguish a memory leak from look-alike symptoms, capture an invalid memory access close to the offending instruction, repair the ownership error, and verify balanced cleanup under the identical workload.
This is a supporting debugging subproject, not a fourth integrated system project. Each delivered experiment must name the CPU/SoC diagnostics, MMIO driver, or DVFS/thermal project blocker that it resolves.
Why this needs a subproject
The existing Memory Failures guide is a detector-selection map. A demonstrable debugging skill needs more than a tool summary: a controlled defect, raw evidence, source localization, a minimal fix, an identical retest, and a cleanup result.
The research material suggests two different investigation paths:
- Leak path: prove a repeated same-phase growth trend, exclude page cache, fragmentation,
vmalloc, and intentional reserved memory, isolate the lifecycle phase, then locate the unmatched allocation or retained owner (Linux Kernel memory leak). - Corruption path: use targeted SLUB checks to establish object damage, then use KASAN to capture the invalid access and its allocation/free/access stacks (Linux Kernel Memory Corruption Debug guide).
Do not use MemFree decline as a leak result, and do not present a later SLUB validation site as the instruction that caused the corruption.
Project slices
Each slice is one focused practice unit of roughly one hour after the shared QEMU environment and debug kernel are available.
| Slice | Concrete question | Primary evidence | Platform / safety |
|---|---|---|---|
| 1. Classify growth | Is repeated memory loss a leak, reclaimable growth, fragmentation, or expected retention? | Same-phase /proc/meminfo, /proc/slabinfo, /proc/buddyinfo, and workload markers across at least 20 cycles | QEMU first; Orin S0 for observation |
| 2. Find an unreachable leak | Which allocation remains unreachable after cleanup? | KMEMLEAK report, allocation stack, module counters, and a post-fix empty scan | QEMU preferred, S1 |
| 3. Catch an out-of-bounds write | Which instruction crosses a slab-object boundary? | KASAN access report plus allocation stack; targeted SLUB red-zone evidence is supporting evidence | QEMU only, S2 |
| 4. Reconstruct a use-after-free | Which asynchronous path accesses an object after teardown? | KASAN access/free/allocation stacks and a lifecycle timeline covering work, timer, IRQ, or RCU ownership | QEMU only, S2 |
| 5. Prove error-unwind balance | Does every allocation unwind when an injected allocation fails? | Bounded fault injection, stable error result, balanced counters, detector silence, and successful unload | QEMU preferred, S1 |
KFENCE is a later extension for low-overhead sampled detection when a defect requires long runtime. It does not replace deterministic KASAN coverage in the initial portfolio.
Common experiment contract
Every slice must preserve the same evidence chain:
symptom → competing hypotheses → detector choice → raw report → source path → ownership error → minimal fix → identical retest → negative verification
Before triggering a defect, record:
- architecture, kernel release, kernel configuration, command line, module hash, compiler, QEMU command, and rootfs identity;
- the required detector interface and effective configuration, rather than assuming a configured option is active;
- a quiet memory and module baseline;
- the exact trigger token, repetition count, runtime bound, and cleanup path.
The raw evidence bundle remains unchanged. A derived report may annotate the first invalid access, allocation site, free site, lifecycle transition, and relevant source line, but must link back to the raw files.
Detector decision ladder
- Compare repeated observations at the same lifecycle phase. If only
MemFreechanges, the result is inconclusive. - Separate
SReclaimable,SUnreclaim, page-allocation order availability,VmallocUsed, memcg state, and intentional reserved memory. - For a growing slab class, compare full object counts and ownership counters; partial-slab data alone cannot exclude growth in full slabs.
- Use KMEMLEAK for unreachable allocations. Use counters, tracepoints, or an ownership walk when an obsolete object remains reachable from a list or global pointer.
- Use targeted
slub_debugfor object-state and red-zone evidence. Escalate to KASAN when the goal is the offending load/store and its call stack. - Retest the fixed build with the identical trigger and cycle count. Require both the positive fixed result and absence of the original detector pattern.
Planned lab delivery order
No lesson directory is created until its demo and fixed module, bounded scripts, stable expected patterns, fixture checks, and cleanup behavior all work.
- Deliver the unreachable-leak lesson to establish evidence packaging and repeated cleanup accounting without an expected crash.
- Deliver the out-of-bounds lesson with KASAN and targeted SLUB evidence.
- Deliver the asynchronous use-after-free lesson only after the simpler KASAN report path is automated.
- Add allocation-failure unwind as the quality-of-code slice.
- Add the observation-only growth classifier after fixtures can distinguish leak, reclaimable growth, and fragmentation without destructive controls.
Module-based lessons follow the repository layout defined in the labs contract and reuse the QEMU auxiliary environment. Loading a defective module must be safe; the defect activates only through an explicit privileged trigger.
Acceptance gates
The subproject is portfolio-ready only when all of the following are linked from this page or a completion report:
- at least one leak diagnosis and one corruption diagnosis are runnable from a fresh QEMU environment;
- every lesson records config checks, exact commands, raw failure evidence, source localization, the minimal fix, and cleanup;
- leak evidence includes at least 20 same-phase cycles and reports the slope or balanced object count instead of relying on a single before/after sample;
- corruption evidence identifies the invalid access, not merely the later allocator check that noticed damaged state;
- the identical post-fix workload produces the stable success signature and no original KMEMLEAK, KASAN, SLUB, oops, or panic signature;
- a negative or unsupported path fails closed, including missing detector configuration and accidental execution on Jetson for an S2 trigger;
- retained evidence is labeled as QEMU, generic ARM64, Orin, fixture, or replay and is never promoted across those boundaries.
Five-minute demonstration
- Show the recorded environment and the healthy baseline.
- Run or replay one bounded trigger and identify the first trustworthy failure signature.
- Explain why the selected detector fits this failure and why one alternative would not answer the same question.
- Move from the report to the faulty ownership transition and minimal patch.
- Run the same verification path, show detector silence plus balanced cleanup, and state the platform and detector limitations.
Sources
The design was synthesized from these workspace pages on 2026-08-30. They are research inputs and may require access to the source Notion workspace:
- Linux Kernel memory leak
- Linux memory leak debug guide
- Linux Kernel Memory Corruption Debug guide
- slab memory corruption
- KASAN debugging: an skb use-after-free example
Use the upstream kernel documentation as the normative reference for commands, configuration, and detector behavior: