From: u-igbb@aetey.se
To: musl@lists.openwall.com
Subject: PATCH (Re: [musl] be able to break inheritance of LD_LIBRARY_PATH)
Date: Fri, 28 Mar 2014 16:02:08 +0000 [thread overview]
Message-ID: <20140328160208.GD8221@example.net> (raw)
In-Reply-To: <20140328140036.GC8221@example.net>
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
On Fri, Mar 28, 2014 at 02:00:36PM +0000, u-igbb@aetey.se wrote:
> By the way, when you say this - LD_PRELOAD should be actually usable
> in a non-inheritable way too. It brings otherwise the same problems
> as LD_LIBRARY_PATH. It could deserve its own loader argument I guess,
> like --preload.
>
> > (there ar no "different versions of the loader" in musl)
>
> Yes this is why I thought that a LD_LIBRARY_PATH removal would
> be enough. Of course it is much better to do this properly, by
> extending the behaviour of the loader when it is being used standalone.
>
> This would cost just a few bytes I guess. I will look into proposing a patch.
Attaching the patch. It seems to work, under some primitive testing.
Could this or similar be considered for applying upstream?
Regards,
Rune
[-- Attachment #2: add--library-path.patch --]
[-- Type: text/plain, Size: 1350 bytes --]
--- src/ldso/dynlink.c.ori 2014-03-28 10:37:34.821317811 +0100
+++ src/ldso/dynlink.c 2014-03-28 16:45:26.435994022 +0100
@@ -1041,12 +1041,34 @@
size_t l = strlen(ldname);
if (l >= 3 && !strcmp(ldname+l-3, "ldd")) ldd_mode = 1;
*argv++ = (void *)-1;
- if (argv[0] && !strcmp(argv[0], "--")) *argv++ = (void *)-1;
+ while (argv[0] && argv[0][0] == '-') {
+ if (argv[0][1] == '-' && argv[0][2] == 0) { /* "--" */
+ *argv++ = (void *)-1;
+ break;
+ }
+ /* care about someone making the dynamic loader
+ * itself (!) setuid? (s)he has possibly good
+ * reasons, who am I to interfere -- thus
+ * no setuid checking here -- rl */
+ if (!strcmp(argv[0], "--library-path")) {
+ *argv++ = (void *)-1;
+ env_path = argv[0]; /* even if NULL */
+ } else if (!strcmp(argv[0], "--preload")) {
+ *argv++ = (void *)-1;
+ env_preload = argv[0]; /* even if NULL */
+ } else
+ /* any -<something-else> stops parsing */
+ break;
+ if (!argv[0])
+ /* missing argument? */
+ break;
+ *argv++ = (void *)-1;
+ }
if (!argv[0]) {
dprintf(2, "musl libc\n"
"Version %s\n"
"Dynamic Program Loader\n"
- "Usage: %s [--] pathname%s\n",
+ "Usage: %s [--library-path path] [--preload path] [--] pathname%s\n",
__libc_get_version(), ldname,
ldd_mode ? "" : " [args]");
_exit(1);
next prev parent reply other threads:[~2014-03-28 16:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 10:42 be able to break inheritance of LD_LIBRARY_PATH u-igbb
2014-03-28 12:18 ` orc
2014-03-28 12:52 ` u-igbb
2014-03-28 12:27 ` Alexander Monakov
2014-03-28 13:04 ` u-igbb
2014-03-28 13:17 ` Szabolcs Nagy
2014-03-28 14:00 ` u-igbb
2014-03-28 15:25 ` Szabolcs Nagy
2014-03-28 15:34 ` Alexander Monakov
2014-03-28 16:02 ` u-igbb [this message]
2014-03-28 16:34 ` Daniel Cegiełka
2014-03-28 17:50 ` u-igbb
2014-03-28 18:03 ` Daniel Cegiełka
2014-03-28 18:21 ` u-igbb
2014-03-28 19:46 ` Rich Felker
2014-03-28 21:07 ` u-igbb
2014-03-28 21:48 ` Rich Felker
2014-03-29 7:25 ` u-igbb
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=20140328160208.GD8221@example.net \
--to=u-igbb@aetey.se \
--cc=musl@lists.openwall.com \
/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.
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).