RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1066894 - Implement for libvirt guest's xml for security label
Summary: Implement for libvirt guest's xml for security label
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1066895
TreeView+ depends on / blocked
 
Reported: 2014-02-19 10:12 UTC by zhenfeng wang
Modified: 2015-03-05 07:30 UTC (History)
8 users (show)

Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1066895 (view as bug list)
Environment:
Last Closed: 2015-03-05 07:30:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description zhenfeng wang 2014-02-19 10:12:36 UTC
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 14:05:39 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2014-July/msg00526.html

Comment 4 Michal Privoznik 2014-07-11 08:41:54 UTC
So I've just pushed the patch upstream:

commit d1abf819cf1b2fda893c029344de77d5b6cc5ba9
Author:     Michal Privoznik <mprivozn>
AuthorDate: Wed Jul 9 15:15:27 2014 +0200
Commit:     Michal Privoznik <mprivozn>
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>

v1.2.6-123-gd1abf81

Comment 6 zhengqin 2014-08-21 06:48:47 UTC
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 08:56:02 UTC
(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 09:26:18 UTC
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 07:30:28 UTC
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.