From patchwork Sat Mar 8 01:26:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 25913 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 858C1203C3 for ; Sat, 8 Mar 2014 01:26:49 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id fp1sf11336235pdb.8 for ; Fri, 07 Mar 2014 17:26:48 -0800 (PST) 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=rb8yvUEUl4VJbB4EVZ87iP1l8EyFzXMQe5ewvhNXgxM=; b=NymHt+ablK0VDIKFefFGsKA7FVIzJLyzjbZr7hxNTsO2tR+ILgLxnotgdZgWFk/F4g QDyMdHU10deniw5/fu9elnTeKIojbeb6vjGJu5Un3/G/9Wob9CRrWn75b3rzW9W7wBLW a7aHF1BFSbZd8FW8gQDwjyyRUFEnhDrxYCiUgLdgZBOBMjJGtyprIJmWpgQmHGSRUxdy +sQoMy20ucEKr5/ND94Aq3QIvqI2AwDZstooDV6kMp4OrkZYP02Xze0nH7qrFQtpcRek Z1xULzc6Z+1im9n21RrNXmJmBZpN/6x2gfUrpZbvv8vfurxjiLobFNEHnQ+s5U045/XK XxXQ== X-Gm-Message-State: ALoCoQk3aN5XWoqr6wpfdp66yvINSfJKbVBWC+Aj7KHnaU9wk2S0HiCBb4VEjhczHq0YnEvHT/z5 X-Received: by 10.66.240.4 with SMTP id vw4mr9128669pac.10.1394242008670; Fri, 07 Mar 2014 17:26:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.75 with SMTP id i69ls1335409qgd.66.gmail; Fri, 07 Mar 2014 17:26:48 -0800 (PST) X-Received: by 10.52.61.133 with SMTP id p5mr14222077vdr.4.1394242008473; Fri, 07 Mar 2014 17:26:48 -0800 (PST) Received: from mail-ve0-x229.google.com (mail-ve0-x229.google.com [2607:f8b0:400c:c01::229]) by mx.google.com with ESMTPS id kl10si3357478vdb.142.2014.03.07.17.26.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Mar 2014 17:26:48 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::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:c01::229; Received: by mail-ve0-f169.google.com with SMTP id pa12so5180029veb.28 for ; Fri, 07 Mar 2014 17:26:48 -0800 (PST) X-Received: by 10.220.95.139 with SMTP id d11mr5757255vcn.21.1394242008271; Fri, 07 Mar 2014 17:26:48 -0800 (PST) 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 i9csp154452vck; Fri, 7 Mar 2014 17:26:47 -0800 (PST) X-Received: by 10.66.146.170 with SMTP id td10mr25664369pab.105.1394242004757; Fri, 07 Mar 2014 17:26:44 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uc9si9961004pac.210.2014.03.07.17.26.44; Fri, 07 Mar 2014 17:26:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S1754672AbaCHB0h (ORCPT + 26 others); Fri, 7 Mar 2014 20:26:37 -0500 Received: from mail-pb0-f44.google.com ([209.85.160.44]:61027 "EHLO mail-pb0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755299AbaCHB0G (ORCPT ); Fri, 7 Mar 2014 20:26:06 -0500 Received: by mail-pb0-f44.google.com with SMTP id rp16so4898591pbb.31 for ; Fri, 07 Mar 2014 17:26:06 -0800 (PST) X-Received: by 10.66.136.103 with SMTP id pz7mr26007685pab.140.1394241966027; Fri, 07 Mar 2014 17:26:06 -0800 (PST) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id lh13sm17289628pab.4.2014.03.07.17.26.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Mar 2014 17:26:04 -0800 (PST) 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 v2] mac80211: LLVMLinux: Remove VLAIS usage from mac80211 Date: Fri, 7 Mar 2014 17:26:00 -0800 Message-Id: <1394241960-1764-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1394177091.4653.1.camel@jlt4.sipsolutions.net> References: <1394177091.4653.1.camel@jlt4.sipsolutions.net> 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=neutral (google.com: 2607:f8b0:400c:c01::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 (bad format) 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..3317578 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) + + 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)); @@ -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[])