Bug 1181338 - SELinux is preventing openvpn from 'relabelfrom' accesses on the tun_socket Unknown.
Summary: SELinux is preventing openvpn from 'relabelfrom' accesses on the tun_socket U...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 21
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:b86fdce991fd5fdcac5eba1fe07...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-01-12 22:47 UTC by colin
Modified: 2015-12-02 17:03 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-3.13.1-105.3.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-02 07:21:18 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
grep -i 'avc: denied' /var/log/audit/audit.log > grep_avc_denied.out (17.03 KB, text/plain)
2015-03-24 14:29 UTC, colin
no flags Details

Description colin 2015-01-12 22:47:08 UTC
Description of problem:
I am running openvpn in a docker container.

The suggestion from the SELinux GUI tool fails:

 [root@vm117 ~]# grep openvpn /var/log/audit/audit.log | audit2allow -M openvpn-relabelfrom
compilation failed:
openvpn-relabelfrom.te:17:ERROR 'syntax error' at token 'constrain' on line 17:
#Constraint rule: 
	constrain tun_socket { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED
/usr/bin/checkmodule:  error(s) encountered while parsing configuration
/usr/bin/checkmodule:  loading policy configuration from openvpn-relabelfrom.te
[root@vm117 ~]# 

SELinux is preventing openvpn from 'relabelfrom' accesses on the tun_socket Unknown.

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

If you believe that openvpn should be allowed relabelfrom access on the Unknown tun_socket 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 openvpn /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:docker_t:s0
Target Context                unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1
                              023
Target Objects                Unknown [ tun_socket ]
Source                        openvpn
Source Path                   openvpn
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-103.fc21.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 3.17.7-300.fc21.x86_64 #1 SMP Wed
                              Dec 17 03:08:44 UTC 2014 x86_64 x86_64
Alert Count                   47
First Seen                    2015-01-07 21:41:33 GMT
Last Seen                     2015-01-12 21:47:34 GMT
Local ID                      e181f8c0-e576-4e34-b51a-63d5e9135329

Raw Audit Messages
type=AVC msg=audit(1421099254.336:3680): avc:  denied  { relabelfrom } for  pid=27267 comm="openvpn" scontext=system_u:system_r:docker_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=tun_socket permissive=1


Hash: openvpn,docker_t,unconfined_t,tun_socket,relabelfrom

Version-Release number of selected component:
selinux-policy-3.13.1-103.fc21.noarch

Additional info:
reporter:       libreport-2.3.0
hashmarkername: setroubleshoot
kernel:         3.17.7-300.fc21.x86_64
type:           libreport

Comment 1 Daniel Walsh 2015-01-13 19:59:21 UTC
Did you disable the SELinux for the daemon?

IE is docker running with --selinux-enabled?

Comment 2 colin 2015-01-16 12:19:23 UTC
Hi Dan
 Sorry for the delay in replying- I am still quite new to SELinux and I had to hunt around abit to find that out.
 I took a look in 
 /etc/sysconfig/docker
and can see that I had commented out the line
#OPTIONS=--selinux-enabled

some 3 weeks ago.

Thanks
Colin.

Comment 3 Daniel Walsh 2015-01-16 14:15:11 UTC
If you comment out the line you need to make sure the boolean is turned on.  I will add a comment to the /etc/sysconfig/docker to clarify this.

Why did you disable SELinux in docker?

Comment 4 colin 2015-01-28 10:32:26 UTC
Hi Dan. 
You said:
> you need to make sure the boolean is turned on

Unfortunately I am not sure what was meant by this. 

> Why did you disable SELinux in docker?

I am trying to do useful development work on this VM, and it is securely isolated on a LAN, with only me accessing it.

The interactions between 'recent' releases of NetworkManager, teamd, OpenVSwitch, Docker and SELinux is already too unreliable. :-(
 
Progress is hampered by the VM freezing or crashing, and stuff failing to work and having to then reboot.

This uses up my time having to then re-establish a bunch of broken connections.

I saw on the Redhat website that I could disable MAC in my development container, but alas it appears to have made no difference.

At least with SELinux set permissive- I can see what _would_ have been denied, if if it had Actually been enforcing. 

Of course - I am still at a loss as to how to 'fix' these SELinux issues, but at least I can work on the main project in the meantime.

I would certainly appreciate any suggestions for a better way to proceed.

Thanks 
Colin

Comment 5 Daniel Walsh 2015-01-28 14:22:19 UTC
a68f731ed84be330dd4e6cc56314d5d5636deb2c fixes this in git.

For now I would just add a custom policy and that should allow this to work.

Comment 6 Lukas Vrabec 2015-02-02 12:17:37 UTC
commit cf2f946cabad6aa7d373868431cdaf5f41c476d3
Author: Dan Walsh <dwalsh>
Date:   Wed Jan 28 09:21:30 2015 -0500

    Allow docker to attach to the sandbox and user domains tun devices

Comment 7 Fedora Update System 2015-02-05 13:15:22 UTC
selinux-policy-3.13.1-105.3.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/selinux-policy-3.13.1-105.3.fc21

Comment 8 Fedora Update System 2015-02-06 04:03:56 UTC
Package selinux-policy-3.13.1-105.3.fc21:
* should fix your issue,
* was pushed to the Fedora 21 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.13.1-105.3.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-1768/selinux-policy-3.13.1-105.3.fc21
then log in and leave karma (feedback).

Comment 9 colin 2015-02-06 21:32:38 UTC
As above- I did
'yum update --enablerepo=updates-testing selinux-policy-3.13.1-105.3.fc21'

to apply the update, and rebooted the VM, but still see the same behaviour.

SELinux Alert Browser still showing new alerts, and the suggested solution still seems to fail with the same error. 

[root@vm117 ~]# grep openvpn /var/log/audit/audit.log | audit2allow -M mypol.tun_socket2
compilation failed:
mypol.tun_socket2.te:15:ERROR 'syntax error' at token 'constrain' on line 15:
#Constraint rule: 
        constrain tun_socket { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED
/usr/bin/checkmodule:  error(s) encountered while parsing configuration
/usr/bin/checkmodule:  loading policy configuration from mypol.tun_socket2.te
[root@vm117 ~]# 

Maybe I did something wrong?

log of yum update attached.
... hmm attachments seem to be disabled.  
will paste inline.

--------------------------------------------------------
[root@vm117 yum]# yum update --enablerepo=updates-testing selinux-policy-3.13.1-105.3.fc21 | tee yum_updates-testing-selinux
Loaded plugins: langpacks
Dependencies Resolved

================================================================================
 Package                   Arch     Version             Repository         Size
================================================================================
Updating:
 selinux-policy            noarch   3.13.1-105.3.fc21   updates-testing   392 k
Updating for dependencies:
 selinux-policy-targeted   noarch   3.13.1-105.3.fc21   updates-testing   3.9 M

Transaction Summary
================================================================================
Upgrade  1 Package (+1 Dependent package)

Total download size: 4.3 M
y
Is this ok [y/d/N]: Downloading packages:
--------------------------------------------------------------------------------
Total                                              413 kB/s | 4.3 MB  00:10     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Updating   : selinux-policy-3.13.1-105.3.fc21.noarch                      1/4 
  Updating   : selinux-policy-targeted-3.13.1-105.3.fc21.noarch             2/4 
  Cleanup    : selinux-policy-targeted-3.13.1-105.fc21.noarch               3/4 
  Cleanup    : selinux-policy-3.13.1-105.fc21.noarch                        4/4 
  Verifying  : selinux-policy-targeted-3.13.1-105.3.fc21.noarch             1/4 
  Verifying  : selinux-policy-3.13.1-105.3.fc21.noarch                      2/4 
  Verifying  : selinux-policy-targeted-3.13.1-105.fc21.noarch               3/4 
  Verifying  : selinux-policy-3.13.1-105.fc21.noarch                        4/4 

Updated:
  selinux-policy.noarch 0:3.13.1-105.3.fc21                                     

Dependency Updated:
  selinux-policy-targeted.noarch 0:3.13.1-105.3.fc21                            

Complete!

Comment 10 Fedora Update System 2015-02-15 03:29:22 UTC
selinux-policy-3.13.1-105.3.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 colin 2015-03-24 11:24:05 UTC
Description of problem:

I have a set of scripts that start openvpn in a docker container.

OpenVPN needs to clone the tun device into the container namespace.


I attempt to modify seLinux local policy as advised by SELinux Browser,
but this seems to fail also.

[root@vm117 ~]# grep openvpn /var/log/audit/audit.log | audit2allow -M myOVPNpol
compilation failed:
myOVPNpol.te:14:ERROR 'syntax error' at token 'constrain' on line 14:
	constrain tun_socket { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED
#Constraint rule: 
/usr/bin/checkmodule:  error(s) encountered while parsing configuration
/usr/bin/checkmodule:  loading policy configuration from myOVPNpol.te
[root@vm117 ~]# 

I am forced to run permissive to make this work.

Version-Release number of selected component:
selinux-policy-3.13.1-105.6.fc21.noarch

Additional info:
reporter:       libreport-2.3.0
hashmarkername: setroubleshoot
kernel:         3.18.8-201.fc21.x86_64
type:           libreport

Comment 12 Daniel Walsh 2015-03-24 13:16:39 UTC
Please attach the actually avc's you are seeing.  Is this tunnel device being shared between two containers?

Comment 13 colin 2015-03-24 14:25:35 UTC
Hi Dan.

> Is this tunnel device being shared between two containers?

 No - strictly one OVPN daemon (with its single Layer 2 Tap device)  per container.

Inter container networking is via veths.

[root@vm117 audit]# grep -i 'avc:  denied' /var/log/audit/audit.log | wc -l
68

I will now upload the output of:
grep -i 'avc:  denied' /var/log/audit/audit.log > grep_avc_denied.out

Comment 14 colin 2015-03-24 14:29:37 UTC
Created attachment 1005890 [details]
grep -i 'avc:  denied' /var/log/audit/audit.log > grep_avc_denied.out

show 'avc:  denied' messages form /var/log/audit/audit.log

Comment 15 colin 2015-03-24 14:38:06 UTC
Also - would it be helpful to open a second #BZ ?

Since this one is describing 2 related problems, i.e.

1) SELinux appears to be blocking stuff

plus

2) The apparent parsing failure when manually running command recommended by the GUI ?

Thanks for your help

Colin.

Comment 16 colin 2015-03-24 15:52:06 UTC
[update...]
 AVC errors seem to have stopped after I installed:

'selinux-policy-3.13.1-105.9.fc21 critical path bugfix update'
from bodhi:
https://admin.fedoraproject.org/updates/selinux-policy-3.13.1-105.9.fc21

see
https://bugzilla.redhat.com/show_bug.cgi?id=1186669#c9

Comment 17 Fedora Update System 2015-04-02 11:53:34 UTC
selinux-policy-3.13.1-105.11.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/selinux-policy-3.13.1-105.11.fc21

Comment 18 Fedora Update System 2015-04-04 07:22:30 UTC
Package selinux-policy-3.13.1-105.11.fc21:
* should fix your issue,
* was pushed to the Fedora 21 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.13.1-105.11.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-5478/selinux-policy-3.13.1-105.11.fc21
then log in and leave karma (feedback).

Comment 19 Fedora End Of Life 2015-11-04 16:03:17 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. 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 EOL if it remains open with a Fedora  'version'
of '21'.

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.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 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  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

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.

Comment 20 Fedora End Of Life 2015-12-02 07:21:21 UTC
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 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. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

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.