Bug 1304723

Summary: Allow {ip|ip6|eb}tables-restore to use read and getattr on files in (/var)/run/firewalld
Product: Red Hat Enterprise Linux 7 Reporter: Thomas Woerner <twoerner>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: bgalvani, dominick.grift, dwalsh, extras-qa, lvrabec, mcepl, mgrepl, mmalik, plautrba, pvrabec, ssekidde, szidek, todoleza
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-89.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1291243
: 1332123 (view as bug list) Environment:
Last Closed: 2016-11-04 02:42:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1291243    
Bug Blocks: 1302802, 1332123    

Description Thomas Woerner 2016-02-04 13:13:47 UTC
This will be needed for the firewalld rebase to 0.4.0: #1302802

+++ This bug was initially created as a clone of Bug #1291243 +++

Description of problem:
For an enhancement of firewalld it is needed to be able to use the {ip|ip6|eb}tables-restore commands with temporary files that are passed to the restore commands on stdin.
firewalld will create the directory /run/firewalld at startup and will create the temporary files in there.

Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-155.fc23

Here are the AVC messages:

ype=AVC msg=audit(1450092486.349:70144): avc:  denied  { read } for  pid=17865 comm="iptables-restor" path="/run/firewalld/temp.gciaj0pn" dev="tmpfs" ino=1078786 scontext=system_u:system_r:iptables_t:s0 tcontext=system_u:object_r:firewalld_var_run_t:s0 tclass=file permissive=1


type=SYSCALL msg=audit(1450092486.349:70144): arch=x86_64 syscall=execve success=yes exit=0 a0=7f3310f82520 a1=55bb740c6b60 a2=55bb73ccdd00 a3=1 items=0 ppid=17787 pid=17865 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=iptables-restor exe=/usr/sbin/xtables-multi subj=system_u:system_r:iptables_t:s0 key=(null)

Hash: iptables-restor,iptables_t,firewalld_var_run_t,file,read



type=AVC msg=audit(1450092486.350:70145): avc:  denied  { getattr } for  pid=17865 comm="iptables-restor" path="/run/firewalld/temp.gciaj0pn" dev="tmpfs" ino=1078786 scontext=system_u:system_r:iptables_t:s0 tcontext=system_u:object_r:firewalld_var_run_t:s0 tclass=file permissive=1


type=SYSCALL msg=audit(1450092486.350:70145): arch=x86_64 syscall=fstat success=yes exit=0 a0=0 a1=7fffa63c6300 a2=7fffa63c6300 a3=7fde21bbc700 items=0 ppid=17787 pid=17865 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=iptables-restor exe=/usr/sbin/xtables-multi subj=system_u:system_r:iptables_t:s0 key=(null)

Hash: iptables-restor,iptables_t,firewalld_var_run_t,file,getattr



Please also add these for F-22 and rawhide.

On F-22 I had to allow firewalld to create the directory in (/var)/run:

allow firewalld_t var_run_t:dir create;

--- Additional comment from Lukas Vrabec on 2015-12-14 07:16:32 EST ---

commit 872c7b4c77ca92788eb0f097a82c73c921469ef7
Author: Lukas Vrabec <lvrabec>
Date:   Mon Dec 14 13:06:06 2015 +0100

    Add interface firewalld_read_pid_files()

commit 132fbc10ee97fa1a9d3838842fadf6e5e842f856
Author: Lukas Vrabec <lvrabec>
Date:   Mon Dec 14 13:07:21 2015 +0100

    Allow iptables to read firewalld pid files. BZ(1291243)

--- Additional comment from Lukas Vrabec on 2015-12-14 07:30:21 EST ---

commit 44a47e0c0d2e9e365a5750539e817a061c7c248c
Author: Lukas Vrabec <lvrabec>
Date:   Mon Dec 14 13:27:19 2015 +0100

    Allow firewalld to create firewalld_var_run_t directory. BZ(1291243)

--- Additional comment from Fedora Update System on 2015-12-16 06:06:35 EST ---

selinux-policy-3.13.1-158.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-eb32da49ac

--- Additional comment from Fedora Update System on 2015-12-17 05:29:02 EST ---

selinux-policy-3.13.1-158.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update selinux-policy'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-eb32da49ac

