[PATCH] malloc: Implement heap protector

DJ Delorie dj@redhat.com
Fri Oct 28 20:45:00 GMT 2016


My only comments on this one are:

> +/* Decrypt a heap header chunk.  */
> +#define HEAP_CRYPT_SIZE(val) (__malloc_header_guard ^ ((INTERNAL_SIZE_T) val))
> +#define HEAP_CRYPT_PREVSIZE(val) \
> +  (__malloc_footer_guard ^ ((INTERNAL_SIZE_T) val))

For readability and maintainability, we should probably have both CRYPT
and DECRYPT macros, used correcly throughout.  Yes, I know they'd be the
same now, but they might not be later.

> +/* The heap cookie.  The lowest three bits (corresponding to
> +   SIZE_BITS) in __malloc_guard_header must be clear.  Initialized
> +   during libc startup, and computed by elf/dl-keysetup.c.  */

If the lowest three bits must be clear, we should either clear them or
assert that they're clear.



More information about the Libc-alpha mailing list