mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 00:51:51 -04:00
Merge tag 'v7.1-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: - Fix IPsec ESN regression in authencesn - Fix hmac setkey failure in eip93 - Guard against IV changing in algif_aead - Fix async completion handling in krb5enc - Fix fallback async completion in acomp - Fix handling of MAY_BACKLOG requests in pcrypt - Fix issues with firmware-returned values in ccp * tag 'v7.1-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: krb5enc - fix async decrypt skipping hash verification crypto: algif_aead - snapshot IV for async AEAD requests crypto: acomp - fix wrong pointer stored by acomp_save_req() crypto: ccp - copy IV using skcipher ivsize crypto: ccp: Don't attempt to copy ID to userspace if PSP command failed crypto: ccp: Don't attempt to copy PDH cert to userspace if PSP command failed crypto: ccp: Don't attempt to copy CSR to userspace if PSP command failed crypto: pcrypt - Fix handling of MAY_BACKLOG requests crypto: sa2ul - Fix AEAD fallback algorithm names crypto: authencesn - Fix src offset when decrypting in-place crypto: eip93 - fix hmac setkey algo selection
This commit is contained in:
@@ -169,15 +169,13 @@ static void acomp_save_req(struct acomp_req *req, crypto_completion_t cplt)
|
||||
state->compl = req->base.complete;
|
||||
state->data = req->base.data;
|
||||
req->base.complete = cplt;
|
||||
req->base.data = state;
|
||||
req->base.data = req;
|
||||
}
|
||||
|
||||
static void acomp_restore_req(struct acomp_req *req)
|
||||
{
|
||||
struct acomp_req_chain *state = req->base.data;
|
||||
|
||||
req->base.complete = state->compl;
|
||||
req->base.data = state->data;
|
||||
req->base.complete = req->chain.compl;
|
||||
req->base.data = req->chain.data;
|
||||
}
|
||||
|
||||
static void acomp_reqchain_virt(struct acomp_req *req)
|
||||
|
||||
@@ -72,8 +72,10 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
|
||||
struct af_alg_ctx *ctx = ask->private;
|
||||
struct crypto_aead *tfm = pask->private;
|
||||
unsigned int as = crypto_aead_authsize(tfm);
|
||||
unsigned int ivsize = crypto_aead_ivsize(tfm);
|
||||
struct af_alg_async_req *areq;
|
||||
struct scatterlist *rsgl_src, *tsgl_src = NULL;
|
||||
void *iv;
|
||||
int err = 0;
|
||||
size_t used = 0; /* [in] TX bufs to be en/decrypted */
|
||||
size_t outlen = 0; /* [out] RX bufs produced by kernel */
|
||||
@@ -125,10 +127,14 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
|
||||
|
||||
/* Allocate cipher request for current operation. */
|
||||
areq = af_alg_alloc_areq(sk, sizeof(struct af_alg_async_req) +
|
||||
crypto_aead_reqsize(tfm));
|
||||
crypto_aead_reqsize(tfm) + ivsize);
|
||||
if (IS_ERR(areq))
|
||||
return PTR_ERR(areq);
|
||||
|
||||
iv = (u8 *)aead_request_ctx(&areq->cra_u.aead_req) +
|
||||
crypto_aead_reqsize(tfm);
|
||||
memcpy(iv, ctx->iv, ivsize);
|
||||
|
||||
/* convert iovecs of output buffers into RX SGL */
|
||||
err = af_alg_get_rsgl(sk, msg, flags, areq, outlen, &usedpages);
|
||||
if (err)
|
||||
@@ -187,7 +193,7 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
|
||||
|
||||
/* Initialize the crypto operation */
|
||||
aead_request_set_crypt(&areq->cra_u.aead_req, tsgl_src,
|
||||
areq->first_rsgl.sgl.sgt.sgl, used, ctx->iv);
|
||||
areq->first_rsgl.sgl.sgt.sgl, used, iv);
|
||||
aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);
|
||||
aead_request_set_tfm(&areq->cra_u.aead_req, tfm);
|
||||
|
||||
|
||||
@@ -228,9 +228,11 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
|
||||
|
||||
decrypt:
|
||||
|
||||
if (src != dst)
|
||||
src = scatterwalk_ffwd(areq_ctx->src, src, assoclen);
|
||||
dst = scatterwalk_ffwd(areq_ctx->dst, dst, assoclen);
|
||||
if (req->src == req->dst)
|
||||
src = dst;
|
||||
else
|
||||
src = scatterwalk_ffwd(areq_ctx->src, src, assoclen);
|
||||
|
||||
skcipher_request_set_tfm(skreq, ctx->enc);
|
||||
skcipher_request_set_callback(skreq, flags,
|
||||
|
||||
@@ -39,12 +39,6 @@ struct krb5enc_request_ctx {
|
||||
char tail[];
|
||||
};
|
||||
|
||||
static void krb5enc_request_complete(struct aead_request *req, int err)
|
||||
{
|
||||
if (err != -EINPROGRESS)
|
||||
aead_request_complete(req, err);
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_krb5enc_extractkeys - Extract Ke and Ki keys from the key blob.
|
||||
* @keys: Where to put the key sizes and pointers
|
||||
@@ -127,7 +121,7 @@ static void krb5enc_encrypt_done(void *data, int err)
|
||||
{
|
||||
struct aead_request *req = data;
|
||||
|
||||
krb5enc_request_complete(req, err);
|
||||
aead_request_complete(req, err);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -188,14 +182,16 @@ static void krb5enc_encrypt_ahash_done(void *data, int err)
|
||||
struct ahash_request *ahreq = (void *)(areq_ctx->tail + ictx->reqoff);
|
||||
|
||||
if (err)
|
||||
return krb5enc_request_complete(req, err);
|
||||
goto out;
|
||||
|
||||
krb5enc_insert_checksum(req, ahreq->result);
|
||||
|
||||
err = krb5enc_dispatch_encrypt(req,
|
||||
aead_request_flags(req) & ~CRYPTO_TFM_REQ_MAY_SLEEP);
|
||||
if (err != -EINPROGRESS)
|
||||
aead_request_complete(req, err);
|
||||
err = krb5enc_dispatch_encrypt(req, 0);
|
||||
if (err == -EINPROGRESS)
|
||||
return;
|
||||
|
||||
out:
|
||||
aead_request_complete(req, err);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -265,17 +261,16 @@ static void krb5enc_decrypt_hash_done(void *data, int err)
|
||||
{
|
||||
struct aead_request *req = data;
|
||||
|
||||
if (err)
|
||||
return krb5enc_request_complete(req, err);
|
||||
|
||||
err = krb5enc_verify_hash(req);
|
||||
krb5enc_request_complete(req, err);
|
||||
if (!err)
|
||||
err = krb5enc_verify_hash(req);
|
||||
aead_request_complete(req, err);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispatch the hashing of the plaintext after we've done the decryption.
|
||||
*/
|
||||
static int krb5enc_dispatch_decrypt_hash(struct aead_request *req)
|
||||
static int krb5enc_dispatch_decrypt_hash(struct aead_request *req,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct crypto_aead *krb5enc = crypto_aead_reqtfm(req);
|
||||
struct aead_instance *inst = aead_alg_instance(krb5enc);
|
||||
@@ -291,7 +286,7 @@ static int krb5enc_dispatch_decrypt_hash(struct aead_request *req)
|
||||
ahash_request_set_tfm(ahreq, auth);
|
||||
ahash_request_set_crypt(ahreq, req->dst, hash,
|
||||
req->assoclen + req->cryptlen - authsize);
|
||||
ahash_request_set_callback(ahreq, aead_request_flags(req),
|
||||
ahash_request_set_callback(ahreq, flags,
|
||||
krb5enc_decrypt_hash_done, req);
|
||||
|
||||
err = crypto_ahash_digest(ahreq);
|
||||
@@ -301,6 +296,21 @@ static int krb5enc_dispatch_decrypt_hash(struct aead_request *req)
|
||||
return krb5enc_verify_hash(req);
|
||||
}
|
||||
|
||||
static void krb5enc_decrypt_done(void *data, int err)
|
||||
{
|
||||
struct aead_request *req = data;
|
||||
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = krb5enc_dispatch_decrypt_hash(req, 0);
|
||||
if (err == -EINPROGRESS)
|
||||
return;
|
||||
|
||||
out:
|
||||
aead_request_complete(req, err);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dispatch the decryption of the ciphertext.
|
||||
*/
|
||||
@@ -324,7 +334,7 @@ static int krb5enc_dispatch_decrypt(struct aead_request *req)
|
||||
|
||||
skcipher_request_set_tfm(skreq, ctx->enc);
|
||||
skcipher_request_set_callback(skreq, aead_request_flags(req),
|
||||
req->base.complete, req->base.data);
|
||||
krb5enc_decrypt_done, req);
|
||||
skcipher_request_set_crypt(skreq, src, dst,
|
||||
req->cryptlen - authsize, req->iv);
|
||||
|
||||
@@ -339,7 +349,7 @@ static int krb5enc_decrypt(struct aead_request *req)
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return krb5enc_dispatch_decrypt_hash(req);
|
||||
return krb5enc_dispatch_decrypt_hash(req, aead_request_flags(req));
|
||||
}
|
||||
|
||||
static int krb5enc_init_tfm(struct crypto_aead *tfm)
|
||||
|
||||
@@ -69,6 +69,9 @@ static void pcrypt_aead_done(void *data, int err)
|
||||
struct pcrypt_request *preq = aead_request_ctx(req);
|
||||
struct padata_priv *padata = pcrypt_request_padata(preq);
|
||||
|
||||
if (err == -EINPROGRESS)
|
||||
return;
|
||||
|
||||
padata->info = err;
|
||||
|
||||
padata_do_serial(padata);
|
||||
@@ -82,7 +85,7 @@ static void pcrypt_aead_enc(struct padata_priv *padata)
|
||||
|
||||
ret = crypto_aead_encrypt(req);
|
||||
|
||||
if (ret == -EINPROGRESS)
|
||||
if (ret == -EINPROGRESS || ret == -EBUSY)
|
||||
return;
|
||||
|
||||
padata->info = ret;
|
||||
@@ -133,7 +136,7 @@ static void pcrypt_aead_dec(struct padata_priv *padata)
|
||||
|
||||
ret = crypto_aead_decrypt(req);
|
||||
|
||||
if (ret == -EINPROGRESS)
|
||||
if (ret == -EINPROGRESS || ret == -EBUSY)
|
||||
return;
|
||||
|
||||
padata->info = ret;
|
||||
|
||||
@@ -30,8 +30,11 @@ static int ccp_aes_complete(struct crypto_async_request *async_req, int ret)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (ctx->u.aes.mode != CCP_AES_MODE_ECB)
|
||||
memcpy(req->iv, rctx->iv, AES_BLOCK_SIZE);
|
||||
if (ctx->u.aes.mode != CCP_AES_MODE_ECB) {
|
||||
size_t ivsize = crypto_skcipher_ivsize(crypto_skcipher_reqtfm(req));
|
||||
|
||||
memcpy(req->iv, rctx->iv, ivsize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1860,7 +1860,10 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
|
||||
|
||||
ret = __sev_do_cmd_locked(SEV_CMD_PEK_CSR, &data, &argp->error);
|
||||
|
||||
/* If we query the CSR length, FW responded with expected data. */
|
||||
/*
|
||||
* Firmware will returns the length of the CSR blob (either the minimum
|
||||
* required length or the actual length written), return it to the user.
|
||||
*/
|
||||
input.length = data.len;
|
||||
|
||||
if (copy_to_user((void __user *)argp->data, &input, sizeof(input))) {
|
||||
@@ -1868,6 +1871,9 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp, bool writable)
|
||||
goto e_free_blob;
|
||||
}
|
||||
|
||||
if (ret || WARN_ON_ONCE(argp->error))
|
||||
goto e_free_blob;
|
||||
|
||||
if (blob) {
|
||||
if (copy_to_user(input_address, blob, input.length))
|
||||
ret = -EFAULT;
|
||||
@@ -2217,6 +2223,9 @@ static int sev_ioctl_do_get_id2(struct sev_issue_cmd *argp)
|
||||
goto e_free;
|
||||
}
|
||||
|
||||
if (ret || WARN_ON_ONCE(argp->error))
|
||||
goto e_free;
|
||||
|
||||
if (id_blob) {
|
||||
if (copy_to_user(input_address, id_blob, data.len)) {
|
||||
ret = -EFAULT;
|
||||
@@ -2333,7 +2342,10 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
|
||||
|
||||
ret = __sev_do_cmd_locked(SEV_CMD_PDH_CERT_EXPORT, &data, &argp->error);
|
||||
|
||||
/* If we query the length, FW responded with expected data. */
|
||||
/*
|
||||
* Firmware will return the length of the blobs (either the minimum
|
||||
* required length or the actual length written), return 'em to the user.
|
||||
*/
|
||||
input.cert_chain_len = data.cert_chain_len;
|
||||
input.pdh_cert_len = data.pdh_cert_len;
|
||||
|
||||
@@ -2342,6 +2354,9 @@ static int sev_ioctl_do_pdh_export(struct sev_issue_cmd *argp, bool writable)
|
||||
goto e_free_cert;
|
||||
}
|
||||
|
||||
if (ret || WARN_ON_ONCE(argp->error))
|
||||
goto e_free_cert;
|
||||
|
||||
if (pdh_blob) {
|
||||
if (copy_to_user(input_pdh_cert_address,
|
||||
pdh_blob, input.pdh_cert_len)) {
|
||||
|
||||
@@ -731,7 +731,7 @@ int eip93_hmac_setkey(u32 ctx_flags, const u8 *key, unsigned int keylen,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ahash_tfm = crypto_alloc_ahash(alg_name, 0, CRYPTO_ALG_ASYNC);
|
||||
ahash_tfm = crypto_alloc_ahash(alg_name, 0, 0);
|
||||
if (IS_ERR(ahash_tfm))
|
||||
return PTR_ERR(ahash_tfm);
|
||||
|
||||
|
||||
@@ -1744,13 +1744,13 @@ static int sa_cra_init_aead(struct crypto_aead *tfm, const char *hash,
|
||||
static int sa_cra_init_aead_sha1(struct crypto_aead *tfm)
|
||||
{
|
||||
return sa_cra_init_aead(tfm, "sha1",
|
||||
"authenc(hmac(sha1-ce),cbc(aes-ce))");
|
||||
"authenc(hmac(sha1),cbc(aes))");
|
||||
}
|
||||
|
||||
static int sa_cra_init_aead_sha256(struct crypto_aead *tfm)
|
||||
{
|
||||
return sa_cra_init_aead(tfm, "sha256",
|
||||
"authenc(hmac(sha256-ce),cbc(aes-ce))");
|
||||
"authenc(hmac(sha256),cbc(aes))");
|
||||
}
|
||||
|
||||
static void sa_exit_tfm_aead(struct crypto_aead *tfm)
|
||||
|
||||
Reference in New Issue
Block a user