Bug 1050210 - lxcCheckNetNsSupport fails to detect NETNS
Summary: lxcCheckNetNsSupport fails to detect NETNS
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-08 20:55 UTC by W. Andrew Denton
Modified: 2014-04-09 06:53 UTC (History)
15 users (show)

Fixed In Version: selinux-policy-3.12.1-116.fc20
Clone Of:
Environment:
Last Closed: 2014-01-16 07:13:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description W. Andrew Denton 2014-01-08 20:55:17 UTC
Description of problem:
I'm trying to use libvirt-lxc to create containers with network namespaces. Libvirt tells me "System lacks NETNS support" but the system does support network namespaces. I'm running the standard f20 kernel which does have CONFIG_NET_NS=y, and I can manually create network namespaces using iproute.

I looked at lxc_driver.c and I see that it executes "ip link set lo netns -1" in lxcCheckNetNsSupport() to determine if the system supports network namespaces. On the two f20 systems I tried this on, ip returns "RTNETLINK answers: No such process". 

Version-Release number of selected component (if applicable):
libvirt-1.1.3.2-1.fc20.x86_64
libvirt-daemon-driver-lxc-1.1.3.2-1.fc20.x86_64
iproute-3.11.0-1.fc20.x86_64
kernel-3.12.6-300.fc20.x86_64

How reproducible:
Always


Steps to Reproduce:
The easiest way to reproduce I've found is to use virt-sandbox-service create to create a new lxc domain.

# virt-sandbox-service create -C -u httpd.service -N dhcp,source=default container1

It will output
Created sandbox container dir /var/lib/libvirt/filesystems/container1
Created unit file /etc/systemd/system/container1_sandbox.service
/bin/virt-sandbox-service: Failed to create domain: Requested operation is not valid: System lacks NETNS support


Actual results:


Expected results:
The lxc domain will be created.


Additional info:

Comment 1 Daniel Berrangé 2014-01-10 12:43:52 UTC
Do you have Selinux in enforcing mode ? If so does switching to permissive mode help at all.

Comment 2 W. Andrew Denton 2014-01-10 16:16:35 UTC
Hi Daniel,

I was in enforcing mode, but I tried it also in permissive.

# getenforce 
Enforcing
# ip link set lo netns -1
RTNETLINK answers: No such process
# setenforce 0
# getenforce 
Permissive
# ip link set lo netns -1
RTNETLINK answers: No such process
# virt-sandbox-service create -C -u httpd.service -N dhcp,source=default container1
Created sandbox container dir /var/lib/libvirt/filesystems/container1
Created unit file /etc/systemd/system/container1_sandbox.service
/bin/virt-sandbox-service: Failed to create domain: Requested operation is not valid: System lacks NETNS support

Comment 3 W. Andrew Denton 2014-01-10 17:19:28 UTC
Hi Daniel,

I was testing incorrectly, and it seems I'm misleading myself by testing "ip link set lo netns -1" on the command line.

I can get the container to create successfully when I've done setenforce 0 and then *restart* the libvirtd service. From the command line, "ip link..." still returns "No such process" but apparently it succeeds from within libvirtd.

I'll turn off the selinux dontaudit and report back any AVCs.

Comment 4 W. Andrew Denton 2014-01-10 17:31:26 UTC
Hi Daniel,

Here are the log messages and AVCs I get in Permissive mode and restarting libvirtd:

