From nobody Fri Sep 19 08:39:05 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6529C4321E for ; Sat, 26 Nov 2022 16:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229475AbiKZQCE (ORCPT ); Sat, 26 Nov 2022 11:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbiKZQBo (ORCPT ); Sat, 26 Nov 2022 11:01:44 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31E6193ED for ; Sat, 26 Nov 2022 08:01:43 -0800 (PST) Received: from dslb-188-096-151-149.188.096.pools.vodafone-ip.de ([188.96.151.149] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1oyxcZ-0000Ub-AR; Sat, 26 Nov 2022 17:01:39 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 07/10] staging: r8188eu: exit if beacon is not from our bss Date: Sat, 26 Nov 2022 17:01:26 +0100 Message-Id: <20221126160129.178697-8-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221126160129.178697-1-martin@kaiser.cx> References: <20221126160129.178697-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Do not process an incoming beacon message in the OnBeacon function if the beacon was sent by a base station other than the one to which we're connected. This patch does not modify the behaviour of the code. It reverts the if condition and returns if the beacon should not be processed. This is simpler than wrapping the entire processing into a large if clause. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 103 ++++++++++---------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/= r8188eu/core/rtw_mlme_ext.c index f7d3ecf551bf..a15998d912a7 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -569,67 +569,68 @@ static void OnBeacon(struct adapter *padapter, struct= recv_frame *precv_frame) return; } =20 - if (!memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - /* we should update current network before auth, or some IE is wrong */ - pbss =3D kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (pbss) { - if (collect_bss_info(padapter, precv_frame, pbss) =3D=3D _SUCCESS) { - update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); - rtw_get_bcn_info(&pmlmepriv->cur_network); - } - kfree(pbss); + if (memcmp(mgmt->bssid, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) + return; + + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, or some IE is wrong */ + pbss =3D kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); + if (pbss) { + if (collect_bss_info(padapter, precv_frame, pbss) =3D=3D _SUCCESS) { + update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); + rtw_get_bcn_info(&pmlmepriv->cur_network); } + kfree(pbss); + } =20 - /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor =3D check_assoc_AP(pframe + sizeof(struct ie= ee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor =3D check_assoc_AP(pframe + sizeof(struct iee= e80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); =20 - pmlmeext->TSFValue =3D le64_to_cpu(mgmt->u.beacon.timestamp); + pmlmeext->TSFValue =3D le64_to_cpu(mgmt->u.beacon.timestamp); =20 - /* start auth */ - start_clnt_auth(padapter); + /* start auth */ + start_clnt_auth(padapter); =20 - return; - } + return; + } =20 - if (((pmlmeinfo->state & 0x03) =3D=3D WIFI_FW_STATION_STATE) && (pmlmein= fo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta =3D rtw_get_stainfo(pstapriv, mgmt->sa); - if (psta) { - ret =3D rtw_check_bcn_info(padapter, pframe, len); - if (!ret) { - receive_disconnect(padapter, - pmlmeinfo->network.MacAddress, 0); - return; - } - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon receive= d */ - if ((sta_rx_pkts(psta) & 0xf) =3D=3D 0) - update_beacon_info(padapter, ie_ptr, ie_len, psta); - process_p2p_ps_ie(padapter, ie_ptr, ie_len); + if (((pmlmeinfo->state & 0x03) =3D=3D WIFI_FW_STATION_STATE) && (pmlmeinf= o->state & WIFI_FW_ASSOC_SUCCESS)) { + psta =3D rtw_get_stainfo(pstapriv, mgmt->sa); + if (psta) { + ret =3D rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + receive_disconnect(padapter, + pmlmeinfo->network.MacAddress, 0); + return; } - } else if ((pmlmeinfo->state & 0x03) =3D=3D WIFI_FW_ADHOC_STATE) { - psta =3D rtw_get_stainfo(pstapriv, mgmt->sa); - if (psta) { - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon receive= d */ - if ((sta_rx_pkts(psta) & 0xf) =3D=3D 0) - update_beacon_info(padapter, ie_ptr, ie_len, psta); - } else { - /* allocate a new CAM entry for IBSS station */ - cam_idx =3D allocate_fw_sta_entry(padapter); - if (cam_idx =3D=3D NUM_STA) - return; + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received= */ + if ((sta_rx_pkts(psta) & 0xf) =3D=3D 0) + update_beacon_info(padapter, ie_ptr, ie_len, psta); + process_p2p_ps_ie(padapter, ie_ptr, ie_len); + } + } else if ((pmlmeinfo->state & 0x03) =3D=3D WIFI_FW_ADHOC_STATE) { + psta =3D rtw_get_stainfo(pstapriv, mgmt->sa); + if (psta) { + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received= */ + if ((sta_rx_pkts(psta) & 0xf) =3D=3D 0) + update_beacon_info(padapter, ie_ptr, ie_len, psta); + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx =3D allocate_fw_sta_entry(padapter); + if (cam_idx =3D=3D NUM_STA) + return; =20 - /* get supported rate */ - if (update_sta_support_rate(padapter, ie_ptr, ie_len, cam_idx) =3D=3D = _FAIL) { - pmlmeinfo->FW_sta_info[cam_idx].status =3D 0; - return; - } + /* get supported rate */ + if (update_sta_support_rate(padapter, ie_ptr, ie_len, cam_idx) =3D=3D _= FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status =3D 0; + return; + } =20 - pmlmeext->TSFValue =3D le64_to_cpu(mgmt->u.beacon.timestamp); + pmlmeext->TSFValue =3D le64_to_cpu(mgmt->u.beacon.timestamp); =20 - report_add_sta_event(padapter, mgmt->sa, cam_idx); - } + report_add_sta_event(padapter, mgmt->sa, cam_idx); } } } --=20 2.30.2