From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23021 invoked from network); 17 Aug 2022 17:03:42 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 17 Aug 2022 17:03:42 -0000 Received: (qmail 30021 invoked by uid 550); 17 Aug 2022 17:03:39 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 13661 invoked from network); 17 Aug 2022 16:26:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=edgedb.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:cc:to:from:from:to:cc; bh=27Dmr2jvqzNjeK/XXWu2qIXTrRItYo068awSP/HhC/Q=; b=X3uoFpIKfR/gxPCoWJkUy+Tqsb7AkaM2ZJU35MUtkad2mahzqlhOPBJrGbgfy6D0VY O7GhBnKct3SsFH9p6dNB5Yj/2ucqKc4UUsi7qGjpOrjh2lQ+S/1VtLv0L1tS5kf7Qulv SyQ4lMl4/tW3KaxLdAAuQ3LEBkOkREInblTLA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc; bh=27Dmr2jvqzNjeK/XXWu2qIXTrRItYo068awSP/HhC/Q=; b=JvPgHvda2R4ETGmFJxorZlYkskQ37tHofWvSoAgH0ipBAKmhJB1Tr2AyP1ScI+lRaK aikLVGymxhUrWEmmUIJzQcIdyKUGrabykRFWcE4WYD1OGzl1lEdN96bzHP0At5zvimBs AHwrX5ZO+i41bSJYDTHxHHCE4EIAYPAbMFMbam6ufizEIYsUMNE6MMYyOKPZ7m74n0Mt mhhfpAIn/VtQkeYx/TswLbmMi7XsH30dn1Z3LhtGEwNAwZmd+SHrgjzOEYEdbZnEv+Sg 6K37RQckF3EnO+nD7yHuN2YL5G2veT7p7vYnIVtzGshbHq9gJQ/EoPONd7/Gqsv2/LsS 4pFQ== X-Gm-Message-State: ACgBeo074L3XdXQQA/17oPWoOTKrq4G+JVsE+MbsOmP8n3yM4hEqhmdc Md9YFGtWQ5bGcfqN33i+9gFyag== X-Google-Smtp-Source: AA6agR7znAwcgHXR9tft9IXMF/q3j/66Sp5OghhvqHHlG2jVJ8Z5fkt1hgnr1Mad+KTkc6Fh+pOhBQ== X-Received: by 2002:a17:902:9b85:b0:16e:cc02:b9b2 with SMTP id y5-20020a1709029b8500b0016ecc02b9b2mr27203762plp.74.1660753596547; Wed, 17 Aug 2022 09:26:36 -0700 (PDT) From: Elvis Pranskevichus To: Rich Felker Cc: musl@lists.openwall.com Date: Wed, 17 Aug 2022 09:26:34 -0700 Message-ID: <23563878.EfDdHjke4D@vulcan.edgedb.net> Organization: EdgeDB Inc. In-Reply-To: <20220817152905.GC7074@brightrain.aerifal.cx> References: <3818608.tdWV9SEqCh@vulcan.edgedb.net> <20220817152905.GC7074@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [musl] [PATCH] ldso/dynlink: Protect LD_ env vars from getting clobbered by apps 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