Skip to content

Commit cd74693

Browse files
Mikulas Patockasnitm
Mikulas Patocka
authored andcommitted
dm crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY
Don't use crypto drivers that have the flag CRYPTO_ALG_ALLOCATES_MEMORY set. These drivers allocate memory and thus they are unsuitable for block I/O processing. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent d4a512e commit cd74693

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/md/dm-crypt.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ static int crypt_iv_lmk_ctr(struct crypt_config *cc, struct dm_target *ti,
424424
return -EINVAL;
425425
}
426426

427-
lmk->hash_tfm = crypto_alloc_shash("md5", 0, 0);
427+
lmk->hash_tfm = crypto_alloc_shash("md5", 0,
428+
CRYPTO_ALG_ALLOCATES_MEMORY);
428429
if (IS_ERR(lmk->hash_tfm)) {
429430
ti->error = "Error initializing LMK hash";
430431
return PTR_ERR(lmk->hash_tfm);
@@ -586,7 +587,8 @@ static int crypt_iv_tcw_ctr(struct crypt_config *cc, struct dm_target *ti,
586587
return -EINVAL;
587588
}
588589

589-
tcw->crc32_tfm = crypto_alloc_shash("crc32", 0, 0);
590+
tcw->crc32_tfm = crypto_alloc_shash("crc32", 0,
591+
CRYPTO_ALG_ALLOCATES_MEMORY);
590592
if (IS_ERR(tcw->crc32_tfm)) {
591593
ti->error = "Error initializing CRC32 in TCW";
592594
return PTR_ERR(tcw->crc32_tfm);
@@ -773,7 +775,8 @@ static int crypt_iv_elephant_ctr(struct crypt_config *cc, struct dm_target *ti,
773775
struct iv_elephant_private *elephant = &cc->iv_gen_private.elephant;
774776
int r;
775777

776-
elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0);
778+
elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0,
779+
CRYPTO_ALG_ALLOCATES_MEMORY);
777780
if (IS_ERR(elephant->tfm)) {
778781
r = PTR_ERR(elephant->tfm);
779782
elephant->tfm = NULL;
@@ -2154,7 +2157,8 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode)
21542157
return -ENOMEM;
21552158

21562159
for (i = 0; i < cc->tfms_count; i++) {
2157-
cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0, 0);
2160+
cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0,
2161+
CRYPTO_ALG_ALLOCATES_MEMORY);
21582162
if (IS_ERR(cc->cipher_tfm.tfms[i])) {
21592163
err = PTR_ERR(cc->cipher_tfm.tfms[i]);
21602164
crypt_free_tfms(cc);
@@ -2180,7 +2184,8 @@ static int crypt_alloc_tfms_aead(struct crypt_config *cc, char *ciphermode)
21802184
if (!cc->cipher_tfm.tfms)
21812185
return -ENOMEM;
21822186

2183-
cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0, 0);
2187+
cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0,
2188+
CRYPTO_ALG_ALLOCATES_MEMORY);
21842189
if (IS_ERR(cc->cipher_tfm.tfms_aead[0])) {
21852190
err = PTR_ERR(cc->cipher_tfm.tfms_aead[0]);
21862191
crypt_free_tfms(cc);
@@ -2667,7 +2672,7 @@ static int crypt_ctr_auth_cipher(struct crypt_config *cc, char *cipher_api)
26672672
return -ENOMEM;
26682673
strncpy(mac_alg, start, end - start);
26692674

2670-
mac = crypto_alloc_ahash(mac_alg, 0, 0);
2675+
mac = crypto_alloc_ahash(mac_alg, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
26712676
kfree(mac_alg);
26722677

26732678
if (IS_ERR(mac))

0 commit comments

Comments
 (0)