public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
	Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: Fangrui Song <maskray@google.com>
Subject: Re: [PATCH 4/7] Move libc_freeres_ptrs and libc_subfreeres to weak functions
Date: Mon, 12 Dec 2022 10:14:20 -0300	[thread overview]
Message-ID: <6e705640-ec79-ed73-3ca8-bd2f00d487fc@linaro.org> (raw)
In-Reply-To: <87cz8ouc0j.fsf@oldenburg.str.redhat.com>



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.

  reply	other threads:[~2022-12-12 13:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 19:31 [PATCH 0/7] Fixing remaining lld issues Adhemerval Zanella
2022-11-15 19:31 ` [PATCH 1/7] configure: Move locale tools early Adhemerval Zanella
2022-11-15 19:31 ` [PATCH 2/7] elf: Do not assume symbol order on tst-audit25{a,b} Adhemerval Zanella
2022-12-12 12:36   ` Adhemerval Zanella Netto
2022-11-15 19:31 ` [PATCH 3/7] stdlib: Move _IO_cleanup to call_function_static_weak Adhemerval Zanella
2022-12-12 10:52   ` Florian Weimer
2022-12-13 16:52     ` Joseph Myers
2022-11-15 19:31 ` [PATCH 4/7] Move libc_freeres_ptrs and libc_subfreeres to weak functions Adhemerval Zanella
2022-12-12 10:55   ` Florian Weimer
2022-12-12 13:14     ` Adhemerval Zanella Netto [this message]
2022-12-12 10:58   ` Florian Weimer
2022-12-12 13:16     ` Adhemerval Zanella Netto
2022-12-12 11:00   ` Florian Weimer
2022-12-12 13:49     ` Adhemerval Zanella Netto
2022-12-12 14:05       ` Florian Weimer
2022-12-12 14:16         ` Adhemerval Zanella Netto
2022-12-12 15:39           ` Florian Weimer
2022-12-12 11:05   ` Andreas Schwab
2022-12-12 13:49     ` Adhemerval Zanella Netto
2022-12-12 11:08   ` Florian Weimer
2022-12-12 13:51     ` Adhemerval Zanella Netto
2022-11-15 19:31 ` [PATCH 5/7] libio: Remove the usage of __libc_IO_vtables Adhemerval Zanella
2022-12-12 11:40   ` Florian Weimer
2022-11-15 19:31 ` [PATCH 6/7] Remove --with-default-link configure option Adhemerval Zanella
2022-11-15 19:31 ` [PATCH 7/7] Remove set-hooks.h from generic includes Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e705640-ec79-ed73-3ca8-bd2f00d487fc@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).