Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
Description of problem:
Repeating error message about failure to delete from collection:
[Fri Sep 23 10:52:17.022473 2016] [:error] [pid 14825] [client ::1] ModSecurity: collections_remove_stale: Failed deleting collection (name "ip", key "44.33.55.777_17c09ec5cebff2507db855e6cac332d395dd43c7"): Internal error [hostname "192.168.1.2"] [uri "*"] [unique_id "V@TtQHqZvlSpAUCIOTgi@gAAACc"]
Files in SecTmpDir and SecDataDir become very large and may be related to the error above.
-rw-r-----. 1 apache apache 0 Sep 19 16:03 global.dir
-rw-r-----. 1 apache apache 0 Sep 19 16:03 global.pag
-rw-r-----. 1 apache apache 36K Sep 23 11:11 ip.dir
-rw-r-----. 1 apache apache 287M Sep 23 11:11 ip.pag
-rw-r-----. 1 apache apache 96K Sep 23 11:10 resource.dir
-rw-r-----. 1 apache apache 932M Sep 23 11:11 resource.pag
Version-Release number of selected component (if applicable):
mod_security-2.7.3-5.el7
How reproducible: Seems to be reproduced over a period of time or after many requests.
Actual results: .pag files become very large and require manual cleanup.
Expected results: .pag files would be cleaned up automatically and not see "collections_remove_stale: Failed".
Additional info:
Customer seeing this issue has only added this single directive:
SecRule REMOTE_ADDR "@ipMatch 44.33.0.0/16,192.168.1.0/24,10.0.0.0/8" "phase:1,id:'981033',nolog,allow,ctl:ruleEngine=Off,ctl:auditEngine=Off
They also have the stock configuration shipped with mod_security.
I think this issue is related to https://issues.jboss.org/browse/JWS-489. Basically, looks like two threads are trying to delete a stale entry from database but one is winning and the other one throws the "Failed deleting collection" error.
This issue has changed slightly since initially reported. The reason for noticing the issue was that the database was growing very very large. The customer had to stop httpd, remove the mod_security collection files in SecDataDir, and then start httpd back up.
There is already a solution for this in mod_security 2.9.1:
https://github.com/SpiderLabs/ModSecurity/pull/836
The root cause was a bad call to srand before calling rand to determine if garbage collection should run (i.e. the logic that removes expired elements from collection).
Can RHEL 7 mod_security be rebased to 2.9.1 or can that one line change in the pull request above be backported?
(In reply to Robert Bost from comment #4)
> This issue has changed slightly since initially reported. The reason for
> noticing the issue was that the database was growing very very large. The
> customer had to stop httpd, remove the mod_security collection files in
> SecDataDir, and then start httpd back up.
>
> There is already a solution for this in mod_security 2.9.1:
>
> https://github.com/SpiderLabs/ModSecurity/pull/836
>
> The root cause was a bad call to srand before calling rand to determine if
> garbage collection should run (i.e. the logic that removes expired elements
> from collection).
>
> Can RHEL 7 mod_security be rebased to 2.9.1 or can that one line change in
> the pull request above be backported?
Looks like an easy fix since we already have a patch for this. Getting the acks for 7.4 might be harder.
Created attachment 1250868[details]
SRPM for testing purposes
Upstream did not accept the solution in PR#1224 yet. That is because of fears of a performance hit that a solution based on a global mutex locking might cause.
Would it be possible to test the provided SRPM w.r.t. to performance in a real world environment?
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://access.redhat.com/errata/RHBA-2018:0908