From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 4BB591F61A for ; Mon, 12 Dec 2022 13:16:12 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="qdJKnXBz"; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 144CD3845874 for ; Mon, 12 Dec 2022 13:16:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 144CD3845874 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670850971; bh=ZdPm990fiXVrmrC6LvpUV2XEBfk3hgQSMoVNY2HM6hQ=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qdJKnXBz0LX3sLCNrv3owACqBWpZRUgOsocJnrn7+kt6fHshEP5NaKezVwMQjFMhZ yL5wL9DklUmYAdKd/dnBnLQEcELp/gtbWjy0KESHH8yrdtUhay7v4gUWgv3e9/Tm27 i+Ip+ZoBZDfQNZN5Xgd4MScHU+lB83Bwk3mgQ1Ls= Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 61E95384C374 for ; Mon, 12 Dec 2022 13:15:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61E95384C374 Received: by mail-ot1-x336.google.com with SMTP id z14-20020a9d65ce000000b0067059c25facso7239439oth.6 for ; Mon, 12 Dec 2022 05:15:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZdPm990fiXVrmrC6LvpUV2XEBfk3hgQSMoVNY2HM6hQ=; b=Gy6jy6C71hWHP/HRLaPqV1PrxWIb7TqPuxOlTv6dkRhlrzkbq4nJ+wioop3uIxoxoG Ptpql0fSHhCQPEo/mMInJ/zQfRJSfv2v9ZhB5A9tHjLQUGFy6UFEDRe1PQ3/luaQRB3Q 6waK45yyfybsyGnMz+gY5/S+6906AtFCnNNoOxr8L07HuOzb82aBymNgfOjSE/DlbAtQ sr8KJtTKYxUTsNVqUWmuF6ngCXZQpQ8DPoSWGMseQP4GD8B8SSj8gFbaZL7NsunfzaXX oYHFjNwjGlK5BqGkMUr9t/BS9B9SDu7n94t85JbJ7qygcVw8bUt6w9EQkLrw7WRg8WH3 5Q4w== X-Gm-Message-State: ANoB5pm7tG+QoCQGiO4aUMvIj4f6t/wluJHxiqZJWg2+ZBYYEzYLmJDj gIXu04JtD9FPL6yTYrt35Ffn/rcrpOqV2N9YZ5E= X-Google-Smtp-Source: AA0mqf52qzNouTcv4IrjLXE94fA5YKAQa4/i9JGr0pKyGEKsqS4MJtl5aqWULOElCAz6gMjuy41efA== X-Received: by 2002:a05:6830:921:b0:66e:83a2:fc6f with SMTP id v33-20020a056830092100b0066e83a2fc6fmr10988360ott.31.1670850938532; Mon, 12 Dec 2022 05:15:38 -0800 (PST) Received: from [192.168.15.31] (201-92-181-161.dsl.telesp.net.br. [201.92.181.161]) by smtp.gmail.com with ESMTPSA id p23-20020a056830131700b00667d9a866b0sm3981961otq.59.2022.12.12.05.15.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 05:15:37 -0800 (PST) Message-ID: <6e705640-ec79-ed73-3ca8-bd2f00d487fc@linaro.org> Date: Mon, 12 Dec 2022 10:14:20 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 4/7] Move libc_freeres_ptrs and libc_subfreeres to weak functions Content-Language: en-US To: Florian Weimer , Adhemerval Zanella via Libc-alpha Cc: Fangrui Song References: <20221115193159.173838-1-adhemerval.zanella@linaro.org> <20221115193159.173838-5-adhemerval.zanella@linaro.org> <87cz8ouc0j.fsf@oldenburg.str.redhat.com> Organization: Linaro In-Reply-To: <87cz8ouc0j.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: , From: Adhemerval Zanella Netto via Libc-alpha Reply-To: Adhemerval Zanella Netto Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 12/12/22 07:55, Florian Weimer wrote: > * 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.) Indeed you are right and for modern systems is highly unlikely that glibc libcrypto will be used anyways (at least for system I usually check libxcrypt is used instead). I will just remove it.