Bug 809189 - SELinux is preventing /bin/systemd-tmpfiles from 'setattr' accesses on the directory regression.
SELinux is preventing /bin/systemd-tmpfiles from 'setattr' accesses on the di...
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: selinux-policy (Show other bugs)
16
x86_64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Grepl
Fedora Extras Quality Assurance
abrt_hash:1fe7c66503cfedeb3b925bc527e...
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-02 13:27 EDT by Donald Cohen
Modified: 2013-02-13 13:54 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-13 13:54:20 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Donald Cohen 2012-04-02 13:27:26 EDT
libreport version: 2.0.8
executable:     /usr/bin/python
hashmarkername: setroubleshoot
kernel:         3.3.0-8.fc16.x86_64
reason:         SELinux is preventing /bin/systemd-tmpfiles from 'setattr' accesses on the directory regression.
time:           Mon 02 Apr 2012 10:25:55 AM PDT

description:
:SELinux is preventing /bin/systemd-tmpfiles from 'setattr' accesses on the directory regression.
:
:*****  Plugin catchall (100. confidence) suggests  ***************************
:
:If you believe that systemd-tmpfiles should be allowed setattr access on the regression directory by default.
:Then you should report this as a bug.
:You can generate a local policy module to allow this access.
:Do
:allow this access for now by executing:
:# grep systemd-tmpfile /var/log/audit/audit.log | audit2allow -M mypol
:# semodule -i mypol.pp
:
:Additional Information:
:Source Context                system_u:system_r:systemd_tmpfiles_t:s0
:Target Context                unconfined_u:object_r:user_home_t:s0
:Target Objects                regression [ dir ]
:Source                        systemd-tmpfile
:Source Path                   /bin/systemd-tmpfiles
:Port                          <Unknown>
:Host                          (removed)
:Source RPM Packages           systemd-units-37-17.fc16.x86_64
:Target RPM Packages           
:Policy RPM                    selinux-policy-3.10.0-80.fc16.noarch
:Selinux Enabled               True
:Policy Type                   targeted
:Enforcing Mode                Enforcing
:Host Name                     (removed)
:Platform                      Linux (removed)
:                              3.3.0-8.fc16.x86_64 #1 SMP Thu Mar 29 18:37:19 UTC
:                              2012 x86_64 x86_64
:Alert Count                   193
:First Seen                    Mon 19 Mar 2012 01:26:22 PM PDT
:Last Seen                     Mon 02 Apr 2012 12:17:55 AM PDT
:Local ID                      df4e8613-b3b9-4a02-8f4c-a7abc83f0508
:
:Raw Audit Messages
:type=AVC msg=audit(1333351075.781:161): avc:  denied  { setattr } for  pid=2332 comm="systemd-tmpfile" name="regression" dev="dm-1" ino=1708404 scontext=system_u:system_r:systemd_tmpfiles_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir
:
:
:type=SYSCALL msg=audit(1333351075.781:161): arch=x86_64 syscall=utimensat success=no exit=EACCES a0=8 a1=0 a2=7ffff416d440 a3=0 items=0 ppid=1 pid=2332 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=systemd-tmpfile exe=/bin/systemd-tmpfiles subj=system_u:system_r:systemd_tmpfiles_t:s0 key=(null)
:
:Hash: systemd-tmpfile,systemd_tmpfiles_t,user_home_t,dir,setattr
:
:audit2allow
:
:#============= systemd_tmpfiles_t ==============
:allow systemd_tmpfiles_t user_home_t:dir setattr;
:
:audit2allow -R
:
:#============= systemd_tmpfiles_t ==============
:allow systemd_tmpfiles_t user_home_t:dir setattr;
:
Comment 1 Donald Cohen 2012-04-02 13:32:30 EDT
Another one that I view as related:
SELinux is preventing /bin/systemd-tmpfiles from write access on the directory ssl-test-certs.

*****  Plugin catchall (100. confidence) suggests  ***************************

If you believe that systemd-tmpfiles should be allowed write access on the ssl-test-certs directory by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep systemd-tmpfile /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:systemd_tmpfiles_t:s0
Target Context                unconfined_u:object_r:user_home_t:s0
Target Objects                ssl-test-certs [ dir ]
Source                        systemd-tmpfile
Source Path                   /bin/systemd-tmpfiles
Port                          <Unknown>
Host                          number11.don-eve.dyndns.org
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.10.0-80.fc16.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     number11.don-eve.dyndns.org
Platform                      Linux number11.don-eve.dyndns.org
                              3.3.0-8.fc16.x86_64 #1 SMP Thu Mar 29 18:37:19 UTC
                              2012 x86_64 x86_64
