render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
5b1a90
From 3a8e136e6b46174f347e088ade020c168fffafad Mon Sep 17 00:00:00 2001
5b1a90
From: Cole Robinson <crobinso@redhat.com>
5b1a90
Date: Wed, 24 Sep 2014 11:47:46 -0400
5b1a90
Subject: [PATCH] security: Fix labelling host devices (bz 1145968)
5b1a90
5b1a90
The check for ISCSI devices was missing a check of subsys type, which
5b1a90
meant we could skip labelling of other host devices as well. This fixes
5b1a90
USB hotplug on F21
5b1a90
5b1a90
https://bugzilla.redhat.com/show_bug.cgi?id=1145968
5b1a90
---
5b1a90
 src/security/security_apparmor.c | 3 ++-
5b1a90
 src/security/security_dac.c      | 6 ++++--
5b1a90
 src/security/security_selinux.c  | 6 ++++--
5b1a90
 3 files changed, 10 insertions(+), 5 deletions(-)
5b1a90
5b1a90
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
5b1a90
index 041ce65..3025284 100644
5b1a90
--- a/src/security/security_apparmor.c
5b1a90
+++ b/src/security/security_apparmor.c
5b1a90
@@ -828,7 +828,8 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
5b1a90
     /* Like AppArmorRestoreSecurityImageLabel() for a networked disk,
5b1a90
      * do nothing for an iSCSI hostdev
5b1a90
      */
5b1a90
-    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
+    if (dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
5b1a90
+        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
         return 0;
5b1a90
 
5b1a90
     if (profile_loaded(secdef->imagelabel) < 0)
5b1a90
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
5b1a90
index e398d2c..85253af 100644
5b1a90
--- a/src/security/security_dac.c
5b1a90
+++ b/src/security/security_dac.c
5b1a90
@@ -523,7 +523,8 @@ virSecurityDACSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
5b1a90
     /* Like virSecurityDACSetSecurityImageLabel() for a networked disk,
5b1a90
      * do nothing for an iSCSI hostdev
5b1a90
      */
5b1a90
-    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
+    if (dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
5b1a90
+        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
         return 0;
5b1a90
 
5b1a90
     cbdata.manager = mgr;
5b1a90
@@ -657,7 +658,8 @@ virSecurityDACRestoreSecurityHostdevLabel(virSecurityManagerPtr mgr,
5b1a90
     /* Like virSecurityDACRestoreSecurityImageLabelInt() for a networked disk,
5b1a90
      * do nothing for an iSCSI hostdev
5b1a90
      */
5b1a90
-    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
+    if (dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
5b1a90
+        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
         return 0;
5b1a90
 
5b1a90
     switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
5b1a90
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
5b1a90
index b9efbc5..ea1efc9 100644
5b1a90
--- a/src/security/security_selinux.c
5b1a90
+++ b/src/security/security_selinux.c
5b1a90
@@ -1327,7 +1327,8 @@ virSecuritySELinuxSetSecurityHostdevSubsysLabel(virDomainDefPtr def,
5b1a90
     /* Like virSecuritySELinuxSetSecurityImageLabelInternal() for a networked
5b1a90
      * disk, do nothing for an iSCSI hostdev
5b1a90
      */
5b1a90
-    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
+    if (dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
5b1a90
+        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
         return 0;
5b1a90
 
5b1a90
     switch (dev->source.subsys.type) {
5b1a90
@@ -1520,7 +1521,8 @@ virSecuritySELinuxRestoreSecurityHostdevSubsysLabel(virSecurityManagerPtr mgr,
5b1a90
     /* Like virSecuritySELinuxRestoreSecurityImageLabelInt() for a networked
5b1a90
      * disk, do nothing for an iSCSI hostdev
5b1a90
      */
5b1a90
-    if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
+    if (dev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
5b1a90
+        scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
5b1a90
         return 0;
5b1a90
 
5b1a90
     switch (dev->source.subsys.type) {