From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6A25C385840D for ; Fri, 19 Nov 2021 20:31:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A25C385840D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-5Z38HmgaNgOgQuHvAui7QA-1; Fri, 19 Nov 2021 15:31:28 -0500 X-MC-Unique: 5Z38HmgaNgOgQuHvAui7QA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD78910B7474; Fri, 19 Nov 2021 20:31:26 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 086EB19D9B; Fri, 19 Nov 2021 20:31:24 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: Jonathon Anderson , John Mellor-Crummey , libc-alpha@sourceware.org, "Mark W. Krentel" , Xiaozhu Meng Subject: Re: Fwd: [PATCH v5 00/22] Some rtld-audit fixes References: <0D3F0C5F-2586-42F9-916D-2F327432AF13@rice.edu> <87bl2i345m.fsf@oldenburg.str.redhat.com> <87ee7c9coo.fsf@oldenburg.str.redhat.com> Date: Fri, 19 Nov 2021 21:31:22 +0100 In-Reply-To: (Adhemerval Zanella's message of "Fri, 19 Nov 2021 16:56:25 -0300") Message-ID: <87wnl399b9.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 20:31:32 -0000 * Adhemerval Zanella: >> "" for the main executable is widely known. Usually code uses it to >> implement a fallback on argv[0] or /proc/self/exe, though. > > There are still the issue where audit interface does not have direct > access to argv[0] from the audited process and '/proc' might also not > be accessible. I am still not convinced that provided argv[0] for > l_name for main executable is worse than "", specially because the > fallback might not work. I think it's better to give the auditor a chance to figure out whether they want to use program_invocation_name (if that's not available in the inner libc, that's for sure a bug we must fix), AT_EXECFN, or /proc/self/exe. If we pick one of these for the auditor, we make it more difficult to make the appropriate choice. >> Changing l_addr will break the libgcc unwinder. It uses l_addr to >> relocate the program header (see the code I quoted previously). Not >> everyone uses the platform unwinder, and the libgcc unwinder is >> sometimes linked statically. This is different from the l_name change: >> The l_addr would definitely cause widespread breakage. >>=20 >>> =C2=A0- Every use case I can think of for obtaining a link_map from the= dl* >>> functions (dlinfo and dladdr1) will either already have the special=20 >>> handling, or won't operate on the main executable, or likely won't opt >>> to use l_addr (vs. dlsym or dli_fbase) or l_name (vs. dli_fname). >>=20 >> Some special-case the main executable based on l_name, I expect, which >> is why I'm so reluctant to change l_name. The GDB comment is actually >> hinting strongly towards a "" convention (that Solaris broke). > > So I take that Solaris does provide the application name to l_name? And > what kind of breakage it has done on gdb? Solaris seems to use the pathname argument to execve as l_name, via AT_SUN_EXECNAME. I do not know if it is an absolute name. The documentation for getexecname suggests it may not be: | Normally this is an absolute pathname, as the majority of commands are | executed by the shells that append the command name to the user's PATH | components. If this is not an absolute path, the output of getcwd(3C) | can be prepended to it to create an absolute path, unless the process | or one of its ancestors has changed its root directory or current | working directory since the last successful call to one of the exec | family of functions. If that's accurate, it would be just like our AT_EXECFN. I suspect this won't work for fexecve, so they are just going to fall back to argv[0] in that case. Still I think we have 20+ years of doing things our way (the BSD way), and I do worry about the backwards compatibility impact of such a change. Thanks, Florian