[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>
This commit is contained in:
parent
64baf3cfea
commit
eb6f1160dd
@ -57,9 +57,11 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info)
|
|||||||
mode = strsep(&cmsp, "-");
|
mode = strsep(&cmsp, "-");
|
||||||
|
|
||||||
if (mode == NULL || strcmp(mode, "cbc") == 0)
|
if (mode == NULL || strcmp(mode, "cbc") == 0)
|
||||||
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC);
|
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC |
|
||||||
|
CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
else if (strcmp(mode, "ecb") == 0)
|
else if (strcmp(mode, "ecb") == 0)
|
||||||
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB);
|
tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB |
|
||||||
|
CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
if (tfm == NULL)
|
if (tfm == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hash the cipher key with the given hash algorithm */
|
/* Hash the cipher key with the given hash algorithm */
|
||||||
hash_tfm = crypto_alloc_tfm(opts, 0);
|
hash_tfm = crypto_alloc_tfm(opts, CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
if (hash_tfm == NULL) {
|
if (hash_tfm == NULL) {
|
||||||
ti->error = PFX "Error initializing ESSIV hash";
|
ti->error = PFX "Error initializing ESSIV hash";
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -172,7 +172,8 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
|
|||||||
|
|
||||||
/* Setup the essiv_tfm with the given salt */
|
/* Setup the essiv_tfm with the given salt */
|
||||||
essiv_tfm = crypto_alloc_tfm(crypto_tfm_alg_name(cc->tfm),
|
essiv_tfm = crypto_alloc_tfm(crypto_tfm_alg_name(cc->tfm),
|
||||||
CRYPTO_TFM_MODE_ECB);
|
CRYPTO_TFM_MODE_ECB |
|
||||||
|
CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
if (essiv_tfm == NULL) {
|
if (essiv_tfm == NULL) {
|
||||||
ti->error = PFX "Error allocating crypto tfm for ESSIV";
|
ti->error = PFX "Error allocating crypto tfm for ESSIV";
|
||||||
kfree(salt);
|
kfree(salt);
|
||||||
@ -587,7 +588,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
|
|||||||
goto bad1;
|
goto bad1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfm = crypto_alloc_tfm(cipher, crypto_flags);
|
tfm = crypto_alloc_tfm(cipher, crypto_flags | CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
if (!tfm) {
|
if (!tfm) {
|
||||||
ti->error = PFX "Error allocating crypto tfm";
|
ti->error = PFX "Error allocating crypto tfm";
|
||||||
goto bad1;
|
goto bad1;
|
||||||
|
@ -1301,7 +1301,7 @@ static int micsetup(struct airo_info *ai) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (ai->tfm == NULL)
|
if (ai->tfm == NULL)
|
||||||
ai->tfm = crypto_alloc_tfm("aes", 0);
|
ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
|
|
||||||
if (ai->tfm == NULL) {
|
if (ai->tfm == NULL) {
|
||||||
printk(KERN_ERR "airo: failed to load transform for AES\n");
|
printk(KERN_ERR "airo: failed to load transform for AES\n");
|
||||||
|
@ -93,7 +93,7 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
|
|||||||
|
|
||||||
dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
|
dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
|
||||||
clname->len, clname->data);
|
clname->len, clname->data);
|
||||||
tfm = crypto_alloc_tfm("md5", 0);
|
tfm = crypto_alloc_tfm("md5", CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
if (tfm == NULL)
|
if (tfm == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
cksum.len = crypto_tfm_alg_digestsize(tfm);
|
cksum.len = crypto_tfm_alg_digestsize(tfm);
|
||||||
|
@ -160,7 +160,7 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
|
|||||||
" unsupported checksum %d", cksumtype);
|
" unsupported checksum %d", cksumtype);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!(tfm = crypto_alloc_tfm(cksumname, 0)))
|
if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP)))
|
||||||
goto out;
|
goto out;
|
||||||
cksum->len = crypto_tfm_alg_digestsize(tfm);
|
cksum->len = crypto_tfm_alg_digestsize(tfm);
|
||||||
if ((cksum->data = kmalloc(cksum->len, GFP_KERNEL)) == NULL)
|
if ((cksum->data = kmalloc(cksum->len, GFP_KERNEL)) == NULL)
|
||||||
|
@ -321,7 +321,7 @@ plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
|
|||||||
"bytes.\n", len, PAGE_SIZE);
|
"bytes.\n", len, PAGE_SIZE);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
tfm = crypto_alloc_tfm("sha1", 0);
|
tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||||
if (tfm == NULL) {
|
if (tfm == NULL) {
|
||||||
seclvl_printk(0, KERN_ERR,
|
seclvl_printk(0, KERN_ERR,
|
||||||
"Failed to load transform for SHA1\n");
|
"Failed to load transform for SHA1\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user