This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: extend dl-minimal malloc implementation

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
    sbrk directly.

(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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]