fix: always set the rseq offset and flags
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 22 Feb 2024 23:16:13 +0000 (18:16 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Feb 2024 20:15:22 +0000 (15:15 -0500)
Even when the rseq syscall is unavailable, set the __rseq_offset to the
correct value as application or library code might try to check the
registration status by reading the cpu_id.

Change-Id: I8f579af236e17a45dfb71c3310bc41a9c17652fd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/rseq.c

index fec7e565a50b2daf2c86012460f3540c6bdadf63..af5c5de310b3b3f83a8b837c68ba30456ae06c2a 100644 (file)
@@ -223,6 +223,12 @@ void rseq_init(void)
        /* librseq owns the registration */
        rseq_ownership = 1;
 
+       /* Calculate the offset of the rseq area from the thread pointer. */
+       rseq_offset = (uintptr_t)&__rseq_abi - (uintptr_t)rseq_thread_pointer();
+
+       /* rseq flags are deprecated, always set to 0. */
+       rseq_flags = 0;
+
        /*
         * Check if the rseq syscall is available, if not set the size and
         * feature_size to 0.
@@ -233,12 +239,6 @@ void rseq_init(void)
                goto unlock;
        }
 
-       /* Calculate the offset of the rseq area from the thread pointer. */
-       rseq_offset = (uintptr_t)&__rseq_abi - (uintptr_t)rseq_thread_pointer();
-
-       /* rseq flags are deprecated, always set to 0. */
-       rseq_flags = 0;
-
        /*
         * If the feature size matches the original ABI (20), set the size to
         * match the original ABI allocation (32), otherwise use the allocated
This page took 0.025338 seconds and 4 git commands to generate.