[PATCH 3/3] arm64: gcs: Do not map the guarded control stack as THP

Mark Brown broonie at kernel.org
Fri Feb 20 06:34:08 PST 2026


On Fri, Feb 20, 2026 at 02:05:31PM +0000, Catalin Marinas wrote:
> The default GCS size allocated on first prctl() for the main thread or
> subsequently on clone() is either half of RLIMIT_STACK or half of a
> thread's stack size. Both of these are likely to be suitable for a THP
> allocation and the kernel is more aggressive in creating such mappings.
> However, it does not make much sense to use a huge page as it didn't
> make sense for the normal stacks either. See commit c4608d1bf7c6 ("mm:
> mmap: map MAP_STACK to VM_NOHUGEPAGE").

> Force VM_NOHUGEPAGE when allocating/mapping the GCS. As per commit
> 7190b3c8bd2b ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE only if THP is
> enabled"), only pass this flag if TRANSPARENT_HUGEPAGE is enabled as not
> to confuse CRIU tools.

I agree that this is sensible however I'm fairly sure this will also
apply to the other shadow stack implementations so I think it would be
better to either do it cross architecture (ideally factoring this out of
the arch code entirely) or put a note in the commit log that it's likely 
going to apply to other architectures.  There's a bunch of stuff that we
should start factoring out into common code now that RISC-V landed and
it looks like the clone3() stuff ran it's course, we should make it as
easy as possible to understand why any divergences we're adding.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260220/032c45a1/attachment.sig>


More information about the linux-arm-kernel mailing list