--- Additional comment from Fedora Update System on 2015-12-22 17:03:35 EST ---

selinux-policy-3.13.1-158.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 1 Thomas Woerner 2016-04-14 16:57:32 UTC
This will be needed for the firewalld rebase to 0.4.x in RHEL-7.3.

Comment 3 Thomas Woerner 2016-04-21 15:35:55 UTC
I am getting the following AVCs on RHEL-7.2 with firewalld-0.4.1.2:

#============= firewalld_t ==============
allow firewalld_t var_log_t:file open;
allow firewalld_t var_run_t:dir create;

#============= iptables_t ==============
allow iptables_t firewalld_var_run_t:file { read getattr };

Test packages are available here: 
http://people.redhat.com/twoerner/firewalld/0.4.1.2-1.el7/

Comment 5 Thomas Woerner 2016-05-30 15:55:07 UTC
For the fix for #1066037, there is an additional change required:

allow firewalld_t net_conf_t:dir write;

Firewalld is trying to change the ZONE setting in the ifcfg file that is using the interface, for which the zone binding has been requested. Only if there is an ifcfg file using this interface.

There is a new te file for RHEL-7: http://people.redhat.com/twoerner/firewalld/0.4.2-1.el7/firewalld-0.4.te

Comment 6 Thomas Woerner 2016-06-07 11:18:58 UTC
*** Bug 1342587 has been marked as a duplicate of this bug. ***

Comment 7 Thomas Woerner 2016-06-13 13:19:17 UTC
It seems that there is an additional rule needed for this:

type=AVC msg=audit(1465486509.538:13194): avc:  denied  { add_name } for  pid=6273 comm="firewalld" name="ifcfg-enp0s25.NdcLYC" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:object_r:net_conf_t:s0 tclass=dir

type=SYSCALL msg=audit(1465486509.538:13194): arch=x86_64 syscall=open success=no exit=EACCES a0=2bb1840 a1=200c2 a2=180 a3=4 items=0 ppid=1 pid=6273 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=firewalld exe=/usr/bin/python2.7 subj=system_u:system_r:firewalld_t:s0 key=(null)

Hash: firewalld,firewalld_t,net_conf_t,dir,add_name

Comment 8 Thomas Woerner 2016-06-13 13:30:31 UTC
What is the meaning of add_name here?

It seems only to happen while restarting the firewalld service - but not if the code is used while firewalld is running already.

After a relabel of /etc it seems to be gone.

Comment 9 Thomas Woerner 2016-06-13 13:31:47 UTC
(In reply to Thomas Woerner from comment #8)
> What is the meaning of add_name here?
> 
> It seems only to happen while restarting the firewalld service - but not if
> the code is used while firewalld is running already.
> 
> After a relabel of /etc it seems to be gone.
No, still happening...

Comment 10 Daniel Walsh 2016-06-13 16:01:46 UTC
This means that firewalld is adding content to a directory labeled net_conf_t

Comment 11 Thomas Woerner 2016-06-13 16:09:28 UTC
firewalld is creating a temporary file that will be renamed when complete. Is there a better way in the case of modifying ifcfg-X files in /etc/sysconfig/network-scripts/ ?

Comment 12 Daniel Walsh 2016-06-13 17:04:49 UTC
That is fine, and SELinux policy should be adjusted.  Only problem I see would be potentially from a security point of view, in that all other domains that can read net_conf_t could read the file.  But if the file has nothing that needs to be protected from other domains, it seems like a good place to store it.

Comment 13 Thomas Woerner 2016-06-14 11:18:33 UTC
firewalld is not adding secrets to this file. Only the ZONE settings is adjusted to make sure that they match in firewalld and in the ifcfg file.

Comment 18 Thomas Woerner 2016-06-30 12:15:46 UTC
It seems that this is missing:

allow firewalld_t net_conf_t:file { write rename create unlink setattr };

Comment 27 Tomas Dolezal 2016-07-20 13:50:43 UTC
*** Bug 1358217 has been marked as a duplicate of this bug. ***

Comment 29 errata-xmlrpc 2016-11-04 02:42:01 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://rhn.redhat.com/errata/RHBA-2016-2283.html