Bug 862564 - SELinux is preventing /usr/bin/qemu-kvm from create access on the rawip_socket .
Summary: SELinux is preventing /usr/bin/qemu-kvm from create access on the rawip_socket .
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-03 08:52 UTC by Carlos Soriano
Modified: 2013-07-04 06:53 UTC (History)
17 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-07-04 06:53:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Carlos Soriano 2012-10-03 08:52:50 UTC
Description of problem:
SELinux is preventing /usr/bin/qemu-kvm from create access on the rawip_socket .

Version-Release number of selected component (if applicable):
Fedora 17

How reproducible:
Creating a virtual OS in Boces application

Actual results:
Boxes crashed

Expected results:
Continue normally creating a virtual OS

Additional info:
It is solved doing:
# grep qemu-kvm /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

But doing this for solve the problem is not a good way. It should not preventing qemu-kvm to write acces in rawip_sockect by deffault

Comment 1 Miroslav Grepl 2012-10-05 12:09:45 UTC
Could you attach AVC msgs which you are getting in permissive mode? Thank you.

Comment 2 Daniel Walsh 2012-10-08 14:54:32 UTC
Carlos why does qemu needs to send rawip?

Comment 3 Michael 2012-10-24 21:21:25 UTC
I have the same problem :(...

@Daniel: Even the ping-command uses rawip-sockets and this is an essential tool for a network administrator and also developers.

nice regards

______________


SELinux is preventing /usr/bin/qemu-kvm from create access on the rawip_socket .

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

If you believe that qemu-kvm should be allowed create access on the  rawip_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 qemu-kvm /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:svirt_t:s0:c30,c485
Target Context                system_u:system_r:svirt_t:s0:c30,c485
Target Objects                 [ rawip_socket ]
Source                        qemu-kvm
Source Path                   /usr/bin/qemu-kvm
Port                          <Unknown>
Host                          michabook
Source RPM Packages           qemu-system-x86-1.0.1-2.fc17.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.10.0-156.fc17.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     michabook
Platform                      Linux michabook 3.6.2-4.fc17.x86_64 #1 SMP Wed Oct
                              17 02:43:21 UTC 2012 x86_64 x86_64
Alert Count                   4
First Seen                    2012-10-24 23:17:56 CEST
Last Seen                     2012-10-24 23:18:11 CEST
Local ID                      c0eee08b-d628-46f1-9315-194a600f1ff1

Raw Audit Messages
type=AVC msg=audit(1351113491.730:176): avc:  denied  { create } for  pid=11072 comm="qemu-kvm" scontext=system_u:system_r:svirt_t:s0:c30,c485 tcontext=system_u:system_r:svirt_t:s0:c30,c485 tclass=rawip_socket


type=SYSCALL msg=audit(1351113491.730:176): arch=x86_64 syscall=socket success=no exit=EACCES a0=2 a1=80002 a2=1 a3=a8 items=0 ppid=1 pid=11072 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=2 comm=qemu-kvm exe=/usr/bin/qemu-kvm subj=system_u:system_r:svirt_t:s0:c30,c485 key=(null)

Hash: qemu-kvm,svirt_t,svirt_t,rawip_socket,create

audit2allow

#============= svirt_t ==============
allow svirt_t self:rawip_socket create;

audit2allow -R

#============= svirt_t ==============
allow svirt_t self:rawip_socket create;

Comment 4 Cole Robinson 2013-01-15 01:34:41 UTC
I see that there's a virt_use_rawip boolean nowadays. Is rawip sufficiently dangerous that we can't just allow it by default?

usermode networking aka slirp uses rawip for ping AIUI. boxes uses usermode networking by default.

Comment 5 Daniel Walsh 2013-01-15 01:50:33 UTC
rawip means that a confined domain could watch all of the traffic coming out of the box, I believe we should not allow it by default.  I think this is a dangerous access for a confined virtual machine.

Comment 6 Paolo Bonzini 2013-01-15 17:13:55 UTC
We can change QEMU to use IPPROTO_ICMP.

Would IPPROTO_ICMP be also powerful enough that we cannot enable it by default?  And/or would it need a separate boolean?

Comment 7 Daniel Walsh 2013-01-15 17:35:57 UTC
Paolo  Not sure what IPPROTO_ICMP is?

Comment 8 Daniel Walsh 2013-01-15 17:37:50 UTC
Basically anything that allows a confined domain to look at rawouput from the ethernet device or able to generate rawip trafic is going to be blocked, if we could get a separate app that qemu could execute which we allowed rawip, like ping or something, that might solve the problem.  I don't know what access you are trying to implement.

I have added Eric Paris and Paul Moore to the CC to see if they have opinions.

Comment 9 Daniel Berrangé 2013-01-15 18:39:39 UTC
> We can change QEMU to use IPPROTO_ICMP.
> 
> Would IPPROTO_ICMP be also powerful enough that we cannot enable it by
> default?  And/or would it need a separate boolean?

What is QEMU using these sockets for ?

Comment 10 Paul Moore 2013-01-15 19:07:13 UTC
Looking quickly at the upstream QEMU sources, there appears to be a socket() call in slirp/ip_icmp.c which could be the source of this AVC:

81:        so->s = qemu_socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);

