~ubuntu-branches/ubuntu/quantal/nova/quantal-security

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2012-5625.patch

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2013-01-29 09:34:02 UTC
  • mfrom: (94.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20130129093402-17tbp37f5load7my
Tags: 2012.2.1+stable-20121212-a99a802e-0ubuntu1.1
* SECURITY UPDATE: fix lack of authentication on block device used for
  os-volume_boot
  - debian/patches/CVE-2013-0208.patch: adjust nova/compute/api.py to
    validate we can access the volumes
  - CVE-2013-0208

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From: Pádraig Brady <pbrady@redhat.com>
2
 
Date: Fri, 23 Nov 2012 14:59:13 +0000 (+0000)
3
 
Subject: Don't leak info from libvirt LVM backed instances
4
 
X-Git-Url: https://review.openstack.org/gitweb?p=openstack%2Fnova.git;a=commitdiff_plain;h=a99a802e008eed18e39fc1d98170edc495cbd354
5
 
 
6
 
Don't leak info from libvirt LVM backed instances
7
 
 
8
 
* nova/virt/libvirt/utils.py (remove_logical_volumes):
9
 
Overwrite each logical volume with zero
10
 
(clear_logical_volume): LV obfuscation implementation.
11
 
(logical_volume_size): A utility function used by
12
 
clear_logical_volume()
13
 
 
14
 
Fixes bug: 1070539
15
 
Change-Id: I4e1024de8dfe9b0be3b0d6437c836d2042862f85
16
 
---
17
 
 
18
 
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
19
 
index cb39eac..82dc956 100644
20
 
--- a/nova/virt/libvirt/utils.py
21
 
+++ b/nova/virt/libvirt/utils.py
22
 
@@ -149,8 +149,52 @@ def list_logical_volumes(vg):
23
 
     return [line.strip() for line in out.splitlines()]
24
 
 
25
 
 
26
 
+def logical_volume_size(path):
27
 
+    """Get logical volume size in bytes.
28
 
+
29
 
+    :param path: logical volume path
30
 
+    """
31
 
+    # TODO(p-draigbrady) POssibly replace with the more general
32
 
+    # use of blockdev --getsize64 in future
33
 
+    out, _err = execute('lvs', '-o', 'lv_size', '--noheadings', '--units',
34
 
+                        'b', '--nosuffix', path, run_as_root=True)
35
 
+
36
 
+    return int(out)
37
 
+
38
 
+
39
 
+def clear_logical_volume(path):
40
 
+    """Obfuscate the logical volume.
41
 
+
42
 
+    :param path: logical volume path
43
 
+    """
44
 
+    # TODO(p-draigbrady): We currently overwrite with zeros
45
 
+    # but we may want to make this configurable in future
46
 
+    # for more or less security conscious setups.
47
 
+
48
 
+    vol_size = logical_volume_size(path)
49
 
+    bs = 1024 * 1024
50
 
+    remaining_bytes = vol_size
51
 
+
52
 
+    # The loop caters for versions of dd that
53
 
+    # don't support the iflag=count_bytes option.
54
 
+    while remaining_bytes:
55
 
+        zero_blocks = remaining_bytes / bs
56
 
+        seek_blocks = (vol_size - remaining_bytes) / bs
57
 
+        zero_cmd = ('dd', 'bs=%s' % bs,
58
 
+                    'if=/dev/zero', 'of=%s' % path,
59
 
+                    'seek=%s' % seek_blocks, 'count=%s' % zero_blocks)
60
 
+        if zero_blocks:
61
 
+            utils.execute(*zero_cmd, run_as_root=True)
62
 
+        remaining_bytes %= bs
63
 
+        bs /= 1024  # Limit to 3 iterations
64
 
+
65
 
+
66
 
 def remove_logical_volumes(*paths):
67
 
     """Remove one or more logical volume."""
68
 
+
69
 
+    for path in paths:
70
 
+        clear_logical_volume(path)
71
 
+
72
 
     if paths:
73
 
         lvremove = ('lvremove', '-f') + paths
74
 
         execute(*lvremove, attempts=3, run_as_root=True)