Bug 1482682

Summary: Open vSwitch selinux policy needs updating
Product: Red Hat Enterprise Linux 7 Reporter: Aaron Conole <aconole>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: urgent Docs Contact: Mirek Jahoda <mjahoda>
Priority: urgent    
Version: 7.5CC: aconole, atomasov, fkrska, ghuang, lvrabec, mgrepl, mjahoda, mmalik, mmirecki, mthacker, osabart, plautrba, pvrabec, rhrazdil, ssekidde, twilson, wmeng
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Prior to this update, the SELinux policy did not contain all the rules needed for Open vSwitch (OVS) 2.8.0. Consequently, this version of OVS did not work properly with SELinux in enforcing mode. With this update, new rules allowing creating `netlink_audit_` and `tun_` sockets, and the `kill` capability have been added to the policy. As a result, OVS 2.8.0 is now able to work properly with SELinux in enforcing mode.
Story Points: ---
Clone Of:
: 1538936 (view as bug list) Environment:
Last Closed: 2018-04-10 12:38:21 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:    
Bug Blocks: 1480897, 1503566, 1503820, 1538936    

Description Aaron Conole 2017-08-17 21:12:20 UTC
Description of problem:

Open vSwitch 2.8.0 will require a new policy in order to have selinux enabled, since it now runs as a non-root user.


The policy to be applied can be found at:

https://mail.openvswitch.org/pipermail/ovs-dev/2017-August/337516.html

In that file, the content between @begin_dpdk@ and @end_dpdk@ needs to be kept (but the lines that contain @begin_dpdk@ and @end_dpdk@ should be cut).

Comment 2 Aaron Conole 2017-08-17 21:14:39 UTC
also note that bz #1482682 also will want this change.

Comment 3 Aaron Conole 2017-08-17 21:15:16 UTC
Oops, I meant to write bz #1442372

Comment 4 Milos Malik 2017-08-18 08:32:02 UTC
Following SELinux denial appeared several times in enforcing mode:
----
type=PROCTITLE msg=audit(08/18/2017 04:28:38.630:302) : proctitle=runuser --user openvswitch -- ovsdb-tool -vconsole:off create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema 
type=SYSCALL msg=audit(08/18/2017 04:28:38.630:302) : arch=x86_64 syscall=socket success=no exit=EACCES(Permission denied) a0=netlink a1=SOCK_RAW a2=igp a3=0x7fff58dcffb0 items=0 ppid=31679 pid=31718 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=runuser exe=/usr/sbin/runuser subj=system_u:system_r:openvswitch_t:s0 key=(null) 
type=AVC msg=audit(08/18/2017 04:28:38.630:302) : avc:  denied  { create } for  pid=31718 comm=runuser scontext=system_u:system_r:openvswitch_t:s0 tcontext=system_u:system_r:openvswitch_t:s0 tclass=netlink_audit_socket 
----

