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.129.124]) by sourceware.org (Postfix) with ESMTPS id B51A33889E18 for ; Mon, 12 Dec 2022 10:55:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B51A33889E18 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670842549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l+IEKPySVmI0FRzbPZ+ZOzqOqJP9w3dJNs1mkzaHg4I=; b=eeZK5ikZpOhiih5dgNRSiLL/1dRA0faKmPnc+5hscsd/aHX0rnE4ijjwZaBKLNv5cMi1JJ jXqC9VwJR89bXK6fpVJOICFr+/Nk1mLLpdMLo5PVvlMRS9eMLMdDQAgc+idKiX6tK9/Xnt GdO8CQiHBpBv60YyBwgzh5lACwVNWL4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-24aHoFDUMK-vtXo-baUzeA-1; Mon, 12 Dec 2022 05:55:46 -0500 X-MC-Unique: 24aHoFDUMK-vtXo-baUzeA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA429803D4B; Mon, 12 Dec 2022 10:55:45 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF39D492B00; Mon, 12 Dec 2022 10:55:44 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Cc: Fangrui Song , Adhemerval Zanella Subject: Re: [PATCH 4/7] Move libc_freeres_ptrs and libc_subfreeres to weak functions References: <20221115193159.173838-1-adhemerval.zanella@linaro.org> <20221115193159.173838-5-adhemerval.zanella@linaro.org> Date: Mon, 12 Dec 2022 11:55:40 +0100 In-Reply-To: <20221115193159.173838-5-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Tue, 15 Nov 2022 16:31:56 -0300") Message-ID: <87cz8ouc0j.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Adhemerval Zanella via Libc-alpha: > diff --git a/crypt/md5-crypt.c b/crypt/md5-crypt.c > index 7c4fb9fb97..9660cdd698 100644 > --- a/crypt/md5-crypt.c > +++ b/crypt/md5-crypt.c > @@ -299,10 +299,7 @@ __md5_crypt_r (const char *key, const char *salt, char *buffer, int buflen) > return buffer; > } > > -#ifndef _LIBC > -# define libc_freeres_ptr(decl) decl > -#endif > -libc_freeres_ptr (static char *buffer); > +static char *buffer; > > char * > __md5_crypt (const char *key, const char *salt) > @@ -330,7 +327,10 @@ __md5_crypt (const char *key, const char *salt) > static void > __attribute__ ((__destructor__)) > free_mem (void) > +#else > +void > +__md5_crypt_freemem (void) > +#endif > { > free (buffer); > } > -#endif > diff --git a/crypt/sha256-crypt.c b/crypt/sha256-crypt.c > index a98a968a8b..75fd582429 100644 > --- a/crypt/sha256-crypt.c > +++ b/crypt/sha256-crypt.c > @@ -386,10 +386,7 @@ __sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen) > return buffer; > } > > -#ifndef _LIBC > -# define libc_freeres_ptr(decl) decl > -#endif > -libc_freeres_ptr (static char *buffer); > +static char *buffer; > > /* This entry point is equivalent to the `crypt' function in Unix > libcs. */ > @@ -422,7 +419,10 @@ __sha256_crypt (const char *key, const char *salt) > static void > __attribute__ ((__destructor__)) > free_mem (void) > +#else > +void > +__sha256_crypt_freemem (void) > +#endif > { > free (buffer); > } > -#endif > diff --git a/crypt/sha512-crypt.c b/crypt/sha512-crypt.c > index ea13527c09..ae6ecaef16 100644 > --- a/crypt/sha512-crypt.c > +++ b/crypt/sha512-crypt.c > @@ -408,10 +408,7 @@ __sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen) > return buffer; > } > > -#ifndef _LIBC > -# define libc_freeres_ptr(decl) decl > -#endif > -libc_freeres_ptr (static char *buffer); > +static char *buffer; > > /* This entry point is equivalent to the `crypt' function in Unix > libcs. */ > @@ -444,7 +441,10 @@ __sha512_crypt (const char *key, const char *salt) > static void > __attribute__ ((__destructor__)) > free_mem (void) > +#else > +void > +__sha512_crypt_freemem (void) > +#endif > { > free (buffer); > } > -#endif I think you should delete the entire deallocation logic, or make use of the ELF destructor unconditional. This wasn't linked into libc, so it wasn't run from __libc_freeres, and the hook registration was a no-op. (I believe, I haven't checked.) Thanks, Florian