public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Szabolcs Nagy <nsz@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/arm/morello/main] TODO(gcc): cheri: work around a gcc bug in _dl_setup_stack_chk_guard
Date: Thu, 27 Oct 2022 13:51:30 +0000 (GMT)	[thread overview]
Message-ID: <20221027135130.DC693385151E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=465880458a62761b9e976e49403485929634ebe9

commit 465880458a62761b9e976e49403485929634ebe9
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Fri Jul 15 19:33:23 2022 +0100

    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

Diff:
---
 sysdeps/unix/sysv/linux/dl-osinfo.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 7888915f12..49d8f973c8 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

             reply	other threads:[~2022-10-27 13:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 13:51 Szabolcs Nagy [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-11-23 14:41 Szabolcs Nagy
2022-10-26 15:12 Szabolcs Nagy
2022-08-05 19:33 Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221027135130.DC693385151E@sourceware.org \
    --to=nsz@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).