Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Herbert Xu and committed by
David S. Miller
eb6f1160 64baf3cf

+12 -9
+4 -2
drivers/block/cryptoloop.c
··· 57 57 mode = strsep(&cmsp, "-"); 58 58 59 59 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); 61 62 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); 63 65 if (tfm == NULL) 64 66 return -EINVAL; 65 67
+4 -3
drivers/md/dm-crypt.c
··· 144 144 } 145 145 146 146 /* 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); 148 148 if (hash_tfm == NULL) { 149 149 ti->error = PFX "Error initializing ESSIV hash"; 150 150 return -EINVAL; ··· 172 172 173 173 /* Setup the essiv_tfm with the given salt */ 174 174 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); 176 177 if (essiv_tfm == NULL) { 177 178 ti->error = PFX "Error allocating crypto tfm for ESSIV"; 178 179 kfree(salt); ··· 588 587 goto bad1; 589 588 } 590 589 591 - tfm = crypto_alloc_tfm(cipher, crypto_flags); 590 + tfm = crypto_alloc_tfm(cipher, crypto_flags | CRYPTO_TFM_REQ_MAY_SLEEP); 592 591 if (!tfm) { 593 592 ti->error = PFX "Error allocating crypto tfm"; 594 593 goto bad1;
+1 -1
drivers/net/wireless/airo.c
··· 1301 1301 int i; 1302 1302 1303 1303 if (ai->tfm == NULL) 1304 - ai->tfm = crypto_alloc_tfm("aes", 0); 1304 + ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP); 1305 1305 1306 1306 if (ai->tfm == NULL) { 1307 1307 printk(KERN_ERR "airo: failed to load transform for AES\n");
+1 -1
fs/nfsd/nfs4recover.c
··· 93 93 94 94 dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n", 95 95 clname->len, clname->data); 96 - tfm = crypto_alloc_tfm("md5", 0); 96 + tfm = crypto_alloc_tfm("md5", CRYPTO_TFM_REQ_MAY_SLEEP); 97 97 if (tfm == NULL) 98 98 goto out; 99 99 cksum.len = crypto_tfm_alg_digestsize(tfm);
+1 -1
net/sunrpc/auth_gss/gss_krb5_crypto.c
··· 160 160 " unsupported checksum %d", cksumtype); 161 161 goto out; 162 162 } 163 - if (!(tfm = crypto_alloc_tfm(cksumname, 0))) 163 + if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP))) 164 164 goto out; 165 165 cksum->len = crypto_tfm_alg_digestsize(tfm); 166 166 if ((cksum->data = kmalloc(cksum->len, GFP_KERNEL)) == NULL)
+1 -1
security/seclvl.c
··· 321 321 "bytes.\n", len, PAGE_SIZE); 322 322 return -ENOMEM; 323 323 } 324 - tfm = crypto_alloc_tfm("sha1", 0); 324 + tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP); 325 325 if (tfm == NULL) { 326 326 seclvl_printk(0, KERN_ERR, 327 327 "Failed to load transform for SHA1\n");