LD_PRELOAD work in progress

Steve Langasek steve.langasek at canonical.com
Tue Feb 24 23:50:16 UTC 2015


On Tue, Feb 24, 2015 at 06:30:01PM -0500, Michael Terry wrote:
> On Tue, Feb 24, 2015 at 6:06 PM, Stéphane Graber <stgraber at ubuntu.com>
> wrote:

> > So the main problem with the LD_PRELOAD approach and why I discarded it
> > back in CPT is that it will not work for file system access coming from
> > a static binary.

> > So if I write a Go piece of software which opens some file from
> > /usr/share provided by the overlay either in the app itself or one of
> > its frameworks, it won't be able to access the file because it won't be
> > using the local libc.

> Forgive me, I'm a bit out of my usual domain.  Is the problem that with a
> statically linked version of libc, a preloaded library can't override the
> symbols from the libc version already embedded in the executable?  And
> there aren't any tricks to alter that behavior?  That'd be a bummer.
> -mt

There's possibly an even bigger problem with that, which is that even for a
dynamically linked program you're not guaranteed to be able to intercept all
VFS calls in libc.  This basically hasn't been supported in glibc for a
decade.

Now, I guess for this case you only need to intercept those calls which take
a filename as an argument, in order to remap to a different name.  It's
*possible* that LD_PRELOAD interposition is supported for all libc calls
that take a filename.  But you'll probably need to verify this carefully
before going down this road.

Cc:ing Adam Conrad.  Adam, do you know if the kind of LD_PRELOAD described
here will work on glibc nowadays, or if there are gaps?

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/snappy-devel/attachments/20150224/aa044099/attachment.pgp>


More information about the snappy-devel mailing list