Alert Count                   778
First Seen                    Mon 19 Mar 2012 01:26:21 PM PDT
Last Seen                     Mon 02 Apr 2012 12:17:55 AM PDT
Local ID                      22d49e0d-5f20-4a2a-97e0-31816d26ca7c

Raw Audit Messages
type=AVC msg=audit(1333351075.798:167): avc:  denied  { write } for  pid=2332 comm="systemd-tmpfile" name="ssl-test-certs" dev="dm-1" ino=1708392 scontext=system_u:system_r:systemd_tmpfiles_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=dir


Hash: systemd-tmpfile,systemd_tmpfiles_t,user_home_t,dir,write

audit2allow

#============= systemd_tmpfiles_t ==============
#!!!! The source type 'systemd_tmpfiles_t' can write to a 'dir' of the following types:
# man_t, device_t, var_auth_t, tmp_t, usr_t, var_t, etc_t, file_t, tmpfs_t, config_home_t, lockfile, pidfile, tmpfile, sandbox_file_t, var_spool_t, httpd_cache_t, faillog_t, var_lib_t, rpm_var_lib_t, httpd_sys_rw_content_t

allow systemd_tmpfiles_t user_home_t:dir write;

audit2allow -R

#============= systemd_tmpfiles_t ==============
#!!!! The source type 'systemd_tmpfiles_t' can write to a 'dir' of the following types:
# man_t, device_t, var_auth_t, tmp_t, usr_t, var_t, etc_t, file_t, tmpfs_t, config_home_t, lockfile, pidfile, tmpfile, sandbox_file_t, var_spool_t, httpd_cache_t, faillog_t, var_lib_t, rpm_var_lib_t, httpd_sys_rw_content_t

allow systemd_tmpfiles_t user_home_t:dir write;
Comment 2 Donald Cohen 2012-04-02 13:40:45 EDT
1. what is /bin/systemd-tmpfiles anyway?  Sounds like it's related to tmpwatch.

2. and how am I supposed to be able to find out other than asking in some place like this?

3. the whole idea that I'm supposed to be able to know whether systemd-tmpfiles should be allowed write access on this directory relies on me at least being able to find out what it is.

4. why doesn't settroubleshoot tell me the complete path to the file?
I have to do find / -name ssl-test-certs in order to find that it's
  /tmp/mysql-connector-java-5.1.18/src/testsuite/ssl-test-certs
Comment 3 Daniel Walsh 2012-04-02 15:03:14 EDT
http://danwalsh.livejournal.com/34903.html?thread=220247

You need to turn on full auditing.
Comment 4 Donald Cohen 2012-04-02 15:28:00 EDT
I guess comment 3 is only responding to #4 of comment 2.
Perhaps I need to classify this bug under a different component in order to learn more about #1.  And #2/3 perhaps also should be discussed in other places, though I don't know where.
Comment 5 Daniel Walsh 2012-04-02 16:05:57 EDT
1. system-tmpfiles could be considered a replacement of tmpreaper, but I think we continue to ship both.
2.  This is the best place to ask.
3. yes
Comment 6 Donald Cohen 2012-04-02 17:04:04 EDT
tmpreaper?  Never heard of it.  Seems not to be installed.  But web search suggests it's like tmpwatch.
It's interesting that in my /etc/cron.daily/tmpwatch I have commented out the part that does /tmp -- I still have /var/tmp and other /var stuff.
But the files denied write access were in /tmp -- so I don't even understand why this is running.  Maybe it's time to replace /bin/systemd-tmpfiles with a shell script to show where it's being run from...
Comment 7 Daniel Walsh 2012-04-09 16:23:05 EDT
Well as far as SELinux is concerned 

/usr/sbin/tmpreaper		--	gen_context(system_u:object_r:tmpreaper_exec_t,s0)
/usr/sbin/tmpwatch		--	gen_context(system_u:object_r:tmpreaper_exec_t,s0)

We treat them the same.
Comment 8 Donald Cohen 2012-04-26 17:29:32 EDT
bug 812555 has taught me that I should not disable systemd-tmpfiles.
But I still get these ridiculous notifications - it doesn't have permission
to write or setattr on some file I've stuck in /tmp.  Am I not supposed to be
writing random files in /tmp ?  I've turned off (at least tried) the config setting to delete files from /tmp.  What is systemd-tmpfiles trying to do and why?  I assume it is not considered normal and acceptable to generate selinux alerts.  Is the normal function of systemd-tmpfiles compatible with this view?
If not, I suggest that either systemd-tmpfiles or selinux should be removed from the distribution.
(Is there a way without offending selinux to FIND OUT whether some operation you want to do WOULD offend selinux ?  If so, one reasonable option would be to
re-specify various services in terms of doing what selinux thinks they should be allowed to do, but without triggering any complaints.)
Comment 9 Daniel Walsh 2012-04-27 11:06:57 EDT
Yes systemd-tmpfiles is new technology and SELinux is slowly adapting to it. You can write random files to /tmp and systemd-tmpfiles should be able to delete them, SELinux should not block it.
Comment 10 Donald Cohen 2012-04-27 14:23:00 EDT
I wonder whether writing files as root might be part of the problem.

