Bug 756187 - AVC for systemd-tmpfile on /var/log/wtmp and btmp
Summary: AVC for systemd-tmpfile on /var/log/wtmp and btmp
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-22 21:51 UTC by Mads Kiilerich
Modified: 2012-03-19 14:04 UTC (History)
1 user (show)

Fixed In Version: selinux-policy-3.10.0-69.fc16
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-30 01:01:48 UTC
Type: ---


Attachments (Terms of Use)

Description Mads Kiilerich 2011-11-22 21:51:41 UTC
With selinux-policy-targeted-3.10.0-56.fc16 and systemd-37-3.fc16 on a live usb I get

[   12.648435] systemd-tmpfiles[906]: Successfully loaded SELinux database in 8ms 920us, size on heap is 479K.
[   12.705021] type=1400 audit(1321997744.213:4): avc:  denied  { relabelfrom } for  pid=906 comm="systemd-tmpfile" name="wtmp" dev=dm-0 ino=20228 scontext=system_u:system_r:systemd_t
[   12.705145] systemd-tmpfiles[906]: Unable to fix label of /var/log/wtmp: Permission denied
[   12.705964] type=1400 audit(1321997744.214:5): avc:  denied  { relabelfrom } for  pid=906 comm="systemd-tmpfile" name="btmp" dev=dm-0 ino=20230 scontext=system_u:system_r:systemd_t
[   12.706054] systemd-tmpfiles[906]: Unable to fix label of /var/log/btmp: Permission denied

As expected the files are
-rw-------. root utmp system_u:object_r:faillog_t:s0   /var/log/btmp
-rw-rw-r--. root utmp system_u:object_r:wtmp_t:s0      /var/log/wtmp

Comment 1 Daniel Walsh 2011-11-23 18:07:14 UTC
You are truncating the AVC.

Could you attach the output of 

ausearch -m avc

Comment 2 Mads Kiilerich 2011-11-23 18:19:05 UTC
This is all I get in dmesg.

This is on a live image without syslog and without audit, so retrieving more information is not completely trivial.

Is it necessary, or can you share some thoughts about what the problem could be and what I could investigate without creating a new and bigger image?

Comment 3 Mads Kiilerich 2011-11-25 14:57:44 UTC
I can reproduce on a running system by removing /var/log/?tmp and creating them again running the commands from initscripts %post. 

That creates the files as
-rw-------. root utmp unconfined_u:object_r:faillog_t:s0 btmp
-rw-rw-r--. root utmp unconfined_u:object_r:wtmp_t:s0  wtmp

On next boot I get the AVCs mentioned above when systemd try to relabel to
-rw-------. root utmp system_u:object_r:faillog_t:s0   btmp
-rw-rw-r--. root utmp system_u:object_r:wtmp_t:s0      wtmp

It seems like the policy doesn't care as much about the SElinux user as systemd does?


This happens so early that audit ausearch doesn't catch it. If that is surprising then there must be some other bug lurking here.

Comment 4 Miroslav Grepl 2011-11-28 13:29:39 UTC
Well, you got it. The problem will be with the user identity. We will need to add

domain_obj_id_change_exemption(systemd_tmpfiles_t)

for constraint issue. We allow relabel of these files.

Comment 5 Miroslav Grepl 2011-12-05 09:05:24 UTC
Fixed in selinux-policy-3.10.0-65.fc16

Comment 6 Fedora Update System 2011-12-25 22:41:42 UTC
selinux-policy-3.10.0-69.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/selinux-policy-3.10.0-69.fc16

Comment 7 Fedora Update System 2011-12-26 19:18:48 UTC
Package selinux-policy-3.10.0-69.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-69.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2011-17464/selinux-policy-3.10.0-69.fc16
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2011-12-30 01:01:48 UTC
selinux-policy-3.10.0-69.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Mads Kiilerich 2012-03-19 11:08:15 UTC
I see indications of a similar problem with selinux-policy-targeted-3.10.0-75.fc16 and systemd-37-15.fc16 :

[    9.502946] systemd-tmpfiles[944]: Successfully loaded SELinux database in 23ms 798us, size on heap is 365K.
[    9.607769] type=1400 audit(1331916365.122:3): avc:  denied  { relabelfrom } for  pid=944 comm="systemd-tmpfile" name="wtmp" dev=dm-0 ino=4349 scontext=system_u:system_r:systemd_tmpfiles_t:s0 tcontext=unconfined_u:object_r:wtmp_t:s0 tclass=file
[    9.609063] type=1400 audit(1331916365.124:4): avc:  denied  { relabelfrom } for  pid=944 comm="systemd-tmpfile" name="btmp" dev=dm-0 ino=4351 scontext=system_u:system_r:systemd_tmpfiles_t:s0 tcontext=unconfined_u:object_r:faillog_t:s0 tclass=file

I will file a new bug if I can collect some further hints of what is going on.

Comment 10 Mads Kiilerich 2012-03-19 14:04:17 UTC
No - that _must_ be caused by running some old version. Can't reproduce.


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