]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: rseq: remove const to avoid readonly permission
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 1 Mar 2022 09:44:14 +0000 (09:44 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 5 Aug 2022 18:45:19 +0000 (19:45 +0100)
Using const on the definition does not work for a pure capability ABI:
the capability permissions when accessing the object will be read only.

Use a hack to hide the public declaration in the TU where the const
objects are initialized. (This should work on non-capability targets
too, but to err on the safe side only enable the hack on capability
targets.)

sysdeps/nptl/dl-tls_init_tp.c

index 53fba774a55c5e76febbe549e30f06d7e4cba6bb..e4d7bb71ad55511f2cae0146c52b40266f81a1ee 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifdef __CHERI_PURE_CAPABILITY__
+/* This hack ensures that the later indirectly included public const
+   declaration does not conflict with the non-const definition here.  */
+# define __rseq_size __rseq_size_public_const
+# define __rseq_offset __rseq_offset_public_const
+# include <sys/rseq.h>
+# undef __rseq_size
+# undef __rseq_offset
+#endif
 #include <kernel-features.h>
 #include <ldsodefs.h>
 #include <list.h>
@@ -45,8 +54,13 @@ rtld_mutex_dummy (pthread_mutex_t *lock)
 #endif
 
 const unsigned int __rseq_flags;
+#ifdef __CHERI_PURE_CAPABILITY__
+unsigned int __rseq_size attribute_relro;
+ptrdiff_t __rseq_offset attribute_relro;
+#else
 const unsigned int __rseq_size attribute_relro;
 const ptrdiff_t __rseq_offset attribute_relro;
+#endif
 
 void
 __tls_pre_init_tp (void)