Re: [RFC PATCH glibc 1/3] glibc: Perform rseq(2) registration at C startup and thread creation (v18)

From: Florian Weimer
Date: Thu Apr 30 2020 - 13:07:34 EST


* Mathieu Desnoyers:

> If we go this way, I'd also recommend to treat any situation where
> __rseq_abi.cpu_id is already initialized as a fatal error. Does the
> code below seem OK to you ?
>
> static inline void
> rseq_register_current_thread (void)
> {
> int ret;
>
> if (__rseq_abi.cpu_id != RSEQ_CPU_ID_UNINITIALIZED)
> __libc_fatal ("rseq already initialized for this thread\n");

Agreed; this should work because this code runs after relocation
processing.

> ret = INTERNAL_SYSCALL_CALL (rseq, &__rseq_abi, sizeof (struct rseq),
> 0, RSEQ_SIG);
> if (INTERNAL_SYSCALL_ERROR_P (ret))
> {
> if (INTERNAL_SYSCALL_ERRNO (ret) == EBUSY)
> __libc_fatal ("rseq already registered for this thread\n");
> __rseq_abi.cpu_id = RSEQ_CPU_ID_REGISTRATION_FAILED;
> }
> }

__libc_fatal does not attribute the error to glibc, so I suggest to
start the error messages with âglibc fatal error: â, so that people know
where to look.

Thanks,
Florian