From: GNU Libc Maintainers Date: Tue, 1 Aug 2017 11:46:34 +0000 (+0100) Subject: cvs-malloc-hardening X-Git-Tag: archive/raspbian/2.25-3+rpi1~1^2^2^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ccda8c6625ab42e376deea06b0bdb08e44160cad;p=glibc.git cvs-malloc-hardening 2017-03-17 Chris Evans * malloc/malloc.c (unlink): Add consistency check between size and next->prev->size, to further harden against 1-byte overflows. 2016-10-27 Florian Weimer * malloc/malloc.c (sysmalloc): Initialize previous size field of mmaped chunks. Gbp-Pq: Topic any Gbp-Pq: Name cvs-malloc-hardening.diff --- diff --git a/malloc/malloc.c b/malloc/malloc.c index 1f5f166ea..37a373c7e 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1405,6 +1405,8 @@ typedef struct malloc_chunk *mbinptr; /* Take a chunk off a bin list */ #define unlink(AV, P, BK, FD) { \ + if (__builtin_expect (chunksize(P) != next_chunk(P)->prev_size, 0)) \ + malloc_printerr (check_action, "corrupted size vs. prev_size", P, AV); \ FD = P->fd; \ BK = P->bk; \ if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) \ @@ -2361,6 +2363,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av) else { p = (mchunkptr) mm; + p->prev_size = 0; set_head (p, size | IS_MMAPPED); }