FAILED: patch "[PATCH] crypto: ccp - Add support for valid authsize values less than" failed to apply to 4.14-stable tree
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9f00baf74e4b6f79a3a3dfab44fb7bb2e797b551 Mon Sep 17 00:00:00 2001
From: Gary R Hook <[email protected]>
Date: Tue, 30 Jul 2019 16:05:24 +0000
Subject: [PATCH] crypto: ccp - Add support for valid authsize values less than
16
AES GCM encryption allows for authsize values of 4, 8, and 12-16 bytes. Validate the requested authsize, and retain it to save in the request context.
drivers/crypto/ccp/ccp-crypto-aes-galois.c +14 -0
@@ -58,6 +58,19 @@ static int ccp_aes_gcm_setkey(struct crypto_aead *tfm, const u8 *key,static int ccp_aes_gcm_setauthsize (struct crypto_aead *tfm,unsigned int authsize) { +switch (authsize) { +case 16 : +case 15 : +case 14 : +case 13 : +case 12 : +case 8 : +case 4 : +break ; +default : +return -EINVAL ; + } +return 0 ; }
@@ -104,6 +117,7 @@ static int ccp_aes_gcm_crypt(struct aead_request *req, bool encrypt)memset (&rctx->cmd,0 ,sizeof (rctx->cmd));INIT_LIST_HEAD (&rctx->cmd.entry); rctx->cmd.engine =CCP_ENGINE_AES ; + rctx->cmd.u.aes.authsize =crypto_aead_authsize (tfm); rctx->cmd.u.aes.type = ctx->u.aes.type; rctx->cmd.u.aes.mode = ctx->u.aes.mode; rctx->cmd.u.aes.action = encrypt;
drivers/crypto/ccp/ccp-ops.c +21 -5
@@ -622,6 +622,7 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,unsigned long long *final;unsigned int dm_offset; +unsigned int authsize;unsigned int jobid;unsigned int ilen;bool in_place = true;/* Default value */
@@ -643,6 +644,21 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,if (!aes->key)/* Gotta have a key SGL */ return -EINVAL ; +/* Zero defaults to 16 bytes, the maximum size */ + authsize = aes->authsize ? aes->authsize :AES_BLOCK_SIZE ; +switch (authsize) { +case 16 : +case 15 : +case 14 : +case 13 : +case 12 : +case 8 : +case 4 : +break ; +default : +return -EINVAL ; + } +/* First, decompose the source buffer into AAD & PT, * and the destination buffer into AAD, CT & tag, or * the input into CT & tag.
@@ -657,7 +673,7 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, p_tag =scatterwalk_ffwd (sg_tag, p_outp, ilen); }else {/* Input length for decryption includes tag */ - ilen = aes->src_len -AES_BLOCK_SIZE ; + ilen = aes->src_len - authsize; p_tag =scatterwalk_ffwd (sg_tag, p_inp, ilen); }
@@ -839,19 +855,19 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,if (aes->action ==CCP_AES_ACTION_ENCRYPT ) {/* Put the ciphered tag after the ciphertext. */ -ccp_get_dm_area (&final_wa,0 , p_tag,0 ,AES_BLOCK_SIZE ); +ccp_get_dm_area (&final_wa,0 , p_tag,0 , authsize); }else {/* Does this ciphered tag match the input? */ - ret =ccp_init_dm_workarea (&tag, cmd_q,AES_BLOCK_SIZE , + ret =ccp_init_dm_workarea (&tag, cmd_q, authsize,DMA_BIDIRECTIONAL );if (ret) goto e_tag; - ret =ccp_set_dm_area (&tag,0 , p_tag,0 ,AES_BLOCK_SIZE ); + ret =ccp_set_dm_area (&tag,0 , p_tag,0 , authsize);if (ret) goto e_tag; ret =crypto_memneq (tag.address, final_wa.address, -AES_BLOCK_SIZE ) ? -EBADMSG :0 ; + authsize) ? -EBADMSG :0 ;ccp_dm_free (&tag); }
include/linux/ccp.h +2 -0
@@ -173,6 +173,8 @@ struct ccp_aes_engine {enum ccp_aes_mode mode;enum ccp_aes_action action; +u32 authsize; +struct scatterlist *key;u32 key_len;/* In bytes */
It turns out that this patch has a pre-req that wasn't properly marked as "Fixes" for 4.14 stable.
If you first apply b698a9f4c5c52, then apply 9f00baf74e4b6, then this be clean.
Mea culpa,
grh
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Sunday, August 11, 2019 9:57 AM
To: Hook, Gary <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: FAILED: patch "[PATCH] crypto: ccp - Add support for valid authsize values less than" failed to apply to 4.14-stable tree
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9f00baf74e4b6f79a3a3dfab44fb7bb2e797b551 Mon Sep 17 00:00:00 2001
From: Gary R Hook <[email protected]>
Date: Tue, 30 Jul 2019 16:05:24 +0000
Subject: [PATCH] crypto: ccp - Add support for valid authsize values less than
16
AES GCM encryption allows for authsize values of 4, 8, and 12-16 bytes. Validate the requested authsize, and retain it to save in the request context.
drivers/crypto/ccp/ccp-crypto-aes-galois.c +14 -0
@@ -58,6 +58,19 @@ static int ccp_aes_gcm_setkey(struct crypto_aead *tfm, const u8 *key, static int ccp_aes_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize) { +switch (authsize) { +case 16 : +case 15 : +case 14 : +case 13 : +case 12 : +case 8 : +case 4 : +break ; +default : +return -EINVAL ; + } +return 0 ; }
@@ -104,6 +117,7 @@ static int ccp_aes_gcm_crypt(struct aead_request *req, bool encrypt)memset (&rctx->cmd,0 ,sizeof (rctx->cmd));INIT_LIST_HEAD (&rctx->cmd.entry); rctx->cmd.engine =CCP_ENGINE_AES ; + rctx->cmd.u.aes.authsize =crypto_aead_authsize (tfm); rctx->cmd.u.aes.type = ctx->u.aes.type; rctx->cmd.u.aes.mode = ctx->u.aes.mode; rctx->cmd.u.aes.action = encrypt;
drivers/crypto/ccp/ccp-ops.c +1 -0
@@ -622,6 +622,7 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,unsigned long long *final;unsigned int dm_offset; +unsigned int authsize;unsigned int jobid;unsigned int ilen; bool in_place = true; /* Default value */ @@ -643,6 +644,21 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
if (!aes->key) /* Gotta have a key SGL */
return -EINVAL;
+ /* Zero defaults to 16 bytes, the maximum size */
+ authsize = aes->authsize ? aes->authsize : AES_BLOCK_SIZE;
+ switch (authsize) {
+ case 16:
+ case 15:
+ case 14:
+ case 13:
+ case 12:
+ case 8:
+ case 4:
+ break;
+ default:
+ return -EINVAL;
+ }
+
/* First, decompose the source buffer into AAD & PT,
* and the destination buffer into AAD, CT & tag, or
* the input into CT & tag.
@@ -657,7 +673,7 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
p_tag = scatterwalk_ffwd(sg_tag, p_outp, ilen);
} else {
/* Input length for decryption includes tag */
- ilen = aes->src_len - AES_BLOCK_SIZE;
+ ilen = aes->src_len - authsize;
p_tag = scatterwalk_ffwd(sg_tag, p_inp, ilen);
}
@@ -839,19 +855,19 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
if (aes->action == CCP_AES_ACTION_ENCRYPT) {
/* Put the ciphered tag after the ciphertext. */
- ccp_get_dm_area(&final_wa, 0, p_tag, 0, AES_BLOCK_SIZE);
+ ccp_get_dm_area(&final_wa, 0, p_tag, 0, authsize);
} else {
/* Does this ciphered tag match the input? */
- ret = ccp_init_dm_workarea(&tag, cmd_q, AES_BLOCK_SIZE,
+ ret = ccp_init_dm_workarea(&tag, cmd_q, authsize,
DMA_BIDIRECTIONAL);
if (ret)
goto e_tag;
- ret = ccp_set_dm_area(&tag, 0, p_tag, 0, AES_BLOCK_SIZE);
+ ret = ccp_set_dm_area(&tag, 0, p_tag, 0, authsize);
if (ret)
goto e_tag;
ret = crypto_memneq(tag.address, final_wa.address,
- AES_BLOCK_SIZE) ? -EBADMSG : 0;
+ authsize) ? -EBADMSG : 0;
ccp_dm_free(&tag);
}
include/linux/ccp.h +2 -0
@@ -173,6 +173,8 @@ struct ccp_aes_engine {enum ccp_aes_mode mode;enum ccp_aes_action action; +u32 authsize; +struct scatterlist *key;u32 key_len;/* In bytes */
[email protected]
maintainerQuoted 3 lines · Gary
It turns out that this patch has a pre-req that wasn't properly marked as "Fixes" for 4.14 stable.
If you first apply
b698a9f4c5c52, then apply9f00baf74e4b6, then this be clean.
That worked, thanks!
greg k-h