lkml.org 
[lkml]   [2020]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH glibc 5/9] glibc: Perform rseq(2) registration at C startup and thread creation (v17)
----- On Apr 27, 2020, at 1:26 PM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:
[...]
>>> We don't mind that user-space uses that pointer, but we never want the kernel
>>> to touch that pointer rather than the 32/64-bit-aware fields. One possibility
>>> would be to do:
>>>
>>> union
>>> {
>>> uint64_t ptr64;
>>> #ifdef __LP64__
>>> uint64_t ptr;
>>> #else
>>> struct
>>> {
>>> #if (defined (__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined
>>> (__BIG_ENDIAN)
>>> uint32_t padding; /* Initialized to zero. */
>>> uint32_t ptr32;
>>> #else /* LITTLE */
>>> uint32_t ptr32;
>>> uint32_t padding; /* Initialized to zero. */
>>> #endif /* ENDIAN */
>>> } ptr;
>>> #endif
>>>
>>> #ifndef __KERNEL__
>>> const struct rseq_cs *uptr;
>>> #endif
>>> } rseq_cs;
>>>
>>> in the union, so only user-space can see that field. Thoughts ?
>>
>> I think this depends on where the x32 question lands.
>
> x32 should not be an issue as explained above, so I'm very open to
> add this "uptr" for user-space only.

Actually, the snippet above is broken on 32-bit. It needs to be:

union
{
uint64_t ptr64;
#ifdef __LP64__
uint64_t ptr;
# ifndef __KERNEL__
const struct rseq_cs *uptr;
# endif
#else
struct
{
#if (defined (__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined (__BIG_ENDIAN)
uint32_t padding; /* Initialized to zero. */
uint32_t ptr32;
#else /* LITTLE */
uint32_t ptr32;
uint32_t padding; /* Initialized to zero. */
#endif /* ENDIAN */
} ptr;
# ifndef __KERNEL__
struct
{
# if (defined (__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined (__BIG_ENDIAN)
uint32_t padding; /* Initialized to zero. */
const struct rseq_cs *uptr32;
# else /* LITTLE */
const struct rseq_cs *uptr32;
uint32_t padding; /* Initialized to zero. */
# endif /* ENDIAN */
} uptr;
# endif
#endif
} rseq_cs;

I'll leave this out of the patchset for now as we'd need more feedback on its
usefulness.

Thanks,

Mathieu

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

\
 
 \ /
  Last update: 2020-04-27 22:28    [W:0.121 / U:2.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site