From patchwork Tue Mar 10 08:52:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cedric Izoard X-Patchwork-Id: 5975851 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 48DFD9F2A9 for ; Tue, 10 Mar 2015 09:07:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 800FA2018E for ; Tue, 10 Mar 2015 09:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2867620121 for ; Tue, 10 Mar 2015 09:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752173AbbCJJHc (ORCPT ); Tue, 10 Mar 2015 05:07:32 -0400 Received: from sbg-il.ceva-dsp.com ([195.82.128.8]:46900 "EHLO sbg-il.ceva-dsp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbbCJJH3 convert rfc822-to-8bit (ORCPT ); Tue, 10 Mar 2015 05:07:29 -0400 X-Greylist: delayed 901 seconds by postgrey-1.27 at vger.kernel.org; Tue, 10 Mar 2015 05:07:28 EDT X-AuditID: ac181808-f798d6d000000db0-08-54feb0c97a88 Received: from ilmail1.ceva-dsp.com (ilmail1.corp.local [192.168.61.16]) by sbg-il.ceva-dsp.com (CEVA eMail Gateway) with SMTP id 93.9B.03504.9C0BEF45; Tue, 10 Mar 2015 10:52:25 +0200 (IST) Received: from ILMAIL1.corp.local ([192.168.61.16]) by ILMAIL1.corp.local ([192.168.61.16]) with mapi id 14.03.0210.002; Tue, 10 Mar 2015 10:52:24 +0200 From: Cedric Izoard To: "linux-wireless@vger.kernel.org" CC: "johannes@sipsolutions.net" Subject: [PATCH] mac80211: Get IV len from key conf and not cipher scheme Thread-Topic: [PATCH] mac80211: Get IV len from key conf and not cipher scheme Thread-Index: AdBbD4ayldurPStBQwi//J6Msh9haQ== Date: Tue, 10 Mar 2015 08:52:23 +0000 Message-ID: <5842EA9CC042B141995329508713AD672105A821@ILMAIL1.corp.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.65.5] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGJsWRmVeSWpSXmKPExsVyYIWtgO7JDf9CDFp38Ft83PCJxeLNijvs Dkwe/b3bWDw+b5ILYIrisklJzcksSy3St0vgyng0pYup4K9gRVfjEsYGxr98XYycHBICJhIX 139lhrDFJC7cW8/WxcjFISSwn1Gi98oBKGcOo8S0ZdvZQarYBAwkDp66BNYhIuAqMXXjZjCb WcBaovP8JzBbWMBT4tCeW4wQNQESPw7MharXk3h1bTEriM0ioCqx4d98NhCbF6h+14xFYDYj 0BXfT61hgpgpLnHryXwmiOsEJJbsOQ91qajEy8f/WCFsBYmd9/8xQtTrSCzY/YkNwtaWWLbw NTPEfEGJkzOfsExgFJmFZOwsJC2zkLTMQtKygJFlFaNwcVK6bmaOXnJqWaJuSnGBXnJ+7iZG YCyskZDg2MH4ZZfVIUYBDkYlHt5Ja/+FCLEmlhVX5h5itORgUhLl/QQS4kvKT6nMSCzOiC8q zUktVpLjDff7GyIkDhcuLi0uyEzOzC8tji8tyjnEKMHBrCTCe7QfqJc3JbGyKrUoH6L1EKM0 B4uSOK/Q7ymBQgLpiSWp2ampBalFMFl7Dg4lCV6X9UCNgkWp6akVaZk5JTBpJUXekyB7pZBl 0K1m4uA8xGjOwQO0334DyP7igsTc4sx0qBGyvPNBRojBRFG1n2K0lhLnXQOyXgCkIqM0D267 lALvvEVACUkkCVTdrxhNgcEozFsD0s8DTO8Ia2V4t4GsFYUKouszB4a1CC878x+Qe0sSS5Dd 6weyVAwmiqpTqoExZIPpxcLqaYZsq/cLvpPedVr63fHdHTdez6ne99bKU1niw96PTzgPC+1k OrXpPX/apfj38/++bNLNOZ1i/fA9Y7xB0EXzlgmC2k6+gsKR28yuWb7dXn1+t8RSy/l9r0wt HlsH/C1riRY7JK8cOSeqgK3aatqLtobwG8fEL3MJ2fz1VvR9nPRSiaU4I9FQi7moOBEACT/m qekDAAA= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not always dereference sta to get cipher scheme as it may be null for broadcast messages. Instead get IV length from key configuration which has been initialized with cipher scheme. Signed-off-by: Cedric Izoard --- net/mac80211/wpa.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { @@ -790,14 +789,14 @@ ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, return TX_CONTINUE; } - if (unlikely(skb_headroom(skb) < cs->hdr_len && - pskb_expand_head(skb, cs->hdr_len, 0, GFP_ATOMIC))) + if (unlikely(skb_headroom(skb) < iv_len && + pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC))) return TX_DROP; hdrlen = ieee80211_hdrlen(hdr->frame_control); - pos = skb_push(skb, cs->hdr_len); - memmove(pos, pos + cs->hdr_len, hdrlen); + pos = skb_push(skb, iv_len); + memmove(pos, pos + iv_len, hdrlen); return TX_CONTINUE; } @@ -1217,11 +1216,9 @@ ieee80211_crypto_hw_encrypt(struct ieee80211_tx_data *tx) if (!info->control.hw_key) return TX_DROP; - if (tx->key->sta->cipher_scheme) { - res = ieee80211_crypto_cs_encrypt(tx, skb); - if (res != TX_CONTINUE) - return res; - } + res = ieee80211_crypto_cs_encrypt(tx, skb); + if (res != TX_CONTINUE) + return res; } ieee80211_tx_set_protected(tx); diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index 75de6fa..ccf7997 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -780,9 +780,8 @@ ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_key *key = tx->key; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - const struct ieee80211_cipher_scheme *cs = key->sta->cipher_scheme; int hdrlen; - u8 *pos; + u8 *pos, iv_len = key->conf.iv_len; if (info->control.hw_key &&