* [PATCH] crypto: ccm - move cbcmac input off the stack
@ 2017-02-27 15:30 Ard Biesheuvel
2017-02-27 16:04 ` Johannes Berg
2017-02-28 9:33 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2017-02-27 15:30 UTC (permalink / raw)
To: linux-crypto, herbert; +Cc: johannes, Ard Biesheuvel
Commit f15f05b0a5de ("crypto: ccm - switch to separate cbcmac driver")
refactored the CCM driver to allow separate implementations of the
underlying MAC to be provided by a platform. However, in doing so, it
moved some data from the linear region to the stack, which violates the
SG constraints when the stack is virtually mapped.
So move idata/odata back to the request ctx struct, of which we can
reasonably expect that it has been allocated using kmalloc() et al.
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Fixes: f15f05b0a5de ("crypto: ccm - switch to separate cbcmac driver")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
crypto/ccm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 442848807a52..1ce37ae0ce56 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -45,6 +45,7 @@ struct crypto_rfc4309_req_ctx {
struct crypto_ccm_req_priv_ctx {
u8 odata[16];
+ u8 idata[16];
u8 auth_tag[16];
u32 flags;
struct scatterlist src[3];
@@ -183,8 +184,8 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain,
AHASH_REQUEST_ON_STACK(ahreq, ctx->mac);
unsigned int assoclen = req->assoclen;
struct scatterlist sg[3];
- u8 odata[16];
- u8 idata[16];
+ u8 *odata = pctx->odata;
+ u8 *idata = pctx->idata;
int ilen, err;
/* format control data for input */
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: ccm - move cbcmac input off the stack
2017-02-27 15:30 [PATCH] crypto: ccm - move cbcmac input off the stack Ard Biesheuvel
@ 2017-02-27 16:04 ` Johannes Berg
2017-02-28 9:33 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2017-02-27 16:04 UTC (permalink / raw)
To: Ard Biesheuvel, linux-crypto, herbert
On Mon, 2017-02-27 at 15:30 +0000, Ard Biesheuvel wrote:
> Commit f15f05b0a5de ("crypto: ccm - switch to separate cbcmac
> driver")
> refactored the CCM driver to allow separate implementations of the
> underlying MAC to be provided by a platform. However, in doing so, it
> moved some data from the linear region to the stack, which violates
> the
> SG constraints when the stack is virtually mapped.
>
> So move idata/odata back to the request ctx struct, of which we can
> reasonably expect that it has been allocated using kmalloc() et al.
>
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Fixes: f15f05b0a5de ("crypto: ccm - switch to separate cbcmac
> driver")
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Johannes Berg <johannes@sipsolutions.net>
Thanks for the quick fix!
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: ccm - move cbcmac input off the stack
2017-02-27 15:30 [PATCH] crypto: ccm - move cbcmac input off the stack Ard Biesheuvel
2017-02-27 16:04 ` Johannes Berg
@ 2017-02-28 9:33 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2017-02-28 9:33 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: linux-crypto, johannes
On Mon, Feb 27, 2017 at 03:30:56PM +0000, Ard Biesheuvel wrote:
> Commit f15f05b0a5de ("crypto: ccm - switch to separate cbcmac driver")
> refactored the CCM driver to allow separate implementations of the
> underlying MAC to be provided by a platform. However, in doing so, it
> moved some data from the linear region to the stack, which violates the
> SG constraints when the stack is virtually mapped.
>
> So move idata/odata back to the request ctx struct, of which we can
> reasonably expect that it has been allocated using kmalloc() et al.
>
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Fixes: f15f05b0a5de ("crypto: ccm - switch to separate cbcmac driver")
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-28 9:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-27 15:30 [PATCH] crypto: ccm - move cbcmac input off the stack Ard Biesheuvel
2017-02-27 16:04 ` Johannes Berg
2017-02-28 9:33 ` Herbert Xu
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.