aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-07-15 19:33:23 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-11-22 14:31:25 +0000
commitc75b4885df122eb0ad63802f7ca9e3604a0d10f3 (patch)
treec6f87396e002738b20f73ee737c6363a2aa70af7 /sysdeps/unix
parent039f2bdd89d539a755c8b5d666fc2b40b8e45078 (diff)
downloadglibc-c75b4885df122eb0ad63802f7ca9e3604a0d10f3.zip
glibc-c75b4885df122eb0ad63802f7ca9e3604a0d10f3.tar.gz
glibc-c75b4885df122eb0ad63802f7ca9e3604a0d10f3.tar.bz2
TODO(gcc): cheri: work around a gcc bug in _dl_setup_stack_chk_guard
morello purecap gcc in some cases inlines 16byte memcpy as a capability load, which is wrong if the source or dest may be unaligned. stack guard only needs random for the address portion since only that part is compared, so 8 byte is enough with 64 bit addresses, but the current code is only right on little endian systems. TODO: drop when gcc is fixed
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/sysv/linux/dl-osinfo.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 7888915..49d8f97 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -34,7 +34,11 @@ _dl_setup_stack_chk_guard (void *dl_random)
/* We need in the moment only 8 bytes on 32-bit platforms and 16
bytes on 64-bit platforms. Therefore we can use the data
directly and not use the kernel-provided data to seed a PRNG. */
+#ifdef __CHERI_PURE_CAPABILITY__
+ memcpy (ret.bytes, dl_random, 8);
+#else
memcpy (ret.bytes, dl_random, sizeof (ret));
+#endif
#if BYTE_ORDER == LITTLE_ENDIAN
ret.num &= ~(uintptr_t) 0xff;
#elif BYTE_ORDER == BIG_ENDIAN