Bug 852609 - [sVirt] selinux user in seclabel changed
[sVirt] selinux user in seclabel changed
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
x86_64 Linux
high Severity medium
: rc
: ---
Assigned To: Gunannan Ren
Virtualization Bugs
Depends On:
Blocks: 822589
  Show dependency treegraph
Reported: 2012-08-29 01:17 EDT by Wayne Sun
Modified: 2014-06-18 03:19 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-09-07 06:58:03 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Wayne Sun 2012-08-29 01:17:32 EDT
Description of problem:
For privilige user, the selinux user used be system_u, now is unconfined_u.

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

How reproducible:

Steps to Reproduce:
1.start a domain and check 
# virsh list --all
 Id    Name                           State
 1     libvirt_test_api               running

# virsh dumpxml libvirt_test_api
  <seclabel type='dynamic' model='dac' relabel='yes'>
  <seclabel type='dynamic' model='selinux' relabel='yes'>

# ll /var/lib/libvirt/images/libvirt-test-api -Z
-rw-r--r--. qemu qemu unconfined_u:object_r:svirt_image_t:s0:c780,c1009 /var/lib/libvirt/images/libvirt-test-api

2. save/restore domain
# virsh save libvirt_test_api /tmp/save

Domain libvirt_test_api saved to /tmp/save
# ll -Z /tmp/save 
-rw-------. root root unconfined_u:object_r:virt_tmp_t:s0 /tmp/save

The save file inherit dir label, it's expected. 

# virsh restore /tmp/save 
Domain restored from /tmp/save

# ll /tmp/save -Z
-rw-------. root root system_u:object_r:virt_content_t:s0 /tmp/save

after restore, the file seclabel changed and with system_u, this is expected. So, unconfined_u is not expected. 

Actual results:
changed from system_u to unconfined_u

Expected results:
remain no change from previous versions.

Additional info:
Comment 2 Alex Jia 2012-08-29 01:53:42 EDT
BTW, I have ever raised this issue on bug 851491, and Peter has committed patches to fix them together on bug 851491.
Comment 3 Wayne Sun 2012-08-29 02:09:57 EDT
(In reply to comment #2)
> BTW, I have ever raised this issue on bug 851491, and Peter has committed
> patches to fix them together on bug 851491.

As the note in:

(Note that the labels are different - probably because the git version isn't labeled correctly -, but the setting still fails)

The label problem still exist, this bug is for tracking this only.
Comment 4 Wayne Sun 2012-08-29 04:27:15 EDT
Tested with latest libvirt:

This problem still exists.
Comment 5 Marcelo Cerri 2012-08-29 15:56:16 EDT
The latest libvirt updates the SELinux user and role from the label that is used as base for label generation with user and role from the current SELinux context of libvirtd process.

I don't know if this is an expected behavior but it seems to be changed by this commit: 

commit 4e365df44fb1b1b93186d6be006ea445e1409a02
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Fri Aug 10 14:27:51 2012 +0100

    Honour current sensitivity and category ranges in SELinux label generation
    Currently the dynamic label generation code will create labels
    with a sensitivity of s0, and a category pair in the range
    0-1023. This is fine when running a standard MCS policy because
    libvirtd will run with a label
    With custom policies though, it is possible for libvirtd to have
    a different sensitivity, or category range. For example
    In this case we must assign the VM a sensitivity matching the
    current lower sensitivity value, and categories in the range
    Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Daniel, can you confirm this?
Comment 6 Daniel Berrange 2012-08-29 19:57:02 EDT
Yes, as described above, for process labels we now copy the user + role from libvirtd's context into the VM's context, instead of hardcoding 'system_u:system_r'. For disk labels we now copy the user from libvirtd's context into the VM's disk context, instead of hardcoding 'system_u'.
Comment 7 Marcelo Cerri 2012-09-05 10:24:34 EDT
Will this bug be changed to NOTABUG?

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