All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] crypto: ccp - Don't assume export/import areas are aligned" failed to apply to 4.4-stable tree
@ 2016-04-09 23:48 gregkh
  2016-04-09 23:54 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2016-04-09 23:48 UTC (permalink / raw)
  To: thomas.lendacky, herbert, stable; +Cc: stable


The patch below does not apply to the 4.4-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 <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From b31dde2a5cb1bf764282abf934266b7193c2bc7c Mon Sep 17 00:00:00 2001
From: Tom Lendacky <thomas.lendacky@amd.com>
Date: Tue, 2 Feb 2016 11:38:21 -0600
Subject: [PATCH] crypto: ccp - Don't assume export/import areas are aligned

Use a local variable for the exported and imported state so that
alignment is not an issue. On export, set a local variable from the
request context and then memcpy the contents of the local variable to
the export memory area. On import, memcpy the import memory area into
a local variable and then use the local variable to set the request
context.

Cc: <stable@vger.kernel.org> # 3.14.x-
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
index 6a2d836eb2d9..d095452b8828 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
@@ -223,12 +223,15 @@ static int ccp_aes_cmac_digest(struct ahash_request *req)
 static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
 {
 	struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
-	struct ccp_aes_cmac_exp_ctx *state = out;
+	struct ccp_aes_cmac_exp_ctx state;
 
-	state->null_msg = rctx->null_msg;
-	memcpy(state->iv, rctx->iv, sizeof(state->iv));
-	state->buf_count = rctx->buf_count;
-	memcpy(state->buf, rctx->buf, sizeof(state->buf));
+	state.null_msg = rctx->null_msg;
+	memcpy(state.iv, rctx->iv, sizeof(state.iv));
+	state.buf_count = rctx->buf_count;
+	memcpy(state.buf, rctx->buf, sizeof(state.buf));
+
+	/* 'out' may not be aligned so memcpy from local variable */
+	memcpy(out, &state, sizeof(state));
 
 	return 0;
 }
@@ -236,12 +239,15 @@ static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
 static int ccp_aes_cmac_import(struct ahash_request *req, const void *in)
 {
 	struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
-	const struct ccp_aes_cmac_exp_ctx *state = in;
+	struct ccp_aes_cmac_exp_ctx state;
+
+	/* 'in' may not be aligned so memcpy to local variable */
+	memcpy(&state, in, sizeof(state));
 
-	rctx->null_msg = state->null_msg;
-	memcpy(rctx->iv, state->iv, sizeof(rctx->iv));
-	rctx->buf_count = state->buf_count;
-	memcpy(rctx->buf, state->buf, sizeof(rctx->buf));
+	rctx->null_msg = state.null_msg;
+	memcpy(rctx->iv, state.iv, sizeof(rctx->iv));
+	rctx->buf_count = state.buf_count;
+	memcpy(rctx->buf, state.buf, sizeof(rctx->buf));
 
 	return 0;
 }
diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c
index a67128a7af23..7002c6b283e5 100644
--- a/drivers/crypto/ccp/ccp-crypto-sha.c
+++ b/drivers/crypto/ccp/ccp-crypto-sha.c
@@ -210,14 +210,17 @@ static int ccp_sha_digest(struct ahash_request *req)
 static int ccp_sha_export(struct ahash_request *req, void *out)
 {
 	struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
-	struct ccp_sha_exp_ctx *state = out;
+	struct ccp_sha_exp_ctx state;
 
-	state->type = rctx->type;
-	state->msg_bits = rctx->msg_bits;
-	state->first = rctx->first;
-	memcpy(state->ctx, rctx->ctx, sizeof(state->ctx));
-	state->buf_count = rctx->buf_count;
-	memcpy(state->buf, rctx->buf, sizeof(state->buf));
+	state.type = rctx->type;
+	state.msg_bits = rctx->msg_bits;
+	state.first = rctx->first;
+	memcpy(state.ctx, rctx->ctx, sizeof(state.ctx));
+	state.buf_count = rctx->buf_count;
+	memcpy(state.buf, rctx->buf, sizeof(state.buf));
+
+	/* 'out' may not be aligned so memcpy from local variable */
+	memcpy(out, &state, sizeof(state));
 
 	return 0;
 }
