mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
crypto: shash - remove shash_desc::flags
The flags field in 'struct shash_desc' never actually does anything. The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP. However, no shash algorithm ever sleeps, making this flag a no-op. With this being the case, inevitably some users who can't sleep wrongly pass MAY_SLEEP. These would all need to be fixed if any shash algorithm actually started sleeping. For example, the shash_ahash_*() functions, which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP from the ahash API to the shash API. However, the shash functions are called under kmap_atomic(), so actually they're assumed to never sleep. Even if it turns out that some users do need preemption points while hashing large buffers, we could easily provide a helper function crypto_shash_update_large() which divides the data into smaller chunks and calls crypto_shash_update() and cond_resched() for each chunk. It's not necessary to have a flag in 'struct shash_desc', nor is it necessary to make individual shash algorithms aware of this at all. Therefore, remove shash_desc::flags, and document that the crypto_shash_*() functions can be called from any context. Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
This commit is contained in:
parent
75f2222832
commit
877b5691f2
66 changed files with 8 additions and 113 deletions
|
|
@ -265,7 +265,6 @@ static int adiantum_hash_message(struct skcipher_request *req,
|
|||
int err;
|
||||
|
||||
hash_desc->tfm = tctx->hash;
|
||||
hash_desc->flags = 0;
|
||||
|
||||
err = crypto_shash_init(hash_desc);
|
||||
if (err)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ static int pkcs7_digest(struct pkcs7_message *pkcs7,
|
|||
goto error_no_desc;
|
||||
|
||||
desc->tfm = tfm;
|
||||
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
/* Digest the message [RFC2315 9.3] */
|
||||
ret = crypto_shash_digest(desc, pkcs7->data, pkcs7->data_len,
|
||||
|
|
|
|||
|
|
@ -354,7 +354,6 @@ static int pefile_digest_pe(const void *pebuf, unsigned int pelen,
|
|||
goto error_no_desc;
|
||||
|
||||
desc->tfm = tfm;
|
||||
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
ret = crypto_shash_init(desc);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ int x509_get_sig_params(struct x509_certificate *cert)
|
|||
goto error;
|
||||
|
||||
desc->tfm = tfm;
|
||||
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
ret = crypto_shash_digest(desc, cert->tbs, cert->tbs_size, sig->digest);
|
||||
if (ret < 0)
|
||||
|
|
|
|||
|
|
@ -545,7 +545,6 @@ static void cryptd_hash_init(struct crypto_async_request *req_async, int err)
|
|||
goto out;
|
||||
|
||||
desc->tfm = child;
|
||||
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
err = crypto_shash_init(desc);
|
||||
|
||||
|
|
@ -637,7 +636,6 @@ static void cryptd_hash_digest(struct crypto_async_request *req_async, int err)
|
|||
goto out;
|
||||
|
||||
desc->tfm = child;
|
||||
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
err = shash_ahash_digest(req, desc);
|
||||
|
||||
|
|
@ -666,7 +664,6 @@ static int cryptd_hash_import(struct ahash_request *req, const void *in)
|
|||
struct shash_desc *desc = cryptd_shash_desc(req);
|
||||
|
||||
desc->tfm = ctx->child;
|
||||
desc->flags = req->base.flags;
|
||||
|
||||
return crypto_shash_import(desc, in);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1587,7 +1587,6 @@ static int drbg_init_hash_kernel(struct drbg_state *drbg)
|
|||
}
|
||||
|
||||
sdesc->shash.tfm = tfm;
|
||||
sdesc->shash.flags = 0;
|
||||
drbg->priv_data = sdesc;
|
||||
|
||||
return crypto_shash_alignmask(tfm);
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ static int hmac_setkey(struct crypto_shash *parent,
|
|||
unsigned int i;
|
||||
|
||||
shash->tfm = hash;
|
||||
shash->flags = crypto_shash_get_flags(parent)
|
||||
& CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
if (keylen > bs) {
|
||||
int err;
|
||||
|
|
@ -91,8 +89,6 @@ static int hmac_export(struct shash_desc *pdesc, void *out)
|
|||
{
|
||||
struct shash_desc *desc = shash_desc_ctx(pdesc);
|
||||
|
||||
desc->flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
return crypto_shash_export(desc, out);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +98,6 @@ static int hmac_import(struct shash_desc *pdesc, const void *in)
|
|||
struct hmac_ctx *ctx = hmac_ctx(pdesc->tfm);
|
||||
|
||||
desc->tfm = ctx->hash;
|
||||
desc->flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
return crypto_shash_import(desc, in);
|
||||
}
|
||||
|
|
@ -117,8 +112,6 @@ static int hmac_update(struct shash_desc *pdesc,
|
|||
{
|
||||
struct shash_desc *desc = shash_desc_ctx(pdesc);
|
||||
|
||||
desc->flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
return crypto_shash_update(desc, data, nbytes);
|
||||
}
|
||||
|
||||
|
|
@ -130,8 +123,6 @@ static int hmac_final(struct shash_desc *pdesc, u8 *out)
|
|||
char *opad = crypto_shash_ctx_aligned(parent) + ss;
|
||||
struct shash_desc *desc = shash_desc_ctx(pdesc);
|
||||
|
||||
desc->flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
return crypto_shash_final(desc, out) ?:
|
||||
crypto_shash_import(desc, opad) ?:
|
||||
crypto_shash_finup(desc, out, ds, out);
|
||||
|
|
@ -147,8 +138,6 @@ static int hmac_finup(struct shash_desc *pdesc, const u8 *data,
|
|||
char *opad = crypto_shash_ctx_aligned(parent) + ss;
|
||||
struct shash_desc *desc = shash_desc_ctx(pdesc);
|
||||
|
||||
desc->flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||
|
||||
return crypto_shash_finup(desc, data, nbytes, out) ?:
|
||||
crypto_shash_import(desc, opad) ?:
|
||||
crypto_shash_finup(desc, out, ds, out);
|
||||
|
|
|
|||
|
|
@ -238,7 +238,6 @@ static int shash_async_init(struct ahash_request *req)
|
|||
struct shash_desc *desc = ahash_request_ctx(req);
|
||||
|
||||
desc->tfm = *ctx;
|
||||
desc->flags = req->base.flags;
|
||||
|
||||
return crypto_shash_init(desc);
|
||||
}
|
||||
|
|
@ -293,7 +292,6 @@ static int shash_async_finup(struct ahash_request *req)
|
|||
struct shash_desc *desc = ahash_request_ctx(req);
|
||||
|
||||
desc->tfm = *ctx;
|
||||
desc->flags = req->base.flags;
|
||||
|
||||
return shash_ahash_finup(req, desc);
|
||||
}
|
||||
|
|
@ -328,7 +326,6 @@ static int shash_async_digest(struct ahash_request *req)
|
|||
struct shash_desc *desc = ahash_request_ctx(req);
|
||||
|
||||
desc->tfm = *ctx;
|
||||
desc->flags = req->base.flags;
|
||||
|
||||
return shash_ahash_digest(req, desc);
|
||||
}
|
||||
|
|
@ -344,7 +341,6 @@ static int shash_async_import(struct ahash_request *req, const void *in)
|
|||
struct shash_desc *desc = ahash_request_ctx(req);
|
||||
|
||||
desc->tfm = *ctx;
|
||||
desc->flags = req->base.flags;
|
||||
|
||||
return crypto_shash_import(desc, in);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1328,7 +1328,6 @@ static void generate_random_hash_testvec(struct crypto_shash *tfm,
|
|||
|
||||
/* Digest */
|
||||
desc->tfm = tfm;
|
||||
desc->flags = 0;
|
||||
vec->digest_error = crypto_shash_digest(desc, vec->plaintext,
|
||||
vec->psize, (u8 *)vec->digest);
|
||||
done:
|
||||
|
|
@ -3027,7 +3026,6 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
|
|||
u32 *ctx = (u32 *)shash_desc_ctx(shash);
|
||||
|
||||
shash->tfm = tfm;
|
||||
shash->flags = 0;
|
||||
|
||||
*ctx = 420553207;
|
||||
err = crypto_shash_final(shash, (u8 *)&val);
|
||||
|
|
|
|||
Loading…
Reference in a new issue