From patchwork Mon Apr 9 07:44:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 10330701 X-Patchwork-Delegate: kvalo@adurom.com 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 B7B5B60236 for ; Mon, 9 Apr 2018 07:44:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA312209D8 for ; Mon, 9 Apr 2018 07:44:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BD1728A98; Mon, 9 Apr 2018 07:44:48 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 A8BFB209D8 for ; Mon, 9 Apr 2018 07:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751140AbeDIHoo (ORCPT ); Mon, 9 Apr 2018 03:44:44 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:35636 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750759AbeDIHon (ORCPT ); Mon, 9 Apr 2018 03:44:43 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w397eVaF026461; Mon, 9 Apr 2018 00:44:38 -0700 Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2h6ubkwstm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 09 Apr 2018 00:44:38 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 9 Apr 2018 00:44:37 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 9 Apr 2018 00:44:37 -0700 Received: from smtp.marvell.com (unknown [10.38.32.132]) by maili.marvell.com (Postfix) with SMTP id C68F23F703F; Mon, 9 Apr 2018 00:44:33 -0700 (PDT) Received: by smtp.marvell.com (sSMTP sendmail emulation); Mon, 09 Apr 2018 15:44:23 +0800 From: Xinming Hu To: Linux Wireless CC: Kalle Valo , Brian Norris , Dmitry Torokhov , , Zhiyuan Yang , Tim Song , Cathy Luo , James Cao , Ganapathi Bhat , Ellie Reeves , Xinming Hu Subject: [PATCH] mwifiex: parse key management suite from RSN IE Date: Mon, 9 Apr 2018 15:44:14 +0800 Message-ID: <1523259854-23131-1-git-send-email-huxm@marvell.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-09_02:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804090086 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 Association failed when using wpa_supplicant with configuration key_mgmt=WPA-PSK-SHA256, and it is noticed that wpa_supplicant set WLAN_AKM_SUITE_PSK_SHA256 in RSN IE, but miss it in start_ap parameters. This patch parse key management suite from RSN IE, in case it is missed. Signed-off-by: Xinming Hu --- drivers/net/wireless/marvell/mwifiex/fw.h | 1 + drivers/net/wireless/marvell/mwifiex/main.h | 12 ++++ drivers/net/wireless/marvell/mwifiex/uap_cmd.c | 86 ++++++++++++++++++-------- 3 files changed, 72 insertions(+), 27 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h index 13cd58e9..2be3ce1 100644 --- a/drivers/net/wireless/marvell/mwifiex/fw.h +++ b/drivers/net/wireless/marvell/mwifiex/fw.h @@ -413,6 +413,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { #define KEY_MGMT_NONE 0x04 #define KEY_MGMT_PSK 0x02 #define KEY_MGMT_EAP 0x01 +#define KEY_MGMT_PSK_SHA256 0x100 #define CIPHER_TKIP 0x04 #define CIPHER_AES_CCMP 0x08 #define VALID_CIPHER_BITMAP 0x0c diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index 598e58b..db20132 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h @@ -364,6 +364,18 @@ struct ieee_types_generic { u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)]; } __packed; +struct ieee_types_rsn { + struct ieee_types_header ieee_hdr; + u8 element_id; + u8 element_len; + u16 rsn_version; + u32 cipher_group; + u16 n_ciphers_pairwise; + u32 ciphers_pairwise[]; +// u16 n_akm_suites; +// u32 *akm_suites; +} __packed; + struct ieee_types_bss_co_2040 { struct ieee_types_header ieee_hdr; u8 bss_2040co; diff --git a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c index 18f7d9b..0a27717 100644 --- a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c +++ b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c @@ -26,9 +26,14 @@ */ int mwifiex_set_secure_params(struct mwifiex_private *priv, struct mwifiex_uap_bss_param *bss_config, - struct cfg80211_ap_settings *params) { + struct cfg80211_ap_settings *params) +{ int i; struct mwifiex_wep_key wep_key; + const struct ieee_types_rsn *rsn_ie = NULL; + const u8 *ie = NULL; + u16 n_akm_suites; + u32 *akm_suites; if (!params->privacy) { bss_config->protocol = PROTOCOL_NO_SECURITY; @@ -58,36 +63,63 @@ int mwifiex_set_secure_params(struct mwifiex_private *priv, bss_config->key_mgmt_operation |= KEY_MGMT_ON_HOST; - for (i = 0; i < params->crypto.n_akm_suites; i++) { - switch (params->crypto.akm_suites[i]) { - case WLAN_AKM_SUITE_8021X: - if (params->crypto.wpa_versions & - NL80211_WPA_VERSION_1) { - bss_config->protocol = PROTOCOL_WPA; - bss_config->key_mgmt = KEY_MGMT_EAP; - } - if (params->crypto.wpa_versions & - NL80211_WPA_VERSION_2) { - bss_config->protocol |= PROTOCOL_WPA2; - bss_config->key_mgmt = KEY_MGMT_EAP; + if (params->crypto.wpa_versions & NL80211_WPA_VERSION_1) + bss_config->protocol = PROTOCOL_WPA; + + if (params->crypto.wpa_versions & NL80211_WPA_VERSION_2) + bss_config->protocol |= PROTOCOL_WPA2; + + if (params->crypto.wpa_versions & + (NL80211_WPA_VERSION_1 | NL80211_WPA_VERSION_2)) { + for (i = 0; i < params->crypto.n_akm_suites; i++) { + switch (params->crypto.akm_suites[i]) { + case WLAN_AKM_SUITE_8021X: + bss_config->key_mgmt = KEY_MGMT_EAP; + break; + case WLAN_AKM_SUITE_PSK: + bss_config->key_mgmt = KEY_MGMT_PSK; + break; + case WLAN_AKM_SUITE_PSK_SHA256: + bss_config->key_mgmt = + KEY_MGMT_PSK_SHA256; + break; + default: + break; } - break; - case WLAN_AKM_SUITE_PSK: - if (params->crypto.wpa_versions & - NL80211_WPA_VERSION_1) { - bss_config->protocol = PROTOCOL_WPA; - bss_config->key_mgmt = KEY_MGMT_PSK; - } - if (params->crypto.wpa_versions & - NL80211_WPA_VERSION_2) { - bss_config->protocol |= PROTOCOL_WPA2; - bss_config->key_mgmt = KEY_MGMT_PSK; + } + + ie = cfg80211_find_ie(WLAN_EID_RSN, params->beacon.tail, + params->beacon.tail_len); + + /* Try to get key management suites from RSN IE */ + if (!bss_config->key_mgmt && ie) { + rsn_ie = (struct ieee_types_rsn *)ie; + ie = (u8 *)(rsn_ie->ciphers_pairwise + + rsn_ie->n_ciphers_pairwise); + n_akm_suites = *((u16 *)ie); + akm_suites = (u32 *)(ie + sizeof(n_akm_suites)); + + for (i = 0; i < n_akm_suites; i++) { + switch (akm_suites[i]) { + case WLAN_AKM_SUITE_8021X: + bss_config->key_mgmt = + KEY_MGMT_EAP; + break; + case WLAN_AKM_SUITE_PSK: + bss_config->key_mgmt = + KEY_MGMT_PSK; + break; + case WLAN_AKM_SUITE_PSK_SHA256: + bss_config->key_mgmt = + KEY_MGMT_PSK_SHA256; + break; + default: + break; + } } - break; - default: - break; } } + for (i = 0; i < params->crypto.n_ciphers_pairwise; i++) { switch (params->crypto.ciphers_pairwise[i]) { case WLAN_CIPHER_SUITE_WEP40: