Re: [RFC PATCH glibc 4/8] glibc: Perform rseq(2) registration at C startup and thread creation (v15)
From: Mathieu Desnoyers
Date: Fri Mar 20 2020 - 10:47:16 EST
----- On Mar 20, 2020, at 9:44 AM, Mathieu Desnoyers mathieu.desnoyers@xxxxxxxxxxxx wrote:
[...]
> Actually, here is an important clarification: the Linux kernel validates
> the struct rseq alignment on registration:
>
> if (!IS_ALIGNED((unsigned long)rseq, __alignof__(*rseq)) ||
> rseq_len != sizeof(*rseq))
> return -EINVAL;
>
> So removing the aligned attribute from struct rseq is actually an
> ABI-breaking change, because it would be incompatible with older
> kernels which perform the IS_ALIGNED check expecting at least at
> 32 bytes alignment.
So I plan to add the following to glibc's sys/rseq.h:
#include <sys/cdefs.h>
[...]
/* Ensure the compiler supports __attribute__ ((aligned)). */
_Static_assert (__alignof__ (struct rseq_cs) >= 4 * sizeof(uint64_t),
"alignment");
_Static_assert (__alignof__ (struct rseq) >= 4 * sizeof(uint64_t),
"alignment");
/* Allocations of struct rseq and struct rseq_cs on the heap need to
be aligned on 32 bytes. Therefore, use of malloc is discouraged
because it does not guarantee alignment. posix_memalign should be
used instead. */
Does it help mitigating your concerns ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com