Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 7 Feb 2018 12:35:31 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Cc: Stefan Fröberg <stefan.froberg@...roprogram.com>
Subject: Re: BUG: $ORIGIN does not seem to work

On Sun, Jan 28, 2018 at 01:54:25AM +0100, Szabolcs Nagy wrote:
> * Stefan Fröberg <stefan.froberg@...roprogram.com> [2018-01-28 00:07:33 +0200]:
> > strace ./x
> ...
> > open("/root/batman/lib/libcrypto.so.1.1", O_RDONLY|O_CLOEXEC) = 3
> ...
> > ldd x
> >     /lib/ld-musl-x86_64.so.1 (0x7f22efa03000)
> >     libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x7f22ef352000)
> >     libc.so => /lib/ld-musl-x86_64.so.1 (0x7f22efa03000)
> 
> this is a bug in musl ldd: if the executable
> path has no / then it assumes origin is /, try
> 
> ldd ./x
> 
> then origin is ./ so it works as expected.

Does the attached patch look ok?

Alternatively we could fix the assumed invariant that p->name always
contains a slash by having the loader code in __dls3 allocate a copy
of argv[0] with "./" prepended, but that's a heavier cost at runtime
and doesn't seem to have any practical advantages.

Rich

View attachment "ldd-curdir.diff" of type "text/plain" (436 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.