From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id EC94F3852C43; Wed, 23 Nov 2022 14:41:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC94F3852C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669214482; bh=jJ/I8tKR2QQKZWvFVJnWYj/sX+1d2A3plXHboZi8KSc=; h=From:To:Subject:Date:From; b=AjX3iVw+XtC7GPsxHHzq9YUhGrL6jXavMzUu11J9Ci+e2LpvlspexX2fKuQDgHIAA j6Y5QU4SqsjIXN3uH+MSOnGG2bl6RaxTVjCzwBkIVBth6rc+DOmu7GJiD26V+1N0d9 Vl1mt18Oo5kvlKFqpQHi3ScnRIv1/hK8I1lnf5eA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] TODO(gcc): cheri: work around a gcc bug in _dl_setup_stack_chk_guard X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 039f2bdd89d539a755c8b5d666fc2b40b8e45078 X-Git-Newrev: c75b4885df122eb0ad63802f7ca9e3604a0d10f3 Message-Id: <20221123144122.EC94F3852C43@sourceware.org> Date: Wed, 23 Nov 2022 14:41:22 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c75b4885df122eb0ad63802f7ca9e3604a0d10f3 commit c75b4885df122eb0ad63802f7ca9e3604a0d10f3 Author: Szabolcs Nagy 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