From patchwork Tue Jun 21 06:23:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masashi Honma X-Patchwork-Id: 9190835 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F03B06075E for ; Tue, 21 Jun 2016 15:29:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB24128161 for ; Tue, 21 Jun 2016 15:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9D1C281F9; Tue, 21 Jun 2016 15:29:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44F3028161 for ; Tue, 21 Jun 2016 15:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752374AbcFUP11 (ORCPT ); Tue, 21 Jun 2016 11:27:27 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35231 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbcFUPZu (ORCPT ); Tue, 21 Jun 2016 11:25:50 -0400 Received: by mail-pf0-f193.google.com with SMTP id t190so1591333pfb.2 for ; Tue, 21 Jun 2016 08:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8LUEtq5PDY1aK+oGEti4AK1Q0YGPE+o5bwDhi+soJEo=; b=RaZEacSt8fpBnkYOqySFklkbvCSAZe5KcXCJkKBOPocU8e/IZQIvBST/pvaM+6GIWw J+q0MmM0vB0z8KL9Tc00DujdswqN0l5x3oszMGTsDoJVEgXdrklyaDT8l+tt5j8HZHCH RI+8ZqeATiH0Zna0+PZorr6qIgyE0MJQxiuu5U1uRBAxr9ijz28MzmI1SFykxFF4Iuud hy3zoRwY7tJOibR0OTnuWjOFmb5VCPRxOqSyAFUhSKxf/kAzVv1tMMajRUUbJ3ijEjXl Cya6vpUw0szfFHDQIG473MAtJzS+4cqAM7TERM3wYUTdt7myS1WgsvePLjFtTlMG5XnM ZHuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8LUEtq5PDY1aK+oGEti4AK1Q0YGPE+o5bwDhi+soJEo=; b=XLsCZAV8U560Pzr5ac2wgI5I2J+3j7iHmaL0j9GjU+X1gFvn2yg1V/fyabJr91LcF8 xFwlOcfdyqxB050DpBYe23msASKIfR5YE1kfvdfvuJSliX2hgEmf2mUuvRgXDKyMPoup vMgGw4V4Hxas5hiVIV84g907fG85/y4yVSIM1004SBGUusvtu3Haw+reJAU/Aqs4powt X8alhXFuOoiCT0MgfJ84NZ/dAjidASopC1fawk7mzLNe66eSfsQ468iqmEoRxLGXajD5 eRMlx/xJ7x+L74fW8fYEkIZhfy9H/L5xbzC8ngQUQqBuhZ7sVzoVxnNc0AGyv9SNcJAo OZkQ== X-Gm-Message-State: ALyK8tJArkJtPI+fTisKAXffSo/2SPYe+dCFo8vPtGiMNg6rb7uU0zDfJnRdfL7vq7l1MQ== X-Received: by 10.98.93.65 with SMTP id r62mr25979147pfb.114.1466490229612; Mon, 20 Jun 2016 23:23:49 -0700 (PDT) Received: from localhost.localdomain (pc66189.kngwnt01.ap.so-net.ne.jp. [123.198.97.137]) by smtp.gmail.com with ESMTPSA id 7sm63281002pfa.28.2016.06.20.23.23.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 23:23:49 -0700 (PDT) From: Masashi Honma To: j@w1.fi Cc: linux-wireless@vger.kernel.org, Masashi Honma Subject: [PATCH v2] mac80211: Encrypt "Group addressed privacy" action frames Date: Tue, 21 Jun 2016 15:23:39 +0900 Message-Id: <1466490219-2891-1-git-send-email-masashi.honma@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <20160620212529.GA19076@w1.fi> References: <20160620212529.GA19076@w1.fi> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, the action frames to group address was not encrypted. But [1] "Table 8-38 Category values" indicates "Mesh" and "Multihop" category action frames should be encrypted (Group addressed privacy == yes). And the encyption key should be MGTK ([1] 10.13 Group addressed robust management frame procedures). So this patch modifies the code to make it suitable for spec. [1] IEEE Std 802.11-2012 Signed-off-by: Masashi Honma --- include/linux/ieee80211.h | 20 ++++++++++++++++++++ net/mac80211/tx.c | 7 +++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index b118744..3ff7d3f 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -2487,6 +2488,25 @@ static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr, } /** + * ieee80211_is_group_privacy_action - check if frame is a group addressed + * privacy action frame + * @hdr: the frame + */ +static inline bool ieee80211_is_group_privacy_action(struct ieee80211_hdr *hdr) +{ + struct ieee80211_mgmt *mgmt; + + if (!ieee80211_is_action(hdr->frame_control) || + !is_multicast_ether_addr(hdr->addr1)) + return false; + + mgmt = (struct ieee80211_mgmt *)hdr; + + return mgmt->u.action.category == WLAN_CATEGORY_MESH_ACTION || + mgmt->u.action.category == WLAN_CATEGORY_MULTIHOP_ACTION; +} + +/** * ieee80211_tu_to_usec - convert time units (TU) to microseconds * @tu: the TUs */ diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 2030443..5ad205e 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -590,6 +590,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) else if (tx->sta && (key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]))) tx->key = key; + else if (ieee80211_is_group_privacy_action(hdr) && + (key = rcu_dereference(tx->sdata->default_multicast_key))) + tx->key = key; else if (ieee80211_is_mgmt(hdr->frame_control) && is_multicast_ether_addr(hdr->addr1) && ieee80211_is_robust_mgmt_frame(tx->skb) && @@ -608,7 +611,6 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) bool skip_hw = false; /* TODO: add threshold stuff again */ - switch (tx->key->conf.cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: @@ -622,7 +624,8 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) case WLAN_CIPHER_SUITE_GCMP_256: if (!ieee80211_is_data_present(hdr->frame_control) && !ieee80211_use_mfp(hdr->frame_control, tx->sta, - tx->skb)) + tx->skb) && + !ieee80211_is_group_privacy_action(hdr)) tx->key = NULL; else skip_hw = (tx->key->conf.flags &