mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] $ORIGIN rpath expansion without /proc: code looks wrong
@ 2021-11-17 14:04 Alexander Sosedkin
  2021-11-17 17:00 ` Érico Nogueira
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Sosedkin @ 2021-11-17 14:04 UTC (permalink / raw)
  To: musl

Hello, I've encountered a case of a binary with an rpath of
/some/meaningful/lib:$ORIGIN/../lib
not starting up due to not finding /some/meaningful/lib/libxyz.so.
ldd'ing said it's there though.
And the library was found alright when I patchelf'd rpath to just
/some/meaningful/lib

I dug into musl code and came across that bit that checks /proc.
Sure enough, when I tried mounting /proc, it started working fine.
Yet the error handling from accessing /proc puzzles me:

ldso/dynlink.c, fixup_rpath():
                 l = readlink("/proc/self/exe", buf, buf_size);
                 if (l == -1) switch (errno) {
                 case ENOENT:
                 case ENOTDIR:
                 case EACCES:
                         break;
                 default:
                         return -1;
                 }
                 if (l >= buf_size)
                         return 0;
                 buf[l] = 0;
                 origin = buf;

hitting that break like I had means zeroing buf[-1], right?
Could somebody take a look at this and double-check that
this codepath makes sense?
My attempts at comprehending it fail irrecoverably at this line.

(CC me on replies, please.
  No nice context to provide, building my own toolchain at
  https://github.com/t184256/bootstrap-from-tcc)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-18 20:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 14:04 [musl] $ORIGIN rpath expansion without /proc: code looks wrong Alexander Sosedkin
2021-11-17 17:00 ` Érico Nogueira
2021-11-17 19:25   ` Alexander Sosedkin
2021-11-18 19:15     ` Érico Nogueira
2021-11-17 20:01   ` Jeffrey Walton
2021-11-18 19:21     ` Érico Nogueira
2021-11-18 19:41       ` Alexander Sosedkin
2021-11-18 19:42       ` Jeffrey Walton
2021-11-18 20:30         ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).