Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2255298ybd; Mon, 24 Jun 2019 03:23:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzD0WVOnEXbun4oOIqITyEgI3i9H6QCJCo/lzaFCaMvfQi7UZxvRHZc0Zzi4zJNKxCmfp1g X-Received: by 2002:a17:90a:9b8a:: with SMTP id g10mr23451932pjp.66.1561371838385; Mon, 24 Jun 2019 03:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371838; cv=none; d=google.com; s=arc-20160816; b=uhwpO+GiPCI60w6uWi18rS8kJylwPb4xFzYTPCRqUdzoqkEKxS0hZvQneuQND+gSLa MuY8KZ/oOjQEfCjfrRGA6ZQjuuNKz/1lyKpBqDqh9a3oNZ/MfCfaU2ZeZu+kn8iyyf97 T/zR1h7dsnTRDqcCdF2f/OFCnHgF3uzzT2SwQmv+xxyMNYk2f+5APfUhvTb3bySdOk90 Hxjgj/VdPa89h5vILtJcEZl0ItG1uuAzIIJk4CRpIMq6hD4ARtAIN89jKg9Ku32D0DC1 tyBLrVuoQ2e5dee6UOwxfN/JbsRzz3aMCO3aO1fd1PFTbj0DMpppLAHMi/a1Y61MzWcT hBSQ== 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=B5BL9/wR24o4cl+Tfr8f4mLhyo775NuizpfDJbindM4=; b=F1huVHF6aLBJSB9N7TSf2oOv9OobeQyBxnf+BJs8Qj4R4L0WJTuqZ8Y99dd8sawSrV wE5OApgd9ffo5Ex0+SwgaRJzMZ/igHsIf4jaGuSNlFTz1dxKUVVgtBg2oxurpDjfH+Bu hxrZG5qpsRu98ekXghM0cZQgcDvp1UGoqDitRHmaWasQVxWE6KOnZnW/orUxbYlWuTuq QiBoR+9lMTY71aH49M/P+4w2hzVMf/SfIVmrAjL5fhRjGOhjcFDOLVk7YP8pAW2OXi27 DEHuPUID2lXKQ35BVl602gVvob9hvL8T2P+0MGJjjsR0lh1uLYPJLVjGQN0VWHtGHrbm PzLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qqSO9Pcc; 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 c1si10137211pld.418.2019.06.24.03.23.42; Mon, 24 Jun 2019 03:23:58 -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=qqSO9Pcc; 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 S1730441AbfFXKVw (ORCPT + 99 others); Mon, 24 Jun 2019 06:21:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:57610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbfFXKVu (ORCPT ); Mon, 24 Jun 2019 06:21:50 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (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 A7A9A20645; Mon, 24 Jun 2019 10:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371710; bh=2O6klZl1Cu9YfcxPEx5jd2KAtElllTh3d9lfI4uuWps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqSO9PccA9A11ZM8UMM7M2hxxZEeL66mjTgveym5dTuj0LL5We/kBV2cTqzPPTsHC lTd4Njp9MwjmY2ClulhYw7s3pvPnNX0BsEFygbMIv64LDX0TAVQNqVKayJv//3yomt S6HQ6hQxFHgf/rCDYco7OnztJnpKz66/RgG7qT80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Wang , Johannes Berg Subject: [PATCH 5.1 118/121] mac80211: handle deauthentication/disassociation from TDLS peer Date: Mon, 24 Jun 2019 17:57:30 +0800 Message-Id: <20190624092326.652262919@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@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: Yu Wang commit 79c92ca42b5a3e0ea172ea2ce8df8e125af237da upstream. When receiving a deauthentication/disassociation frame from a TDLS peer, a station should not disconnect the current AP, but only disable the current TDLS link if it's enabled. Without this change, a TDLS issue can be reproduced by following the steps as below: 1. STA-1 and STA-2 are connected to AP, bidirection traffic is running between STA-1 and STA-2. 2. Set up TDLS link between STA-1 and STA-2, stay for a while, then teardown TDLS link. 3. Repeat step #2 and monitor the connection between STA and AP. During the test, one STA may send a deauthentication/disassociation frame to another, after TDLS teardown, with reason code 6/7, which means: Class 2/3 frame received from nonassociated STA. On receive this frame, the receiver STA will disconnect the current AP and then reconnect. It's not a expected behavior, purpose of this frame should be disabling the TDLS link, not the link with AP. Cc: stable@vger.kernel.org Signed-off-by: Yu Wang Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/ieee80211_i.h | 3 +++ net/mac80211/mlme.c | 12 +++++++++++- net/mac80211/tdls.c | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2222,6 +2222,9 @@ void ieee80211_tdls_cancel_channel_switc const u8 *addr); void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata); void ieee80211_tdls_chsw_work(struct work_struct *wk); +void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata, + const u8 *peer, u16 reason); +const char *ieee80211_get_reason_code_string(u16 reason_code); extern const struct ethtool_ops ieee80211_ethtool_ops; --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2963,7 +2963,7 @@ static void ieee80211_rx_mgmt_auth(struc #define case_WLAN(type) \ case WLAN_REASON_##type: return #type -static const char *ieee80211_get_reason_code_string(u16 reason_code) +const char *ieee80211_get_reason_code_string(u16 reason_code) { switch (reason_code) { case_WLAN(UNSPECIFIED); @@ -3028,6 +3028,11 @@ static void ieee80211_rx_mgmt_deauth(str if (len < 24 + 2) return; + if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { + ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); + return; + } + if (ifmgd->associated && ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) { const u8 *bssid = ifmgd->associated->bssid; @@ -3077,6 +3082,11 @@ static void ieee80211_rx_mgmt_disassoc(s reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); + if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { + ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); + return; + } + sdata_info(sdata, "disassociated from %pM (Reason: %u=%s)\n", mgmt->sa, reason_code, ieee80211_get_reason_code_string(reason_code)); --- a/net/mac80211/tdls.c +++ b/net/mac80211/tdls.c @@ -1994,3 +1994,26 @@ void ieee80211_tdls_chsw_work(struct wor } rtnl_unlock(); } + +void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata, + const u8 *peer, u16 reason) +{ + struct ieee80211_sta *sta; + + rcu_read_lock(); + sta = ieee80211_find_sta(&sdata->vif, peer); + if (!sta || !sta->tdls) { + rcu_read_unlock(); + return; + } + rcu_read_unlock(); + + tdls_dbg(sdata, "disconnected from TDLS peer %pM (Reason: %u=%s)\n", + peer, reason, + ieee80211_get_reason_code_string(reason)); + + ieee80211_tdls_oper_request(&sdata->vif, peer, + NL80211_TDLS_TEARDOWN, + WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE, + GFP_ATOMIC); +}