[PATCH 3/3] arm64: gcs: Do not map the guarded control stack as THP
David Hildenbrand (Arm)
david at kernel.org
Fri Feb 20 07:33:12 PST 2026
On 2/20/26 15:05, 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").
Agreed. At least when it comes to PMD THPs.
>
> 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 was briefly concerned that we wouldn't even have PMD support to handle
shadow stack, but turns out we do have pmd_mkwrite() that consumes a VMA
to handle it.
>
> While at it, use the PROT_WRITE prot argument rather than the VM_WRITE
> flag when calling do_mmap().
That LGTM as well.
Agreed with trying to let common code deal with that.
I'll note that madvise() would be able to turn THPs back on; I assume
that's okay.
--
Cheers,
David
More information about the linux-arm-kernel
mailing list