Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10486737ybi; Thu, 25 Jul 2019 00:09:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZ5nHiTh0xjgBZa/ZyyFRPw1xdBgRsb0aBVKFdSp540u/fD9vu0zBVTHL7a6LochN+0KJt X-Received: by 2002:a17:902:ac87:: with SMTP id h7mr92638934plr.36.1564038589693; Thu, 25 Jul 2019 00:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564038589; cv=none; d=google.com; s=arc-20160816; b=HWVHxUuTg7NJ49YWpNnyGg2WGjtq4uoP5eVriYOnLyl/CpL8VD562BP9ZL+ZsOwo4O WWDh0pW7gmyrE3JhfLYRaoCGBY+S+D00nHOhSQFM/aaXfDtK95L0AnuXNWiS5cSbvcLC uV5TFdEBQSk4FQ2nrnh1MYUpfFHVqUydaVeRbJQ0HT2+oWJ/Yfh6p+bWiIYWRuPsbrEH rrDLVKAXrp6gdk1pj+a8jc/w7HYF0hXhGDh7CMaLNH3D2eqw5pu788IbVH68rpk+mrJs Zn9T9E/5npBMbc5Xn0HV66VQ6zk9a7jm4vyegWVOfm1+6xJr8DiYE4RCP99qW9yRz3Vy 859A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XI8sivqoeqqz4ojR1g59rjsfjMIlZLZLD9BF2e14UXs=; b=WeUpGWsKiEtCHx495oNZDlv5N9jRS/7VShPu3p+CigBy9Lz3oMc8J6T00Q4kfL9qT2 IcxrrtoMh2jL+0kVEaZZN80ZPb5CuCF1PdPCV48haESws03PSOusR7EsOm+tv9zmmUaV Bjew+aTkl6vA4ul+iV8n3E7eFKfOxFlJluOKl5j89IP0g7UB3a0zqqsfoB3IaoFsAcXH 0iaOku4BUWbuDfONv4wudym2AZ1qF6emcOURTPzGjLt0ogJrRJhMAjyr2QVbmgScTKq6 c8J3DNyIQw2BxlLmqjIi0VAGONY/zXygDCwzuiTGMrrh4nrXLMHDegKgxomnOw9JdZXh 4vEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pjzgw5An; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k22si17568737pfi.289.2019.07.25.00.09.35; Thu, 25 Jul 2019 00:09:49 -0700 (PDT) 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; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pjzgw5An; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404626AbfGXT4W (ORCPT + 99 others); Wed, 24 Jul 2019 15:56:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404219AbfGXT4U (ORCPT ); Wed, 24 Jul 2019 15:56:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7654A205C9; Wed, 24 Jul 2019 19:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998180; bh=RekJmt4P3VwYWask21t40jH6pmqmpa2CiSzNj2xKwLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjzgw5AncFRsGR7mmcmrPyF7A7DlbEMUwYE0+Jhv5a1srJvLzWoHdmbVudz2E19cc T+HcF4HUOMpj7/4VlMugG6ZxnR204+aQ+2VhMZtQAIgyHifE5CfTayxlmCiUSQ21QN oFKodmk49/h8pbiCErq+ho8RECx600FKjexfLhwo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho Subject: [PATCH 5.1 274/371] iwlwifi: mvm: delay GTK setting in FW in AP mode Date: Wed, 24 Jul 2019 21:20:26 +0200 Message-Id: <20190724191744.956439706@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit c56e00a3feaee2b46b7d33875fb7f52efd30241f upstream. In AP (and IBSS) mode, we can only set GTKs to firmware after we have sent down the multicast station, but this we can only do after we've enabled beaconing, etc. However, during rfkill exit, hostapd will configure the keys before starting the AP, and cfg80211/mac80211 accept it happily. On earlier devices, this didn't bother us as GTK TX wasn't really handled in firmware, we just put the key material into the TX cmd and thus it only mattered when we actually transmitted a frame. On newer devices, however, the firmware needs to track all of this and that doesn't work if we add the key before the (multicast) sta it belongs to. To fix this, keep a list of keys to add during AP enable, and call the function there. Cc: stable@vger.kernel.org Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 53 +++++++++++++++++++++- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 3 + 2 files changed, 54 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -207,6 +207,12 @@ static const struct cfg80211_pmsr_capabi }, }; +static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, + enum set_key_cmd cmd, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key); + void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) { if (!iwl_mvm_is_d0i3_supported(mvm)) @@ -2535,7 +2541,7 @@ static int iwl_mvm_start_ap_ibss(struct { struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); - int ret; + int ret, i; /* * iwl_mvm_mac_ctxt_add() might read directly from the device @@ -2609,6 +2615,20 @@ static int iwl_mvm_start_ap_ibss(struct /* must be set before quota calculations */ mvmvif->ap_ibss_active = true; + /* send all the early keys to the device now */ + for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) { + struct ieee80211_key_conf *key = mvmvif->ap_early_keys[i]; + + if (!key) + continue; + + mvmvif->ap_early_keys[i] = NULL; + + ret = iwl_mvm_mac_set_key(hw, SET_KEY, vif, NULL, key); + if (ret) + goto out_quota_failed; + } + if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) { iwl_mvm_vif_set_low_latency(mvmvif, true, LOW_LATENCY_VIF_TYPE); @@ -3378,11 +3398,12 @@ static int iwl_mvm_mac_set_key(struct ie struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm_sta *mvmsta; struct iwl_mvm_key_pn *ptk_pn; int keyidx = key->keyidx; - int ret; + int ret, i; u8 key_offset; if (iwlwifi_mod_params.swcrypto) { @@ -3455,6 +3476,22 @@ static int iwl_mvm_mac_set_key(struct ie key->hw_key_idx = STA_KEY_IDX_INVALID; break; } + + if (!mvmvif->ap_ibss_active) { + for (i = 0; + i < ARRAY_SIZE(mvmvif->ap_early_keys); + i++) { + if (!mvmvif->ap_early_keys[i]) { + mvmvif->ap_early_keys[i] = key; + break; + } + } + + if (i >= ARRAY_SIZE(mvmvif->ap_early_keys)) + ret = -ENOSPC; + + break; + } } /* During FW restart, in order to restore the state as it was, @@ -3523,6 +3560,18 @@ static int iwl_mvm_mac_set_key(struct ie break; case DISABLE_KEY: + ret = -ENOENT; + for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) { + if (mvmvif->ap_early_keys[i] == key) { + mvmvif->ap_early_keys[i] = NULL; + ret = 0; + } + } + + /* found in pending list - don't do anything else */ + if (ret == 0) + break; + if (key->hw_key_idx == STA_KEY_IDX_INVALID) { ret = 0; break; --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h @@ -498,6 +498,9 @@ struct iwl_mvm_vif { netdev_features_t features; struct iwl_probe_resp_data __rcu *probe_resp_data; + + /* we can only have 2 GTK + 2 IGTK active at a time */ + struct ieee80211_key_conf *ap_early_keys[4]; }; static inline struct iwl_mvm_vif *