From patchwork Wed Mar 19 03:32:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 26532 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 07F32202FA for ; Wed, 19 Mar 2014 03:33:26 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf19584762vcb.2 for ; Tue, 18 Mar 2014 20:33:26 -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=t+EgwZWtQxpiXTiOAl2CQc5NMZL94sEsQMbGuszYYFs=; b=Oge14PR+kG4/w2MJn1A63KmxxDJ9ruy+xNkb0hXdBCvRoev1mttULOA64Ht9MR0NBK gRvd6SDHzyZnAGvu736CbksKh2CkDQQfhRN9SA/OLJjfqG9NMS71SkyOmEYeBA7HPiLL pDaZ5yfuX0ZG7JoaZGb6VBhU7a04CM2+2md8NWVHWeNSLOtYa2jhpLyul+5zS9VPqIxa atqe0iyyQgC9BNNbxoOSRbFIxzHEl50DkK4OHRN+K5f2T6kxHiEq0U51KJhRNRBrdw0Y jZU8MzmTJ7A9bSHI+tPM+bpzk/apv/Zf0I42jg+i5Z+40HtlXWWlBTCStSyE7+kff5E3 UKPQ== X-Gm-Message-State: ALoCoQldotqn7nn7CurO090FyOdcgvJ86Po7HWFrMmcS9FFH9vA1IR0fHJBCoAwSj1bOyscOHHFS X-Received: by 10.58.58.41 with SMTP id n9mr3942535veq.23.1395200006718; Tue, 18 Mar 2014 20:33:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.50 with SMTP id l47ls2319360qga.49.gmail; Tue, 18 Mar 2014 20:33:26 -0700 (PDT) X-Received: by 10.52.173.165 with SMTP id bl5mr14728811vdc.13.1395200006520; Tue, 18 Mar 2014 20:33:26 -0700 (PDT) Received: from mail-ve0-x22e.google.com (mail-ve0-x22e.google.com [2607:f8b0:400c:c01::22e]) by mx.google.com with ESMTPS id g4si7234887vch.73.2014.03.18.20.33.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 20:33:26 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22e; Received: by mail-ve0-f174.google.com with SMTP id oz11so8170696veb.33 for ; Tue, 18 Mar 2014 20:33:26 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr28114422vcm.11.1395200006399; Tue, 18 Mar 2014 20:33:26 -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.220.78.9 with SMTP id i9csp264800vck; Tue, 18 Mar 2014 20:33:25 -0700 (PDT) X-Received: by 10.66.226.145 with SMTP id rs17mr14526509pac.144.1395200005324; Tue, 18 Mar 2014 20:33:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi5si19964472pbb.289.2014.03.18.20.33.25; Tue, 18 Mar 2014 20:33:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759068AbaCSDcx (ORCPT ); Tue, 18 Mar 2014 23:32:53 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:41152 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759043AbaCSDcW (ORCPT ); Tue, 18 Mar 2014 23:32:22 -0400 Received: by mail-pa0-f49.google.com with SMTP id lj1so8240677pab.22 for ; Tue, 18 Mar 2014 20:32:22 -0700 (PDT) X-Received: by 10.68.178.1 with SMTP id cu1mr36570275pbc.34.1395199942108; Tue, 18 Mar 2014 20:32:22 -0700 (PDT) Received: from localhost.localdomain ([75.148.49.89]) by mx.google.com with ESMTPSA id qq5sm57470332pbb.24.2014.03.18.20.32.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 20:32:20 -0700 (PDT) From: behanw@converseincode.com To: linville@tuxdriver.com, johannes@sipsolutions.net, davem@davemloft.net Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, dwmw2@infradead.org, pageexec@freemail.hu, =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= , Behan Webster , =?UTF-8?q?Vin=C3=ADcius=20Tinti?= , Mark Charlebois Subject: [PATCH v3] mac80211: LLVMLinux: Remove VLAIS usage from mac80211 Date: Tue, 18 Mar 2014 20:32:13 -0700 Message-Id: <1395199933-4686-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (no key for signature) header.i=@converseincode.com 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 is the original VLAIS struct. struct { struct aead_request req; u8 priv[crypto_aead_reqsize(tfm)]; } aead_req; This patch instead allocates the appropriate amount of memory using an char array. The new code can be compiled with both gcc and clang. Signed-off-by: Jan-Simon Möller Signed-off-by: Behan Webster Signed-off-by: Vinícius Tinti Signed-off-by: Mark Charlebois --- net/mac80211/aes_ccm.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index 7c7df47..20521f9 100644 --- a/net/mac80211/aes_ccm.c +++ b/net/mac80211/aes_ccm.c @@ -23,12 +23,14 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, u8 *data, size_t data_len, u8 *mic) { struct scatterlist assoc, pt, ct[2]; - struct { - struct aead_request req; - u8 priv[crypto_aead_reqsize(tfm)]; - } aead_req; - memset(&aead_req, 0, sizeof(aead_req)); + char aead_req_data[sizeof(struct aead_request) + + crypto_aead_reqsize(tfm)] + __aligned(__alignof__(struct aead_request)); + + struct aead_request *aead_req = (void *) aead_req_data; + + memset(aead_req, 0, sizeof(aead_req_data)); sg_init_one(&pt, data, data_len); sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); @@ -36,23 +38,25 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, sg_set_buf(&ct[0], data, data_len); sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN); - aead_request_set_tfm(&aead_req.req, tfm); - aead_request_set_assoc(&aead_req.req, &assoc, assoc.length); - aead_request_set_crypt(&aead_req.req, &pt, ct, data_len, b_0); + aead_request_set_tfm(aead_req, tfm); + aead_request_set_assoc(aead_req, &assoc, assoc.length); + aead_request_set_crypt(aead_req, &pt, ct, data_len, b_0); - crypto_aead_encrypt(&aead_req.req); + crypto_aead_encrypt(aead_req); } int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, u8 *data, size_t data_len, u8 *mic) { struct scatterlist assoc, pt, ct[2]; - struct { - struct aead_request req; - u8 priv[crypto_aead_reqsize(tfm)]; - } aead_req; - memset(&aead_req, 0, sizeof(aead_req)); + char aead_req_data[sizeof(struct aead_request) + + crypto_aead_reqsize(tfm) + + CRYPTO_MINALIGN] CRYPTO_MINALIGN_ATTR; + + struct aead_request *aead_req = (void *) aead_req_data; + + memset(aead_req, 0, sizeof(aead_req_data)); sg_init_one(&pt, data, data_len); sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); @@ -60,12 +64,12 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, sg_set_buf(&ct[0], data, data_len); sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN); - aead_request_set_tfm(&aead_req.req, tfm); - aead_request_set_assoc(&aead_req.req, &assoc, assoc.length); - aead_request_set_crypt(&aead_req.req, ct, &pt, + aead_request_set_tfm(aead_req, tfm); + aead_request_set_assoc(aead_req, &assoc, assoc.length); + aead_request_set_crypt(aead_req, ct, &pt, data_len + IEEE80211_CCMP_MIC_LEN, b_0); - return crypto_aead_decrypt(&aead_req.req); + return crypto_aead_decrypt(aead_req); } struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])