From: Florian Weimer <fweimer@redhat.com>
To: Andreas Fink via Libc-help <libc-help@sourceware.org>
Subject: Re: Hooking execve for an LD_PRELOAD library
Date: Sun, 17 Jan 2021 09:30:10 +0100 [thread overview]
Message-ID: <878s8srmnh.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <1MiMEW-1lf4081KQ2-00fS4y@smtp.web.de> (Andreas Fink via Libc-help's message of "Sun, 17 Jan 2021 08:07:32 +0100")
* Andreas Fink via Libc-help:
> Now I would like the same for execvp to happen. Reading the man page of
> execvp it is mentioned that exec-family functions are just
> frontends to execve, so I replaced in my executable source code the
> explicit call to execve with a call to execvp. I expected that this
> would just work, as execvp would in turn call execve and this would be
> caught by the hook, then logged and forwarded to the real
> implementation. But to my surprise no such thing happened. execvp would
> run successfully, but my hook would never be called.
> Why is the hook not called, what did I miss?
Most internal function calls are implemented as direct function call,
and it is not possible to use symbol interposition to redirect them.
An exception is the malloc family of functions:
Replacing malloc
<http://www.gnu.org/software/libc/manual/html_node/Replacing-malloc.html>
If you want to modify the behavior of execve, you should consider a
kernel-based mechanism. This will likely make it easier to achieve
correct behavior after vfork, too.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
next prev parent reply other threads:[~2021-01-17 8:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-17 7:07 Andreas Fink
2021-01-17 8:30 ` Florian Weimer [this message]
2021-01-17 11:28 ` Andreas Fink
2021-01-18 10:39 ` Florian Weimer
2021-01-20 11:00 ` Andreas Fink
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878s8srmnh.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=libc-help@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).