Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1066894 - Implement for libvirt guest's xml for security label
Implement for libvirt guest's xml for security label
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
x86_64 Linux
low Severity low
: rc
: ---
Assigned To: Michal Privoznik
Virtualization Bugs
: Upstream
Depends On:
Blocks: 1066895
  Show dependency treegraph
 
Reported: 2014-02-19 05:12 EST by zhenfeng wang
Modified: 2015-03-05 02:30 EST (History)
8 users (show)

See Also:
Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1066895 (view as bug list)
Environment:
Last Closed: 2015-03-05 02:30:28 EST
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)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 07:10:54 EST

  None (edit)
Description zhenfeng wang 2014-02-19 05:12:36 EST
Description of problem:
Implement for libvirt guest's xml that it should report error or left only one uniqure security label while there have two or more same Security label in the guest's xml

Version-Release number of selected component (if applicable):
kernel-3.10.0-88.el7.x86_64
qemu-kvm-rhev-1.5.3-47.el7.x86_64
libvirt-1.1.1-23.el7.x86_64
libselinux-2.2.2-6.el7.x86_64
selinux-policy-3.12.1-125.el7.noarch
How reproducible:
100%

Steps
1.Prepare a normal guest
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel75                         shut off

2.Edit the guest's xml, Add 5 or more same security label, save the guest's xml,
it didn't report error while edit the guest's xml, also it generate many same
seclabel in the guest's xml , i think we can do some implement for this issue
#virsh edit rhel75
--
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
--

#virsh dumpxml rhel75|grep seclabel
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>

3.Start the guest, check the guest's xml, we can see only one seclabel work,
other seclabel didn't work
#virsh start rhel75
# virsh dumpxml rhel75 |grep seclabel -A 3
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c12,c756</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c12,c756</imagelabel>
  </seclabel>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>

Actual results:
As step 2

Expected results:
As Description
Comment 3 Michal Privoznik 2014-07-10 10:05:39 EDT
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2014-July/msg00526.html
Comment 4 Michal Privoznik 2014-07-11 04:41:54 EDT
So I've just pushed the patch upstream:

commit d1abf819cf1b2fda893c029344de77d5b6cc5ba9
Author:     Michal Privoznik <mprivozn@redhat.com>
AuthorDate: Wed Jul 9 15:15:27 2014 +0200
Commit:     Michal Privoznik <mprivozn@redhat.com>
CommitDate: Fri Jul 11 10:36:08 2014 +0200

    conf: Don't allow multiple seclabels for same model
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1066894
    
    With current code it's possible to have for instance:
    
    virsh dumpxml mydomain | grep seclabel
      <seclabel type='dynamic' model='selinux' relabel='yes'/>
      <seclabel type='dynamic' model='selinux' relabel='yes'/>
      <seclabel type='dynamic' model='selinux' relabel='yes'/>
      <seclabel type='dynamic' model='selinux' relabel='yes'/>
      <seclabel type='dynamic' model='selinux' relabel='yes'/>
    
    what doesn't make any sense. We should reject the XML in the config
    parsing phase.
    
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

v1.2.6-123-gd1abf81
Comment 6 zhengqin 2014-08-21 02:48:47 EDT
I could reproduce this issue with libvirt-1.1.1-23.el7.x86_64 as following steps:

1.Prepare a normal guest
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel6                         shut off

2.Edit the guest's xml, Add 5 or more same security label, save the guest's xml,
it didn't report error while edit the guest's xml, also it generate many same
seclabel in the guest's xml , i think we can do some implement for this issue
#virsh edit rhel6
--
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
--

#virsh dumpxml rhel6 | grep seclabel
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>

3.Start the guest, check the guest's xml, we can see only one seclabel work,
other seclabel didn't work
#virsh start rhel6
# virsh dumpxml rhel6 |grep seclabel -A 3
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c12,c756</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c12,c756</imagelabel>
  </seclabel>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>
  <seclabel type='dynamic' model='selinux' relabel='yes'/>






Verified this with libvirt-1.2.7-1.el7.x86_64:

1.Prepare a normal guest
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel6                         shut off

2.Edit the guest's xml, Add 5 or more same security label, save the guest's xml,
it will report error while edit the guest's xml to prevent this change:

#virsh edit rhel6
--
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>
--

error: seclablel for model selinux is already provided
Failed. Try again? [y,n,f,?]:


Only one instance for seclabel is allowed to save.
Comment 7 Michal Privoznik 2014-08-21 04:56:02 EDT
(In reply to zhengqin from comment #6)
> 
> Only one instance for seclabel is allowed to save.

Awesome, that's expected behavior.
Comment 8 zhenfeng wang 2014-11-24 04:26:18 EST
Verify this bug with libvirt-1.2.8-8.el7.x86_64
steps
1.Prepare a normal guest
# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel7.0                        shut off

2.Edit the guest's xml, Add 2 or more same security label, save the guest's xml,
it will report error while edit the guest's xml to prevent this change:

#virsh edit rhel7.0
--
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='selinux'/>

--

error: seclablel for model selinux is already provided
Failed. Try again? [y,n,f,?]:


Only one instance for seclabel is allowed to save.

3.add multi-seclabel with different model,which could be saved successfully
<seclabel type='dynamic' model='selinux'/>
<seclabel type='dynamic' model='dac' relabel='yes'/>
<seclabel type='dynamic' model='abc' relabel='yes'/>

According to the upper steps, mark this bug verifed
Comment 10 errata-xmlrpc 2015-03-05 02:30:28 EST
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/RHSA-2015-0323.html

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