mbox series

[0/4] elf: Fix hwcaps string size overestimation

Message ID 20220905200652.d69204581d15c64647da5cd2@otheo.eu
Headers show
Series elf: Fix hwcaps string size overestimation | expand

Message

Javier Pello Sept. 5, 2022, 6:06 p.m. UTC
Dear list,

Here is a series of patches related to the construction of the hwcaps
power set strings in function _dl_important_hwcaps in elf/dl-hwcaps.c.

The first patch is the main one. It fixes an overallocation of memory
for the subdirectory strings in _dl_important_hwcaps that was introduced
when adding glibc-hwcaps support for LD_LIBRARY_PATH. This overallocation
does not have any user-visible impact (extra space is simply unused) but
it would be nice to have it fixed.

The other patches are small changes, also in _dl_important_hwcaps, that
I have been carrying around for some time now, and I am submitting them
in case there is interest in having them merged. The last one improves
generation of the hwcaps power set strings by using a single pass over
all needed strings, instead of two, resulting in shorter code.

The third and fourth patches could conceivably be squashed together.

Regards,
Javier

Javier Pello (4):
  elf: Fix hwcaps string size overestimation
  elf: Simplify hwcaps masked value bit counting
  elf: Remove unneeded conditional in _dl_important_hwcaps
  elf: Simplify hwcaps power set string construction

 elf/dl-hwcaps.c | 98 +++++++++++++++++++------------------------------
 1 file changed, 38 insertions(+), 60 deletions(-)

Comments

Florian Weimer Sept. 6, 2022, 7:35 a.m. UTC | #1
* Javier Pello:

> Here is a series of patches related to the construction of the hwcaps
> power set strings in function _dl_important_hwcaps in elf/dl-hwcaps.c.

We deprecated this mechanism in glibc 2.33.  I think it's time to remove
it in glibc 2.37.

Since you are evidently familiar with the code now, would like to
implement the removal?

Thanks,
Florian
Javier Pello Sept. 6, 2022, 6:12 p.m. UTC | #2
> We deprecated this mechanism in glibc 2.33.  I think it's time
> to remove it in glibc 2.37.
> 
> Since you are evidently familiar with the code now,

That may be a bit of a stretch. :-)

> would like to implement the removal?

What would this removal be? Do you want _dl_important_hwcaps to
return only the glibc-hwcaps subdirectories, and not the legacy
hwcaps power set subdirectories? That should be doable.

In any case, even if hwcaps power set support is removed, I think
that at least my first patch sould be applied first. If the removal
were to be reverted later, or if somebody looked at the code as it
was before the removal for whatever reason, I think that it would
be better if it had been left in the best possible shape, at least
with the overallocation bug fixed.

Regards,
Javier
Florian Weimer Sept. 8, 2022, 11:23 a.m. UTC | #3
* Javier Pello:

>> We deprecated this mechanism in glibc 2.33.  I think it's time
>> to remove it in glibc 2.37.
>> 
>> Since you are evidently familiar with the code now,
>
> That may be a bit of a stretch. :-)
>
>> would like to implement the removal?
>
> What would this removal be? Do you want _dl_important_hwcaps to
> return only the glibc-hwcaps subdirectories, and not the legacy
> hwcaps power set subdirectories? That should be doable.

Exactly.  And in separate commits, update ldconfig and the cache reading
logic in elf/dl-cache.c.

> In any case, even if hwcaps power set support is removed, I think
> that at least my first patch sould be applied first. If the removal
> were to be reverted later, or if somebody looked at the code as it
> was before the removal for whatever reason, I think that it would
> be better if it had been left in the best possible shape, at least
> with the overallocation bug fixed.

Agreed.

Thanks,
Florian