Re: [PATCH v2 00/13] Dynamic Kernel Stacks

From: Matthew Wilcox

Date: Mon Jun 29 2026 - 16:19:47 EST


On Mon, Jun 29, 2026 at 09:02:08AM -0700, Dave Hansen wrote:
> It could be done with really little overhead if the vmalloc()'d stacks
> set Accessed=0 on their PTEs and then checked them near vfree(). The
> PTEs are already getting touched there, so the cachelines should be hot
> anyway.
>
> The granularity would only be 4k, but it would be so cheap that we could
> turn it on universally. It would also be 100% deterministic.
>
> There are, of course, more games that could be played with stack depth
> checks on normal interrupts or NMIs. But those would be less deterministic.

I mean, if we just memset64() the whole stack to 0x535441434b544f50 and
then searched the stack for the lowest word that wasn't that value at
process exit, we'd get a much more granular idea with vanishingly few
false positives.