Bug 885836 - Create a svirt_tcg_t type extending svirt_t to allow execmem
Create a svirt_tcg_t type extending svirt_t to allow execmem
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: selinux-policy (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Grepl
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 885837
  Show dependency treegraph
 
Reported: 2012-12-10 13:36 EST by Daniel Berrange
Modified: 2013-04-01 14:38 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 885837 (view as bug list)
Environment:
Last Closed: 2013-04-01 14:38:55 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Berrange 2012-12-10 13:36:59 EST
Description of problem:
The current svirt_t type, correctly, refuses to allow the 'execmem' privilege for virtual machines. This is good when using KVM, but for non-native architectures (eg ARM-on-x86) we need to fallback to using QEMU's plain emulator TCG instead of KVM. Due to the nature of the emulator this requires using execmem.

Currently we tell users to manually run

  # setsebool -P virt_use_execmem 1

This sucks because it is systemwide, so reduces confinement of all their VMs, not just the one that requires execmem.

I suggest we should have a new type

  svirt_tcg_t

that extends 'svirt_t', just adding the 'execmem' privilege.

The /etc/selinux/targeted/contexts/virtual_domain_context file can be extended to have 2 lines, the second listing the new svirt_tcg_t type

libvirt's QEMU driver should then be modified to automatically default to 'svirt_tcg_t'  when running non-KVM based guest.

Then, after a release or two, we can kill off the execmem boolean completely.
Comment 1 Daniel Walsh 2012-12-10 14:43:02 EST
Fixed in selinux-policy-3.11.1-62.fc18.noarch


I switched to using your type svirt_tcg_t and updated the virtual_domain_context

I will ask Miroslav to do a build.

You can try this out on your machine now.

#  cat myvirt.te
policy_module(myvirt,1.0)
gen_require(`
role system_r;
')

virt_domain_template(svirt_tcg)
role system_r types svirt_tcg_t;

allow svirt_tcg_t self:process { execmem execstack };
corenet_udp_sendrecv_generic_if(svirt_tcg_t)
corenet_udp_sendrecv_generic_node(svirt_tcg_t)
corenet_udp_sendrecv_all_ports(svirt_tcg_t)
corenet_udp_bind_generic_node(svirt_tcg_t)
corenet_udp_bind_all_ports(svirt_tcg_t)
corenet_tcp_bind_all_ports(svirt_tcg_t)
corenet_tcp_connect_all_ports(svirt_tcg_t)

# make -f /usr/share/selinux/devel/Makefile myvirt.pp
# semodule -i myvirt.pp
Comment 2 Daniel Berrange 2012-12-12 06:46:28 EST
This seems to work ok when libvirtd is running 'virtd_t', but it doesn't work if libvirtd is 'unconfined_t'.  IIRC, we put in a special case to allow a transition from unconfined_t -> svirt_t, so we need the same for svirt_tcg_t.
Comment 3 Daniel Walsh 2012-12-13 10:28:25 EST
Yup I got to fix the virt_transition_svirt interface to include all virt_domains, not just svirt_t.
Comment 4 Cole Robinson 2012-12-16 14:07:27 EST
(In reply to comment #1)
> Fixed in selinux-policy-3.11.1-62.fc18.noarch
> 
> 
> I switched to using your type svirt_tcg_t and updated the
> virtual_domain_context
> 

Actually it doesn't look like virtual_domain_context was updated. There's a commit that claims it does just that, but:

$ rpm -q selinux-policy-targeted
selinux-policy-targeted-3.11.1-62.fc18.noarch
$ cat /etc/selinux/targeted/contexts/virtual_domain_context
system_u:system_r:svirt_t:s0

Please also make that change in F17 as well
Comment 5 Miroslav Grepl 2012-12-16 15:09:41 EST
Yes, you are right. It is going to be fixed.
Comment 6 Miroslav Grepl 2012-12-16 18:05:03 EST
Fixed in selinux-policy-3.11.1-65.fc18

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