|
Message-ID: <20180207202800.GR4418@port70.net> Date: Wed, 7 Feb 2018 21:28:01 +0100 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Cc: Stefan Fröberg <stefan.froberg@...roprogram.com> Subject: Re: BUG: $ORIGIN does not seem to work * Rich Felker <dalias@...c.org> [2018-02-07 12:35:31 -0500]: > 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? > looks good. > 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 > diff --git a/ldso/dynlink.c b/ldso/dynlink.c > index 3380240..f507bc4 100644 > --- a/ldso/dynlink.c > +++ b/ldso/dynlink.c > @@ -807,7 +807,12 @@ static int fixup_rpath(struct dso *p, char *buf, size_t buf_size) > origin = p->name; > } > t = strrchr(origin, '/'); > - l = t ? t-origin : 0; > + if (t) { > + l = t-origin; > + } else { > + origin = "."; > + l = 1; > + } > p->rpath = malloc(strlen(p->rpath_orig) + n*l + 1); > if (!p->rpath) return -1; >
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.