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 1861301 - Huge memory leak in probe_rpmverifyfile
Summary: Huge memory leak in probe_rpmverifyfile
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: openscap
Version: 8.2
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: 8.0
Assignee: Jan Černý
QA Contact: Matus Marhefka
Jan Fiala
URL:
Whiteboard:
: 1882160 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-28 09:13 UTC by Renaud Métrich
Modified: 2020-11-04 02:30 UTC (History)
6 users (show)

Fixed In Version: openscap-1.3.3-4.el8
Doc Type: Bug Fix
Doc Text:
.OpenSCAP no longer crashes after evaluating large systems Previously, the OpenSCAP scanner caused memory leaks when evaluating `rpmverifyfile` OVAL tests. As a consequence, the scanner crashed during evaluation of systems with large numbers of files. This affected the Payment Card Industry Data Security Standard (PCI-DSS) and Essential Eight RHEL 8 security profiles included in the `scap-security-guide` package. This update removes the memory leak, and as a result, reduces memory requirements of the `rpmverifyfile` rule to a level recommended for RHEL 8 systems.
Clone Of:
Environment:
Last Closed: 2020-11-04 02:29:44 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:4623 0 None None None 2020-11-04 02:29:47 UTC

Description Renaud Métrich 2020-07-28 09:13:48 UTC
This bug was initially created as a copy of Bug #1861300

I am copying this bug because: 

From plain looking at the code, the issue is still present on RHEL8.2.
The source file is now named "rpmverifyfile_probe.c".

Description of problem:

A huge memory leak is present in probe_rpmverifyfile, causing various issues on the system when executing oscap, typically OOMKiller starts killing processes and services.

On a small system with 450 RPMs, the memory consumed grows up to 900 MB!

    ==1668== 901,115,904 bytes in 219,999 blocks are definitely lost in loss
    record 77 of 77
    ==1668==    at 0x4C29F73: malloc (vg_replace_malloc.c:309)
    ==1668==    by 0x749B93D: realpath@@GLIBC_2.3 (canonicalize.c:78)
    ==1668==    by 0x10EC5D: UnknownInlinedFun (stdlib.h:48)
    ==1668==    by 0x10EC5D: rpmverify_collect (rpmverifyfile.c:249)
    ==1668==    by 0x10EC5D: probe_main (rpmverifyfile.c:546)
    ==1668==    by 0x110C4F: probe_worker (worker.c:954)
    ==1668==    by 0x11074B: probe_worker_runfn (worker.c:56)
    ==1668==    by 0x7243EA4: start_thread (pthread_create.c:307)
    ==1668==    by 0x75568DC: clone (clone.S:111)
    
    ==1668== LEAK SUMMARY:
    ==1668==    definitely lost: 901,150,675 bytes in 224,438 blocks


Version-Release number of selected component (if applicable):

openscap-1.2.17-9.el7_8 and later


How reproducible:

Always


Steps to Reproduce:
1. Start probe_rpmverifyfile under Valgrind

  # /usr/bin/valgrind --tool=memcheck --leak-check=yes /usr/libexec/openscap/probe_rpmverifyfile

2. Send the various orders on stdin one at a time, wait for result

