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 3F2EF3858010 for ; Fri, 17 Dec 2021 12:21:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3F2EF3858010 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-122-mx2WULzBPrmy-nd94jdTwA-1; Fri, 17 Dec 2021 07:21:18 -0500 X-MC-Unique: mx2WULzBPrmy-nd94jdTwA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F01BE81CCB5; Fri, 17 Dec 2021 12:21:16 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 921AD10016F4; Fri, 17 Dec 2021 12:21:15 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, John Mellor-Crummey , Ben Woodard Subject: Re: [PATCH v6 04/20] elf: Add _dl_audit_objsearch References: <20211115183734.531155-1-adhemerval.zanella@linaro.org> <20211115183734.531155-5-adhemerval.zanella@linaro.org> Date: Fri, 17 Dec 2021 13:21:13 +0100 In-Reply-To: <20211115183734.531155-5-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Mon, 15 Nov 2021 15:37:18 -0300") Message-ID: <87pmpvmngm.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.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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, 17 Dec 2021 12:21:20 -0000 * Adhemerval Zanella: > diff --git a/elf/dl-audit.c b/elf/dl-audit.c > index 5fbc76a36c..de85ef1ddd 100644 > --- a/elf/dl-audit.c > +++ b/elf/dl-audit.c > @@ -42,6 +42,43 @@ _dl_audit_activity_nsid (Lmid_t nsid, int action) > _dl_audit_activity_map (head, action); > } > > +bool > +_dl_audit_objsearch (const char **name, const char **origname, > + struct link_map *l, unsigned int code) > +{ > + if (__glibc_likely (GLRO(dl_naudit) == 0) > + || l == NULL || l->l_auditing > + || code == 0) > + return true; > + > + struct audit_ifaces *afct = GLRO(dl_audit); > + for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt) > + { > + if (afct->objsearch != NULL) > + { > + const char *before = *name; > + struct auditstate *state = link_map_audit_state (l, cnt); > + *name = afct->objsearch (*name, &state->cookie, code); > + if (*name == NULL) > + return false; > + > + if (origname != NULL && before != *name > + && strcmp (before, *name) != 0) > + { > + if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) > + _dl_debug_printf ("audit changed filename %s -> %s\n", > + before, *name); > + > + if (*origname == NULL) > + *origname = before; > + } > + } > + afct = afct->next; > + } > + > + return true; > +} Sorry, I find the interface rather confusing. *name is an in-out parameter, and *origname is an out parameter. This is not really clear from their names. I looked at the rest of elf/dl-load.c, and origname appears to be solely used as an optimization, to avoid having to call add_name_to_object twice. (add_name_to_object already filters out duplicate names.) I think this interface should work: const char *_dl_audit_objsearch (const char *name, struct link_map *l, unsigned int code); Callers need to check for NULL return values and stop loading the object. Otherwise they have to register both names with add_name_to_object. What do you think? Thanks, Florian