Bug 847339 - logrotate ACL fix race condition
logrotate ACL fix race condition
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: logrotate (Show other bugs)
6.3
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Jan Kaluža
Tomas Dolezal
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-10 11:31 EDT by Daniel Crisman
Modified: 2014-01-30 04:21 EST (History)
4 users (show)

See Also:
Fixed In Version: logrotate-3.7.8-17.el6
Doc Type: Bug Fix
Doc Text:
Cause: Both acl_set_fd() and fchmod() functions has been called to set the log files permissions. Consequence: There was a race condition where the log file could have unsafe permissions for short time during its creation. Fix: Only one of those functions is called now depending on directives combination used in configuration file. Result: Race condition between these two functions is not possible anymore.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-18 05:35:14 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch (3.97 KB, patch)
2012-08-13 08:07 EDT, Jan Kaluža
no flags Details | Diff

  None (edit)
Description Daniel Crisman 2012-08-10 11:31:37 EDT
Description of problem:
Looks like a race condition in ACL change.

Version-Release number of selected component (if applicable):
From logrotate-3.7.8-15.el6.src.rpm

In logrotate.c between
    Inside Line 1259 at line 258
        rename() inside createOutputFile()
and
    Line 1266 acl_set_fd
Has the same style of race condition as
bug 680798 (CVE-2011-1098)

Might be similar issues before the other uses of acl_set_fd.
Comment 2 Jan Kaluža 2012-08-13 08:06:56 EDT
Proposed patch should fix this issue if I'm right. It just moves acl_set_fd before the rename. I will do something like that in logrotate upstream version too and merge it with patch Bug 847338 patch.
Comment 3 Jan Kaluža 2012-08-13 08:07:27 EDT
Created attachment 603970 [details]
patch
Comment 4 Daniel Crisman 2012-08-13 17:18:04 EDT
That patch reverses the race to between the line 256 acl_set_fd and the line 267 fchmod.  But it still has a race condition.

Also acl_set_fd will never get seen outside that race period so the ACL fix will not be there.
Comment 5 Jan Kaluža 2012-08-14 04:02:50 EDT
I'm not sure I see the race condition in the patched code. Can you please explain it more?
Comment 6 Daniel Crisman 2012-08-14 13:35:11 EDT
chmod and setfacl change overlapping data.  If you do one and then the other in either order it is possible to have between the first call and the second more permissions then then end file has.
Comment 7 Jan Kaluža 2012-09-03 07:45:16 EDT
This is fixed upstream and the patches can be backported. If "create" directive is used, fchmod is used. Otherwise, acl_set_fd is used.

https://fedorahosted.org/logrotate/changeset/382
https://fedorahosted.org/logrotate/changeset/383
https://fedorahosted.org/logrotate/changeset/384
https://fedorahosted.org/logrotate/changeset/385
Comment 8 RHEL Product and Program Management 2012-09-07 01:12:03 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.
Comment 15 errata-xmlrpc 2013-07-18 05:35:14 EDT
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.

http://rhn.redhat.com/errata/RHBA-2013-1095.html

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