Skip to content

Commit a1fc19d

Browse files
ahossugregkh
authored andcommitted
staging: rtl8723bs: fix WEP length underflow and OOB read in OnAuth()
OnAuth() has two bugs in the shared-key authentication path. When the Privacy bit is set, rtw_wep_decrypt() is called without verifying that the frame is long enough to contain a valid WEP IV and ICV. Inside rtw_wep_decrypt(), length is computed as: length = len - WLAN_HDR_A3_LEN - iv_len and then passed as (length - 4) to crc32_le(). If len is less than WLAN_HDR_A3_LEN + iv_len + icv_len (32 bytes), length - 4 is negative and, after the implicit cast to size_t, causes crc32_le() to read far beyond the frame buffer. Add a minimum length check before accessing the IV field and calling the decryption path. When processing a seq=3 response, rtw_get_ie() stores the Challenge Text IE length in ie_len, but the subsequent memcmp() always reads 128 bytes regardless of ie_len. IEEE 802.11 mandates a challenge text of exactly 128 bytes; reject any IE whose length field differs, matching the check already applied to OnAuthClient(). Fixes: 554c0a3 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable <stable@kernel.org> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com> Link: https://patch.msgid.link/20260522004605.1039209-1-hossu.alexandru@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 151edde commit a1fc19d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,9 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
677677
if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
678678
return _FAIL;
679679

680+
if (len < WLAN_HDR_A3_LEN)
681+
return _FAIL;
682+
680683
sa = GetAddr2Ptr(pframe);
681684

682685
auth_mode = psecuritypriv->dot11AuthAlgrthm;
@@ -688,6 +691,9 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
688691
prxattrib->hdrlen = WLAN_HDR_A3_LEN;
689692
prxattrib->encrypt = _WEP40_;
690693

694+
if (len < WLAN_HDR_A3_LEN + 8)
695+
return _FAIL;
696+
691697
iv = pframe+prxattrib->hdrlen;
692698
prxattrib->key_index = ((iv[3]>>6)&0x3);
693699

@@ -787,7 +793,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
787793
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&ie_len,
788794
len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4);
789795

790-
if (!p || ie_len <= 0) {
796+
if (!p || ie_len != 128) {
791797
status = WLAN_STATUS_CHALLENGE_FAIL;
792798
goto auth_fail;
793799
}

0 commit comments

Comments
 (0)