Jan 10 09:21:01 dali systemd[1]: Starting Virtualization daemon...
Jan 10 09:21:01 dali systemd[1]: Started Virtualization daemon.
Jan 10 09:21:01 dali kernel: type=1400 audit(1389374461.725:33): avc:  denied  { rlimitinh } for  pid=12606 comm="libvirtd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:01 dali kernel: type=1400 audit(1389374461.725:34): avc:  denied  { noatsecure } for  pid=12606 comm="libvirtd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:01 dali kernel: type=1400 audit(1389374461.920:35): avc:  denied  { rlimitinh } for  pid=12618 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:01 dali kernel: type=1400 audit(1389374461.920:36): avc:  denied  { siginh } for  pid=12618 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:01 dali kernel: type=1400 audit(1389374461.920:37): avc:  denied  { noatsecure } for  pid=12618 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:02 dali kernel: type=1400 audit(1389374462.310:38): avc:  denied  { rlimitinh } for  pid=12622 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:21:02 dali kernel: type=1400 audit(1389374462.310:39): avc:  denied  { siginh } for  pid=12622 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:21:02 dali kernel: type=1400 audit(1389374462.310:40): avc:  denied  { noatsecure } for  pid=12622 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:21:06 dali dnsmasq[21276]: read /etc/hosts - 3 addresses
Jan 10 09:21:06 dali dnsmasq[21276]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 10 09:21:06 dali dnsmasq-dhcp[21276]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 10 09:21:07 dali kernel: type=1400 audit(1389374467.237:41): avc:  denied  { rlimitinh } for  pid=12699 comm="dmidecode" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dmidecode_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:07 dali kernel: type=1400 audit(1389374467.237:42): avc:  denied  { siginh } for  pid=12699 comm="dmidecode" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dmidecode_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:07 dali kernel: type=1400 audit(1389374467.237:43): avc:  denied  { noatsecure } for  pid=12699 comm="dmidecode" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dmidecode_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:09 dali kernel: SELinux: initialized (dev mqueue, type mqueue), uses transition SIDs
Jan 10 09:21:09 dali kernel: SELinux: initialized (dev proc, type proc), uses genfs_contexts
Jan 10 09:21:09 dali libvirtd[12606]: libvirt version: 1.1.3.2, package: 1.fc20 (Fedora Project, 2013-12-14-21:11:12, buildvm-04.phx2.fedoraproject.org)
Jan 10 09:21:09 dali libvirtd[12606]: internal error: End of file from monitor
Jan 10 09:21:09 dali kernel: type=1400 audit(1389374469.276:44): avc:  denied  { rlimitinh } for  pid=12812 comm="ip" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:ifconfig_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:09 dali kernel: type=1400 audit(1389374469.276:45): avc:  denied  { siginh } for  pid=12812 comm="ip" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:ifconfig_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:09 dali kernel: type=1400 audit(1389374469.276:46): avc:  denied  { noatsecure } for  pid=12812 comm="ip" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:ifconfig_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:21:09 dali kernel: SELinux: initialized (dev mqueue, type mqueue), uses transition SIDs
Jan 10 09:21:09 dali kernel: SELinux: initialized (dev proc, type proc), uses genfs_contexts


