This is the mail archive of the
mailing list for the glibc project.
Re: extend dl-minimal malloc implementation
- From: Carlos O'Donell <carlos at redhat dot com>
- To: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Cc: DJ Delorie <dj at redhat dot com>, Carlos O'Donell <codonell at redhat dot com>
- Date: Fri, 11 Aug 2017 08:38:48 -0400
- Subject: Re: extend dl-minimal malloc implementation
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com> <firstname.lastname@example.org>
On 08/11/2017 06:49 AM, Florian Weimer wrote:
> On 06/29/2017 03:39 AM, DJ Delorie wrote:
>> + * elf/dl-minimal.c: Upgrade minimal malloc to allow for reusing
>> + free'd memory. Migrate malloc/calloc/realloc to morecore(),
>> + add free list, optimize calloc zeroing.
>> + * elf/tst-dl-minimal-malloc.c: New.
>> + * elf/Makefile: Run it.
> What's the general feeling about this patch? Is this a direction we
> want to move in?
We should accept this patch.
I see two alternatives though:
(a) Remove malloc from the early loader entirely and delete the
implementation in dl-minimal.c, and instead use alloca, or
(b) Use a fully supported bootstrap malloc.
I believe that (a) is a step backwards, it adds more alloca which
we are trying to remove because of the security implications. It
also means we have continued object ownership problems e.g. who
owns the memory, can we free it, when is it safe to free?
In my experience (b) is the only way forward, particularly if we
want to do more accruate accounting of memory during early bootstrap,
if we want to record IREL relocs and process them later, etc. etc.
There area number of examples that would benefit from a proper alloctor.
Even better I think we can poison bootstrap chunks to abort if they
ever get passed to the non-bootstrap malloc to catch hand-off problems
during the bootstrap.