From patchwork Tue Mar 10 16:02:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cedric Izoard X-Patchwork-Id: 5978761 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 E083B9F2A9 for ; Tue, 10 Mar 2015 16:02:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C26D02020F for ; Tue, 10 Mar 2015 16:02:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C19A2201FA for ; Tue, 10 Mar 2015 16:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbbCJQCO (ORCPT ); Tue, 10 Mar 2015 12:02:14 -0400 Received: from sbg-il.ceva-dsp.com ([195.82.128.8]:49871 "EHLO sbg-il.ceva-dsp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbbCJQCN convert rfc822-to-8bit (ORCPT ); Tue, 10 Mar 2015 12:02:13 -0400 X-AuditID: ac181808-f798d6d000000db0-7e-54ff158169ad 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 C4.1D.03504.1851FF45; Tue, 10 Mar 2015 18:02:09 +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 18:02:09 +0200 From: Cedric Izoard To: "linux-wireless@vger.kernel.org" CC: johannes Berg Subject: [PATCH v2] mac80211: Get IV len from key conf and not cipher scheme Thread-Topic: [PATCH v2] mac80211: Get IV len from key conf and not cipher scheme Thread-Index: AdBbS4+1I/llYa2lQXu31P/z3U98fw== Date: Tue, 10 Mar 2015 16:02:08 +0000 Message-ID: <5842EA9CC042B141995329508713AD672105A9B0@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+NgFrrKJsWRmVeSWpSXmKPExsVyYIWtgG6j6P8Qg91fdC0+bvjEYvFmxR12 ByaP/t5tLB6fN8kFMEVx2aSk5mSWpRbp2yVwZZw8tp+lYJdQxfO2y0wNjOv5uxg5OSQETCQ6 Zr5ng7DFJC7cWw9kc3EICexnlJjdepkJwpnDKPHlzAMmkCo2AQOJg6cuMYPYIgKuElM3bgaz mQV0JSb//soIYgsL+EhcebsCqiZY4tmNA0C9HEC2nkT/xBqQMIuAqsT3tW2sIDavgKfErpdv WUBsRqAjvp9awwQxUlzi1pP5TBDHCUgs2XOeGcIWlXj5+B8rhK0gsfP+P0aIeh2JBbs/sUHY 2hLLFr5mhpgvKHFy5hOWCYwis5CMnYWkZRaSlllIWhYwsqxiFC5OStfNzNFLTi1L1E0pLtBL zs/dxAiMhDUSEhw7GL/ssjrEKMDBqMTDu+zbvxAh1sSy4srcQ4yWHExKorxN/P9DhPiS8lMq MxKLM+KLSnNSi5XkeMP9/oYIicOFi0uLCzKTM/NLi+NLi3IOMUpwMCuJ8Mb9AxrHm5JYWZVa lA/ReohRmoNFSZxX6PeUQCGB9MSS1OzU1ILUIpisPQeHkgTvI2GgpYJFqempFWmZOSUwaSVF 3pMge6WQZdCtZuLgPMRozsEDtL9OBGgMb3FBYm5xZjrUCFne+SAjxGCiqNpPMVpLifMqg/QJ gFRklObBbZdS4J23COghSSQJVN2vGE2BwSjMuwWknweY3BHWyvBuA1krChVE12cODGsRXnbm PyD3liSWILvXD2SpGEwUVadUA2PfhYgkfcPFIRuvL1v7NXDK+TNX5aXiPu4xF7wmKOksbM3I p+AgHB+7ee6UiqAJxsd+X3Tvn+1lLsnm2a2w123ifpUp/w/0TLCqkXyf63T/w6wL3UGX7H+U dQbO5T86PztYlSckOJ75rOqSsLAgv9TURZNqtx1a2mafz+gr1nxKxvBjd8ImOSWW4oxEQy3m ouJEACoHZQboAwAA 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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { @@ -790,14 +789,17 @@ 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 (iv_len == 0) + return TX_CONTINUE; + + 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 +1219,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..e5d7bfa 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 &&