From patchwork Mon Sep 15 07:30:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37408 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CFA9A206A5 for ; Mon, 15 Sep 2014 07:33:25 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id m15sf1931739wgh.3 for ; Mon, 15 Sep 2014 00:33:22 -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 :in-reply-to:references: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=Qfqxe/b3OxcCNPPcYBJUgP7+aYiQetJWy4957QjTatU=; b=kDhg0MCsKFbAnRf8p5yT5JVwYjIA/deTagaismT7BC2K3rzVDzYP6ZMwNF7s59FE7P jhAxkj7FJffLkGgZlLJpEI3JM/R/6M1VUjGOnDEMDzW4gkxS1UQNKt6EsGQ6XxtWPkaT JAGDZf+6JtRUTkOKHf+NgI4bIpw4mTVgD8AO4c7J5ePjR9cjDPzmQACYbt65cYbcobS0 BB2/Rh4ns4PutHNjbm6Id3+nOjbazPNMKccgaMmZm8p0OCfkJxpN0HrIkHTkeRtMgJ8V Do7wSDDPVKY29Rar1MDBfJ4jh0S08dMcDRCVgSNl9uiyi4K3UxY1X4ITpJsSiOd3Sp0A Mfmg== X-Gm-Message-State: ALoCoQki3Nh8E/WffItehDBwZfug/oQgG+mSfWcIDilbpL42eQj+FFHGIHJtWjJQn+4Zn7cxptPe X-Received: by 10.152.44.227 with SMTP id h3mr6785459lam.2.1410766402670; Mon, 15 Sep 2014 00:33:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.104 with SMTP id lf8ls204994lac.87.gmail; Mon, 15 Sep 2014 00:33:22 -0700 (PDT) X-Received: by 10.112.141.7 with SMTP id rk7mr1117952lbb.83.1410766402370; Mon, 15 Sep 2014 00:33:22 -0700 (PDT) Received: from mail-lb0-x231.google.com (mail-lb0-x231.google.com [2a00:1450:4010:c04::231]) by mx.google.com with ESMTPS id ep11si17599395lac.50.2014.09.15.00.33.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 00:33:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) client-ip=2a00:1450:4010:c04::231; Received: by mail-lb0-f177.google.com with SMTP id l4so3862706lbv.8 for ; Mon, 15 Sep 2014 00:33:22 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr24442846lbs.34.1410766402196; Mon, 15 Sep 2014 00:33:22 -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.112.130.169 with SMTP id of9csp161804lbb; Mon, 15 Sep 2014 00:33:21 -0700 (PDT) X-Received: by 10.70.45.107 with SMTP id l11mr2327639pdm.141.1410766400695; Mon, 15 Sep 2014 00:33:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id co3si21071751pdb.194.2014.09.15.00.33.20 for ; Mon, 15 Sep 2014 00:33:20 -0700 (PDT) Received-SPF: none (google.com: linux-crypto-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 S1752818AbaIOHdS (ORCPT ); Mon, 15 Sep 2014 03:33:18 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36119 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbaIOHbu (ORCPT ); Mon, 15 Sep 2014 03:31:50 -0400 Received: by mail-pa0-f46.google.com with SMTP id kq14so5769616pab.33 for ; Mon, 15 Sep 2014 00:31:50 -0700 (PDT) X-Received: by 10.66.186.167 with SMTP id fl7mr34756873pac.14.1410766310173; Mon, 15 Sep 2014 00:31:50 -0700 (PDT) Received: from galdor.edimax.com ([38.126.120.10]) by mx.google.com with ESMTPSA id cz1sm1011611pdb.85.2014.09.15.00.31.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:49 -0700 (PDT) From: behanw@converseincode.com To: agk@redhat.com, clm@fb.com, davem@davemloft.net, dm-devel@redhat.com, fabf@skynet.be, herbert@gondor.apana.org.au, jbacik@fb.com, snitzer@redhat.com, tadeusz.struk@intel.com Cc: akpm@linux-foundation.org, bruce.w.allan@intel.com, d.kasatkin@samsung.com, james.l.morris@oracle.com, john.griffin@intel.com, linux-btrfs@vger.kernel.org, linux-crypto@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, neilb@suse.de, qat-linux@intel.com, serge@hallyn.com, thomas.lendacky@amd.com, zohar@linux.vnet.ibm.com, torvalds@linux-foundation.org, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster , pageexec@freemail.hu Subject: [PATCH v3 09/12] crypto: LLVMLinux: Remove VLAIS usage from crypto/hmac.c Date: Mon, 15 Sep 2014 00:30:31 -0700 Message-Id: <1410766234-1634-10-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410766234-1634-1-git-send-email-behanw@converseincode.com> References: <1410766234-1634-1-git-send-email-behanw@converseincode.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-crypto@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 2a00:1450:4010:c04::231 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 a char array using the SHASH_DESC_ON_STACK macro. The new code can be compiled with both gcc and clang. Signed-off-by: Jan-Simon Möller Signed-off-by: Behan Webster Cc: pageexec@freemail.hu --- crypto/hmac.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/crypto/hmac.c b/crypto/hmac.c index 8d9544c..e392219 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -52,20 +52,17 @@ static int hmac_setkey(struct crypto_shash *parent, struct hmac_ctx *ctx = align_ptr(opad + ss, crypto_tfm_ctx_alignment()); struct crypto_shash *hash = ctx->hash; - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(hash)]; - } desc; + SHASH_DESC_ON_STACK(shash, hash); unsigned int i; - desc.shash.tfm = hash; - desc.shash.flags = crypto_shash_get_flags(parent) & - CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = hash; + shash->flags = crypto_shash_get_flags(parent) + & CRYPTO_TFM_REQ_MAY_SLEEP; if (keylen > bs) { int err; - err = crypto_shash_digest(&desc.shash, inkey, keylen, ipad); + err = crypto_shash_digest(shash, inkey, keylen, ipad); if (err) return err; @@ -81,12 +78,12 @@ static int hmac_setkey(struct crypto_shash *parent, opad[i] ^= 0x5c; } - return crypto_shash_init(&desc.shash) ?: - crypto_shash_update(&desc.shash, ipad, bs) ?: - crypto_shash_export(&desc.shash, ipad) ?: - crypto_shash_init(&desc.shash) ?: - crypto_shash_update(&desc.shash, opad, bs) ?: - crypto_shash_export(&desc.shash, opad); + return crypto_shash_init(shash) ?: + crypto_shash_update(shash, ipad, bs) ?: + crypto_shash_export(shash, ipad) ?: + crypto_shash_init(shash) ?: + crypto_shash_update(shash, opad, bs) ?: + crypto_shash_export(shash, opad); } static int hmac_export(struct shash_desc *pdesc, void *out)