Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1820621imm; Mon, 3 Sep 2018 10:16:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ4Qn4HHG0HjY0pwtbjlyYwpaJ5HOUBFvQMp2pivxDvkl0PRude6zRI4M3iepVcsT0sMoEo X-Received: by 2002:a62:a65a:: with SMTP id t87-v6mr30243869pfe.225.1535995003712; Mon, 03 Sep 2018 10:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995003; cv=none; d=google.com; s=arc-20160816; b=dBxjW0PVq7+dU3jMxwSMusdwypdyfKIdjVGf8lEVmeWl8WCcMBQbkPWovqvPcPpRzj uBTY9i0flNk/QulPqNRO8DSFRak6ILwLGMwVyOGM1x+lwapBXGzLtFeEjcPifYXmYYUE PEER5JMyQ8oVTU9S3FObBluQavXWOpFpZqeOmT01HyOxFi5smnuhg9z/YaOhxya7cyg0 7jXgs+Bs2dRigwcteKBeT6OW9Zma0+Cd3WDde5JESBt+kiV0+xrlLNFEazf4lSACVM3z MSbF1/50u5Zn1YBou+BU+iZ1C0qrQudDKVhvnIYRzJtAP12+cwJ2Qu9acSUJP4eW9ION n5dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rnGmicyG/Ok+jl9mvPHQI/rUKWOmhsLgB5COFdWeBgA=; b=NCUNVmqwsaheQmuPYXjvNLMz4G0yD9LHFLCVFpL8V+wyd7NI5el7WllMpvvEztvmaD xIM5U3wzLHeVnvTkTfo5zrcTw5LmxAQADZ3auxDdPVR9Jcs+jWE/bsk9AM3w8NwZA4U7 9mhZo/wjvRrb+WPVvRCHVrT8F+jHe1ShzH0SSKk2CeFYW7dfl6D3dX981PDLd0OsnxOE EKD/081zHK/6PPMtl6J3PXhg+C18+E0ckJ4kP7epK02SmMn3XMcRszr3U0KtINcJSI5J IK2xvpIutIEo6sw0AWlM4eKz/BGUEF577dNETDKZa9Pumf+tjm76dCOpaw+s03tf9fic nzeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12-v6si20386242pfj.190.2018.09.03.10.16.28; Mon, 03 Sep 2018 10:16:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729619AbeICVg3 (ORCPT + 99 others); Mon, 3 Sep 2018 17:36:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42380 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbeICVg2 (ORCPT ); Mon, 3 Sep 2018 17:36:28 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1F3DFD02; Mon, 3 Sep 2018 17:15:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paulo Flabiano Smorigo , Herbert Xu Subject: [PATCH 4.14 001/165] crypto: vmx - Use skcipher for ctr fallback Date: Mon, 3 Sep 2018 18:54:47 +0200 Message-Id: <20180903165655.071871280@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Flabiano Smorigo commit e666d4e9ceec94c0a88c94b7db31d56474da43b3 upstream. Signed-off-by: Paulo Flabiano Smorigo Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/vmx/aes_ctr.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) --- a/drivers/crypto/vmx/aes_ctr.c +++ b/drivers/crypto/vmx/aes_ctr.c @@ -27,21 +27,23 @@ #include #include #include +#include + #include "aesp8-ppc.h" struct p8_aes_ctr_ctx { - struct crypto_blkcipher *fallback; + struct crypto_skcipher *fallback; struct aes_key enc_key; }; static int p8_aes_ctr_init(struct crypto_tfm *tfm) { const char *alg = crypto_tfm_alg_name(tfm); - struct crypto_blkcipher *fallback; + struct crypto_skcipher *fallback; struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm); - fallback = - crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK); + fallback = crypto_alloc_skcipher(alg, 0, + CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); if (IS_ERR(fallback)) { printk(KERN_ERR "Failed to allocate transformation for '%s': %ld\n", @@ -49,9 +51,9 @@ static int p8_aes_ctr_init(struct crypto return PTR_ERR(fallback); } - crypto_blkcipher_set_flags( + crypto_skcipher_set_flags( fallback, - crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm)); + crypto_skcipher_get_flags((struct crypto_skcipher *)tfm)); ctx->fallback = fallback; return 0; @@ -62,7 +64,7 @@ static void p8_aes_ctr_exit(struct crypt struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm); if (ctx->fallback) { - crypto_free_blkcipher(ctx->fallback); + crypto_free_skcipher(ctx->fallback); ctx->fallback = NULL; } } @@ -81,7 +83,7 @@ static int p8_aes_ctr_setkey(struct cryp pagefault_enable(); preempt_enable(); - ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen); + ret += crypto_skcipher_setkey(ctx->fallback, key, keylen); return ret; } @@ -115,15 +117,14 @@ static int p8_aes_ctr_crypt(struct blkci struct blkcipher_walk walk; struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); - struct blkcipher_desc fallback_desc = { - .tfm = ctx->fallback, - .info = desc->info, - .flags = desc->flags - }; if (in_interrupt()) { - ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src, - nbytes); + SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); + skcipher_request_set_tfm(req, ctx->fallback); + skcipher_request_set_callback(req, desc->flags, NULL, NULL); + skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); + ret = crypto_skcipher_encrypt(req); + skcipher_request_zero(req); } else { blkcipher_walk_init(&walk, dst, src, nbytes); ret = blkcipher_walk_virt_block(desc, &walk, AES_BLOCK_SIZE);