RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1144132 - calloc in dl-reloc.c computes size incorrectly
Summary: calloc in dl-reloc.c computes size incorrectly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: glibc
Version: 6.5
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Carlos O'Donell
QA Contact: Arjun Shankar
URL:
Whiteboard:
Depends On:
Blocks: 1138860
TreeView+ depends on / blocked
 
Reported: 2014-09-18 18:23 UTC by Ben Woodard
Modified: 2016-11-24 12:20 UTC (History)
8 users (show)

Fixed In Version: glibc-2.12-1.158.el6
Doc Type: Bug Fix
Doc Text:
When the dynamic loader is profiling an application it maintains an internal cache of pre-computed data. This size of this cache of data was being incorrectly computed as being much larger than required. This large allocation could cause some profiled applications to fail with out of memory errors. The dynamic loader has been corrected to allocate only the required amount of storage for the internal cache. Applications should no longer fail with out of memory errors for this particular situation.
Clone Of:
: 1144133 (view as bug list)
Environment:
Last Closed: 2015-07-22 06:14:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1286 0 normal SHIPPED_LIVE glibc bug fix and enhancement update 2015-07-20 17:50:22 UTC
Sourceware 17411 0 None None None Never

Description Ben Woodard 2014-09-18 18:23:58 UTC
This bug was discovered by Matt LeGendre who works at LLNL. He pointed out the problem and corrected my patch to the problem. It seems to exist in quite a range of glibc versions. The problem was discovered in RHEL6's glibc and it still exists in RHEL7 and upstream.

In elf/dl-reloc.c the AUDIT code does a calloc of a library's  DT_PLTRELSZ*sizeof(struct reloc_result) (this is the one we're seeing making ~300MB of allocations).  It's treating the DT_PLTRELSZ as a count of PLTREL entries, but DT_PLTRELSZ is the size in bytes of the PLTREL entries.  So it's doing a much larger memory allocation than necessary.

I looked and the code is the same in RHEL6,7, and upstream glibc.
He suggested a patch like:

diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index d2c6dac..0c85f08 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -280,7 +280,8 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
          }
 
        l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]),
-                                   l->l_info[DT_PLTRELSZ]->d_un.d_val);
+                                   l->l_info[DT_PLTRELSZ]->d_un.d_val /
+                                   (l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA ? sizeof(ElfW(Rela)) : sizeof(ElfW(Rel))));
        if (l->l_reloc_result == NULL)
          {
            errstring = N_("\

Comment 8 errata-xmlrpc 2015-07-22 06:14:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1286.html


Note You need to log in before you can comment on or make changes to this bug.