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:
logrotate crash when using long dateformat
Version-Release number of selected component (if applicable):
Seen using logrotate-3.7.8-23.el6.x86_64 but also I could not see the (Fedora and upstream) patch to fix this in -26.
How reproducible:
valgrind reports errors every time, crashes are sporadic and not seen on every run.
Steps to Reproduce:
1. Use a logrotate conf file with the following parameters for a file:
dateext
dateformat -alonghostname01-%Y%m%d-%s
2. Run logrotate under valgrind when the file is rotated.
3. Or run logrotate to rotate the file repeatedly and generate a backtrace from the core.
Actual results:
valgrind /usr/sbin/logrotate -v -s ~/logrotate/test.status ~/logrotate/test.conf
...
reading config file ~/logrotate/test.conf
reading config info for ~/logrotate/test/*.log
compress_options is now -1
Handling 1 logs
rotating pattern: ~/logrotate/test/*.log 1048576 bytes (14 rotations)
empty log files are not rotated, old logs are removed
considering log ~/logrotate/test/file.log
log needs rotating
rotating log ~/logrotate/test/file.log, log->rotateCount is 14
Converted ' -alonghostname01-%Y-%s' -> '-alonghostname01-%Y-%s'
dateext suffix '-alonghostname01-2016-1471886664'
glob pattern '-alonghostname-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding logs to compress failed
glob finding old rotated logs failed
==29193== Invalid write of size 1
==29193== at 0x316D2FFAC2: __vsprintf_chk (in /lib64/libc-2.12.so)
==29193== by 0x316D2FF9FE: __sprintf_chk (in /lib64/libc-2.12.so)
==29193== by 0x4059D5: ??? (in /usr/sbin/logrotate)
==29193== by 0x40644F: ??? (in /usr/sbin/logrotate)
==29193== by 0x406B6E: ??? (in /usr/sbin/logrotate)
==29193== by 0x316D21ED1C: (below main) (in /lib64/libc-2.12.so)
==29193== Address 0x4c4819b is 0 bytes after a block of size 75 alloc'd
==29193== at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==29193== by 0x404FF3: ??? (in /usr/sbin/logrotate)
==29193== by 0x40644F: ??? (in /usr/sbin/logrotate)
==29193== by 0x406B6E: ??? (in /usr/sbin/logrotate)
==29193== by 0x316D21ED1C: (below main) (in /lib64/libc-2.12.so)
gdb -c core.1471881601_62_62_6_52839_logrotate /usr/sbin/logrotate
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-83.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/sbin/logrotate...(no debugging symbols found)...done.
[New Thread 52839]
Reading symbols from /lib64/libpopt.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib64/libpopt.so.0
Reading symbols from /lib64/libselinux.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libselinux.so.1
Reading symbols from /lib64/libacl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libacl.so.1
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libattr.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libattr.so.1
Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libgcc_s.so.1
Core was generated by `/usr/sbin/logrotate -s /var/run/logrotate.status REMOVED'.
Program terminated with signal 6, Aborted.
#0 0x0000003df1e325e5 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install logrotate-3.7.8-23.el6.x86_64
(gdb) symbol-file /usr/lib/debug/usr/sbin/logrotate.debug
Reading symbols from /usr/lib/debug/usr/sbin/logrotate.debug...done.
(gdb) bt
#0 0x0000003df1e325e5 in raise () from /lib64/libc.so.6
#1 0x0000003df1e33dc5 in abort () from /lib64/libc.so.6
#2 0x0000003df1e704f7 in __libc_message () from /lib64/libc.so.6
#3 0x0000003df1e75f3e in malloc_printerr () from /lib64/libc.so.6
#4 0x0000003df1e78dd0 in _int_free () from /lib64/libc.so.6
#5 0x00000000004060bf in rotateLogSet (log=<value optimized out>, force=<value optimized out>) at logrotate.c:1573
#6 0x0000000000406b6f in main (argc=<value optimized out>, argv=<value optimized out>) at logrotate.c:2017
/usr/src/debug/logrotate-3.7.8/logrotate.c
for (i = 0; i < log->numFiles; i++) {
free(rotNames[i]->firstRotated); <- line 1573
free(rotNames[i]->disposeName);
free(rotNames[i]->finalName);
free(rotNames[i]->dirName);
free(rotNames[i]->baseName);
free(rotNames[i]);
}
Expected results:
No valgrind errors.
No heap corruption due to too small memory allocation.
Does not crash.
Additional info:
Fix:
https://fedorahosted.org/logrotate/ticket/50https://fedorahosted.org/logrotate/changeset/474https://github.com/logrotate/logrotate/commit/768b23c0bd94f973abf108f6e2cf4138c426f140https://fedorahosted.org/logrotate/browser/tags/r3-9-1/CHANGES#L4
Workaround:
Use shorter dateformat.
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-2017-0625.html
Description of problem: logrotate crash when using long dateformat Version-Release number of selected component (if applicable): Seen using logrotate-3.7.8-23.el6.x86_64 but also I could not see the (Fedora and upstream) patch to fix this in -26. How reproducible: valgrind reports errors every time, crashes are sporadic and not seen on every run. Steps to Reproduce: 1. Use a logrotate conf file with the following parameters for a file: dateext dateformat -alonghostname01-%Y%m%d-%s 2. Run logrotate under valgrind when the file is rotated. 3. Or run logrotate to rotate the file repeatedly and generate a backtrace from the core. Actual results: valgrind /usr/sbin/logrotate -v -s ~/logrotate/test.status ~/logrotate/test.conf ... reading config file ~/logrotate/test.conf reading config info for ~/logrotate/test/*.log compress_options is now -1 Handling 1 logs rotating pattern: ~/logrotate/test/*.log 1048576 bytes (14 rotations) empty log files are not rotated, old logs are removed considering log ~/logrotate/test/file.log log needs rotating rotating log ~/logrotate/test/file.log, log->rotateCount is 14 Converted ' -alonghostname01-%Y-%s' -> '-alonghostname01-%Y-%s' dateext suffix '-alonghostname01-2016-1471886664' glob pattern '-alonghostname-[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' glob finding logs to compress failed glob finding old rotated logs failed ==29193== Invalid write of size 1 ==29193== at 0x316D2FFAC2: __vsprintf_chk (in /lib64/libc-2.12.so) ==29193== by 0x316D2FF9FE: __sprintf_chk (in /lib64/libc-2.12.so) ==29193== by 0x4059D5: ??? (in /usr/sbin/logrotate) ==29193== by 0x40644F: ??? (in /usr/sbin/logrotate) ==29193== by 0x406B6E: ??? (in /usr/sbin/logrotate) ==29193== by 0x316D21ED1C: (below main) (in /lib64/libc-2.12.so) ==29193== Address 0x4c4819b is 0 bytes after a block of size 75 alloc'd ==29193== at 0x4A06A2E: malloc (vg_replace_malloc.c:270) ==29193== by 0x404FF3: ??? (in /usr/sbin/logrotate) ==29193== by 0x40644F: ??? (in /usr/sbin/logrotate) ==29193== by 0x406B6E: ??? (in /usr/sbin/logrotate) ==29193== by 0x316D21ED1C: (below main) (in /lib64/libc-2.12.so) gdb -c core.1471881601_62_62_6_52839_logrotate /usr/sbin/logrotate GNU gdb (GDB) Red Hat Enterprise Linux (7.2-83.el6) Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /usr/sbin/logrotate...(no debugging symbols found)...done. [New Thread 52839] Reading symbols from /lib64/libpopt.so.0...(no debugging symbols found)...done. Loaded symbols for /lib64/libpopt.so.0 Reading symbols from /lib64/libselinux.so.1...(no debugging symbols found)...done. Loaded symbols for /lib64/libselinux.so.1 Reading symbols from /lib64/libacl.so.1...(no debugging symbols found)...done. Loaded symbols for /lib64/libacl.so.1 Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done. Loaded symbols for /lib64/libc.so.6 Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done. Loaded symbols for /lib64/libdl.so.2 Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done. Loaded symbols for /lib64/ld-linux-x86-64.so.2 Reading symbols from /lib64/libattr.so.1...(no debugging symbols found)...done. Loaded symbols for /lib64/libattr.so.1 Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols found)...done. Loaded symbols for /lib64/libgcc_s.so.1 Core was generated by `/usr/sbin/logrotate -s /var/run/logrotate.status REMOVED'. Program terminated with signal 6, Aborted. #0 0x0000003df1e325e5 in raise () from /lib64/libc.so.6 Missing separate debuginfos, use: debuginfo-install logrotate-3.7.8-23.el6.x86_64 (gdb) symbol-file /usr/lib/debug/usr/sbin/logrotate.debug Reading symbols from /usr/lib/debug/usr/sbin/logrotate.debug...done. (gdb) bt #0 0x0000003df1e325e5 in raise () from /lib64/libc.so.6 #1 0x0000003df1e33dc5 in abort () from /lib64/libc.so.6 #2 0x0000003df1e704f7 in __libc_message () from /lib64/libc.so.6 #3 0x0000003df1e75f3e in malloc_printerr () from /lib64/libc.so.6 #4 0x0000003df1e78dd0 in _int_free () from /lib64/libc.so.6 #5 0x00000000004060bf in rotateLogSet (log=<value optimized out>, force=<value optimized out>) at logrotate.c:1573 #6 0x0000000000406b6f in main (argc=<value optimized out>, argv=<value optimized out>) at logrotate.c:2017 /usr/src/debug/logrotate-3.7.8/logrotate.c for (i = 0; i < log->numFiles; i++) { free(rotNames[i]->firstRotated); <- line 1573 free(rotNames[i]->disposeName); free(rotNames[i]->finalName); free(rotNames[i]->dirName); free(rotNames[i]->baseName); free(rotNames[i]); } Expected results: No valgrind errors. No heap corruption due to too small memory allocation. Does not crash. Additional info: Fix: https://fedorahosted.org/logrotate/ticket/50 https://fedorahosted.org/logrotate/changeset/474 https://github.com/logrotate/logrotate/commit/768b23c0bd94f973abf108f6e2cf4138c426f140 https://fedorahosted.org/logrotate/browser/tags/r3-9-1/CHANGES#L4 Workaround: Use shorter dateformat.