From patchwork Fri Sep 5 22:59:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 36902 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 12730202A1 for ; Fri, 5 Sep 2014 22:59:59 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf58134149iga.6 for ; Fri, 05 Sep 2014 15:59:58 -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=22LK3kuBGyUEpdQAUngnSNRnTxKssn7vljFUQngdpQk=; b=BCp32Q54IiytK/dyK+6omRpVTpC+B3x0lzxghtmqdMnH+Vqe1JPEyfoJkNoGPD3L28 /7qvAupSGL1CLl1+wyjPAhSfHjd5uzVC9o0DVi/g6WPj26/smrkTgs8zcjEjQ/NF780e 7GRh7Ih9wxd8cXikWXDjWmakqBug4kmU8F+3zC3FLauGWT3BIDpAlZmCJLcs6oCwsFcu W5yND/y4qWtwQI2Cngh+sPcus54nJDwQpPM10KIR41Gi5T7vA4MOCMaTh8Ud2btI9pKn 3q+jSXFKsG16/xom42vgV/fiAxH0cHW/ec272b/oPybeGB4zcsUmcobGa20zcJ5kokBg I8ww== X-Gm-Message-State: ALoCoQlRg9Nylkk2rc2bQ6VoEg9Ge4b2pfEsjUa+7c7x10oqqNXfiKY2M1OrNY+gx1lndfEOS6BU X-Received: by 10.42.90.209 with SMTP id l17mr7504747icm.34.1409957998629; Fri, 05 Sep 2014 15:59:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.232 with SMTP id 95ls931587qgb.94.gmail; Fri, 05 Sep 2014 15:59:58 -0700 (PDT) X-Received: by 10.52.136.196 with SMTP id qc4mr10793392vdb.22.1409957998521; Fri, 05 Sep 2014 15:59:58 -0700 (PDT) Received: from mail-vc0-x22a.google.com (mail-vc0-x22a.google.com [2607:f8b0:400c:c03::22a]) by mx.google.com with ESMTPS id s18si1555219vcu.2.2014.09.05.15.59.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 15:59:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::22a as permitted sender) client-ip=2607:f8b0:400c:c03::22a; Received: by mail-vc0-f170.google.com with SMTP id la4so13256527vcb.29 for ; Fri, 05 Sep 2014 15:59:58 -0700 (PDT) X-Received: by 10.220.105.142 with SMTP id t14mr12849156vco.14.1409957998432; Fri, 05 Sep 2014 15:59:58 -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 uj3csp148189vcb; Fri, 5 Sep 2014 15:59:57 -0700 (PDT) X-Received: by 10.70.91.73 with SMTP id cc9mr26579695pdb.138.1409957997594; Fri, 05 Sep 2014 15:59:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj1si6133743pbb.193.2014.09.05.15.59.57 for ; Fri, 05 Sep 2014 15:59:57 -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 S1752513AbaIEW74 (ORCPT ); Fri, 5 Sep 2014 18:59:56 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:38519 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751990AbaIEW7z (ORCPT ); Fri, 5 Sep 2014 18:59:55 -0400 Received: by mail-pa0-f51.google.com with SMTP id rd3so22987829pab.24 for ; Fri, 05 Sep 2014 15:59:55 -0700 (PDT) X-Received: by 10.66.141.165 with SMTP id rp5mr25846209pab.115.1409957995204; Fri, 05 Sep 2014 15:59:55 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id yr3sm2799024pac.1.2014.09.05.15.59.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Sep 2014 15:59:53 -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, Behan Webster , Mark Charlebois , =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= Subject: [PATCH] crypto: LLVMLinux: Remove VLAIS from crypto/mv_cesa.c Date: Fri, 5 Sep 2014 15:59:41 -0700 Message-Id: <1409957981-31166-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 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 2607:f8b0:400c:c03::22a 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: Behan Webster 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: Behan Webster Signed-off-by: Mark Charlebois Signed-off-by: Jan-Simon Möller --- drivers/crypto/mv_cesa.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 29d0ee5..0d92c85 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c @@ -402,26 +402,25 @@ static int mv_hash_final_fallback(struct ahash_request *req) { const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm); struct mv_req_hash_ctx *req_ctx = ahash_request_ctx(req); - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(tfm_ctx->fallback)]; - } desc; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(tfm_ctx->fallback)] CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; int rc; - desc.shash.tfm = tfm_ctx->fallback; - desc.shash.flags = CRYPTO_TFM_REQ_MAY_SLEEP; + shash->tfm = tfm_ctx->fallback; + shash->flags = CRYPTO_TFM_REQ_MAY_SLEEP; if (unlikely(req_ctx->first_hash)) { - crypto_shash_init(&desc.shash); - crypto_shash_update(&desc.shash, req_ctx->buffer, + crypto_shash_init(shash); + crypto_shash_update(shash, req_ctx->buffer, req_ctx->extra_bytes); } else { /* only SHA1 for now.... */ - rc = mv_hash_import_sha1_ctx(req_ctx, &desc.shash); + rc = mv_hash_import_sha1_ctx(req_ctx, shash); if (rc) goto out; } - rc = crypto_shash_final(&desc.shash, req->result); + rc = crypto_shash_final(shash, req->result); out: return rc; } @@ -794,23 +793,24 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key, ss = crypto_shash_statesize(ctx->base_hash); { - struct { - struct shash_desc shash; - char ctx[crypto_shash_descsize(ctx->base_hash)]; - } desc; + char desc[sizeof(struct shash_desc) + + crypto_shash_descsize(ctx->base_hash)] + CRYPTO_MINALIGN_ATTR; + struct shash_desc *shash = (struct shash_desc *)desc; + unsigned int i; char ipad[ss]; char opad[ss]; - desc.shash.tfm = ctx->base_hash; - desc.shash.flags = crypto_shash_get_flags(ctx->base_hash) & + shash->tfm = ctx->base_hash; + shash->flags = crypto_shash_get_flags(ctx->base_hash) & CRYPTO_TFM_REQ_MAY_SLEEP; if (keylen > bs) { int err; err = - crypto_shash_digest(&desc.shash, key, keylen, ipad); + crypto_shash_digest(shash, key, keylen, ipad); if (err) return err; @@ -826,12 +826,12 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key, opad[i] ^= 0x5c; } - rc = 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); + rc = 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); if (rc == 0) mv_hash_init_ivs(ctx, ipad, opad);