mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Elvis Pranskevichus <elvis@edgedb.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] ldso/dynlink: Protect LD_ env vars from getting clobbered by apps
Date: Wed, 17 Aug 2022 09:26:34 -0700	[thread overview]
Message-ID: <23563878.EfDdHjke4D@vulcan.edgedb.net> (raw)
In-Reply-To: <20220817152905.GC7074@brightrain.aerifal.cx>

On Wednesday, August 17, 2022 8:29:05 AM PDT Rich Felker wrote:
> On Tue, Aug 16, 2022 at 10:45:45PM -0700, Elvis Pranskevichus wrote:
> > There is no guarantee that the environment block will remain intact.
> > For example, PostgreSQL clobbers argv/environ area to implement its
> > "setproctitle" emulation on non-BSD [1], and there is a popular
> > Python library inspired by it [2].  As a result, setting
> > `LD_LIBRARY_PATH` or `LD_PRELOAD` has no effect on Postgres
> > subprocesses when linking against musl.
> 
> This is explicitly not allowed and is UB. This memory is not available
> for the application to clobber, and code attempting to do that needs
> to be patched out. Aside from the general principle, POSIX is very
> clear in the specification of environ:
> 
>     "Any application that directly modifies the pointers to which the
>     environ variable points has undefined behavior."

I understand that what Postgres et al are doing is a nasty hack.  My 
thinking was that it is a question of compatibility with glibc's 
behavior, which seems to tolerate these shenanigans (at least with 
respect to `LD_*` variables.  Good point regarding the allocator bringup 
overhead, I haven't thought of that.

Thanks,

                                Elvis




  reply	other threads:[~2022-08-17 17:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17  5:45 Elvis Pranskevichus
2022-08-17  6:23 ` [musl] [RESEND PATCH] " Elvis Pranskevichus
2022-08-17 15:29 ` [musl] [PATCH] " Rich Felker
2022-08-17 16:26   ` Elvis Pranskevichus [this message]
2022-08-17 16:10 ` James Y Knight
2022-08-17 19:28   ` Rich Felker
2022-08-17 21:30     ` James Y Knight

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=23563878.EfDdHjke4D@vulcan.edgedb.net \
    --to=elvis@edgedb.com \
    --cc=dalias@libc.org \
    --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).