Bug 1328269

Summary: Missing SELinux rule for UDP socket
Product: Red Hat Enterprise Linux 7 Reporter: Mauricio Teixeira <mteixeira>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED WONTFIX QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: gwync, huzaifas, lvrabec, mgrepl, mmalik, orion, plautrba, pvrabec, ssekidde, steve
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-03 12:49:27 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:

Description Mauricio Teixeira 2016-04-18 20:52:12 UTC
RHEL7 is missing an SELinux rule that would allow OpenVPN to bind to a UDP socket:

***
module ovpn 2.0;

require {
  type reserved_port_t;
  class udp_socket name_bind;
}

#============= openvpn_t ==============
allow openvpn_t reserved_port_t:udp_socket name_bind;
***

I would like to know if it's possible to integrate this rule on the package that ships from EPEL7.

Comment 1 Orion Poplawski 2016-04-18 20:58:52 UTC
What port are you trying to bind to?  The default port 1194 is labeled openvpn_port_t and openvpn should be able to use it.  If you want to use a different port you need to do:

semanage port --add -t openvpn_port_t -p udp <port>

Comment 2 Mauricio Teixeira 2016-04-28 12:20:41 UTC
So there is an inconsistency here.
We use port 443 to avoid issues with random firewalls. The TCP daemon loads fine, out of the box, without any SELinux modifications. However for UDP I had to run the semanage rule above.
It would be good if UDP was allowed to use 443 by default, just like TCP is.

Comment 3 Orion Poplawski 2016-04-28 15:41:26 UTC
If you are going to use a different port than the standard one you are going to need to make selinux modifications.  These are the standard ports:

# semanage port -l | grep openvpn
openvpn_port_t                 tcp      1194
openvpn_port_t                 udp      1194

443 is the standard port for https, so:

# semanage port -l | grep 443
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000

I'm reassigning to the selinux folks to see what is up with TCP working.  But the UDP behavior is as expected.

Comment 5 Miroslav Grepl 2016-05-03 12:49:27 UTC
Ok we don't support this labeling in the policy. I believe the best solution for this local modification is a local change using semanage how Orion wrote above.

semanage port --add -t openvpn_port_t -p udp <port>

Thank you.