Skip to content

Commit

Permalink
GL for __rseq_handled
Browse files Browse the repository at this point in the history
  • Loading branch information
compudj committed Jun 14, 2019
1 parent f9aa525 commit 8a02acf
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
18 changes: 18 additions & 0 deletions elf/dl-support.c
Expand Up @@ -221,6 +221,24 @@ __rtld_lock_define_initialized_recursive (, _dl_load_lock)
that list. */
__rtld_lock_define_initialized_recursive (, _dl_load_write_lock)

/* Advertise Restartable Sequences registration ownership across
application and shared libraries.
Libraries and applications must check whether this variable is zero or
non-zero if they wish to perform rseq registration on their own. If it
is zero, it means restartable sequence registration is not handled, and
the library or application is free to perform rseq registration. In
that case, the library or application is taking ownership of rseq
registration, and may set __rseq_handled to 1. It may then set it back
to 0 after it completes unregistering rseq.
If __rseq_handled is found to be non-zero, it means that another
library (or the application) is currently handling rseq registration.
Typical use of __rseq_handled is within library constructors and
destructors, or at program startup. */

int __rseq_handled;

#ifdef HAVE_AUX_VECTOR
int _dl_clktck;
Expand Down
22 changes: 21 additions & 1 deletion elf/rtld.c
Expand Up @@ -115,6 +115,25 @@ strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
# define SECURE_PATH_LIMIT 1024
#endif

/* Advertise Restartable Sequences registration ownership across
application and shared libraries.
Libraries and applications must check whether this variable is zero or
non-zero if they wish to perform rseq registration on their own. If it
is zero, it means restartable sequence registration is not handled, and
the library or application is free to perform rseq registration. In
that case, the library or application is taking ownership of rseq
registration, and may set __rseq_handled to 1. It may then set it back
to 0 after it completes unregistering rseq.
If __rseq_handled is found to be non-zero, it means that another
library (or the application) is currently handling rseq registration.
Typical use of __rseq_handled is within library constructors and
destructors, or at program startup. */

int __rseq_handled;

/* Check that AT_SECURE=0, or that the passed name does not contain
directories and is not overly long. Reject empty names
unconditionally. */
Expand Down Expand Up @@ -247,7 +266,8 @@ struct rtld_global _rtld_global =
[LM_ID_BASE] = { ._ns_unique_sym_table
= { .lock = _RTLD_LOCK_RECURSIVE_INITIALIZER } }
#endif
}
},
.__rseq_handled = 0
};
/* If we would use strong_alias here the compiler would see a
non-hidden definition. This would undo the effect of the previous
Expand Down
3 changes: 3 additions & 0 deletions sysdeps/generic/ldsodefs.h
Expand Up @@ -419,6 +419,9 @@ struct rtld_global
/* Alignment requirement of the static TLS block. */
EXTERN size_t _dl_tls_static_align;

/* Restartable Sequences registration ownership. */
EXTERN int __rseq_handled;

/* Number of additional entries in the slotinfo array of each slotinfo
list element. A large number makes it almost certain take we never
have to iterate beyond the first element in the slotinfo list. */
Expand Down
3 changes: 2 additions & 1 deletion sysdeps/unix/sysv/linux/rseq-internal.h
Expand Up @@ -20,6 +20,7 @@

#include <sysdep.h>
#include <errno.h>
#include <ldsodefs.h>

#ifdef __NR_rseq
#include <sys/rseq.h>
Expand Down Expand Up @@ -64,7 +65,7 @@ rseq_unregister_current_thread (void)
static inline void
rseq_init (void)
{
__rseq_handled = 1;
GL(_rseq_handled) = 1;
}
#else
static inline int
Expand Down
19 changes: 0 additions & 19 deletions sysdeps/unix/sysv/linux/rseq-sym.c
Expand Up @@ -41,22 +41,3 @@ struct rseq {
__thread struct rseq __rseq_abi = {
.cpu_id = RSEQ_CPU_ID_UNINITIALIZED,
};

/* Advertise Restartable Sequences registration ownership across
application and shared libraries.
Libraries and applications must check whether this variable is zero or
non-zero if they wish to perform rseq registration on their own. If it
is zero, it means restartable sequence registration is not handled, and
the library or application is free to perform rseq registration. In
that case, the library or application is taking ownership of rseq
registration, and may set __rseq_handled to 1. It may then set it back
to 0 after it completes unregistering rseq.
If __rseq_handled is found to be non-zero, it means that another
library (or the application) is currently handling rseq registration.
Typical use of __rseq_handled is within library constructors and
destructors, or at program startup. */

int __rseq_handled;

0 comments on commit 8a02acf

Please sign in to comment.