[PATCH v2 7/7] malloc: Check the alignment of mmapped chunks before unmapping.

DJ Delorie dj@redhat.com
Thu Nov 15 23:58:00 GMT 2018


I +1'd this patch series last year when it was first posted (sorry about
the lack of consensus-building) but just to revive it I'll +1 it again
independently.  Could we get a second review too?  Florian?

Reviewed-Again-By: DJ Delorie <dj@redhat.com>

Istvan Kurucsai <pistukem@gmail.com> writes:
> +  size_t pagesize = GLRO (dl_pagesize);

pagesize is used multiple times, so save the overhead.  OK.

> +  uintptr_t mem = (uintptr_t) chunk2mem(p);

This is the pointer the application sees.  OK

> -  if (__builtin_expect (((block | total_size) & (GLRO (dl_pagesize) - 1)) != 0, 0))
> +  if (__glibc_unlikely ((block | total_size) & (pagesize - 1)) != 0
> +      || __glibc_unlikely (!powerof2 (mem & (pagesize - 1))))

This adds a test for "is the pointer the application saw, some
unexpected offset into the page?".  OK.



More information about the Libc-alpha mailing list