kernel-resource-lifecycle
Skill2 starsChanged 2 months agoApache-2.0View on GitHub
Use when a Linux kernel PR diff allocates, frees, or hands off objects, tracks lifetimes (Sashiko stage 4): memory leaks on error paths, use-after-free, refcount imbalance, and asymmetric async teardown (missing cancel_work_sync and friends) in the CHANGED code only. Part of the linux-kernel-review suite.
In this repository18 other files it gives its agents.
- accessibility-reviewSkill
- apex-reviewSkill
- appsec-compliance-reviewSkill
- clang-formatSkill
- commit-message-reviewSkill
- design-doc-conformanceSkill
- guideline-distillerSkill
- kernel-change-intentSkill
- kernel-driver-hardwareSkill
- kernel-execution-flowSkill
- kernel-locking-concurrencySkill
- kernel-review-disciplineSkill
- kernel-security-auditSkill
- kernel-subsystem-guidesSkill
- linux-kernel-reviewSkill
- qodo-calibrate-rulesSkill
- terraform-reviewSkill
- toml-portal-migration-auditSkill
The file
Files
kernel-resource-lifecycle
Lens for memory and object lifetime analysis (Sashiko stage 4). Tracks every allocated struct, reference count, and asynchronous handoff in the diff from alloc to free.
How to apply
- Track the lifetime of every allocated object and file descriptor: alloc -> init -> use -> cleanup -> free. Flag any unbalanced pair.
- Pay special attention to error paths, that is where leaks live.
- For every object handed to a background task or registered with a core subsystem, demand teardown symmetry proof.
Rule index
- L1. Memory leaks, especially on error/unwind paths.
- L2. Use-after-free and double free. Verify refcount logic (kref_get/kref_put); prove objects are not touched after the count can hit zero.
- L3. Uninitialized use. list_add and similar APIs must receive fully initialized objects; flag partially-initialized publication.
- L4. Async handoff / teardown symmetry (the highest-value rule). If an object is handed to a timer, workqueue, or notifier, or registered to a subsystem, you must find the explicit cancel_work_sync()/ del_timer_sync()/unregister call BEFORE the memory is freed or the queue destroyed. Absence is a finding; do not assume "it probably can't race."
- L5. Unbalanced acquisition: get without put, enable without disable, register without unregister, across all paths including errors.
Mapping a finding to the contract
- action_level: action_required for UAF, double free, or a leak on a repeating path; remediation_recommended for cold-path leaks.
- category: Correctness (Security when the UAF is reachable from untrusted input).
- evidence: the allocation site, the handoff or failure path, and the missing release/cancel, all by function and line.
What NOT to flag
- Leaks in kselftests or short-lived userspace test programs unless they can crash the system.
- Teardown-path release calls whose returns are ignored (teardown must proceed regardless).
- Cleanup-attribute code (__free, guard()) that is actually balanced , check kernel-subsystem-guides cleanup.md triggers before flagging.
Sourcing
Stage text adapted from Sashiko (Apache-2.0).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

