From patchwork Thu Mar 6 19:52:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 25847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77917203C3 for ; Thu, 6 Mar 2014 19:54:17 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id i17sf7342283qcy.11 for ; Thu, 06 Mar 2014 11:54:17 -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 :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=QqMsHJDYzsByi0B7YqAWegMaewRq7rQ7U5r6G//LE80=; b=fyL0nxwNARCDQgYEZQ1AdxtwdIzvtzk8laez4W1/07Sz2xJ2clo7JsOubn/NNVXeNP /7d6cTT4B2PrhodKeTQQb0od1MRpc8sh7eUMS8baxe5TOJRKk2Bg6H6zjZcNHMT12/cT CpEItd2UyafJB2DdqVdbw3pq1RE5mIGFSA4XMU8QbqUWurno2ZhS2UoYHN6erSBnF1gg a9oLcNfa60f+PItWIZwsR8CJ+RlvRIF2rmhZ9lxBsu4VYYNyJIbm3xmg3bvQpimux/1I 9pd4LAXLJmEjNuPPj0dBtuVQocnSPg5RgAsJLNgNpiVBKpZkKmlpjg/YgRrVbT6oDfFT mQVw== X-Gm-Message-State: ALoCoQk7QKqrpETjaNcoKFI8sqK1SLyhj6FqL0/RIJbF4m9jML+6uHcuIUQl1gmebHR2hRhxRCNz X-Received: by 10.236.94.166 with SMTP id n26mr5007299yhf.25.1394135656992; Thu, 06 Mar 2014 11:54:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.177 with SMTP id s46ls904038qga.24.gmail; Thu, 06 Mar 2014 11:54:16 -0800 (PST) X-Received: by 10.221.39.138 with SMTP id tm10mr6500704vcb.7.1394135656766; Thu, 06 Mar 2014 11:54:16 -0800 (PST) Received: from mail-vc0-x22d.google.com (mail-vc0-x22d.google.com [2607:f8b0:400c:c03::22d]) by mx.google.com with ESMTPS id b20si1468368veu.30.2014.03.06.11.54.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 11:54:16 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::22d 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::22d; Received: by mail-vc0-f173.google.com with SMTP id ld13so3108067vcb.18 for ; Thu, 06 Mar 2014 11:54:16 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr2476511vcv.28.1394135656553; Thu, 06 Mar 2014 11:54:16 -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 i9csp63019vck; Thu, 6 Mar 2014 11:54:16 -0800 (PST) X-Received: by 10.68.229.164 with SMTP id sr4mr16643748pbc.82.1394135655716; Thu, 06 Mar 2014 11:54:15 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si5894553pbl.341.2014.03.06.11.54.13; Thu, 06 Mar 2014 11:54:13 -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 S1753207AbaCFTyH (ORCPT + 26 others); Thu, 6 Mar 2014 14:54:07 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:59626 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753098AbaCFTyE (ORCPT ); Thu, 6 Mar 2014 14:54:04 -0500 Received: by mail-pa0-f44.google.com with SMTP id bj1so3099968pad.31 for ; Thu, 06 Mar 2014 11:54:02 -0800 (PST) X-Received: by 10.68.12.74 with SMTP id w10mr16887674pbb.39.1394135642772; Thu, 06 Mar 2014 11:54:02 -0800 (PST) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id iq10sm22703819pbc.14.2014.03.06.11.54.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 11:54:01 -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, 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] mac80211: LLVMLinux: Remove VLAIS usage from mac80211 Date: Thu, 6 Mar 2014 11:52:50 -0800 Message-Id: <1394135570-26730-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.8.3.2 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:c03::22d 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 | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index 7c7df47..9612e95 100644 --- a/net/mac80211/aes_ccm.c +++ b/net/mac80211/aes_ccm.c @@ -23,12 +23,16 @@ 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 + = (struct aead_request *) aead_req_data; + + memset(&aead_req_data, 0, (sizeof(struct aead_request)+ + crypto_aead_reqsize(tfm) + CRYPTO_MINALIGN)); sg_init_one(&pt, data, data_len); sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); @@ -36,23 +40,27 @@ 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 + = (struct aead_request *) aead_req_data; + + memset(&aead_req_data, 0, (sizeof(struct aead_request)+ + crypto_aead_reqsize(tfm) + CRYPTO_MINALIGN)); sg_init_one(&pt, data, data_len); sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad)); @@ -60,12 +68,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[])