When I restart it in Enforcing mode I now see what the real failure is: it can't find the "ip" command in the first place!
Jan 10 09:26:16 dali systemd[1]: Starting Virtualization daemon...
[root@dali ~]# Jan 10 09:26:16 dali systemd[1]: Started Virtualization daemon.
Jan 10 09:26:16 dali kernel: type=1400 audit(1389374776.535:53): avc:  denied  { rlimitinh } for  pid=13008 comm="libvirtd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:26:16 dali kernel: type=1400 audit(1389374776.535:54): avc:  denied  { noatsecure } for  pid=13008 comm="libvirtd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:26:16 dali kernel: type=1400 audit(1389374776.612:55): avc:  denied  { rlimitinh } for  pid=13020 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:26:16 dali kernel: type=1400 audit(1389374776.613:56): avc:  denied  { siginh } for  pid=13020 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:26:16 dali kernel: type=1400 audit(1389374776.613:57): avc:  denied  { noatsecure } for  pid=13020 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:26:16 dali kernel: type=1400 audit(1389374776.615:58): avc:  denied  { rlimitinh } for  pid=13021 comm="dnsmasq" scontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:dnsmasq_t:s0-s0:c0.c1023 tclass=process
Jan 10 09:26:18 dali kernel: audit_printk_skb: 78 callbacks suppressed
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.026:85): avc:  denied  { rlimitinh } for  pid=13040 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.026:86): avc:  denied  { siginh } for  pid=13040 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.026:87): avc:  denied  { noatsecure } for  pid=13040 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.173:88): avc:  denied  { rlimitinh } for  pid=13042 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.173:89): avc:  denied  { siginh } for  pid=13042 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.173:90): avc:  denied  { noatsecure } for  pid=13042 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.325:91): avc:  denied  { rlimitinh } for  pid=13044 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.325:92): avc:  denied  { siginh } for  pid=13044 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.325:93): avc:  denied  { noatsecure } for  pid=13044 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:18 dali kernel: type=1400 audit(1389374778.470:94): avc:  denied  { rlimitinh } for  pid=13046 comm="iptables" scontext=system_u:system_r:firewalld_t:s0 tcontext=system_u:system_r:iptables_t:s0 tclass=process
Jan 10 09:26:21 dali dnsmasq[21276]: read /etc/hosts - 3 addresses
Jan 10 09:26:21 dali dnsmasq[21276]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jan 10 09:26:21 dali dnsmasq-dhcp[21276]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jan 10 09:26:22 dali libvirtd[13008]: libvirt version: 1.1.3.2, package: 1.fc20 (Fedora Project, 2013-12-14-21:11:12, buildvm-04.phx2.fedoraproject.org)
Jan 10 09:26:22 dali libvirtd[13008]: internal error: Failed to find path for dmidecode binary
Jan 10 09:26:22 dali libvirtd[13008]: internal error: Failed to find path for dmidecode binary
Jan 10 09:26:24 dali kernel: SELinux: initialized (dev mqueue, type mqueue), uses transition SIDs
Jan 10 09:26:24 dali kernel: SELinux: initialized (dev proc, type proc), uses genfs_contexts
Jan 10 09:26:24 dali libvirtd[13008]: internal error: End of file from monitor
Jan 10 09:26:24 dali libvirtd[13008]: internal error: Failed to find path for dmidecode binary
Jan 10 09:26:24 dali libvirtd[13008]: Cannot find 'ip' in path: No such file or directory

I don't understand why it can't find IP, pid 13008's PATH looks good:
# cat /proc/13008/environ 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/binLANG=en_US.utf8LC_NUMERIC=en_US.UTF-8LC_TIME=en_US.UTF-8LC_MONETARY=en_US.UTF-8LC_PAPER=en_US.UTF-8LC_MEASUREMENT=en_US.UTF-8
# ls -la /usr/sbin/ip
-rwxr-xr-x. 1 root root 301712 Oct 22 00:20 /usr/sbin/ip

Comment 5 Daniel Berrangé 2014-01-10 17:39:41 UTC
Ok, this is a SELinux policy bug I believe.

Comment 7 Daniel Walsh 2014-01-10 18:09:56 UTC
We have this rule in rawhide

#!!!! This avc is allowed in the current policy
allow init_t virtd_t:process { rlimitinh noatsecure };

We should back port all of virt.* to F20.  

Also need a3f5ac8b13d4af1a800d80d4576c5ecb17c5acee from init.

Comment 8 Miroslav Grepl 2014-01-13 13:31:46 UTC
#============= init_t ==============

#!!!! This avc is allowed in the current policy
allow init_t virtd_t:process { rlimitinh noatsecure }


All changes for virt.te go also to F20/RHEL7.

Comment 9 Fedora Update System 2014-01-13 22:58:31 UTC
selinux-policy-3.12.1-116.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/selinux-policy-3.12.1-116.fc20

Comment 10 W. Andrew Denton 2014-01-14 22:24:03 UTC
selinux-policy-3.12.1-116.fc20 has resolved my problem. Thanks!

Comment 11 Fedora Update System 2014-01-15 06:00:08 UTC
Package selinux-policy-3.12.1-116.fc20:
* should fix your issue,
* was pushed to the Fedora 20 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.12.1-116.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-0806/selinux-policy-3.12.1-116.fc20
then log in and leave karma (feedback).

Comment 12 Fedora Update System 2014-01-16 07:13:20 UTC
selinux-policy-3.12.1-116.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.