[PATCH v2 2/3] nptl: Add libc allocated shadow stack for new threads

Yury Khrustalev yury.khrustalev@arm.com
Fri Sep 19 08:42:04 GMT 2025


* H.J.

I'm happy to answer questions, but I think this part of the thread just
repeats what has already been discussed. I suggest we instead focus on
answering the points raised by Catalin in

https://inbox.sourceware.org/libc-alpha/aMxA8y_OX2JGSHLs@arm.com/

On Thu, Sep 18, 2025 at 03:33:57PM -0700, H.J. Lu wrote:
> On Thu, Sep 18, 2025 at 3:23 PM Mark Brown <broonie@kernel.org> wrote:
> >
> > On Thu, Sep 18, 2025 at 02:56:23PM -0700, H.J. Lu wrote:
> > > On Thu, Sep 18, 2025 at 1:55 PM Mark Brown <broonie@kernel.org> wrote:
> >
> > ...
> >
> > > I have 2 questions:
> >
> > > 1. Can kernel improve shadow stack size calculation based on the stack
> > > size?
> >
> > It is currently based on RLIMIT_STACK.
> 
> Can you point me to the kernel code where shadow stack size is determined?

I believe this is the code:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/mm/gcs.c#n30

In Glibc, when we need to allocate shadow stack for makecontext(), we
use similar logic:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/aarch64/__alloc_gcs.c#l39

Hope this helps,
Yury



More information about the Libc-alpha mailing list