c401cc
From 29dbb2c9264e62ced2134af1a9346ff815843722 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <29dbb2c9264e62ced2134af1a9346ff815843722@dist-git>
c401cc
From: "Daniel P. Berrange" <berrange@redhat.com>
c401cc
Date: Tue, 18 Feb 2014 15:45:35 -0700
c401cc
Subject: [PATCH] Disks are always block devices, never character devices
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1045643
c401cc
prereq of CVE-2013-6456
c401cc
c401cc
The LXC disk hotplug code was allowing block or character devices
c401cc
to be given as disk. A disk is always a block device.
c401cc
c401cc
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
c401cc
(cherry picked from commit d24e6b8b1eb87daa6ee467b76cf343725468949c)
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/lxc/lxc_driver.c | 10 +++-------
c401cc
 1 file changed, 3 insertions(+), 7 deletions(-)
c401cc
c401cc
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
c401cc
index b098d29..227ea32 100644
c401cc
--- a/src/lxc/lxc_driver.c
c401cc
+++ b/src/lxc/lxc_driver.c
c401cc
@@ -3103,9 +3103,9 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
c401cc
         goto cleanup;
c401cc
     }
c401cc
 
c401cc
-    if (!S_ISCHR(sb.st_mode) && !S_ISBLK(sb.st_mode)) {
c401cc
+    if (!S_ISBLK(sb.st_mode)) {
c401cc
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c401cc
-                       _("Disk source %s must be a character/block device"),
c401cc
+                       _("Disk source %s must be a block device"),
c401cc
                        def->src);
c401cc
         goto cleanup;
c401cc
     }
c401cc
@@ -3117,11 +3117,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
c401cc
     if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
c401cc
         goto cleanup;
c401cc
 
c401cc
-    mode = 0700;
c401cc
-    if (S_ISCHR(sb.st_mode))
c401cc
-        mode |= S_IFCHR;
c401cc
-    else
c401cc
-        mode |= S_IFBLK;
c401cc
+    mode = 0700 | S_IFBLK;
c401cc
 
c401cc
     /* Yes, the device name we're creating may not
c401cc
      * actually correspond to the major:minor number
c401cc
-- 
c401cc
1.9.0
c401cc