[PATCH v7 21/23] aarch64: Add GCS user-space allocation logic
Yury Khrustalev
yury.khrustalev@arm.com
Wed Jan 8 14:03:13 GMT 2025
On Tue, Jan 07, 2025 at 02:11:13PM -0300, Adhemerval Zanella Netto wrote:
>
> > +#include <sysdep.h>
> > +#include <unistd.h>
> > +#include <sys/mman.h>
> > +
> > +#ifndef __NR_map_shadow_stack
> > +# define __NR_map_shadow_stack 453
> > +#endif
>
> This is already define at sysdeps/unix/sysv/linux/aarch64/arch-syscall.h
Fair point. I will remove this bit.
>
> > +#ifndef SHADOW_STACK_SET_TOKEN
> > +# define SHADOW_STACK_SET_TOKEN (1UL << 0)
> > +# define SHADOW_STACK_SET_MARKER (1UL << 1)
>
> x86 defines SHADOW_STACK_SET_TOKEN on its bits/mman.h, maybe do the same.
The idea here is to define these constants locally rather than in
any of the public headers. Once Linux kernel is released there will
be another patch to declare some of these constants in the public
headers, but this will likely be after the upcoming Glibc release.
I will leave this unchanged.
> > + unsigned long flags = SHADOW_STACK_SET_MARKER | SHADOW_STACK_SET_TOKEN;
> > + void *base = map_shadow_stack (NULL, size, flags);
> > + if (base == (void *) -1)
>
> I think map_shadow_stack is essentially a mmap wrapper, so maybe use
> MMAP_FAILED here.
I will use MAP_FAILED here, it makes sense.
> > + if (((uint64_t)gcsp & 0xfffffffffffff000) + 1 != *gcsp)
>
> This is essentially aliasing violations, but since aarch64 allows unaligned
> access I think this is fine.
OK.
Thanks,
Yury
More information about the Libc-alpha
mailing list