From patchwork Fri Mar 21 06:39:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 26788 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 257E2202E0 for ; Fri, 21 Mar 2014 06:39:55 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 19sf10191781ykq.0 for ; Thu, 20 Mar 2014 23:39:54 -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=eQdFKlWFlratzFVB5lbDb7CUmdTc5+AEZsh5Oaz3Z0A=; b=F1/gWfGC+6s9tW9kmBW3AwKsQjgEmsZPBf35k1flAuAv5ufiDZ3TmARZm6cm6jY5p2 M7g565kbfyUiz6AFBvm9GGIde+kwmWi/Q7MvAL+ivlU9pKWPjNxdIcruFAyY8ueelFff r+qhqY8msFD64J67dRDj/N7ANQryJCjxLxVRZJ10DCan/LgjOk1ox0L9Q/jJPe6QJrMz /5mJSdyTiJGaS+ddd/FSkwNBYSoAjW5fIYBE6F4mlqa+0w/yqwQPWYkdYhck6zyAw8fL 6YgvnN2zYlGj7wajlV4mqMvQhpPrJwbTRSRQFGt3A5Cw+CJpZNNdXibSIZLujgZGvs2w GTuw== X-Gm-Message-State: ALoCoQk7+FfGpX6B5nllVRGVlph5JfeTFIxGPrIZWFeyKyHqely13ig3i9KBmyFbiUAfnoVUF2uC X-Received: by 10.58.88.136 with SMTP id bg8mr10287640veb.21.1395383994430; Thu, 20 Mar 2014 23:39:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.233 with SMTP id 96ls533018qgp.61.gmail; Thu, 20 Mar 2014 23:39:54 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr23281998vei.20.1395383994309; Thu, 20 Mar 2014 23:39:54 -0700 (PDT) Received: from mail-vc0-x229.google.com (mail-vc0-x229.google.com [2607:f8b0:400c:c03::229]) by mx.google.com with ESMTPS id bw7si946849vcb.51.2014.03.20.23.39.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 23:39:54 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::229 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:c03::229; Received: by mail-vc0-f169.google.com with SMTP id ik5so2197785vcb.0 for ; Thu, 20 Mar 2014 23:39:54 -0700 (PDT) X-Received: by 10.52.161.130 with SMTP id xs2mr2626739vdb.49.1395383994205; Thu, 20 Mar 2014 23:39:54 -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 i9csp8254vck; Thu, 20 Mar 2014 23:39:53 -0700 (PDT) X-Received: by 10.66.248.227 with SMTP id yp3mr51216986pac.116.1395383983523; Thu, 20 Mar 2014 23:39:43 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh4si3001920pbc.176.2014.03.20.23.39.43; Thu, 20 Mar 2014 23:39:43 -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 S1755933AbaCUGjl (ORCPT ); Fri, 21 Mar 2014 02:39:41 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:33124 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498AbaCUGjj (ORCPT ); Fri, 21 Mar 2014 02:39:39 -0400 Received: by mail-pb0-f42.google.com with SMTP id rr13so2028593pbb.1 for ; Thu, 20 Mar 2014 23:39:39 -0700 (PDT) X-Received: by 10.68.170.66 with SMTP id ak2mr51862789pbc.5.1395383979145; Thu, 20 Mar 2014 23:39:39 -0700 (PDT) Received: from localhost.localdomain ([75.148.49.89]) by mx.google.com with ESMTPSA id c7sm7847809pbt.0.2014.03.20.23.39.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 23:39:37 -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, 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 v4] mac80211: LLVMLinux: Remove VLAIS usage from mac80211 Date: Thu, 20 Mar 2014 23:39:32 -0700 Message-Id: <1395383972-20372-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395237113.4142.5.camel@jlt4.sipsolutions.net> References: <1395237113.4142.5.camel@jlt4.sipsolutions.net> 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:c03::229 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 | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index 7c7df47..71e2abd 100644 --- a/net/mac80211/aes_ccm.c +++ b/net/mac80211/aes_ccm.c @@ -23,12 +23,12 @@ 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 +36,22 @@ 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)] + __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)); @@ -60,12 +59,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[])