Skip to content

Commit 42cfcaf

Browse files
horiagherbertx
authored andcommitted
crypto: caam - fix gfp allocation flags (part I)
Changes in the SW cts (ciphertext stealing) code in commit 0605c41 ("crypto: cts - Convert to skcipher") revealed a problem in the CAAM driver: when cts(cbc(aes)) is executed and cts runs in SW, cbc(aes) is offloaded in CAAM; cts encrypts the last block in atomic context and CAAM incorrectly decides to use GFP_KERNEL for memory allocation. Fix this by allowing GFP_KERNEL (sleeping) only when MAY_SLEEP flag is set, i.e. remove MAY_BACKLOG flag. We split the fix in two parts - first is sent to -stable, while the second is not (since there is no known failure case). Link: http://lkml.kernel.org/g/20170602122446.2427-1-david@sigma-star.at Cc: <stable@vger.kernel.org> # 4.8+ Reported-by: David Gstir <david@sigma-star.at> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent b61929c commit 42cfcaf

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎drivers/crypto/caam/caamalg.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,8 +1475,7 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request
14751475
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
14761476
struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
14771477
struct device *jrdev = ctx->jrdev;
1478-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1479-
CRYPTO_TFM_REQ_MAY_SLEEP)) ?
1478+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
14801479
GFP_KERNEL : GFP_ATOMIC;
14811480
int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
14821481
struct ablkcipher_edesc *edesc;

0 commit comments

Comments
 (0)