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 1744617 - Memory leak in readjournal() when cs.bWorkAroundJournalBug = 1
Summary: Memory leak in readjournal() when cs.bWorkAroundJournalBug = 1
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rsyslog
Version: 7.7
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Jiří Vymazal
QA Contact: Dalibor Pospíšil
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-22 14:28 UTC by Kyle Walker
Modified: 2023-09-07 20:26 UTC (History)
4 users (show)

Fixed In Version: rsyslog-8.24.0-46.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-31 19:10:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2020:1000 0 None None None 2020-03-31 19:10:48 UTC

Description Kyle Walker 2019-08-22 14:28:58 UTC
Description of problem:
 The WorkAroundJournalBug imjournal plugin configuration leads to a memory leak. With enough time and use, the leak grows sufficiently large to cause system outages.

Version-Release number of selected component (if applicable):
 rsyslog-8.24.0-41.el7_7.x86_64

How reproducible:
 Easily

Steps to Reproduce:
1. Remove the "imjournal" plugin configuration options from the /etc/rsyslog.conf and add the applicable module configuration option
    # diff -up /etc/rsyslog.conf.orig /etc/rsyslog.conf
    --- /etc/rsyslog.conf.orig      2019-08-22 10:12:22.152412234 -0400
    +++ /etc/rsyslog.conf   2019-08-21 12:01:53.838303690 -0400
    @@ -7,7 +7,7 @@
     
     # The imjournal module bellow is now used as a message source instead of imuxsock.
     $ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
    -$ModLoad imjournal # provides access to the systemd journal
    +#$ModLoad imjournal # provides access to the systemd journal
     #$ModLoad imklog # reads kernel messages (the same are read from journald)
     #$ModLoad immark  # provides --MARK-- message capability
     
    @@ -40,7 +40,8 @@ $IncludeConfig /etc/rsyslog.d/*.conf
     $OmitLocalLogging on
     
     # File to store the position in the journal
    -$IMJournalStateFile imjournal.state
    +#$IMJournalStateFile imjournal.state
    +module(load="imjournal" StateFile="imjournal.state" WorkAroundJournalBug="on")
     
     
     #### RULES ####

2. Stop the service-initiated rsyslog instance
    # systemctl stop rsyslog

3. Start rsyslog in a valgrind instance with the following flags
    # valgrind --keep-debuginfo=yes --show-leak-kinds=definite --leak-check=full --show-leak-kinds=all -v --log-file=/tmp/valgrind.rsyslog $(which rsyslogd) -n

4. Issue a fairly large amount of "logger" commands to exercise the logging processes, and then stop the valgrind/rsyslog instance
    # for entry in {0..9999}; do logger test-$entry; done && kill $(cat /var/run/syslogd.pid)

5. Verify the output of the /tmp/valgrind.rsyslog log file to verify the amount of definitely lost memory chunks. Specifically within the readjournal() codepath

Actual results:

    ==29126== 5,462,423 bytes in 44,073 blocks are definitely lost in loss record 22 of 22
    ==29126==    at 0x4C29E63: malloc (vg_replace_malloc.c:309)
    ==29126==    by 0x5FB5F6F: __vasprintf_chk (vasprintf_chk.c:80)
    ==29126==    by 0x5FB5E41: __asprintf_chk (asprintf_chk.c:33)
    ==29126==    by 0x6C8E7B0: UnknownInlinedFun (stdio2.h:178)
    ==29126==    by 0x6C8E7B0: sd_journal_get_cursor (sd-journal.c:926)
    ==29126==    by 0x6A7E6C7: readjournal (imjournal.c:414)
    ==29126==    by 0x6A7E6C7: runInput (imjournal.c:691)
    ==29126==    by 0x150443: thrdStarter (threads.c:226)
    ==29126==    by 0x5054EA4: start_thread (pthread_create.c:307)
    ==29126==    by 0x5F9C8CC: clone (clone.S:111)


Expected results:
    <None>


Additional info:
 Though the workaround may not be necessary, it will still be necessary to resolve this memory leak so that users that already deployed the workaround do not experience system outages.

Comment 2 Kyle Walker 2019-08-22 14:56:17 UTC
Whoops! Missed a step in my reproducer. You wont get stacktraces without the applicable debuginfo installed. 

That necessary change results in the following reproducer:

1. Remove the "imjournal" plugin configuration options from the /etc/rsyslog.conf and add the applicable module configuration option
    # diff -up /etc/rsyslog.conf.orig /etc/rsyslog.conf
    --- /etc/rsyslog.conf.orig      2019-08-22 10:12:22.152412234 -0400
    +++ /etc/rsyslog.conf   2019-08-21 12:01:53.838303690 -0400
    @@ -7,7 +7,7 @@
     
     # The imjournal module bellow is now used as a message source instead of imuxsock.
     $ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
    -$ModLoad imjournal # provides access to the systemd journal
    +#$ModLoad imjournal # provides access to the systemd journal
     #$ModLoad imklog # reads kernel messages (the same are read from journald)
     #$ModLoad immark  # provides --MARK-- message capability
     
    @@ -40,7 +40,8 @@ $IncludeConfig /etc/rsyslog.d/*.conf
     $OmitLocalLogging on
     
     # File to store the position in the journal
    -$IMJournalStateFile imjournal.state
    +#$IMJournalStateFile imjournal.state
    +module(load="imjournal" StateFile="imjournal.state" WorkAroundJournalBug="on")
     
     
     #### RULES ####

2. Stop the service-initiated rsyslog instance
    # systemctl stop rsyslog

3. Install the applicable debuginfo
    # debuginfo-install rsyslog

4. Start rsyslog in a valgrind instance with the following flags
    # valgrind --keep-debuginfo=yes --show-leak-kinds=definite --leak-check=full --show-leak-kinds=all -v --log-file=/tmp/valgrind.rsyslog $(which rsyslogd) -n

5. Issue a fairly large amount of "logger" commands to exercise the logging processes, and then stop the valgrind/rsyslog instance
    # for entry in {0..9999}; do logger test-$entry; done && kill $(cat /var/run/syslogd.pid)

6. Verify the output of the /tmp/valgrind.rsyslog log file to verify the amount of definitely lost memory chunks. Specifically within the readjournal() codepath


Sorry for the confusion!

Comment 17 errata-xmlrpc 2020-03-31 19:10:09 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://access.redhat.com/errata/RHSA-2020:1000


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