Here's another case - on a newly installed machine I create a user and then
want to allow him to ssh in using a public key.
As root I create his .ssh directory and authorized_keys file, give them the
right owner/group/permissions and then he can't ssh in.  From /var/log/messages:
Apr 26 12:57:16 cmc-db setroubleshoot: SELinux is preventing sshd from getattr access on the file /home/ryan/.ssh/authorized_keys. For complete SELinux messages. run sealert -l 705d2791-84ce-4da1-8e12-5418c25b0006 

Evidently whenever I create a file I should be setting not only its permissions, owner, group but also its selinux label.  Please tell me where to look to find out how to do this and also how to figure out what the setting should be.
Comment 11 Daniel Walsh 2012-04-27 16:10:46 EDT
restorecon -R -v /home/ryan/.ssh

Should fix the problem

What does ls -lZd /home/ryan/.ssh

Say before you run the restorecon command?

SELinux cares about labeling, usually just running restorecon on a directory will set the directories labels to the system defaults.
Comment 12 Donald Cohen 2012-04-27 19:00:49 EDT
Too late to find out on .ssh above, though I suppose I could try to recreate what I did before.

I now see on the original system many things like this:
Apr 27 08:58:04 number11 setroubleshoot: SELinux is preventing /bin/systemd-tmpfiles from write access on the directory /. For complete SELinux messages. run sealert -l 04ee1962-e6dd-4529-b2bf-3aadeb6beb36
Apr 27 08:58:04 number11 setroubleshoot: SELinux is preventing /bin/systemd-tmpfiles from write access on the directory /. For complete SELinux messages. run sealert -l 04ee1962-e6dd-4529-b2bf-3aadeb6beb36
Apr 27 08:58:04 number11 rsyslogd-2177: imuxsock begins to drop messages from pid 3907 due to rate-limiting

also,
Apr 27 08:57:59 number11 systemd-tmpfiles[14614]: utimensat(/tmp/mysql-connector-java-5.1.18/src/com/mysql/jdbc/log): Permission denied
Apr 27 08:57:59 number11 systemd-tmpfiles[14614]: unlink(/tmp/mysql-connector-java-5.1.18/src/com/mysql/jdbc/JDBC4NClob.java): Permission denied

which suggests that it's trying to delete stuff ...
looks like my /usr/lib/tmpfiles.d/tmp.conf was overwritten by some recent
yum update (~!@#$^%)
So in this case I'm glad that selinux prevented it.
BTW, how can I tell selinux not to allow systemd.tmpfiles to delete anything?
In this case I'd find that to be useful.

So it sounds like you're suggesting that every program that I run should know
what files it writes and do restorecon of them?

BTW:
$ ls -lZd /tmp/mysql-connector-java-5.1.18/src/com/mysql/jdbc/log
drwxr-xr-x. don don unconfined_u:object_r:user_home_t:s0 /tmp/mysql-connector-java-5.1.18/src/com/mysql/jdbc/log
Comment 13 Daniel Walsh 2012-05-02 14:05:19 EDT
Not I am not saying you need to run restorecon on every file you create.   If you can recreate what you did to get the .ssh mislabeled, that would be useful.  Since this is not supposed to happen any longer.


$ ls -lZd /tmp/mysql-connector-java-5.1.18/src/com/mysql/jdbc/log
drwxr-xr-x. don don unconfined_u:object_r:user_home_t:s0
/tmp/mysql-connector-java-5.1.18/src/com/mysql/jdbc/log

Was this data originally in a homedir?
Comment 14 Donald Cohen 2012-05-02 14:15:32 EDT
I might be able to reconstruct -- I think as root I created the .ssh directory and then the authorized keys file, then chown/chgrp/chmod.
Perhaps restorecon belongs in that group.  What exactly does restorecon do to decide what label to use?  Does it depend on the user running it or the path or what?
In the case of mysql-connector it's less likely, though still possible, that I can reconstruct, but it's quite possible that this came from a homedir.
Comment 15 Fedora End Of Life 2013-01-16 10:44:56 EST
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 16 Fedora End Of Life 2013-02-13 13:54:23 EST
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

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