Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1631439rdb; Wed, 20 Sep 2023 15:06:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+Pr8sg+/Lhcpq3sak9t4Xw+k5FyNnGYXaOLdcdmidiKdhDIMg6fbxeOIFbM0/TBm6Ejyt X-Received: by 2002:a17:902:6941:b0:1c5:70d3:f193 with SMTP id k1-20020a170902694100b001c570d3f193mr3545789plt.10.1695247573326; Wed, 20 Sep 2023 15:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695247573; cv=none; d=google.com; s=arc-20160816; b=v7J+NY9KXhAFiliGFjAcB6WJ9mJi78KmJKOpH1v3dxv2YTkNESkRN+vaPvRJpePTKP W8Vwkk/uoPEn8v4b7ac+bR80+yi3jyjAhBTqgt67jiJxEhyYAnedb7q2Fm5mnNMUrkXB LO7Mnt++pRy7uEmRm5KOzjx9eKd0vEfYimL7mSRPTEZOLat8gqNFRD7FTG50xRt0Ysac URN2/Yy7pf/9QMC/aQUYRjE7EF+kLi6t/T5X8GydBmbkFB7rsq2ee9PXCwvLqypSKyxD Y/1QiIXqOwp0deYosVqeA8hUKswjsjVl5bvKDOLZeA+NxI7kasPcw2r5GSy7bW1TfCuY GxhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZZSlvkjNcbTE5TSu6Svw1lHchYL/P3QULjYtPRajVT0=; fh=Mnp68qKnnHkwEEQEtO53ILhv/UavV1FUaagOvXxb8CE=; b=HGdc2G7vulGXWDr2idDuiSWZ1Edm7yBScfZNkUsgiS7jw6iwcI3r9YsXoKt1mwJGwC vjS9e4EruXBxO5Bynhq9M9A3pTke+KsouJtAfvSdl1/N0SpmaCnuUdtM+igXp75y7NTV +tn/yCDyMH4AmQ43qk+rgGKN+LoWL59bhq/oLLs3ZNxXZUKGUDTbeH6w0XSngZ5SzkbM Mn5PyPo+Aid7WVCvPRal2gxh9vH/R1q2FvQPZa2jvZPr6lSGTKdI0SLwVjXf9WAvhKQi tiIFxqyzpWggXYvQkQ+QEPaCFn827SWDesT6qSsrC/+ZxDt0kYMB0qlfEHRzGqslcpP9 rx7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IwVeQC7i; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id kg3-20020a170903060300b001c3f6dbe2bdsi22172plb.105.2023.09.20.15.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 15:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IwVeQC7i; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2E68F80DB4E9; Wed, 20 Sep 2023 11:26:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbjITS0a (ORCPT + 56 others); Wed, 20 Sep 2023 14:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbjITS02 (ORCPT ); Wed, 20 Sep 2023 14:26:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E568DE for ; Wed, 20 Sep 2023 11:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695234380; x=1726770380; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=53pYuu+MEOeCHl72WU349izM3mAA9KUXodCVH992Q5U=; b=IwVeQC7iYylnuaoSEuH+1CrXHl0aciLbfZvH3Ic5936gbpWXIEHcIazI +3vZDefoDqo9zo+f59L1jpMURMnrrO5NaMsSVNR2JjjgfCaI3HbAGFXyh VyDA0kJfAE6sLHLiT+BYKZHsR1ebL3YZwIPqnH2eQ1irzLwPx/JM583a2 96F5Gk7xskX3bwRjaslEmL0k+PItzGldndDHTBJE4ECPKlKF31I4pJt+h WnGMwahE8vq9w4p8SzwEjMFSaB/Vvk39xgl/0G7xQHfJqEV/V8l0JT2w5 tN0sPCleqBX+Ir4ZPrs1jCqdYJGqfyg2pFrS6iJVZvGKy2civl8d6ONzB g==; X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="360556317" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="360556317" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 11:26:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="723424212" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="723424212" Received: from dmani-mobl1.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.214.217.100]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 11:26:18 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ayala Beker , Gregory Greenman Subject: [PATCH v2 03/18] wifi: mac80211: don't connect to an AP while it's in a CSA process Date: Wed, 20 Sep 2023 21:25:14 +0300 Message-Id: <20230920211508.e5001a762a4a.I9745c695f3403b259ad000ce94110588a836c04a@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230920182529.659973-1-gregory.greenman@intel.com> References: <20230920182529.659973-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 20 Sep 2023 11:26:28 -0700 (PDT) From: Ayala Beker Connection to an AP that is running a CSA flow may end up with a failure as the AP might change its channel during the connection flow while we do not track the channel change yet. Avoid that by rejecting a connection to such an AP. Signed-off-by: Ayala Beker Signed-off-by: Gregory Greenman --- net/mac80211/mlme.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index a211f594f25a..a85873f305bf 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -7015,6 +7015,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_mgd_auth_data *auth_data; struct ieee80211_link_data *link; + const struct element *csa_elem, *ecsa_elem; u16 auth_alg; int err; bool cont_auth; @@ -7057,6 +7058,22 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, if (ifmgd->assoc_data) return -EBUSY; + rcu_read_lock(); + csa_elem = ieee80211_bss_get_elem(req->bss, WLAN_EID_CHANNEL_SWITCH); + ecsa_elem = ieee80211_bss_get_elem(req->bss, + WLAN_EID_EXT_CHANSWITCH_ANN); + if ((csa_elem && + csa_elem->datalen == sizeof(struct ieee80211_channel_sw_ie) && + ((struct ieee80211_channel_sw_ie *)csa_elem->data)->count != 0) || + (ecsa_elem && + ecsa_elem->datalen == sizeof(struct ieee80211_ext_chansw_ie) && + ((struct ieee80211_ext_chansw_ie *)ecsa_elem->data)->count != 0)) { + rcu_read_unlock(); + sdata_info(sdata, "AP is in CSA process, reject auth\n"); + return -EINVAL; + } + rcu_read_unlock(); + auth_data = kzalloc(sizeof(*auth_data) + req->auth_data_len + req->ie_len, GFP_KERNEL); if (!auth_data) @@ -7364,7 +7381,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_mgd_assoc_data *assoc_data; - const struct element *ssid_elem; + const struct element *ssid_elem, *csa_elem, *ecsa_elem; struct ieee80211_vif_cfg *vif_cfg = &sdata->vif.cfg; ieee80211_conn_flags_t conn_flags = 0; struct ieee80211_link_data *link; @@ -7394,6 +7411,21 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, kfree(assoc_data); return -EINVAL; } + + csa_elem = ieee80211_bss_get_elem(cbss, WLAN_EID_CHANNEL_SWITCH); + ecsa_elem = ieee80211_bss_get_elem(cbss, WLAN_EID_EXT_CHANSWITCH_ANN); + if ((csa_elem && + csa_elem->datalen == sizeof(struct ieee80211_channel_sw_ie) && + ((struct ieee80211_channel_sw_ie *)csa_elem->data)->count != 0) || + (ecsa_elem && + ecsa_elem->datalen == sizeof(struct ieee80211_ext_chansw_ie) && + ((struct ieee80211_ext_chansw_ie *)ecsa_elem->data)->count != 0)) { + sdata_info(sdata, "AP is in CSA process, reject assoc\n"); + rcu_read_unlock(); + kfree(assoc_data); + return -EINVAL; + } + memcpy(assoc_data->ssid, ssid_elem->data, ssid_elem->datalen); assoc_data->ssid_len = ssid_elem->datalen; memcpy(vif_cfg->ssid, assoc_data->ssid, assoc_data->ssid_len); -- 2.38.1