Bug 1343776

Summary: "ip netns del" cannot unmount /run/netns/*
Product: Red Hat Enterprise Linux 7 Reporter: Garrett Holmstrom <gholms>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: lvrabec, mgrepl, mmalik, plautrba, pvrabec, ssekidde
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-80.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 02:30:52 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:

Description Garrett Holmstrom 2016-06-07 22:55:25 UTC
Description of problem:
While the ifconfig policy appears to have some support for ``ip netns add'' commands, it does not appear to have a working policy for ``ip netns del'' commands, resulting in the following audit messages:

type=EXECVE msg=audit(1465332391.813:10109): argc=4 a0="ip" a1="netns" a2="del" a3="test"
type=CWD msg=audit(1465332391.813:10109):  cwd="/"
type=PATH msg=audit(1465332391.813:10109): item=0 name="/usr/sbin/ip" inode=671234140 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00
 obj=system_u:object_r:ifconfig_exec_t:s0 objtype=NORMAL
type=PATH msg=audit(1465332391.813:10109): item=1 name="/lib64/ld-linux-x86-64.so.2" inode=134225977 dev=fd:00 mode=0100755 ouid=0 og
id=0 rdev=00:00 obj=system_u:object_r:ld_so_t:s0 objtype=NORMAL
type=AVC msg=audit(1465332391.814:10110): avc:  denied  { unmount } for  pid=13634 comm="ip" scontext=system_u:system_r:ifconfig_t:s0 tcontext=system_u:object_r:proc_t:s0 tclass=filesystem
type=SYSCALL msg=audit(1465332391.814:10110): arch=c000003e syscall=166 success=yes exit=0 a0=7fff21238770 a1=2 a2=7fff2123878b a3=7fff212384e0 items=1 ppid=16607 pid=13634 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ip" exe="/usr/sbin/ip" subj=system_u:system_r:ifconfig_t:s0 key=(null)
type=CWD msg=audit(1465332391.814:10110):  cwd="/"
type=PATH msg=audit(1465332391.814:10110): item=0 name="/var/run/netns/test" inode=4026532434 dev=00:03 mode=0100444 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:proc_t:s0 objtype=NORMAL


Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-60.el7_2.3.noarch


How reproducible:
When enforcing


Steps to Reproduce:
1. setenforce 0  # work around bug 1340572
2. ip netns add test
3. setenforce 1
4. ip netns del test


Actual results:
Cannot remove namespace file "/var/run/netns/test": Device or resource busy


Expected results:
(no output)

Comment 2 Milos Malik 2016-06-08 08:23:12 UTC
# sestatus 
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28
# runcon system_u:system_r:initrc_t:s0 bash -c '/usr/sbin/ip netns add test'
# runcon system_u:system_r:initrc_t:s0 bash -c '/usr/sbin/ip netns list'
test
# runcon system_u:system_r:initrc_t:s0 bash -c '/usr/sbin/ip netns del test'
Cannot remove namespace file "/var/run/netns/test": Device or resource busy
# 

Following SELinux denial appeared in permissive mode:
----
type=PATH msg=audit(06/08/2016 10:17:39.213:821) : item=0 name=/var/run/netns/test inode=4026532240 dev=00:03 mode=file,444 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:proc_t:s0 objtype=NORMAL 
type=CWD msg=audit(06/08/2016 10:17:39.213:821) :  cwd=/root 
type=SYSCALL msg=audit(06/08/2016 10:17:39.213:821) : arch=x86_64 syscall=umount2 success=yes exit=0 a0=0x7ffc728c7fe0 a1=MNT_DETACH a2=0x7ffc728c7ff3 a3=0x7ffc728c7d50 items=1 ppid=3240 pid=8134 auid=root uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts0 ses=1 comm=ip exe=/usr/sbin/ip subj=system_u:system_r:ifconfig_t:s0 key=(null) 
type=AVC msg=audit(06/08/2016 10:17:39.213:821) : avc:  denied  { unmount } for  pid=8134 comm=ip scontext=system_u:system_r:ifconfig_t:s0 tcontext=system_u:object_r:proc_t:s0 tclass=filesystem 
----

Following SELinux denial appeared in enforcing mode:
----
type=PATH msg=audit(06/08/2016 10:19:01.462:862) : item=0 name=/var/run/netns/test inode=4026532240 dev=00:03 mode=file,444 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:proc_t:s0 objtype=NORMAL 
type=CWD msg=audit(06/08/2016 10:19:01.462:862) :  cwd=/root 
type=SYSCALL msg=audit(06/08/2016 10:19:01.462:862) : arch=x86_64 syscall=umount2 success=no exit=EACCES(Permission denied) a0=0x7ffcb98c68c0 a1=MNT_DETACH a2=0x7ffcb98c68d3 a3=0x7ffcb98c6630 items=1 ppid=3240 pid=8426 auid=root uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts0 ses=1 comm=ip exe=/usr/sbin/ip subj=system_u:system_r:ifconfig_t:s0 key=(null) 
type=AVC msg=audit(06/08/2016 10:19:01.462:862) : avc:  denied  { unmount } for  pid=8426 comm=ip scontext=system_u:system_r:ifconfig_t:s0 tcontext=system_u:object_r:proc_t:s0 tclass=filesystem 
----

Comment 6 errata-xmlrpc 2016-11-04 02:30:52 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