Skip to content

Initialization overhaul using allocsld? #97

@stephenrkell

Description

@stephenrkell

The initialization of liballocs has always been fragile. It often suffers reentrancy problems, e.g. from early malloc calls in the ld.so. We have ways of dealing with these case-by-case, but it's not very satisfactory. At present, the ld.so always runs before we do, so we are always at its mercy. We already have a certain amount of complexity for bringing ourselves up during normal DSO construction, e.g. allowing for the span where systrapping is not enabled. Recent glibc bug workaround efforts (#81) are an especially nasty case of this.

The addition of allocsld allows us to change that. I am in the process of a basic version of binary instrumentation of allocation functions (#11). Combining these two, we may be able to introspect on the whole of execution much more uniformly, starting from the ld.so or even from allocsld itself, and seeing all mmap calls from the off. (The only code in allocsld that needs to be runnable after it jumps to the real ld.so is the _dl_debug_state function. We could put that on a separate page, even, so that none of the other code retains execute permission.)

Of course there is a meta-completeness issue (#16). Binary instrumentation complicates this because it involves allocating trampolines that currently have no meta-information of their own and break backtraces. This is fixable, however.

I'm vaguely imagining a simplified initialization where

  1. all mmaps are caught uniformly (but by what code? it may need to be duplicated in allocsld)
  2. liballocs would ideally need no constructor at all (but how is this different from allocsld just being liballocs? I think I considered and rejected that in Dummyweaks library should go away #56)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions