Skip to content

Commit

Permalink
crypto: ccm - move cbcmac input off the stack
Browse files Browse the repository at this point in the history
Commit f15f05b ("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 <[email protected]>
Fixes: f15f05b ("crypto: ccm - switch to separate cbcmac driver")
Signed-off-by: Ard Biesheuvel <[email protected]>
Tested-by: Johannes Berg <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Ard Biesheuvel authored and herbertx committed Feb 28, 2017
1 parent 8902757 commit 3b30460
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crypto/ccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 3b30460

Please sign in to comment.