Re: [PATCH 18/35] mm: Add guard pages around a shadow stack.

From: Edgecombe, Rick P
Date: Thu Feb 10 2022 - 18:42:49 EST


On Thu, 2022-02-10 at 22:38 +0000, David Laight wrote:
> Do you need a real guard page?
> Or is it just enough to ensure that the adjacent page isn't another
> shadow stack page?
>
> Any other page will cause a fault because the PTE isn't
> readonly+dirty.
>
> I'm not sure how common single page allocates are in Linux.

I think it came from this discussion:

https://lore.kernel.org/lkml/CAG48ez1ytOfQyNZMNPFp7XqKcpd7_aRai9G5s7rx0V=8ZG+r2A@xxxxxxxxxxxxxx/#t

> But adjacent shadow stacks may be rare anyway.
> So a check against both adjacent PTE entries would suffice.
> Or maybe always allocate an even (or odd) numbered page.

It just needs to not be adjacent to shadow stack memory to do the job.
Would that be small to implement? It might be a tradeoff of code
complexity.