In this case qemu_socket(...) is defined in util/osdep.c and is a simple wrapper to socket().

With the current SELinux code, any socket created as AF_INET[6] SOCK_DGRAM socket that is created with a non-default protocol (IPPROTO_ICMP is not the default protocol for SOCK_DGRAM) will appear as a rawip_socket in SELinux.

I suspect the AVC is the result of the people running QEMU with the usermode networking stack.

Comment 11 Richard W.M. Jones 2013-01-16 10:54:28 UTC
Although libguestfs allows people to enable SLIRP in qemu, it's
not the default and is fairly unusual.  Also we wouldn't expect
ICMP to work in any case, because libguestfs normally runs as
non-root.  (ie. only TCP connections and the like are expected
to work).

Comment 12 Paolo Bonzini 2013-01-16 14:09:05 UTC
> With the current SELinux code, any socket created as AF_INET[6] SOCK_DGRAM 
> socket that is created with a non-default protocol (IPPROTO_ICMP is not the 
> default protocol for SOCK_DGRAM) will appear as a rawip_socket in SELinux.

Ok, that explains it.

Comment 13 Daniel Walsh 2013-01-16 15:02:49 UTC
So the question then is what to do with this bug?  Is it a bug in the kernel? qemu?  Or do we just go with the boolean.

F18 has

#============= svirt_t ==============
#!!!! This avc can be allowed using the boolean 'virt_use_rawip'

allow svirt_t self:rawip_socket create;

Comment 14 Paul Moore 2013-01-16 15:28:56 UTC
(In reply to comment #13)
> Is it a bug in the kernel?

No.  At least I don't consider it a bug.

> qemu?

No.  QEMU is a bit "odd" as far as applications go in that it does unusual things; this is just one case of its unusual behavior.

> Or do we just go with the boolean.

That seems reasonable to me.  Perhaps we can make setroubleshoot more intelligent about this particular AVC?

Comment 15 Daniel Walsh 2013-01-16 20:42:38 UTC
F18 setroubleshoot would say.

*****  Plugin catchall_boolean (89.3 confidence) suggests  *******************

If you want to allow confined virtual guests to interact with rawip sockets
Then you must tell SELinux about this by enabling the 'virt_use_rawip' boolean.
You can read 'virt_selinux' man page for more details.
Do
setsebool -P virt_use_rawip 1

Comment 16 Paul Moore 2013-01-16 21:07:53 UTC
As long as the virt_selinux manpage makes some reference to usermode networking in conjunction with the virt_use_rawip boolean I think we are okay.  Unfortunately I just checked the virt_selinux manpage on my Rawhide system and didn't see any reference of the virt_use_rawip boolean.

Comment 17 Daniel Walsh 2013-01-16 21:31:13 UTC
man svirt_selinux will be there in the next build.

Comment 18 Fedora End Of Life 2013-07-04 06:17:51 UTC
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. 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 WONTFIX if it remains open with a Fedora 
'version' of '17'.

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 prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 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 to Fedora 17's end of life.

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.


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