This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v2 7/7] malloc: Check the alignment of mmapped chunks before unmapping.
- From: DJ Delorie <dj at redhat dot com>
- To: Istvan Kurucsai <pistukem at gmail dot com>
- Cc: libc-alpha at sourceware dot org, pistukem at gmail dot com
- Date: Thu, 15 Nov 2018 18:58:01 -0500
- Subject: Re: [PATCH v2 7/7] malloc: Check the alignment of mmapped chunks before unmapping.
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 <firstname.lastname@example.org>
Istvan Kurucsai <email@example.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.