Skip to content

Commit eb6f116

Browse files
herbertxdavem330
authored andcommitted
[CRYPTO]: Use CRYPTO_TFM_REQ_MAY_SLEEP where appropriate
This patch goes through the current users of the crypto layer and sets CRYPTO_TFM_REQ_MAY_SLEEP at crypto_alloc_tfm() where all crypto operations are performed in process context. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 64baf3c commit eb6f116

6 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎drivers/block/cryptoloop.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info)
5757
mode = strsep(&cmsp, "-");
5858

5959
if (mode == NULL || strcmp(mode, "cbc") == 0)
60-
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC);
60+
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC |
61+
CRYPTO_TFM_REQ_MAY_SLEEP);
6162
else if (strcmp(mode, "ecb") == 0)
62-
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB);
63+
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB |
64+
CRYPTO_TFM_REQ_MAY_SLEEP);
6365
if (tfm == NULL)
6466
return -EINVAL;
6567

‎drivers/md/dm-crypt.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
144144
}
145145

146146
/* Hash the cipher key with the given hash algorithm */
147-
hash_tfm = crypto_alloc_tfm(opts, 0);
147+
hash_tfm = crypto_alloc_tfm(opts, CRYPTO_TFM_REQ_MAY_SLEEP);
148148
if (hash_tfm == NULL) {
149149
ti->error = PFX "Error initializing ESSIV hash";
150150
return -EINVAL;
@@ -172,7 +172,8 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
172172

173173
/* Setup the essiv_tfm with the given salt */
174174
essiv_tfm = crypto_alloc_tfm(crypto_tfm_alg_name(cc->tfm),
175-
CRYPTO_TFM_MODE_ECB);
175+
CRYPTO_TFM_MODE_ECB |
176+
CRYPTO_TFM_REQ_MAY_SLEEP);
176177
if (essiv_tfm == NULL) {
177178
ti->error = PFX "Error allocating crypto tfm for ESSIV";
178179
kfree(salt);
@@ -587,7 +588,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
587588
goto bad1;
588589
}
589590

590-
tfm = crypto_alloc_tfm(cipher, crypto_flags);
591+
tfm = crypto_alloc_tfm(cipher, crypto_flags | CRYPTO_TFM_REQ_MAY_SLEEP);
591592
if (!tfm) {
592593
ti->error = PFX "Error allocating crypto tfm";
593594
goto bad1;

‎drivers/net/wireless/airo.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ static int micsetup(struct airo_info *ai) {
13011301
int i;
13021302

13031303
if (ai->tfm == NULL)
1304-
ai->tfm = crypto_alloc_tfm("aes", 0);
1304+
ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP);
13051305

13061306
if (ai->tfm == NULL) {
13071307
printk(KERN_ERR "airo: failed to load transform for AES\n");

‎fs/nfsd/nfs4recover.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
9393

9494
dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
9595
clname->len, clname->data);
96-
tfm = crypto_alloc_tfm("md5", 0);
96+
tfm = crypto_alloc_tfm("md5", CRYPTO_TFM_REQ_MAY_SLEEP);
9797
if (tfm == NULL)
9898
goto out;
9999
cksum.len = crypto_tfm_alg_digestsize(tfm);

‎net/sunrpc/auth_gss/gss_krb5_crypto.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
160160
" unsupported checksum %d", cksumtype);
161161
goto out;
162162
}
163-
if (!(tfm = crypto_alloc_tfm(cksumname, 0)))
163+
if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP)))
164164
goto out;
165165
cksum->len = crypto_tfm_alg_digestsize(tfm);
166166
if ((cksum->data = kmalloc(cksum->len, GFP_KERNEL)) == NULL)

‎security/seclvl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
321321
"bytes.\n", len, PAGE_SIZE);
322322
return -ENOMEM;
323323
}
324-
tfm = crypto_alloc_tfm("sha1", 0);
324+
tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP);
325325
if (tfm == NULL) {
326326
seclvl_printk(0, KERN_ERR,
327327
"Failed to load transform for SHA1\n");

0 commit comments

Comments
 (0)