From patchwork Thu Apr 19 16:41:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 10351311 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40E716053F for ; Thu, 19 Apr 2018 16:42:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 340CA1FE8A for ; Thu, 19 Apr 2018 16:42:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 293821FF22; Thu, 19 Apr 2018 16:42:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F8721FF13 for ; Thu, 19 Apr 2018 16:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754054AbeDSQmE (ORCPT ); Thu, 19 Apr 2018 12:42:04 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45791 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754023AbeDSQmC (ORCPT ); Thu, 19 Apr 2018 12:42:02 -0400 Received: by mail-wr0-f196.google.com with SMTP id u11-v6so15755033wri.12 for ; Thu, 19 Apr 2018 09:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:in-reply-to :references; bh=xchCtsNcVW3T22gHZw8juoO5GdRQUEBvmG9LnAuZFfY=; b=O68PwrF9ewgTB5HvAxoSrzK4Vxtcgkx2dDwhOIzxwJ5xwEwuhmh+390HGRt5b4LTAI aaXeetPjcqeXmVmD64/oSZ5v7kx3rB4suYBySbBD1kYqnDXOjvIjHGJAIPJjtHMUK+We lEimvG7DWihx6ClZYFAhl5l2ufw4719exrZ+wGdfYwP6gxxPnop/zVnDxyVeBEAK3EN4 xyCUBSphaNvXqyHhPWRIszOnr+8KiOH9UTuxuatngnivsAoLBVFMouQ3oRlBI6arjUrS pNuKM3fqsnEoS+2pNyi4i7I4rQTqFcjSClk9kgvsA1oYn6uDARSZ0f6Y9R+uV89SUuQm GGtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=xchCtsNcVW3T22gHZw8juoO5GdRQUEBvmG9LnAuZFfY=; b=O3dgncnr1IsnwZCNpF+DQN+orbdUwX874ERLa2eDafKWA3Q+02M6Rb65vnhiD4QFel 9kkJkoXRBCQ3uQtKtCLP6gAiKZCgC+XX8zk0oaU6v2rM/TIH6J+/TdRHBQn5teOHD3kq V5oO2YpVH6nSYvYDmXS17SQsaNqgJ4LncKxZPMxxHhAgyf3ukajMXQzTRo2sL8dD0B4J 1hdSgYJeU8zuILe6asEel+B+NiYGG4z/kwfyGyHaKBURuwNRLf1l2eslaHI9ypqLtx95 rOVP+lRIsxTs9SRxrolpc+hN7h4Z6mpsRsOJDhn2v6O4bI4+dxIHxFNi7r/+544HlC6O nyMw== X-Gm-Message-State: ALQs6tAlSkf5Jm/t0adCBPADt0Jq+mu9rdSpTFyV1YzwECOhsCqTHUyF wecgefrDsU7XOkJRHkl4ABNBQDn3 X-Google-Smtp-Source: AIpwx49Qwj4d3jRiV2WfrP1dWukGsxhhG+OCzGZliBGHNkPvC65VOVE9+GZjvAgdIAINMgbyO0KkGA== X-Received: by 2002:adf:a453:: with SMTP id e19-v6mr5502089wra.121.1524156120857; Thu, 19 Apr 2018 09:42:00 -0700 (PDT) Received: from debian64.daheim (p200300D5FBC3D8FC0000000000000830.dip0.t-ipconnect.de. [2003:d5:fbc3:d8fc::830]) by smtp.gmail.com with ESMTPSA id f2-v6sm3062555wre.76.2018.04.19.09.41.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Apr 2018 09:41:58 -0700 (PDT) Received: from chuck by debian64.daheim with local (Exim 4.90_1) (envelope-from ) id 1f9CdC-000276-1B for linux-crypto@vger.kernel.org; Thu, 19 Apr 2018 18:41:58 +0200 From: Christian Lamparter To: linux-crypto@vger.kernel.org Subject: [PATCH v1 3/7] crypto: crypto4xx - avoid VLA use Date: Thu, 19 Apr 2018 18:41:53 +0200 Message-Id: <69e4e7d9b21743df43f7f2eaac25a6beef28e999.1524156017.git.chunkeey@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes some of the -Wvla warnings. crypto4xx_alg.c:83:19: warning: Variable length array is used. crypto4xx_alg.c:273:56: warning: Variable length array is used. crypto4xx_alg.c:380:32: warning: Variable length array is used. Signed-off-by: Christian Lamparter --- drivers/crypto/amcc/crypto4xx_alg.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/amcc/crypto4xx_alg.c b/drivers/crypto/amcc/crypto4xx_alg.c index 2a8e4f0fe1e9..2dfeb71deca9 100644 --- a/drivers/crypto/amcc/crypto4xx_alg.c +++ b/drivers/crypto/amcc/crypto4xx_alg.c @@ -80,7 +80,7 @@ static inline int crypto4xx_crypt(struct skcipher_request *req, { struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req); struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher); - __le32 iv[ivlen]; + __le32 iv[AES_IV_SIZE]; if (ivlen) crypto4xx_memcpy_to_le32(iv, req->iv, ivlen); @@ -270,13 +270,7 @@ static inline bool crypto4xx_aead_need_fallback(struct aead_request *req, static int crypto4xx_aead_fallback(struct aead_request *req, struct crypto4xx_ctx *ctx, bool do_decrypt) { - char aead_req_data[sizeof(struct aead_request) + - crypto_aead_reqsize(ctx->sw_cipher.aead)] - __aligned(__alignof__(struct aead_request)); - - struct aead_request *subreq = (void *) aead_req_data; - - memset(subreq, 0, sizeof(aead_req_data)); + struct aead_request *subreq = aead_request_ctx(req); aead_request_set_tfm(subreq, ctx->sw_cipher.aead); aead_request_set_callback(subreq, req->base.flags, @@ -377,7 +371,7 @@ static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt) struct crypto_aead *aead = crypto_aead_reqtfm(req); unsigned int len = req->cryptlen; __le32 iv[16]; - u32 tmp_sa[ctx->sa_len * 4]; + u32 tmp_sa[SA_AES128_CCM_LEN + 4]; struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *)tmp_sa; if (crypto4xx_aead_need_fallback(req, true, decrypt)) @@ -386,7 +380,7 @@ static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt) if (decrypt) len -= crypto_aead_authsize(aead); - memcpy(tmp_sa, decrypt ? ctx->sa_in : ctx->sa_out, sizeof(tmp_sa)); + memcpy(tmp_sa, decrypt ? ctx->sa_in : ctx->sa_out, ctx->sa_len * 4); sa->sa_command_0.bf.digest_len = crypto_aead_authsize(aead) >> 2; if (req->iv[0] == 1) {