summaryrefslogtreecommitdiffstats
path: root/recipes-extended/ceph/ceph/CVE-2021-3979.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-extended/ceph/ceph/CVE-2021-3979.patch')
-rw-r--r--recipes-extended/ceph/ceph/CVE-2021-3979.patch158
1 files changed, 0 insertions, 158 deletions
diff --git a/recipes-extended/ceph/ceph/CVE-2021-3979.patch b/recipes-extended/ceph/ceph/CVE-2021-3979.patch
deleted file mode 100644
index 081b32ba..00000000
--- a/recipes-extended/ceph/ceph/CVE-2021-3979.patch
+++ /dev/null
@@ -1,158 +0,0 @@
1From 47c33179f9a15ae95cc1579a421be89378602656 Mon Sep 17 00:00:00 2001
2From: Guillaume Abrioux <gabrioux@redhat.com>
3Date: Tue, 25 Jan 2022 10:25:53 +0100
4Subject: [PATCH] ceph-volume: honour osd_dmcrypt_key_size option
5
6ceph-volume doesn't honour osd_dmcrypt_key_size.
7It means the default size is always applied.
8
9It also changes the default value in `get_key_size_from_conf()`
10
11From cryptsetup manpage:
12
13> For XTS mode you can optionally set a key size of 512 bits with the -s option.
14
15Using more than 512bits will end up with the following error message:
16
17```
18Key size in XTS mode must be 256 or 512 bits.
19```
20
21Fixes: https://tracker.ceph.com/issues/54006
22
23Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
24
25Upstream-Status: Backport
26 github.com/ceph/ceph.git
27 equivalent to cherry-pick of commit 47c33179f9a15ae95cc1579a421be89378602656
28
29CVE: CVE-2021-3979
30
31Signed-off-by: Joe Slater <joe.slater@windriver.com>
32---
33 .../ceph_volume/tests/util/test_encryption.py | 41 +++++++++++++------
34 .../ceph_volume/util/encryption.py | 34 ++++++++++-----
35 2 files changed, 51 insertions(+), 24 deletions(-)
36
37diff --git a/src/ceph-volume/ceph_volume/tests/util/test_encryption.py b/src/ceph-volume/ceph_volume/tests/util/test_encryption.py
38index e1420b440d3..c86dc50b7c7 100644
39--- a/src/ceph-volume/ceph_volume/tests/util/test_encryption.py
40+++ b/src/ceph-volume/ceph_volume/tests/util/test_encryption.py
41@@ -1,5 +1,31 @@
42 from ceph_volume.util import encryption
43+import base64
44
45+class TestGetKeySize(object):
46+ def test_get_size_from_conf_default(self, conf_ceph_stub):
47+ conf_ceph_stub('''
48+ [global]
49+ fsid=asdf
50+ ''')
51+ assert encryption.get_key_size_from_conf() == '512'
52+
53+ def test_get_size_from_conf_custom(self, conf_ceph_stub):
54+ conf_ceph_stub('''
55+ [global]
56+ fsid=asdf
57+ [osd]
58+ osd_dmcrypt_key_size=256
59+ ''')
60+ assert encryption.get_key_size_from_conf() == '256'
61+
62+ def test_get_size_from_conf_custom_invalid(self, conf_ceph_stub):
63+ conf_ceph_stub('''
64+ [global]
65+ fsid=asdf
66+ [osd]
67+ osd_dmcrypt_key_size=1024
68+ ''')
69+ assert encryption.get_key_size_from_conf() == '512'
70
71 class TestStatus(object):
72
73@@ -37,17 +63,6 @@ class TestDmcryptClose(object):
74
75 class TestDmcryptKey(object):
76
77- def test_dmcrypt_with_default_size(self, conf_ceph_stub):
78- conf_ceph_stub('[global]\nfsid=asdf-lkjh')
79- result = encryption.create_dmcrypt_key()
80- assert len(result) == 172
81-
82- def test_dmcrypt_with_custom_size(self, conf_ceph_stub):
83- conf_ceph_stub('''
84- [global]
85- fsid=asdf
86- [osd]
87- osd_dmcrypt_size=8
88- ''')
89+ def test_dmcrypt(self):
90 result = encryption.create_dmcrypt_key()
91- assert len(result) == 172
92+ assert len(base64.b64decode(result)) == 128
93diff --git a/src/ceph-volume/ceph_volume/util/encryption.py b/src/ceph-volume/ceph_volume/util/encryption.py
94index 72a0ccf121e..2a2c03337b6 100644
95--- a/src/ceph-volume/ceph_volume/util/encryption.py
96+++ b/src/ceph-volume/ceph_volume/util/encryption.py
97@@ -9,21 +9,29 @@ from .disk import lsblk, device_family, get_part_entry_type
98
99 logger = logging.getLogger(__name__)
100
101-
102-def create_dmcrypt_key():
103+def get_key_size_from_conf():
104 """
105- Create the secret dm-crypt key used to decrypt a device.
106+ Return the osd dmcrypt key size from config file.
107+ Default is 512.
108 """
109- # get the customizable dmcrypt key size (in bits) from ceph.conf fallback
110- # to the default of 1024
111- dmcrypt_key_size = conf.ceph.get_safe(
112+ default_key_size = '512'
113+ key_size = conf.ceph.get_safe(
114 'osd',
115 'osd_dmcrypt_key_size',
116- default=1024,
117- )
118- # The size of the key is defined in bits, so we must transform that
119- # value to bytes (dividing by 8) because we read in bytes, not bits
120- random_string = os.urandom(int(dmcrypt_key_size / 8))
121+ default='512')
122+
123+ if key_size not in ['256', '512']:
124+ logger.warning(("Invalid value set for osd_dmcrypt_key_size ({}). "
125+ "Falling back to {}bits".format(key_size, default_key_size)))
126+ return default_key_size
127+
128+ return key_size
129+
130+def create_dmcrypt_key():
131+ """
132+ Create the secret dm-crypt key (KEK) used to encrypt/decrypt the Volume Key.
133+ """
134+ random_string = os.urandom(128)
135 key = base64.b64encode(random_string).decode('utf-8')
136 return key
137
138@@ -38,6 +46,8 @@ def luks_format(key, device):
139 command = [
140 'cryptsetup',
141 '--batch-mode', # do not prompt
142+ '--key-size',
143+ get_key_size_from_conf(),
144 '--key-file', # misnomer, should be key
145 '-', # because we indicate stdin for the key here
146 'luksFormat',
147@@ -83,6 +93,8 @@ def luks_open(key, device, mapping):
148 """
149 command = [
150 'cryptsetup',
151+ '--key-size',
152+ get_key_size_from_conf(),
153 '--key-file',
154 '-',
155 '--allow-discards', # allow discards (aka TRIM) requests for device
156--
1572.35.1
158