First: (fast)
(#d8:seap.msg#d3::id#d0((#d20:rpmverifyfile_object#d3::id#d47:oval:ssg-object_files_fail_user_ownership:obj:1#d13::oval_version#d4:5.11)((#d4:name#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d5:epoch#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d7:version#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d7:release#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d4:arch#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d8:filepath#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d6:filter#d7::action#d2)#d46:oval:ssg-state_files_fail_user_ownership:ste:1)((#d9:behaviors#d6::nomd5#d4:true#d13::noghostfiles#d4:true))))

Second: (slow)
(#d8:seap.cmd#d3::id#d0#d9::reply_id#d0#d6::class#d3:usr#d5::type#d5:async#d1(((#d19:rpmverifyfile_state#d3::id#d46:oval:ssg-state_files_fail_user_ownership:ste:1#d9::operator#d1)((#d17:ownership_differs#d10::operation#d5#d10::var_check#d1#d13::entity_check#d1#d16::check_existence#d3)#d4:fail))))

Third: (fast)
(#d8:seap.msg#d3::id#d1((#d20:rpmverifyfile_object#d3::id#d48:oval:ssg-object_files_fail_group_ownership:obj:1#d13::oval_version#d4:5.11)((#d4:name#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d5:epoch#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d7:version#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d7:release#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d4:arch#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d8:filepath#d10::operation#d11#d10::var_check#d1)#d2:.*)((#d6:filter#d7::action#d2)#d47:oval:ssg-state_files_fail_group_ownership:ste:1)((#d9:behaviors#d6::nomd5#d4:true#d13::noghostfiles#d4:true))))

Fourth: (slow)
(#d8:seap.cmd#d3::id#d1#d9::reply_id#d1#d6::class#d3:usr#d5::type#d5:async#d1(((#d19:rpmverifyfile_state#d3::id#d47:oval:ssg-state_files_fail_group_ownership:ste:1#d9::operator#d1)((#d13:group_differs#d10::operation#d5#d10::var_check#d1#d13::entity_check#d1#d16::check_existence#d3)#d4:fail))))


Actual results:

High memory consumption

Expected results:

Small memory consumption (~200MB)


Additional info:

This is a critical issue, system can get down due to this.

Comment 1 Jan Černý 2020-07-28 11:57:50 UTC
The bug is reproducible also with current upstream maint-1.3 branch as of HEAD 802eb801dd083a67bd64d4f9c711ba1426e626cb.

It seems to be triggered by any rule that uses rpmverifyfile probe, eg. xccdf_org.ssgproject.content_rule_rpm_verify_permissions, xccdf_org.ssgproject.content_rule_rpm_verify_ownership.

For example, on Fedora 32:

oscap xccdf eval --profile standard --rule xccdf_org.ssgproject.content_rule_rpm_verify_permissions /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml

Valgrind reports the same leak:

==400443== 
==400443== 352,256 bytes in 86 blocks are possibly lost in loss record 352 of 353
==400443==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==400443==    by 0x51F23A6: realpath@@GLIBC_2.3 (in /usr/lib64/libc-2.31.so)
==400443==    by 0x489F8EA: oscap_realpath (util.c:251)
==400443==    by 0x495E766: rpmverify_collect (rpmverifyfile_probe.c:248)
==400443==    by 0x495F4D8: rpmverifyfile_probe_main (rpmverifyfile_probe.c:543)
==400443==    by 0x493560F: probe_worker (worker.c:1090)
==400443==    by 0x4932F87: probe_worker_runfn (worker.c:81)
==400443==    by 0x4CDA431: start_thread (in /usr/lib64/libpthread-2.31.so)
==400443==    by 0x52A99D2: clone (in /usr/lib64/libc-2.31.so)
==400443== 
==400443== 2,359,775,232 bytes in 576,117 blocks are definitely lost in loss record 353 of 353
==400443==    at 0x483A809: malloc (vg_replace_malloc.c:307)
==400443==    by 0x51F23A6: realpath@@GLIBC_2.3 (in /usr/lib64/libc-2.31.so)
==400443==    by 0x489F8EA: oscap_realpath (util.c:251)
==400443==    by 0x495E766: rpmverify_collect (rpmverifyfile_probe.c:248)
==400443==    by 0x495F4D8: rpmverifyfile_probe_main (rpmverifyfile_probe.c:543)
==400443==    by 0x493560F: probe_worker (worker.c:1090)
==400443==    by 0x4932F87: probe_worker_runfn (worker.c:81)
==400443==    by 0x4CDA431: start_thread (in /usr/lib64/libpthread-2.31.so)
==400443==    by 0x52A99D2: clone (in /usr/lib64/libc-2.31.so)

Comment 13 Jan Černý 2020-09-24 12:19:24 UTC
*** Bug 1882160 has been marked as a duplicate of this bug. ***

Comment 19 errata-xmlrpc 2020-11-04 02:29:44 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 (openscap bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2020:4623


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