@@ -225,14 +228,17 @@ static int ccp_sha_export(struct ahash_request *req, void *out)
 static int ccp_sha_import(struct ahash_request *req, const void *in)
 {
 	struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
-	const struct ccp_sha_exp_ctx *state = in;
-
-	rctx->type = state->type;
-	rctx->msg_bits = state->msg_bits;
-	rctx->first = state->first;
-	memcpy(rctx->ctx, state->ctx, sizeof(rctx->ctx));
-	rctx->buf_count = state->buf_count;
-	memcpy(rctx->buf, state->buf, sizeof(rctx->buf));
+	struct ccp_sha_exp_ctx state;
+
+	/* 'in' may not be aligned so memcpy to local variable */
+	memcpy(&state, in, sizeof(state));
+
+	rctx->type = state.type;
+	rctx->msg_bits = state.msg_bits;
+	rctx->first = state.first;
+	memcpy(rctx->ctx, state.ctx, sizeof(rctx->ctx));
+	rctx->buf_count = state.buf_count;
+	memcpy(rctx->buf, state.buf, sizeof(rctx->buf));
 
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: FAILED: patch "[PATCH] crypto: ccp - Don't assume export/import areas are aligned" failed to apply to 4.4-stable tree
  2016-04-09 23:48 FAILED: patch "[PATCH] crypto: ccp - Don't assume export/import areas are aligned" failed to apply to 4.4-stable tree gregkh
@ 2016-04-09 23:54 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2016-04-09 23:54 UTC (permalink / raw)
  To: thomas.lendacky, herbert, stable

Oops, nevermind, this was my fault, I've applied this to all of the
needed trees now, sorry for the noise,

greg k-h


On Sat, Apr 09, 2016 at 04:48:02PM -0700, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 4.4-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 <stable@vger.kernel.org>.
> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> >From b31dde2a5cb1bf764282abf934266b7193c2bc7c Mon Sep 17 00:00:00 2001
> From: Tom Lendacky <thomas.lendacky@amd.com>
> Date: Tue, 2 Feb 2016 11:38:21 -0600
> Subject: [PATCH] crypto: ccp - Don't assume export/import areas are aligned
> 
> Use a local variable for the exported and imported state so that
> alignment is not an issue. On export, set a local variable from the
> request context and then memcpy the contents of the local variable to
> the export memory area. On import, memcpy the import memory area into
> a local variable and then use the local variable to set the request
> context.
> 
> Cc: <stable@vger.kernel.org> # 3.14.x-
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
> index 6a2d836eb2d9..d095452b8828 100644
> --- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
> +++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
> @@ -223,12 +223,15 @@ static int ccp_aes_cmac_digest(struct ahash_request *req)
>  static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
>  {
>  	struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
> -	struct ccp_aes_cmac_exp_ctx *state = out;
> +	struct ccp_aes_cmac_exp_ctx state;
>  
> -	state->null_msg = rctx->null_msg;
> -	memcpy(state->iv, rctx->iv, sizeof(state->iv));
> -	state->buf_count = rctx->buf_count;
> -	memcpy(state->buf, rctx->buf, sizeof(state->buf));
> +	state.null_msg = rctx->null_msg;
> +	memcpy(state.iv, rctx->iv, sizeof(state.iv));
> +	state.buf_count = rctx->buf_count;
> +	memcpy(state.buf, rctx->buf, sizeof(state.buf));
> +
> +	/* 'out' may not be aligned so memcpy from local variable */
> +	memcpy(out, &state, sizeof(state));
>  
>  	return 0;
>  }
> @@ -236,12 +239,15 @@ static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
>  static int ccp_aes_cmac_import(struct ahash_request *req, const void *in)
>  {
>  	struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
> -	const struct ccp_aes_cmac_exp_ctx *state = in;
> +	struct ccp_aes_cmac_exp_ctx state;
> +
> +	/* 'in' may not be aligned so memcpy to local variable */
> +	memcpy(&state, in, sizeof(state));
>  
> -	rctx->null_msg = state->null_msg;
> -	memcpy(rctx->iv, state->iv, sizeof(rctx->iv));
> -	rctx->buf_count = state->buf_count;
> -	memcpy(rctx->buf, state->buf, sizeof(rctx->buf));
> +	rctx->null_msg = state.null_msg;
> +	memcpy(rctx->iv, state.iv, sizeof(rctx->iv));
> +	rctx->buf_count = state.buf_count;
> +	memcpy(rctx->buf, state.buf, sizeof(rctx->buf));
>  
>  	return 0;
>  }
> diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c
> index a67128a7af23..7002c6b283e5 100644
> --- a/drivers/crypto/ccp/ccp-crypto-sha.c
> +++ b/drivers/crypto/ccp/ccp-crypto-sha.c
> @@ -210,14 +210,17 @@ static int ccp_sha_digest(struct ahash_request *req)
>  static int ccp_sha_export(struct ahash_request *req, void *out)
>  {
>  	struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
> -	struct ccp_sha_exp_ctx *state = out;
> +	struct ccp_sha_exp_ctx state;
>  
> -	state->type = rctx->type;
> -	state->msg_bits = rctx->msg_bits;
> -	state->first = rctx->first;
> -	memcpy(state->ctx, rctx->ctx, sizeof(state->ctx));
> -	state->buf_count = rctx->buf_count;
> -	memcpy(state->buf, rctx->buf, sizeof(state->buf));
> +	state.type = rctx->type;
> +	state.msg_bits = rctx->msg_bits;
> +	state.first = rctx->first;
> +	memcpy(state.ctx, rctx->ctx, sizeof(state.ctx));
> +	state.buf_count = rctx->buf_count;
> +	memcpy(state.buf, rctx->buf, sizeof(state.buf));
> +
> +	/* 'out' may not be aligned so memcpy from local variable */
> +	memcpy(out, &state, sizeof(state));
>  
>  	return 0;
>  }
> @@ -225,14 +228,17 @@ static int ccp_sha_export(struct ahash_request *req, void *out)
>  static int ccp_sha_import(struct ahash_request *req, const void *in)
>  {
>  	struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
> -	const struct ccp_sha_exp_ctx *state = in;
> -
> -	rctx->type = state->type;
> -	rctx->msg_bits = state->msg_bits;
> -	rctx->first = state->first;
> -	memcpy(rctx->ctx, state->ctx, sizeof(rctx->ctx));
> -	rctx->buf_count = state->buf_count;
> -	memcpy(rctx->buf, state->buf, sizeof(rctx->buf));
> +	struct ccp_sha_exp_ctx state;
> +
> +	/* 'in' may not be aligned so memcpy to local variable */
> +	memcpy(&state, in, sizeof(state));
> +
> +	rctx->type = state.type;
> +	rctx->msg_bits = state.msg_bits;
> +	rctx->first = state.first;
> +	memcpy(rctx->ctx, state.ctx, sizeof(rctx->ctx));
> +	rctx->buf_count = state.buf_count;
> +	memcpy(rctx->buf, state.buf, sizeof(rctx->buf));
>  
>  	return 0;
>  }
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-09 23:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-09 23:48 FAILED: patch "[PATCH] crypto: ccp - Don't assume export/import areas are aligned" failed to apply to 4.4-stable tree gregkh
2016-04-09 23:54 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.