Bug 21502 - Excessive memory allocation due to LD_HWCAP_MASK
Summary: Excessive memory allocation due to LD_HWCAP_MASK
Status: RESOLVED DUPLICATE of bug 21391
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Siddhesh Poyarekar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-18 20:17 UTC by Siddhesh Poyarekar
Modified: 2017-05-25 09:14 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Siddhesh Poyarekar 2017-05-18 20:17:51 UTC
It was discovered that setting LD_HWCAP_MASK to a large numeric value results in significant memory allocation in the dynamic linker and sometimes results in malloc failure, causing the program to crash.  A simple test like this demonstrates the problem:

LD_HWCAP_MASK=0xffffffffffffffff /bin/true

On a system with constrained overcommit, this should fail with the following error:

/bin/true: error while loading shared libraries: cannot create capability list: Cannot allocate memory

or at least take a very long time to finish.
Comment 1 Andreas Schwab 2017-05-22 12:19:28 UTC
_dl_important_hwcaps wants to create all combinations of the unmasked hwcap strings.  On x86_64 there are 28 hwcaps, computing those 2^28 combinations takes its time.
Comment 2 Siddhesh Poyarekar 2017-05-22 18:31:42 UTC
HJ's patch fixed that by setting dl_hwcap to 0 since x86 uses the cpu_features struct.  So this is fixed by bug #21391.

*** This bug has been marked as a duplicate of bug 21391 ***