Skip to content

kernel-kasan: a debug kernel that reports a bad write where it happens - #217

Merged
closer-claudio merged 1 commit into
mainfrom
claudio/20261115-kernel-kasan
Nov 15, 2026
Merged

closer-claudio merged 1 commit into
mainfrom
claudio/20261115-kernel-kasan

Conversation

@closer-claudio

Copy link
Copy Markdown
Contributor

🎯 Why

Slab debugging on the debug kernel found whole slab pages zeroed while in use on 2026-11-15 (#214 (comment)). It checks an object when it is next allocated or freed, so it names the damaged page minutes late and cannot name the writer. Finding the writer needs a kernel that checks the access itself.

🛠️ What

  • kernel/config/kernel-kasan-fragment: KASAN (generic, inline, vmalloc covered), DEBUG_VM, DEBUG_VFS, DEBUG_LIST, each with what it reports and what it costs.
  • just kernel-kasan: merges the ship fragment, the debug fragment, then this one with kernel/merge-fragments.sh, and builds .build/kernel-arm64.kasan (localversion ossein-kasan). It mirrors kernel-debug, including skipping kernel-verify-config.

Nothing shipped changes.

🧪 How

  • V: just lint exit 0, just test exit 0, just do lint commits PASS, on the committed tree.
  • V: the recipe's two merge steps, run by hand, give a fragment in which no symbol is decided twice and the seven new lines are present.
  • V: read in the 7.3.4 source: KASAN_INLINE is the default instrumentation; arm64 selects KASAN_VMALLOC under KASAN and VMAP_STACK depends on it; DEBUG_VM, DEBUG_VFS and DEBUG_LIST depend only on DEBUG_KERNEL; KASAN depends on SYSFS and !SLUB_TINY, which the ship fragment satisfies.
  • U: the build. The agent sandbox cannot run just kernel*. Whether every line survives olddefconfig (build.sh checks each), whether the image links under ThinLTO, and whether the Virtualization framework boots it, are for the first just kernel-kasan to say.

Slab debugging found whole slab pages zeroed while in use on
2026-11-15, minutes after the fact and with nothing to name the writer.
It checks an object when it is next allocated or freed; it cannot see
the access.

`just kernel-kasan` builds the debug kernel with, on top:

- KASAN, generic and inline, with vmalloc covered: a use after free, an
  out-of-bounds access or a write into a red zone is reported at the
  access, with the stacks that allocated, freed and (for call_rcu)
  queued the free.
- DEBUG_VM: the page descriptor is checked on every allocation and
  free.
- DEBUG_VFS: the inode reference-count assertions.
- DEBUG_LIST.

The fragment stacks on the debug one through merge-fragments.sh, and
the result goes to .build/kernel-arm64.kasan. Nothing shipped changes.

Not built: this sandbox cannot run the kernel build. The merge of the
three fragments was run and yields no symbol decided twice; whether
every line survives olddefconfig is for the first build to say.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: closer-claudio <claudio@farcloser.world>
@closer-claudio closer-claudio added the internal Changes nothing for a consumer; left out of the release notes label Nov 15, 2026
@closer-claudio

Copy link
Copy Markdown
Contributor Author

Reviewed at f68f0de

@closer-claudio
closer-claudio merged commit a2578ae into main Nov 15, 2026
14 checks passed
@closer-claudio
closer-claudio deleted the claudio/20261115-kernel-kasan branch November 15, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Changes nothing for a consumer; left out of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants