public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Running via <ld.so> gives a different executable
@ 2021-02-26 18:21 Tyson Whitehead
  2021-02-26 19:23 ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Tyson Whitehead @ 2021-02-26 18:21 UTC (permalink / raw)
  To: libc-alpha

Happened to discover that, at least under glibc 2.31, if you launch a binary via <ld.so> on linux, the proc exe link is set to <ld.so>.

This causes ps to report the program as ld.so and also breaks (at least) any Qt application that uses QCoreApplication::applicationDirPath()

https://doc.qt.io/qt-5/qcoreapplication.html#applicationDirPath

Reaching out to the mailing list to see if this is I should be opening a bug report about?

Thanks!  -Tyson

PS: Discovered this trying to use <ld.so> --preload on a Qt binary where I couldn't use LD_PRELOAD as it would pollute the forked children.

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

* Re: Running via <ld.so> gives a different executable
  2021-02-26 18:21 Running via <ld.so> gives a different executable Tyson Whitehead
@ 2021-02-26 19:23 ` Andreas Schwab
  2021-02-26 21:08   ` Tyson Whitehead
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2021-02-26 19:23 UTC (permalink / raw)
  To: Tyson Whitehead via Libc-alpha; +Cc: Tyson Whitehead

This cannot be fixed in user-space.  The kernel always uses the first
argument of the execve syscall as the exe link, and it cannot be changed
afterwards.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: Running via <ld.so> gives a different executable
  2021-02-26 19:23 ` Andreas Schwab
@ 2021-02-26 21:08   ` Tyson Whitehead
  2021-02-26 21:23     ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Tyson Whitehead @ 2021-02-26 21:08 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Tyson Whitehead via Libc-alpha

From the prctrl man page, it sounded like

prctl(PR_SET_MM_EXE_FILE, ...)

would let you do this once for Linux 3.5-4.9 and multiple times for 4.10+.
Am I correct in understanding you are saying that the system execve call
uses this one-time opportunity?

Thanks!  -Tyson

On Fri, 26 Feb 2021 at 14:23, Andreas Schwab <schwab@linux-m68k.org> wrote:

> This cannot be fixed in user-space.  The kernel always uses the first
> argument of the execve syscall as the exe link, and it cannot be changed
> afterwards.
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>

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

* Re: Running via <ld.so> gives a different executable
  2021-02-26 21:08   ` Tyson Whitehead
@ 2021-02-26 21:23     ` Andreas Schwab
  2021-02-26 21:53       ` Tyson Whitehead
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2021-02-26 21:23 UTC (permalink / raw)
  To: Tyson Whitehead via Libc-alpha; +Cc: Tyson Whitehead

On Feb 26 2021, Tyson Whitehead via Libc-alpha wrote:

> From the prctrl man page, it sounded like
>
> prctl(PR_SET_MM_EXE_FILE, ...)
>
> would let you do this once for Linux 3.5-4.9 and multiple times for 4.10+.

Thanks, I didn't know about that prctl.  But it cannot be used, as it
forbids changing the exe file if the original file is still mapped.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: Running via <ld.so> gives a different executable
  2021-02-26 21:23     ` Andreas Schwab
@ 2021-02-26 21:53       ` Tyson Whitehead
  0 siblings, 0 replies; 5+ messages in thread
From: Tyson Whitehead @ 2021-02-26 21:53 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Tyson Whitehead via Libc-alpha

I guess that is that then. Thank you for the quick responses and
clarification!  :)

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

end of thread, other threads:[~2021-02-26 21:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 18:21 Running via <ld.so> gives a different executable Tyson Whitehead
2021-02-26 19:23 ` Andreas Schwab
2021-02-26 21:08   ` Tyson Whitehead
2021-02-26 21:23     ` Andreas Schwab
2021-02-26 21:53       ` Tyson Whitehead

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 read-only IMAP folder(s) and NNTP newsgroup(s).