From patchwork Fri Sep 5 22:59:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36901 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3F3DE202A1 for ; Fri, 5 Sep 2014 22:59:21 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf107211450pab.0 for ; Fri, 05 Sep 2014 15:59:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=GN3QD1VUT/ZkMSuzNSmB6jmHhZXilcneeTO6wR8AuGc=; b=ddCpZGYEyIZN9EC1VYzzzg8NUMzRiFooEDsAEWVrTUt1y5IkkyAx14NpRAtancgsqp abBmZ8A4vhEBymy7ewcioCHiXteHkDNReY/Hlj9RB0/R2NopuqYj3BsKjrRAWXABrZEG hc0iXBUu0WZZnnlnJVYU3lHshODATXskMTOFr/djXEj5AogqAUwuFIz5XPXan6smELkF Wvaw1wSWmDLPRamdOvE1OX+yop8T7G/LtDCJylhmQDXtTBm7vX7ojd3lu1vibai7qjY1 WSEhut5C/KfYvvDSrTqoAKLbNheXAhBY/rSyJVd5ktnxANL0As5mKjJPOktkU7zJGs1I 4zOA== X-Gm-Message-State: ALoCoQkEhse3WZY4SMAwHt0I8RdqCCckywNAZ6/aHLalv4/yxUlp5ZYFFvVbtePFRteXmhN4KxP8 X-Received: by 10.69.29.234 with SMTP id jz10mr131974pbd.1.1409957960559; Fri, 05 Sep 2014 15:59:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.73 with SMTP id f67ls244610qge.61.gmail; Fri, 05 Sep 2014 15:59:20 -0700 (PDT) X-Received: by 10.220.166.68 with SMTP id l4mr12865473vcy.20.1409957960451; Fri, 05 Sep 2014 15:59:20 -0700 (PDT) Received: from mail-vc0-x235.google.com (mail-vc0-x235.google.com [2607:f8b0:400c:c03::235]) by mx.google.com with ESMTPS id cf5si1535738vcb.46.2014.09.05.15.59.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 15:59:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::235 as permitted sender) client-ip=2607:f8b0:400c:c03::235; Received: by mail-vc0-f181.google.com with SMTP id le20so1719834vcb.12 for ; Fri, 05 Sep 2014 15:59:20 -0700 (PDT) X-Received: by 10.221.44.69 with SMTP id uf5mr12874474vcb.4.1409957960358; Fri, 05 Sep 2014 15:59:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp148146vcb; Fri, 5 Sep 2014 15:59:19 -0700 (PDT) X-Received: by 10.70.96.74 with SMTP id dq10mr26839405pdb.112.1409957959536; Fri, 05 Sep 2014 15:59:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fk4si6063513pbb.236.2014.09.05.15.59.18 for ; Fri, 05 Sep 2014 15:59:19 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754046AbaIEW7R (ORCPT + 26 others); Fri, 5 Sep 2014 18:59:17 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:46423 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752513AbaIEW7P (ORCPT ); Fri, 5 Sep 2014 18:59:15 -0400 Received: by mail-pa0-f49.google.com with SMTP id kq14so23048530pab.36 for ; Fri, 05 Sep 2014 15:59:15 -0700 (PDT) X-Received: by 10.68.68.168 with SMTP id x8mr160201pbt.84.1409957955405; Fri, 05 Sep 2014 15:59:15 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id 5sm2495012pdu.0.2014.09.05.15.59.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 15:59:14 -0700 (PDT) From: behanw@converseincode.com To: davem@davemloft.net, herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.lendacky@amd.com, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster Subject: [PATCH] crypto: LLVMLinux: Remove VLAIS from crypto/ccp/ccp-crypto-sha.c Date: Fri, 5 Sep 2014 15:59:04 -0700 Message-Id: <1409957944-30173-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Jan-Simon Möller Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This patch allocates the appropriate amount of memory using an char array. The new code can be compiled with both gcc and clang. struct shash_desc contains a flexible array member member ctx declared with CRYPTO_MINALIGN_ATTR, so sizeof(struct shash_desc) aligns the beginning of the array declared after struct shash_desc with long long. No trailing padding is required because it is not a struct type that can be used in an array. The CRYPTO_MINALIGN_ATTR is required so that desc is aligned with long long as would be the case for a struct containing a member with CRYPTO_MINALIGN_ATTR. Signed-off-by: Jan-Simon Möller Signed-off-by: Behan Webster --- drivers/crypto/ccp/ccp-crypto-sha.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c index 873f234..29f9fda 100644 --- a/drivers/crypto/ccp/ccp-crypto-sha.c +++ b/drivers/crypto/ccp/ccp-crypto-sha.c @@ -198,10 +198,11 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, { struct ccp_ctx *ctx = crypto_tfm_ctx(crypto_ahash_tfm(tfm)); struct crypto_shash *shash = ctx->u.sha.hmac_tfm; - struct { - struct shash_desc sdesc; - char ctx[crypto_shash_descsize(shash)]; - } desc; + + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(shash)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *sdesc = (struct shash_desc *)desc; + unsigned int block_size = crypto_shash_blocksize(shash); unsigned int digest_size = crypto_shash_digestsize(shash); int i, ret; @@ -216,11 +217,11 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, if (key_len > block_size) { /* Must hash the input key */ - desc.sdesc.tfm = shash; - desc.sdesc.flags = crypto_ahash_get_flags(tfm) & + sdesc->tfm = shash; + sdesc->flags = crypto_ahash_get_flags(tfm) & CRYPTO_TFM_REQ_MAY_SLEEP; - ret = crypto_shash_digest(&desc.sdesc, key, key_len, + ret = crypto_shash_digest(sdesc, key, key_len, ctx->u.sha.key); if (ret) { crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);