Comment 5 Milos Malik 2017-08-18 08:34:43 UTC
Following SELinux denials appeared in permissive mode:
----
type=PROCTITLE msg=audit(08/18/2017 04:33:00.080:313) : proctitle=runuser --user openvswitch -- ovsdb-tool -vconsole:off schema-version /usr/share/openvswitch/vswitch.ovsschema 
type=SYSCALL msg=audit(08/18/2017 04:33:00.080:313) : arch=x86_64 syscall=socket success=yes exit=3 a0=netlink a1=SOCK_RAW a2=igp a3=0x7ffe4fc24ec0 items=0 ppid=20283 pid=20284 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=runuser exe=/usr/sbin/runuser subj=system_u:system_r:openvswitch_t:s0 key=(null) 
type=AVC msg=audit(08/18/2017 04:33:00.080:313) : avc:  denied  { create } for  pid=20284 comm=runuser scontext=system_u:system_r:openvswitch_t:s0 tcontext=system_u:system_r:openvswitch_t:s0 tclass=netlink_audit_socket 
----
type=PROCTITLE msg=audit(08/18/2017 04:33:00.080:314) : proctitle=runuser --user openvswitch -- ovsdb-tool -vconsole:off schema-version /usr/share/openvswitch/vswitch.ovsschema 
type=SYSCALL msg=audit(08/18/2017 04:33:00.080:314) : arch=x86_64 syscall=sendto success=yes exit=136 a0=0x3 a1=0x7ffe4fc1e660 a2=0x88 a3=0x0 items=0 ppid=20283 pid=20284 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=runuser exe=/usr/sbin/runuser subj=system_u:system_r:openvswitch_t:s0 key=(null) 
type=AVC msg=audit(08/18/2017 04:33:00.080:314) : avc:  denied  { audit_write } for  pid=20284 comm=runuser capability=audit_write  scontext=system_u:system_r:openvswitch_t:s0 tcontext=system_u:system_r:openvswitch_t:s0 tclass=capability 
type=AVC msg=audit(08/18/2017 04:33:00.080:314) : avc:  denied  { nlmsg_relay } for  pid=20284 comm=runuser scontext=system_u:system_r:openvswitch_t:s0 tcontext=system_u:system_r:openvswitch_t:s0 tclass=netlink_audit_socket 
----

Comment 6 Milos Malik 2017-08-18 09:09:44 UTC
----
type=PROCTITLE msg=audit(08/18/2017 04:46:23.876:383) : proctitle=/bin/sh /usr/s
hare/openvswitch/scripts/ovs-ctl --no-ovs-vswitchd stop 
type=SYSCALL msg=audit(08/18/2017 04:46:23.876:383) : arch=x86_64 syscall=kill s
uccess=no exit=EPERM(Operation not permitted) a0=0x51f2 a1=SIGKILL a2=0x0 a3=0x5
1f2 items=0 ppid=1 pid=31461 auid=unset uid=root gid=root euid=root suid=root fs
uid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=ovs-ctl exe=/u
sr/bin/bash subj=system_u:system_r:openvswitch_t:s0 key=(null) 
type=AVC msg=audit(08/18/2017 04:46:23.876:383) : avc:  denied  { kill } for  pi
d=31461 comm=ovs-ctl capability=kill  scontext=system_u:system_r:openvswitch_t:s
0 tcontext=system_u:system_r:openvswitch_t:s0 tclass=capability 
----

I can't reproduce the other AVCs mentioned in https://mail.openvswitch.org/pipermail/ovs-dev/2017-August/337516.html but that's expected because I'm not familiar with openvswitch and DPDK.

Comment 9 Terry Wilson 2017-08-25 14:25:19 UTC
Arie, one thing you could try is making sure that this line in /etc/sysconfig/openvswitch:

OVS_USER_ID="openvswitch:openvswitch"

is removed, so that it runs as root and probably won't be selinux issues anymore.

Comment 10 Aaron Conole 2017-08-25 15:28:35 UTC
Would be better to set selinux enforcement mode to Permissive and then the selinux "problems" will be allowed, but the various errors will still be logged.

Comment 11 Terry Wilson 2017-08-25 15:45:59 UTC
oops, commented on the wrong bug. in bz 1480897, they are setting to permissive, but director is somehow setting it back to enforcing in the process. so services start, but then fail to function. I meant to suggest in the *other* bug that if he needed to move past this known issue for CI, he could just make that change and change it back when this issue is resolved.

Comment 13 Aaron Conole 2017-11-27 22:18:21 UTC
*** Bug 1503820 has been marked as a duplicate of this bug. ***

Comment 20 Timothy Redaelli 2018-02-05 11:20:42 UTC
*** Bug 1541926 has been marked as a duplicate of this bug. ***

Comment 23 errata-xmlrpc 2018-04-10 12:38:21 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://access.redhat.com/errata/RHBA-2018:0763

Comment 24 Dan Kenigsberg 2018-04-19 19:25:01 UTC
*** Bug 1566373 has been marked as a duplicate of this bug. ***