]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: malloc: Disable pointer protection
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 7 Jul 2021 13:21:40 +0000 (14:21 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 27 Oct 2022 13:46:53 +0000 (14:46 +0100)
Such arithmetic invalidates capabilities so this security measure does
not work for CHERI.

Note: the architecture makes it hard to corrupt pointers in malloc
metadata, but not impossible: current allocation bounds include the
metadata and capabilities are not revoked after free. These issues can
be fixed by a capability aware malloc.

malloc/malloc.c

index bd3c76ed310c4c2cbf8f141eb6b76182926cf24a..062ca0dc0aa4b6cd6d60789542af7591966b9ff7 100644 (file)
@@ -341,8 +341,12 @@ Fatal glibc error: malloc assertion failure in %s: %s\n",
    It assumes a minimum page size of 4096 bytes (12 bits).  Systems with
    larger pages provide less entropy, although the pointer mangling
    still works.  */
+#ifdef __CHERI_PURE_CAPABILITY__
+#define PROTECT_PTR(pos, ptr) (ptr)
+#else
 #define PROTECT_PTR(pos, ptr) \
   ((__typeof (ptr)) ((((size_t) pos) >> 12) ^ ((size_t) ptr)))
+#endif
 #define REVEAL_PTR(ptr)  PROTECT_PTR (&ptr, ptr)
 
 /*